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:
parent
3cbfb98f38
commit
cd86f9f477
@ -17,7 +17,7 @@ from apps.common import coininfo, seed
|
|||||||
from apps.common.writers import write_bitcoin_varint
|
from apps.common.writers import write_bitcoin_varint
|
||||||
|
|
||||||
from .. import addresses, common, multisig, scripts, writers
|
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 ..ownership import verify_nonownership
|
||||||
from ..verification import SignatureVerifier
|
from ..verification import SignatureVerifier
|
||||||
from . import approvers, helpers, progress
|
from . import approvers, helpers, progress
|
||||||
@ -541,6 +541,7 @@ class Bitcoin:
|
|||||||
return False
|
return False
|
||||||
return (
|
return (
|
||||||
self.wallet_path.output_matches(txo)
|
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[-2] <= _BIP32_CHANGE_CHAIN
|
||||||
and txo.address_n[-1] <= _BIP32_MAX_LAST_ELEMENT
|
and txo.address_n[-1] <= _BIP32_MAX_LAST_ELEMENT
|
||||||
and txo.amount > 0
|
and txo.amount > 0
|
||||||
|
@ -79,7 +79,7 @@ class MatchChecker:
|
|||||||
|
|
||||||
class WalletPathChecker(MatchChecker):
|
class WalletPathChecker(MatchChecker):
|
||||||
def attribute_from_tx(self, txio: Union[TxInputType, TxOutputType]) -> Any:
|
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 None
|
||||||
return txio.address_n[:-BIP32_WALLET_DEPTH]
|
return txio.address_n[:-BIP32_WALLET_DEPTH]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user