add segwit to get_preimage_script
This commit is contained in:
parent
79bda98ba2
commit
f7096010f0
|
@ -675,6 +675,10 @@ class Transaction:
|
|||
elif txin['type'] == 'p2sh':
|
||||
pubkeys, x_pubkeys = self.get_sorted_pubkeys(txin)
|
||||
return multisig_script(pubkeys, txin['num_sig'])
|
||||
elif txin['type'] == 'p2wpkh-p2sh':
|
||||
pubkey = txin['pubkeys'][0]
|
||||
pkh = bitcoin.hash_160(pubkey.decode('hex')).encode('hex')
|
||||
return '76a9' + push_script(pkh) + '88ac'
|
||||
else:
|
||||
raise TypeError('Unknown txin type', _type)
|
||||
|
||||
|
@ -722,9 +726,7 @@ class Transaction:
|
|||
hashSequence = Hash(''.join(int_to_hex(txin.get('sequence', 0xffffffff), 4) for txin in inputs).decode('hex')).encode('hex')
|
||||
hashOutputs = Hash(''.join(self.serialize_output(o) for o in outputs).decode('hex')).encode('hex')
|
||||
outpoint = self.serialize_outpoint(txin)
|
||||
pubkey = txin['pubkeys'][0]
|
||||
pkh = bitcoin.hash_160(pubkey.decode('hex')).encode('hex')
|
||||
scriptCode = push_script('76a9' + push_script(pkh) + '88ac')
|
||||
scriptCode = push_script(self.get_preimage_script(txin))
|
||||
amount = int_to_hex(txin['value'], 8)
|
||||
nSequence = int_to_hex(txin.get('sequence', 0xffffffff), 4)
|
||||
preimage = nVersion + hashPrevouts + hashSequence + outpoint + scriptCode + amount + nSequence + hashOutputs + nLocktime + nHashType
|
||||
|
|
|
@ -298,14 +298,7 @@ class Ledger_KeyStore(Hardware_KeyStore):
|
|||
else:
|
||||
self.give_error("No matching x_key for sign_transaction") # should never happen
|
||||
|
||||
redeemScript = txin.get('redeemScript')
|
||||
if not redeemScript:
|
||||
if segwitTransaction:
|
||||
pkh = bitcoin.hash_160(pubkeys[0].decode('hex')).encode('hex')
|
||||
redeemScript = '76a9' + push_script(pkh) + '88ac'
|
||||
elif p2shTransaction:
|
||||
redeemScript = Transaction.get_preimage_script(txin)
|
||||
|
||||
redeemScript = Transaction.get_preimage_script(txin)
|
||||
inputs.append([txin['prev_tx'].raw, txin['prevout_n'], redeemScript, txin['prevout_hash'], signingPos, txin.get('sequence', 0xffffffff) ])
|
||||
inputsPaths.append(hwAddress)
|
||||
pubKeys.append(pubkeys)
|
||||
|
|
Loading…
Reference in New Issue