Skip to content

Commit

Permalink
python: Raise ValueError for non-existant tx hashes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
achow101 committed Feb 2, 2021
1 parent 6be367b commit 91bfe69
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/src/trezorlib/btc.py
Expand Up @@ -279,6 +279,8 @@ def copy_tx_meta(tx: messages.TransactionType) -> messages.TransactionType:

# 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
Expand Down

0 comments on commit 91bfe69

Please sign in to comment.