tfix #2961 - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 4273c607b7ef991aad28a80ec63dc9627fffc653 DIR parent 1ebc8727559030dc826bae0c459ba05ae65411c0 HTML Author: ThomasV <thomasv@electrum.org> Date: Tue, 3 Oct 2017 14:16:43 +0200 fix #2961 Diffstat: M lib/bitcoin.py | 12 ++++++++++-- M lib/transaction.py | 12 ++---------- 2 files changed, 12 insertions(+), 12 deletions(-) --- DIR diff --git a/lib/bitcoin.py b/lib/bitcoin.py t@@ -332,6 +332,14 @@ def public_key_to_p2wpkh(public_key): def script_to_p2wsh(script): return hash_to_segwit_addr(sha256(bfh(script))) +def p2wpkh_nested_script(pubkey): + pubkey = safe_parse_pubkey(pubkey) + pkh = bh2u(hash_160(bfh(pubkey))) + return '00' + push_script(pkh) + +def p2wsh_nested_script(witness_script): + wsh = bh2u(sha256(bfh(witness_script))) + return '00' + push_script(wsh) def pubkey_to_address(txin_type, pubkey): if txin_type == 'p2pkh': t@@ -339,7 +347,7 @@ def pubkey_to_address(txin_type, pubkey): elif txin_type == 'p2wpkh': return hash_to_segwit_addr(hash_160(bfh(pubkey))) elif txin_type == 'p2wpkh-p2sh': - scriptSig = transaction.p2wpkh_nested_script(pubkey) + scriptSig = p2wpkh_nested_script(pubkey) return hash160_to_p2sh(hash_160(bfh(scriptSig))) else: raise NotImplementedError(txin_type) t@@ -350,7 +358,7 @@ def redeem_script_to_address(txin_type, redeem_script): elif txin_type == 'p2wsh': return script_to_p2wsh(redeem_script) elif txin_type == 'p2wsh-p2sh': - scriptSig = transaction.p2wsh_nested_script(redeem_script) + scriptSig = p2wsh_nested_script(redeem_script) return hash160_to_p2sh(hash_160(bfh(scriptSig))) else: raise NotImplementedError(txin_type) DIR diff --git a/lib/transaction.py b/lib/transaction.py t@@ -487,14 +487,6 @@ def deserialize(raw): # pay & redeem scripts -def p2wpkh_nested_script(pubkey): - pubkey = safe_parse_pubkey(pubkey) - pkh = bh2u(hash_160(bfh(pubkey))) - return '00' + push_script(pkh) - -def p2wsh_nested_script(witness_script): - wsh = bh2u(sha256(bfh(witness_script))) - return '00' + push_script(wsh) def multisig_script(public_keys, m): t@@ -677,11 +669,11 @@ class Transaction: elif _type in ['p2wpkh', 'p2wsh']: return '' elif _type == 'p2wpkh-p2sh': - scriptSig = p2wpkh_nested_script(pubkeys[0]) + scriptSig = bitcoin.p2wpkh_nested_script(pubkeys[0]) return push_script(scriptSig) elif _type == 'p2wsh-p2sh': witness_script = self.get_preimage_script(txin) - scriptSig = p2wsh_nested_script(witness_script) + scriptSig = bitcoin.p2wsh_nested_script(witness_script) return push_script(scriptSig) elif _type == 'address': script += push_script(pubkeys[0])