feat(python): Raise ValueError for non-existant tx hashes

If the device asks for a tx_hash which is not present in prev_txes,
raise a ValueError with some more detailed messaging about the missing
hash rather than the default dictionary lookup failure of KeyError.
pull/1989/head
Andrew Chow 3 years ago committed by matejcik
parent ff7d5c224b
commit 23a09fc047

@ -0,0 +1 @@
Raise `ValueError` when the txid for an input is not present in `prev_txes` during `btc.sign_tx`

@ -334,6 +334,10 @@ def sign_tx(
# Device asked for one more information, let's process it.
if res.details.tx_hash is not None:
if res.details.tx_hash not in prev_txes:
raise ValueError(
f"Previous transaction {res.details.tx_hash.hex()} not available"
)
current_tx = prev_txes[res.details.tx_hash]
else:
current_tx = this_tx

Loading…
Cancel
Save