electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 8e644a4dc8bbb7b3e10bda0ad1c474c279cade35
parent 66e1e2707d4a82ecbe3f2bf7d532036d0a9651a8
Author: ThomasV <thomasv@gitorious>
Date:   Thu,  3 Apr 2014 20:48:31 +0200

sort signatures for multisig

Diffstat:
Mlib/transaction.py | 14+++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/transaction.py b/lib/transaction.py @@ -443,7 +443,9 @@ class Transaction: script += pubkey else: script = '00' # op_0 - for sig in signatures: + for pubkey in pubkeys: + sig = signatures.get(pubkey) + if not sig: continue sig = sig + '01' script += op_push(len(sig)/2) script += sig @@ -511,7 +513,7 @@ class Transaction: # add pubkeys txin["pubkeys"] = redeem_pubkeys # get list of already existing signatures - signatures = txin.get("signatures",[]) + signatures = txin.get("signatures",{}) # continue if this txin is complete if len(signatures) == num: continue @@ -531,7 +533,9 @@ class Transaction: public_key = private_key.get_verifying_key() sig = private_key.sign_digest_deterministic( Hash( tx_for_sig.decode('hex') ), hashfunc=hashlib.sha256, sigencode = ecdsa.util.sigencode_der ) assert public_key.verify_digest( sig, Hash( tx_for_sig.decode('hex') ), sigdecode = ecdsa.util.sigdecode_der) - signatures.append( sig.encode('hex') ) + + # insert signature in the list + signatures[pubkey] = sig.encode('hex') print_error("adding signature for", pubkey) txin["signatures"] = signatures @@ -572,7 +576,7 @@ class Transaction: pubkeys, signatures, address = get_address_from_input_script(scriptSig) else: pubkeys = [] - signatures = [] + signatures = {} address = None d['address'] = address @@ -681,7 +685,7 @@ class Transaction: 'redeemScript':i.get('redeemScript'), 'redeemPubkey':i.get('redeemPubkey'), 'pubkeys':i.get('pubkeys'), - 'signatures':i.get('signatures',[]), + 'signatures':i.get('signatures',{}), } info.append(item) return info