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 4, 2021
1 parent 6be367b commit be46644
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/CHANGELOG.md
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Enabled session management via `EndSession` [#1227]
- Support for temporary or permanent `safety-checks` setting
- Support for Output Descriptors export [#1363]
- Raises `ValueError` when the txid for an input is not present in `prev_txes` during `btc.sign_tx` [#1442]

### Changed

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

Please sign in to comment.