electrum

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

commit a0455725bd32cc71810c7db353ad1f8f6fba180e
parent 30b6d9b64e1034301ae834789d24ffb88a86c332
Author: ThomasV <thomasv@gitorious>
Date:   Sat, 23 Feb 2013 17:36:32 +0100

fix is_complete: count number of valid signatures

Diffstat:
Mlib/bitcoin.py | 17+++++------------
Mlib/deserialize.py | 2+-
2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/lib/bitcoin.py b/lib/bitcoin.py @@ -18,7 +18,7 @@ import hashlib, base64, ecdsa, re - +from util import print_error def rev_hex(s): return s.decode('hex')[::-1].encode('hex') @@ -605,13 +605,10 @@ class Transaction: # list of already existing signatures signatures = txin.get("signatures",[]) - found = False - complete = True + print_error("signatures",signatures) - # check if we have a key corresponding to the redeem script for pubkey in redeem_pubkeys: public_key = ecdsa.VerifyingKey.from_string(pubkey[2:].decode('hex'), curve = SECP256k1) - for s in signatures: try: public_key.verify_digest( s.decode('hex')[:-1], Hash( tx_for_sig.decode('hex') ), sigdecode = ecdsa.util.sigdecode_der) @@ -619,6 +616,7 @@ class Transaction: except ecdsa.keys.BadSignatureError: continue else: + # check if we have a key corresponding to the redeem script if pubkey in keypairs.keys(): # add signature sec = keypairs[pubkey] @@ -630,16 +628,11 @@ class Transaction: sig = private_key.sign_digest( Hash( tx_for_sig.decode('hex') ), 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') ) - found = True - else: - complete = False - if not found: - raise BaseException("public key not found", keypairs.keys(), redeem_pubkeys) - # for p2sh, pubkeysig is a tuple (may be incomplete) self.inputs[i]["signatures"] = signatures - self.is_complete = complete + print_error("signatures",signatures) + self.is_complete = len(signatures) == num else: sec = private_keys[txin['address']] diff --git a/lib/deserialize.py b/lib/deserialize.py @@ -240,7 +240,7 @@ def parse_redeemScript(bytes): match = [ opcodes.OP_2, opcodes.OP_PUSHDATA4, opcodes.OP_PUSHDATA4, opcodes.OP_PUSHDATA4, opcodes.OP_3, opcodes.OP_CHECKMULTISIG ] if match_decoded(dec, match): pubkeys = [ dec[1][1].encode('hex'), dec[2][1].encode('hex'), dec[3][1].encode('hex') ] - return 3, pubkeys + return 2, pubkeys