1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-17 21:22:10 +00:00

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.
This commit is contained in:
Andrew Chow 2021-02-01 21:26:14 -05:00 committed by matejcik
parent ff7d5c224b
commit 23a09fc047
2 changed files with 5 additions and 0 deletions

View File

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

View File

@ -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