1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-03 03:50:58 +00:00

feat(core): add tx argument to create_sig_hasher method

This commit is contained in:
Tomas Krnak 2022-03-31 15:13:54 +02:00 committed by matejcik
parent a411a964e1
commit 670d11d627
4 changed files with 8 additions and 8 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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

View File

@ -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: