Browse Source

Fix tests, fix bug in mixed-transaction signing (not used in JM)

More on bug: when signing txs with SW and non-SW inputs, the
existing signature_form for non-SW inputs didnt pay attention
to whether the tx serialization was SW or non-SW style, so if
a SW-style tx serialization was passed in, it was kept in SW
form after passing through signature_form, resulting in an attempt
to create a signature based on SW style sighashing. The fix here
just ensures that signature_form always enforces the tx format
to be non-SW style, so allowing callers to sign() to get a valid
signature whatever they pass in.
master
Adam Gibson 9 years ago
parent
commit
b58b8fcbcd
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 3
      jmbitcoin/jmbitcoin/secp256k1_transaction.py
  2. 4
      jmclient/test/test_configure.py

3
jmbitcoin/jmbitcoin/secp256k1_transaction.py

@ -223,6 +223,9 @@ def signature_form(tx, i, script, hashcode=SIGHASH_ALL):
return serialize(signature_form(deserialize(tx), i, script, hashcode))
newtx = copy.deepcopy(tx)
for inp in newtx["ins"]:
#If tx is passed in in segwit form, it must be switched to non-segwit.
if "txinwitness" in inp:
del inp["txinwitness"]
inp["script"] = ""
newtx["ins"][i]["script"] = script
if hashcode & 0x1f == SIGHASH_NONE:

4
jmclient/test/test_configure.py

@ -23,9 +23,9 @@ def test_load_config():
load_program_config(bs="regtest")
os.makedirs("dummydirforconfig")
ncp = os.path.join(os.getcwd(), "dummydirforconfig")
#need to erase remembered data in global config
jm_single().config_location = "joinmarket.cfg"
load_program_config(config_path=ncp)
#TODO hack: the default config won't load on bitcoin-rpc; need to fix.
load_program_config(config_path=ncp, bs="blockr")
os.remove("dummydirforconfig/joinmarket.cfg")
os.removedirs("dummydirforconfig")
jm_single().config_location = "joinmarket.cfg"

Loading…
Cancel
Save