mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 05:28:40 +00:00
core/sign_tx: Remove unused index parameters.
This commit is contained in:
parent
c9814e50ba
commit
04bdf1dc6c
@ -123,7 +123,9 @@ class Bitcoin:
|
||||
progress.advance()
|
||||
txi = await helpers.request_tx_input(self.tx_req, i, self.coin)
|
||||
self.weight.add_input(txi)
|
||||
await self.process_input(i, txi)
|
||||
if input_is_segwit(txi):
|
||||
self.segwit.add(i)
|
||||
await self.process_input(txi)
|
||||
|
||||
async def step2_confirm_outputs(self) -> None:
|
||||
txo_bin = TxOutputBinType()
|
||||
@ -133,7 +135,7 @@ class Bitcoin:
|
||||
txo_bin.amount = txo.amount
|
||||
txo_bin.script_pubkey = self.output_derive_script(txo)
|
||||
self.weight.add_output(txo_bin.script_pubkey)
|
||||
await self.confirm_output(i, txo, txo_bin)
|
||||
await self.confirm_output(txo, txo_bin)
|
||||
|
||||
async def step3_confirm_tx(self) -> None:
|
||||
fee = self.total_in - self.total_out
|
||||
@ -186,7 +188,7 @@ class Bitcoin:
|
||||
self.write_tx_footer(self.serialized_tx, self.tx)
|
||||
await helpers.request_tx_finish(self.tx_req)
|
||||
|
||||
async def process_input(self, i: int, txi: TxInputType) -> None:
|
||||
async def process_input(self, txi: TxInputType) -> None:
|
||||
self.wallet_path.add_input(txi)
|
||||
self.multisig_fingerprint.add_input(txi)
|
||||
writers.write_tx_input_check(self.h_confirmed, txi)
|
||||
@ -196,30 +198,27 @@ class Bitcoin:
|
||||
await helpers.confirm_foreign_address(txi.address_n)
|
||||
|
||||
if input_is_segwit(txi):
|
||||
self.segwit.add(i)
|
||||
await self.process_segwit_input(i, txi)
|
||||
await self.process_segwit_input(txi)
|
||||
elif input_is_nonsegwit(txi):
|
||||
await self.process_nonsegwit_input(i, txi)
|
||||
await self.process_nonsegwit_input(txi)
|
||||
else:
|
||||
raise SigningError(FailureType.DataError, "Wrong input script type")
|
||||
|
||||
async def process_segwit_input(self, i: int, txi: TxInputType) -> None:
|
||||
await self.process_bip143_input(i, txi)
|
||||
async def process_segwit_input(self, txi: TxInputType) -> None:
|
||||
await self.process_bip143_input(txi)
|
||||
|
||||
async def process_nonsegwit_input(self, i: int, txi: TxInputType) -> None:
|
||||
async def process_nonsegwit_input(self, txi: TxInputType) -> None:
|
||||
self.total_in += await self.get_prevtx_output_value(
|
||||
txi.prev_hash, txi.prev_index
|
||||
)
|
||||
|
||||
async def process_bip143_input(self, i: int, txi: TxInputType) -> None:
|
||||
async def process_bip143_input(self, txi: TxInputType) -> None:
|
||||
if not txi.amount:
|
||||
raise SigningError(FailureType.DataError, "Expected input with amount")
|
||||
self.bip143_in += txi.amount
|
||||
self.total_in += txi.amount
|
||||
|
||||
async def confirm_output(
|
||||
self, i: int, txo: TxOutputType, txo_bin: TxOutputBinType
|
||||
) -> None:
|
||||
async def confirm_output(self, txo: TxOutputType, txo_bin: TxOutputBinType) -> None:
|
||||
if self.change_out == 0 and self.output_is_change(txo):
|
||||
# output is change and does not need confirmation
|
||||
self.change_out = txo.amount
|
||||
@ -228,7 +227,7 @@ class Bitcoin:
|
||||
|
||||
self.write_tx_output(self.h_confirmed, txo_bin)
|
||||
self.hash143_add_output(txo_bin)
|
||||
self.total_out += txo_bin.amount
|
||||
self.total_out += txo.amount
|
||||
|
||||
def on_negative_fee(self) -> None:
|
||||
raise SigningError(FailureType.NotEnoughFunds, "Not enough funds")
|
||||
|
@ -17,16 +17,16 @@ _SIGHASH_FORKID = const(0x40)
|
||||
|
||||
|
||||
class Bitcoinlike(Bitcoin):
|
||||
async def process_segwit_input(self, i: int, txi: TxInputType) -> None:
|
||||
async def process_segwit_input(self, txi: TxInputType) -> None:
|
||||
if not self.coin.segwit:
|
||||
raise SigningError(FailureType.DataError, "Segwit not enabled on this coin")
|
||||
await super().process_segwit_input(i, txi)
|
||||
await super().process_segwit_input(txi)
|
||||
|
||||
async def process_nonsegwit_input(self, i: int, txi: TxInputType) -> None:
|
||||
async def process_nonsegwit_input(self, txi: TxInputType) -> None:
|
||||
if self.coin.force_bip143:
|
||||
await self.process_bip143_input(i, txi)
|
||||
await self.process_bip143_input(txi)
|
||||
else:
|
||||
await super().process_nonsegwit_input(i, txi)
|
||||
await super().process_nonsegwit_input(txi)
|
||||
|
||||
async def sign_nonsegwit_bip143_input(self, i_sign: int) -> None:
|
||||
txi = await helpers.request_tx_input(self.tx_req, i_sign, self.coin)
|
||||
|
@ -52,22 +52,20 @@ class Decred(Bitcoin):
|
||||
self.write_tx_footer(self.serialized_tx, self.tx)
|
||||
self.write_tx_footer(self.h_prefix, self.tx)
|
||||
|
||||
async def process_input(self, i: int, txi: TxInputType) -> None:
|
||||
await super().process_input(i, txi)
|
||||
async def process_input(self, txi: TxInputType) -> None:
|
||||
await super().process_input(txi)
|
||||
|
||||
# Decred serializes inputs early.
|
||||
self.write_tx_input(self.serialized_tx, txi)
|
||||
|
||||
async def confirm_output(
|
||||
self, i: int, txo: TxOutputType, txo_bin: TxOutputBinType
|
||||
) -> None:
|
||||
async def confirm_output(self, txo: TxOutputType, txo_bin: TxOutputBinType) -> None:
|
||||
if txo.decred_script_version != 0:
|
||||
raise SigningError(
|
||||
FailureType.ActionCancelled,
|
||||
"Cannot send to output with script version != 0",
|
||||
)
|
||||
txo_bin.decred_script_version = txo.decred_script_version
|
||||
await super().confirm_output(i, txo, txo_bin)
|
||||
await super().confirm_output(txo, txo_bin)
|
||||
self.write_tx_output(self.serialized_tx, txo_bin)
|
||||
|
||||
async def step4_serialize_inputs(self) -> None:
|
||||
|
@ -70,8 +70,8 @@ class Overwintered(Bitcoinlike):
|
||||
|
||||
await helpers.request_tx_finish(self.tx_req)
|
||||
|
||||
async def process_nonsegwit_input(self, i: int, txi: TxInputType) -> None:
|
||||
await self.process_bip143_input(i, txi)
|
||||
async def process_nonsegwit_input(self, txi: TxInputType) -> None:
|
||||
await self.process_bip143_input(txi)
|
||||
|
||||
async def sign_nonsegwit_input(self, i_sign: int) -> None:
|
||||
await self.sign_nonsegwit_bip143_input(i_sign)
|
||||
|
Loading…
Reference in New Issue
Block a user