mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-28 22:15:42 +00:00
fix(core): fix missing refresh in progress layout
[no changelog]
This commit is contained in:
parent
b62dc27f06
commit
66583f2ebf
@ -261,11 +261,10 @@ fn screen_progress(
|
|||||||
bg_color,
|
bg_color,
|
||||||
);
|
);
|
||||||
display::loader(progress, -20, fg_color, bg_color, icon);
|
display::loader(progress, -20, fg_color, bg_color, icon);
|
||||||
|
display::refresh();
|
||||||
if initialize {
|
if initialize {
|
||||||
fadein();
|
fadein();
|
||||||
}
|
}
|
||||||
|
|
||||||
display::refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -16,6 +16,8 @@ from .sig_hasher import BitcoinSigHasher
|
|||||||
from .tx_info import OriginalTxInfo
|
from .tx_info import OriginalTxInfo
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from trezor.crypto import bip32
|
from trezor.crypto import bip32
|
||||||
from trezor.messages import SignTx, TxAckPaymentRequest, TxInput, TxOutput
|
from trezor.messages import SignTx, TxAckPaymentRequest, TxInput, TxOutput
|
||||||
|
|
||||||
@ -23,6 +25,7 @@ if TYPE_CHECKING:
|
|||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
|
||||||
from ..authorization import CoinJoinAuthorization
|
from ..authorization import CoinJoinAuthorization
|
||||||
|
from .bitcoin import Bitcoin
|
||||||
from .payment_request import PaymentRequestVerifier
|
from .payment_request import PaymentRequestVerifier
|
||||||
from .tx_info import TxInfo
|
from .tx_info import TxInfo
|
||||||
|
|
||||||
@ -132,7 +135,12 @@ class Approver:
|
|||||||
) -> None:
|
) -> None:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
async def approve_tx(self, tx_info: TxInfo, orig_txs: list[OriginalTxInfo]) -> None:
|
async def approve_tx(
|
||||||
|
self,
|
||||||
|
tx_info: TxInfo,
|
||||||
|
orig_txs: list[OriginalTxInfo],
|
||||||
|
signer: Optional[Bitcoin],
|
||||||
|
) -> None:
|
||||||
self.finish_payment_request()
|
self.finish_payment_request()
|
||||||
|
|
||||||
|
|
||||||
@ -270,13 +278,18 @@ class BasicApprover(Approver):
|
|||||||
else:
|
else:
|
||||||
return TR.bitcoin__title_update_transaction
|
return TR.bitcoin__title_update_transaction
|
||||||
|
|
||||||
async def approve_tx(self, tx_info: TxInfo, orig_txs: list[OriginalTxInfo]) -> None:
|
async def approve_tx(
|
||||||
|
self,
|
||||||
|
tx_info: TxInfo,
|
||||||
|
orig_txs: list[OriginalTxInfo],
|
||||||
|
signer: Optional[Bitcoin],
|
||||||
|
) -> None:
|
||||||
from trezor.wire import NotEnoughFunds
|
from trezor.wire import NotEnoughFunds
|
||||||
|
|
||||||
coin = self.coin # local_cache_attribute
|
coin = self.coin # local_cache_attribute
|
||||||
amount_unit = self.amount_unit # local_cache_attribute
|
amount_unit = self.amount_unit # local_cache_attribute
|
||||||
|
|
||||||
await super().approve_tx(tx_info, orig_txs)
|
await super().approve_tx(tx_info, orig_txs, signer)
|
||||||
|
|
||||||
if self.has_unverified_external_input:
|
if self.has_unverified_external_input:
|
||||||
await helpers.confirm_unverified_external_input()
|
await helpers.confirm_unverified_external_input()
|
||||||
@ -336,6 +349,8 @@ class BasicApprover(Approver):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not self.is_payjoin():
|
if not self.is_payjoin():
|
||||||
|
if signer is not None:
|
||||||
|
signer.init_signing()
|
||||||
title = self._replacement_title(tx_info, orig_txs)
|
title = self._replacement_title(tx_info, orig_txs)
|
||||||
# Not a PayJoin: Show the actual fee difference, since any difference in the fee is
|
# Not a PayJoin: Show the actual fee difference, since any difference in the fee is
|
||||||
# coming entirely from the user's own funds and from decreases of external outputs.
|
# coming entirely from the user's own funds and from decreases of external outputs.
|
||||||
@ -344,6 +359,8 @@ class BasicApprover(Approver):
|
|||||||
title, fee - orig_fee, fee, fee_rate, coin, amount_unit
|
title, fee - orig_fee, fee, fee_rate, coin, amount_unit
|
||||||
)
|
)
|
||||||
elif spending > orig_spending:
|
elif spending > orig_spending:
|
||||||
|
if signer is not None:
|
||||||
|
signer.init_signing()
|
||||||
title = self._replacement_title(tx_info, orig_txs)
|
title = self._replacement_title(tx_info, orig_txs)
|
||||||
# PayJoin and user is spending more: Show the increase in the user's contribution
|
# PayJoin and user is spending more: Show the increase in the user's contribution
|
||||||
# to the fee, ignoring any contribution from external inputs. Decreasing of
|
# to the fee, ignoring any contribution from external inputs. Decreasing of
|
||||||
@ -363,6 +380,9 @@ class BasicApprover(Approver):
|
|||||||
tx_info.tx.lock_time, tx_info.lock_time_disabled()
|
tx_info.tx.lock_time, tx_info.lock_time_disabled()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if signer is not None:
|
||||||
|
signer.init_signing()
|
||||||
|
|
||||||
if not self.external_in:
|
if not self.external_in:
|
||||||
await helpers.confirm_total(
|
await helpers.confirm_total(
|
||||||
total,
|
total,
|
||||||
@ -511,10 +531,15 @@ class CoinJoinApprover(Approver):
|
|||||||
self.h_request.get_digest(),
|
self.h_request.get_digest(),
|
||||||
)
|
)
|
||||||
|
|
||||||
async def approve_tx(self, tx_info: TxInfo, orig_txs: list[OriginalTxInfo]) -> None:
|
async def approve_tx(
|
||||||
|
self,
|
||||||
|
tx_info: TxInfo,
|
||||||
|
orig_txs: list[OriginalTxInfo],
|
||||||
|
signer: Optional[Bitcoin],
|
||||||
|
) -> None:
|
||||||
from ..authorization import FEE_RATE_DECIMALS
|
from ..authorization import FEE_RATE_DECIMALS
|
||||||
|
|
||||||
await super().approve_tx(tx_info, orig_txs)
|
await super().approve_tx(tx_info, orig_txs, signer)
|
||||||
|
|
||||||
if not self._verify_coinjoin_request(tx_info):
|
if not self._verify_coinjoin_request(tx_info):
|
||||||
raise DataError("Invalid signature in coinjoin request.")
|
raise DataError("Invalid signature in coinjoin request.")
|
||||||
|
@ -40,6 +40,20 @@ _SERIALIZED_TX_BUFFER = empty_bytearray(_MAX_SERIALIZED_CHUNK_SIZE)
|
|||||||
|
|
||||||
|
|
||||||
class Bitcoin:
|
class Bitcoin:
|
||||||
|
def init_signing(self) -> None:
|
||||||
|
# Next shown progress bar is already signing progress, but it isn't shown until approval from next dialog
|
||||||
|
progress.init_signing(
|
||||||
|
len(self.external),
|
||||||
|
len(self.segwit),
|
||||||
|
len(self.presigned),
|
||||||
|
self.taproot_only,
|
||||||
|
self.serialize,
|
||||||
|
self.coin,
|
||||||
|
self.tx_info.tx,
|
||||||
|
self.orig_txs,
|
||||||
|
)
|
||||||
|
self.signing = True
|
||||||
|
|
||||||
async def signer(self) -> None:
|
async def signer(self) -> None:
|
||||||
progress.init(
|
progress.init(
|
||||||
self.tx_info.tx, is_coinjoin=isinstance(self.approver, CoinJoinApprover)
|
self.tx_info.tx, is_coinjoin=isinstance(self.approver, CoinJoinApprover)
|
||||||
@ -56,18 +70,13 @@ class Bitcoin:
|
|||||||
await self.step2_approve_outputs()
|
await self.step2_approve_outputs()
|
||||||
|
|
||||||
# Check fee, approve lock_time and total.
|
# Check fee, approve lock_time and total.
|
||||||
await self.approver.approve_tx(self.tx_info, self.orig_txs)
|
await self.approver.approve_tx(self.tx_info, self.orig_txs, self)
|
||||||
|
|
||||||
progress.init_signing(
|
# Make sure proper progress is shown, in case dialog was not required
|
||||||
len(self.external),
|
if not self.signing:
|
||||||
len(self.segwit),
|
self.init_signing()
|
||||||
len(self.presigned),
|
progress.report_init()
|
||||||
self.taproot_only,
|
progress.report()
|
||||||
self.serialize,
|
|
||||||
self.coin,
|
|
||||||
self.tx_info.tx,
|
|
||||||
self.orig_txs,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Following steps can take a long time, make sure autolock doesn't kick in.
|
# Following steps can take a long time, make sure autolock doesn't kick in.
|
||||||
# This is set to True again after workflow is finished in start_default().
|
# This is set to True again after workflow is finished in start_default().
|
||||||
@ -129,6 +138,9 @@ class Bitcoin:
|
|||||||
# indicates whether all internal inputs are Taproot
|
# indicates whether all internal inputs are Taproot
|
||||||
self.taproot_only = True
|
self.taproot_only = True
|
||||||
|
|
||||||
|
# indicates whether the transaction is being signed
|
||||||
|
self.signing = False
|
||||||
|
|
||||||
# transaction and signature serialization
|
# transaction and signature serialization
|
||||||
_SERIALIZED_TX_BUFFER[:] = bytes()
|
_SERIALIZED_TX_BUFFER[:] = bytes()
|
||||||
self.serialized_tx = _SERIALIZED_TX_BUFFER
|
self.serialized_tx = _SERIALIZED_TX_BUFFER
|
||||||
|
@ -97,9 +97,6 @@ class Progress:
|
|||||||
if serialize and not coin.decred:
|
if serialize and not coin.decred:
|
||||||
self.steps += tx.outputs_count
|
self.steps += tx.outputs_count
|
||||||
|
|
||||||
self.report_init()
|
|
||||||
self.report()
|
|
||||||
|
|
||||||
def init_prev_tx(self, inputs: int, outputs: int) -> None:
|
def init_prev_tx(self, inputs: int, outputs: int) -> None:
|
||||||
self.prev_tx_step = _PREV_TX_MULTIPLIER / (inputs + outputs)
|
self.prev_tx_step = _PREV_TX_MULTIPLIER / (inputs + outputs)
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ class RustProgress:
|
|||||||
self.layout = layout
|
self.layout = layout
|
||||||
self.layout.attach_timer_fn(self.set_timer)
|
self.layout.attach_timer_fn(self.set_timer)
|
||||||
self.layout.paint()
|
self.layout.paint()
|
||||||
|
ui.refresh()
|
||||||
|
|
||||||
def set_timer(self, token: int, deadline: int) -> None:
|
def set_timer(self, token: int, deadline: int) -> None:
|
||||||
raise RuntimeError # progress layouts should not set timers
|
raise RuntimeError # progress layouts should not set timers
|
||||||
|
@ -18,6 +18,7 @@ class RustProgress:
|
|||||||
ui.backlight_fade(ui.style.BACKLIGHT_DIM)
|
ui.backlight_fade(ui.style.BACKLIGHT_DIM)
|
||||||
self.layout.attach_timer_fn(self.set_timer)
|
self.layout.attach_timer_fn(self.set_timer)
|
||||||
self.layout.paint()
|
self.layout.paint()
|
||||||
|
ui.refresh()
|
||||||
ui.backlight_fade(ui.style.BACKLIGHT_NORMAL)
|
ui.backlight_fade(ui.style.BACKLIGHT_NORMAL)
|
||||||
|
|
||||||
def set_timer(self, token: int, deadline: int) -> None:
|
def set_timer(self, token: int, deadline: int) -> None:
|
||||||
|
@ -188,7 +188,7 @@ class TestApprover(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
await_result(approver.add_external_output(txo, script_pubkey=bytes(22)))
|
await_result(approver.add_external_output(txo, script_pubkey=bytes(22)))
|
||||||
|
|
||||||
await_result(approver.approve_tx(TxInfo(signer, tx), []))
|
await_result(approver.approve_tx(TxInfo(signer, tx), [], None))
|
||||||
|
|
||||||
def test_coinjoin_input_account_depth_mismatch(self):
|
def test_coinjoin_input_account_depth_mismatch(self):
|
||||||
txi = TxInput(
|
txi = TxInput(
|
||||||
|
Loading…
Reference in New Issue
Block a user