mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-13 01:58:08 +00:00
chore(core): In apps.bitcoin move h_inputs back to bitcoin class.
This commit is contained in:
parent
0f0d1ef363
commit
b213a55428
@ -97,6 +97,11 @@ class Bitcoin:
|
|||||||
# stable device tests.
|
# stable device tests.
|
||||||
self.orig_txs = [] # type: List[OriginalTxInfo]
|
self.orig_txs = [] # type: List[OriginalTxInfo]
|
||||||
|
|
||||||
|
# h_inputs is a digest of the inputs streamed for approval in Step 1, which
|
||||||
|
# is used to ensure that the inputs streamed for verification in Step 3 are
|
||||||
|
# the same as those in Step 1.
|
||||||
|
self.h_inputs = None # type: Optional[bytes]
|
||||||
|
|
||||||
progress.init(tx.inputs_count, tx.outputs_count)
|
progress.init(tx.inputs_count, tx.outputs_count)
|
||||||
|
|
||||||
def create_hash_writer(self) -> HashWriter:
|
def create_hash_writer(self) -> HashWriter:
|
||||||
@ -124,7 +129,7 @@ class Bitcoin:
|
|||||||
if txi.orig_hash:
|
if txi.orig_hash:
|
||||||
await self.process_original_input(txi)
|
await self.process_original_input(txi)
|
||||||
|
|
||||||
self.tx_info.h_inputs = self.tx_info.h_tx_check.get_digest()
|
self.h_inputs = self.tx_info.get_tx_check_digest()
|
||||||
|
|
||||||
# Finalize original inputs.
|
# Finalize original inputs.
|
||||||
for orig in self.orig_txs:
|
for orig in self.orig_txs:
|
||||||
@ -170,7 +175,7 @@ class Bitcoin:
|
|||||||
await self.verify_external_input(i, txi, script_pubkey)
|
await self.verify_external_input(i, txi, script_pubkey)
|
||||||
|
|
||||||
# check that the inputs were the same as those streamed for approval
|
# check that the inputs were the same as those streamed for approval
|
||||||
if h_check.get_digest() != self.tx_info.h_inputs:
|
if h_check.get_digest() != self.h_inputs:
|
||||||
raise wire.ProcessError("Transaction has changed during signing")
|
raise wire.ProcessError("Transaction has changed during signing")
|
||||||
|
|
||||||
# verify the signature of one SIGHASH_ALL input in each original transaction
|
# verify the signature of one SIGHASH_ALL input in each original transaction
|
||||||
@ -554,7 +559,7 @@ class Bitcoin:
|
|||||||
writers.write_uint32(h_sign, self.get_sighash_type(txi_sign))
|
writers.write_uint32(h_sign, self.get_sighash_type(txi_sign))
|
||||||
|
|
||||||
# check that the inputs were the same as those streamed for approval
|
# check that the inputs were the same as those streamed for approval
|
||||||
if tx_info.h_tx_check.get_digest() != h_check.get_digest():
|
if tx_info.get_tx_check_digest() != h_check.get_digest():
|
||||||
raise wire.ProcessError("Transaction has changed during signing")
|
raise wire.ProcessError("Transaction has changed during signing")
|
||||||
|
|
||||||
tx_digest = writers.get_tx_hash(h_sign, double=self.coin.sign_hash_double)
|
tx_digest = writers.get_tx_hash(h_sign, double=self.coin.sign_hash_double)
|
||||||
|
@ -122,6 +122,9 @@ class TxInfoBase:
|
|||||||
def lock_time_disabled(self) -> bool:
|
def lock_time_disabled(self) -> bool:
|
||||||
return self.min_sequence == _SEQUENCE_FINAL
|
return self.min_sequence == _SEQUENCE_FINAL
|
||||||
|
|
||||||
|
def get_tx_check_digest(self) -> bytes:
|
||||||
|
return self.h_tx_check.get_digest()
|
||||||
|
|
||||||
|
|
||||||
# Used to keep track of the transaction currently being signed.
|
# Used to keep track of the transaction currently being signed.
|
||||||
class TxInfo(TxInfoBase):
|
class TxInfo(TxInfoBase):
|
||||||
@ -129,11 +132,6 @@ class TxInfo(TxInfoBase):
|
|||||||
super().__init__(signer)
|
super().__init__(signer)
|
||||||
self.tx = tx
|
self.tx = tx
|
||||||
|
|
||||||
# h_inputs is a digest of the inputs streamed for approval in Step 1, which
|
|
||||||
# is used to ensure that the inputs streamed for verification in Step 3 are
|
|
||||||
# the same as those in Step 1.
|
|
||||||
self.h_inputs = None # type: Optional[bytes]
|
|
||||||
|
|
||||||
|
|
||||||
# Used to keep track of any original transactions which are being replaced by the current transaction.
|
# Used to keep track of any original transactions which are being replaced by the current transaction.
|
||||||
class OriginalTxInfo(TxInfoBase):
|
class OriginalTxInfo(TxInfoBase):
|
||||||
|
Loading…
Reference in New Issue
Block a user