1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

core/bitcoin: make change check more robust against short paths

This commit is contained in:
matejcik 2020-07-31 15:52:30 +02:00 committed by Andrew Kozlik
parent 3cbfb98f38
commit cd86f9f477
2 changed files with 3 additions and 2 deletions

View File

@ -17,7 +17,7 @@ from apps.common import coininfo, seed
from apps.common.writers import write_bitcoin_varint
from .. import addresses, common, multisig, scripts, writers
from ..common import SIGHASH_ALL, ecdsa_sign
from ..common import BIP32_WALLET_DEPTH, SIGHASH_ALL, ecdsa_sign
from ..ownership import verify_nonownership
from ..verification import SignatureVerifier
from . import approvers, helpers, progress
@ -541,6 +541,7 @@ class Bitcoin:
return False
return (
self.wallet_path.output_matches(txo)
and len(txo.address_n) >= BIP32_WALLET_DEPTH
and txo.address_n[-2] <= _BIP32_CHANGE_CHAIN
and txo.address_n[-1] <= _BIP32_MAX_LAST_ELEMENT
and txo.amount > 0

View File

@ -79,7 +79,7 @@ class MatchChecker:
class WalletPathChecker(MatchChecker):
def attribute_from_tx(self, txio: Union[TxInputType, TxOutputType]) -> Any:
if not txio.address_n:
if len(txio.address_n) < BIP32_WALLET_DEPTH:
return None
return txio.address_n[:-BIP32_WALLET_DEPTH]