diff --git a/core/src/apps/bitcoin/sign_tx/bitcoin.py b/core/src/apps/bitcoin/sign_tx/bitcoin.py index a5c66a202..ec7321557 100644 --- a/core/src/apps/bitcoin/sign_tx/bitcoin.py +++ b/core/src/apps/bitcoin/sign_tx/bitcoin.py @@ -135,7 +135,7 @@ class Bitcoin: def create_hash_writer(self) -> HashWriter: return HashWriter(sha256()) - def create_sig_hasher(self) -> SigHasher: + def create_sig_hasher(self, tx: SignTx | PrevTx) -> SigHasher: return BitcoinSigHasher() async def step1_process_inputs(self) -> None: diff --git a/core/src/apps/bitcoin/sign_tx/decred.py b/core/src/apps/bitcoin/sign_tx/decred.py index 8f295f9fb..d819e8abd 100644 --- a/core/src/apps/bitcoin/sign_tx/decred.py +++ b/core/src/apps/bitcoin/sign_tx/decred.py @@ -106,7 +106,7 @@ class Decred(Bitcoin): def create_hash_writer(self) -> HashWriter: return HashWriter(blake256()) - def create_sig_hasher(self) -> SigHasher: + def create_sig_hasher(self, tx: SignTx | PrevTx) -> SigHasher: return DecredSigHasher(self.h_prefix) async def step2_approve_outputs(self) -> None: diff --git a/core/src/apps/bitcoin/sign_tx/tx_info.py b/core/src/apps/bitcoin/sign_tx/tx_info.py index 2b67ebdb4..5272ae50c 100644 --- a/core/src/apps/bitcoin/sign_tx/tx_info.py +++ b/core/src/apps/bitcoin/sign_tx/tx_info.py @@ -27,7 +27,7 @@ if TYPE_CHECKING: def create_hash_writer(self) -> HashWriter: ... - def create_sig_hasher(self) -> SigHasher: + def create_sig_hasher(self, tx: SignTx | PrevTx) -> SigHasher: ... def write_tx_header( @@ -60,7 +60,7 @@ _MAX_BIP125_RBF_SEQUENCE = const(0xFFFF_FFFD) class TxInfoBase: - def __init__(self, signer: Signer) -> None: + def __init__(self, signer: Signer, tx: SignTx | PrevTx) -> None: # Checksum of multisig inputs, used to validate change-output. self.multisig_fingerprint = MultisigFingerprintChecker() @@ -73,7 +73,7 @@ class TxInfoBase: self.h_tx_check = HashWriter(sha256()) # not a real tx hash # BIP-0143 transaction hashing. - self.sig_hasher = signer.create_sig_hasher() + self.sig_hasher = signer.create_sig_hasher(tx) # The minimum nSequence of all inputs. self.min_sequence = _SEQUENCE_FINAL @@ -122,14 +122,14 @@ class TxInfoBase: # Used to keep track of the transaction currently being signed. class TxInfo(TxInfoBase): def __init__(self, signer: Signer, tx: SignTx) -> None: - super().__init__(signer) + super().__init__(signer, tx) self.tx = tx # Used to keep track of any original transactions which are being replaced by the current transaction. class OriginalTxInfo(TxInfoBase): def __init__(self, signer: Signer, tx: PrevTx, orig_hash: bytes) -> None: - super().__init__(signer) + super().__init__(signer, tx) self.tx = tx self.signer = signer self.orig_hash = orig_hash diff --git a/core/src/apps/bitcoin/sign_tx/zcash.py b/core/src/apps/bitcoin/sign_tx/zcash.py index 0c3476c17..0de428ad2 100644 --- a/core/src/apps/bitcoin/sign_tx/zcash.py +++ b/core/src/apps/bitcoin/sign_tx/zcash.py @@ -128,7 +128,7 @@ class Zcashlike(Bitcoinlike): if tx.version != 4: raise wire.DataError("Unsupported transaction version.") - def create_sig_hasher(self) -> SigHasher: + def create_sig_hasher(self, tx: SignTx | PrevTx) -> SigHasher: return ZcashSigHasher() async def step7_finish(self) -> None: