Post
Topic
Board Development & Technical Discussion
Topic OP
Pybitcointools txhash function, and SIGHASH_ALL = 0
by
HeadsOrTails
on 06/08/2015, 07:48:11 UTC
pybitcointools has a txhash function which returns the singable form of a transaction, with SIGHASH appended.

However the code returns a reversed hash without the appended SIGHASH bytes for SIGHASH=None, as seen here: https://github.com/vbuterin/pybitcointools/blob/master/bitcoin/transaction.py#L177-L178

Code:
def txhash(tx, hashcode=None):
    if isinstance(tx, str) and re.match('^[0-9a-fA-F]*$', tx):
        tx = changebase(tx, 16, 256)
    if hashcode:
        return dbl_sha256(from_string_to_bytes(tx) + encode(int(hashcode), 256, 4)[::-1])
    else:
        return safe_hexlify(bin_dbl_sha256(tx)[::-1])


That doesn't seem right; is it?

Also, how is a SIGHASH_ALL value of zero (rare case) calculated? (See this related SE question)

Is it just changing the 00 to 01?