1
0

add support for p2wsh-in-p2sh

This commit is contained in:
ThomasV
2017-09-18 08:52:06 +02:00
parent d1e897bf8f
commit fcea2a065d
2 changed files with 22 additions and 18 deletions

View File

@@ -491,11 +491,17 @@ def deserialize(raw):
# pay & redeem scripts
def segwit_script(pubkey):
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):
print('wit', witness_script)
wsh = bh2u(sha256(bfh(witness_script)))
print(len(wsh)//2)
return '00' + push_script(wsh)
def multisig_script(public_keys, m):
n = len(public_keys)
@@ -676,9 +682,13 @@ class Transaction:
script += push_script(pubkeys[0])
elif _type in ['p2wpkh', 'p2wsh']:
return segwit_value
elif _type in ['p2wpkh-p2sh', 'p2wsh-p2sh']:
redeem_script = txin.get('redeemScript') or segwit_script(pubkeys[0])
return segwit_value + push_script(redeem_script)
elif _type == 'p2wpkh-p2sh':
scriptSig = p2wpkh_nested_script(pubkeys[0])
return segwit_value + push_script(scriptSig)
elif _type == 'p2wsh-p2sh':
witness_script = self.get_preimage_script(txin)
scriptSig = p2wsh_nested_script(witness_script)
return segwit_value + push_script(scriptSig)
elif _type == 'address':
script += push_script(pubkeys[0])
elif _type == 'unknown':