vbuterin / pybitcointools

SImple, common-sense Bitcoin-themed Python ECC library
1.28k stars 857 forks source link

signining chokes on unicode strings #69

Closed arnuschky closed 9 years ago

arnuschky commented 9 years ago

Signing transactions represented using unicode strings (standard in python) fails in signature_form:

def signature_form(tx, i, script, hashcode = SIGHASH_ALL):
    i, hashcode = int(i), int(hashcode)
    if isinstance(tx, str):
        return serialize(signature_form(deserialize(tx), i, script, hashcode))
    newtx = copy.deepcopy(tx)

Here, the check if isinstance(tx, str): fails. It should read if isinstance(tx, str) or isinstance(tx, unicode):.

User-side workaround:

signed_raw_tx = pybitcointools.signall(tx.encode('ascii','ignore'), privateKey)
vbuterin commented 9 years ago

Latest version already does if isinstance(tx, (str, unicode)) . Which version are you using?

On Fri, Jan 9, 2015 at 10:46 AM, arnuschky notifications@github.com wrote:

Signing transactions represented using unicode strings (standard in python) fails in signature_form:

def signature_form(tx, i, script, hashcode = SIGHASH_ALL): i, hashcode = int(i), int(hashcode) if isinstance(tx, str): return serialize(signature_form(deserialize(tx), i, script, hashcode)) newtx = copy.deepcopy(tx)

Here, the check if isinstance(tx, str): fails. It should read if isinstance(tx, str) or isinstance(tx, unicode):.

User-side workaround:

signed_raw_tx = pybitcointools.signall(tx.encode('ascii','ignore'), privateKey)

— Reply to this email directly or view it on GitHub https://github.com/vbuterin/pybitcointools/issues/69.

arnuschky commented 9 years ago

I used the one that installs when using pip. I also thought that I checked the code on github, but I must have been on an old branch while doing this. Sorry for the noise.