add support for p2wsh-in-p2sh
This commit is contained in:
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user