vbuterin / pybitcointools

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

Wrong MultiSignature Address Generation #71

Closed shayanb closed 9 years ago

shayanb commented 9 years ago

This generates the wrong address for multisigniture addresses:

 TestMultisig = mk_multisig_script(["0254236f7d1124fc07600ad3eec5ac47393bf963fbf0608bcce255e685580d16d9","03560cad89031c412ad8619398bd43b3d673cb5bdcdac1afc46449382c6a8e0b2b"],2)

    multisig_address = p2sh_scriptaddr(TestMultisig)

This will Generate : 3Qu1wLEVDda4EjCCgtirUuz5kq6geoaDQW

Although if you check with either pycoin or http://ms-brainwallet.org, it should generate: 33byJBaS5N45RHFcatTSt9ZjiGb6nK4iV3

kewllife commented 9 years ago

I had the same problem with mk_multisig_script. It appears there is a problem when encoding the OP_CHECKMULTISIG value of 174 at the end of the script. Instead of adding AE, its adding 5B3137345D, which is the hex value for the string [174]. I had to just hard-code the hex value as a string, then it works fine.

FROM

return serialize_script([k]+pubs+[len(pubs), 174])

TO

return serialize_script([k]+pubs+[len(pubs)]) + 'ae'

I'm sure there is a much cleaner way, which is why I won't do a pull request (still studying the codebase).

badluckiskillingme commented 9 years ago

This issue was really nasty. And it turns out that I'm victim of it. Is there any chance to transfer from multisig 2-3 address based on such a broken script?

shayanb commented 9 years ago

@badluckiskillingme I don't think you can cause basically you have one address that you don't hold the required private keys for that address. p.s. realistic username here ;)

badluckiskillingme commented 9 years ago

Buterin, you ***\ I will remember this :> I lost ... a new car