diff --git a/src/apps/wallet/sign_tx/__init__.py b/src/apps/wallet/sign_tx/__init__.py index 93252326..109195a2 100644 --- a/src/apps/wallet/sign_tx/__init__.py +++ b/src/apps/wallet/sign_tx/__init__.py @@ -1,13 +1,12 @@ -from trezor import wire +from trezor import ui, wire +from trezor.messages.RequestType import TXFINISHED +from trezor.messages.wire_types import TxAck +from apps.common import seed +@ui.layout async def sign_tx(ctx, msg): - from trezor.messages.RequestType import TXFINISHED - from trezor.messages.wire_types import TxAck - - from apps.common import seed - from . import signing - from . import layout + from apps.wallet.sign_tx import layout, progress, signing # TODO: rework this so we don't have to pass root to signing.sign_tx root = await seed.derive_node(ctx, []) @@ -33,10 +32,13 @@ async def sign_tx(ctx, msg): res = await ctx.call(req, TxAck) elif req.__qualname__ == 'UiConfirmOutput': res = await layout.confirm_output(ctx, req.output, req.coin) + progress.report_init() elif req.__qualname__ == 'UiConfirmTotal': res = await layout.confirm_total(ctx, req.spending, req.fee, req.coin) + progress.report_init() elif req.__qualname__ == 'UiConfirmFeeOverThreshold': res = await layout.confirm_feeoverthreshold(ctx, req.fee, req.coin) + progress.report_init() else: raise TypeError('Invalid signing instruction') return req diff --git a/src/apps/wallet/sign_tx/progress.py b/src/apps/wallet/sign_tx/progress.py index a8939a89..ea0c3fca 100644 --- a/src/apps/wallet/sign_tx/progress.py +++ b/src/apps/wallet/sign_tx/progress.py @@ -1,3 +1,5 @@ +from trezor import ui + _progress = 0 _steps = 0 @@ -5,12 +7,22 @@ _steps = 0 def init(inputs, outputs): global _progress, _steps _progress = 0 - _steps = inputs + outputs + inputs + outputs + inputs + _steps = inputs + inputs + outputs + inputs + report_init() + report() def advance(): - global _progress, _steps + global _progress _progress += 1 + report() + + +def report_init(): + ui.display.clear() + ui.header('Signing transaction') + + +def report(): p = int(1000 * _progress / _steps) - # TODO: draw progress circle using loader - print("%d" % p) + ui.display.loader(p, 18, ui.WHITE, ui.BG) diff --git a/src/apps/wallet/sign_tx/signing.py b/src/apps/wallet/sign_tx/signing.py index 4aa2266f..e00bf6a6 100644 --- a/src/apps/wallet/sign_tx/signing.py +++ b/src/apps/wallet/sign_tx/signing.py @@ -113,7 +113,6 @@ async def check_tx_fee(tx: SignTx, root: bip32.HDNode): 'Wrong input script type') for o in range(tx.outputs_count): - progress.advance() # STAGE_REQUEST_3_OUTPUT txo = await request_tx_output(tx_req, o) txo_bin.amount = txo.amount