1
0

Merge pull request #9839 from SomberNight/202505_transaction_verify_sig_2

transaction: add method verify_sig_for_txin
This commit is contained in:
ThomasV
2025-05-30 14:32:27 +02:00
committed by GitHub
4 changed files with 350 additions and 131 deletions

View File

@@ -565,10 +565,10 @@ class DigitalBitbox_KeyStore(Hardware_KeyStore):
if p2pkhTransaction:
tx_copy = copy.deepcopy(tx)
# monkey-patch method of tx_copy instance to change serialization
def input_script(self, txin: PartialTxInput, *, estimate_size=False):
def input_script(self, txin: PartialTxInput, *, estimate_size=False) -> bytes:
desc = txin.script_descriptor
if isinstance(desc, descriptor.PKHDescriptor):
return Transaction.get_preimage_script(txin)
return txin.get_scriptcode_for_sighash()
raise Exception(f"unsupported txin type. only p2pkh is supported. got: {desc.to_string()[:10]}")
tx_copy.input_script = input_script.__get__(tx_copy, PartialTransaction)
tx_dbb_serialized = tx_copy.serialize_to_network()

View File

@@ -592,7 +592,7 @@ class Ledger_Client_Legacy(Ledger_Client):
self.give_error("No matching pubkey for sign_transaction") # should never happen
full_path = convert_bip32_intpath_to_strpath(full_path)[2:]
redeemScript = Transaction.get_preimage_script(txin).hex()
redeemScript = txin.get_scriptcode_for_sighash().hex()
txin_prev_tx = txin.utxo
if txin_prev_tx is None and not txin.is_segwit():
raise UserFacingException(_('Missing previous tx for legacy input.'))