From aa71c20f2c262ae72820ef9c58d3f54a2d8e099d Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Tue, 24 Mar 2020 09:20:10 +0000 Subject: [PATCH] core: require hold to confirm --- core/src/apps/binance/layout.py | 10 ++++++---- core/src/apps/cardano/layout/__init__.py | 6 +++--- core/src/apps/cardano/sign_tx.py | 15 +++++---------- core/src/apps/management/reset_device/layout.py | 4 ++-- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/core/src/apps/binance/layout.py b/core/src/apps/binance/layout.py index e2a7422fd7..89b430cc56 100644 --- a/core/src/apps/binance/layout.py +++ b/core/src/apps/binance/layout.py @@ -13,7 +13,7 @@ from trezor.ui.text import Text from . import helpers -from apps.common.confirm import hold_to_confirm +from apps.common.confirm import require_hold_to_confirm from apps.common.layout import split_address @@ -38,7 +38,9 @@ async def require_confirm_transfer(ctx, msg: BinanceTransferMsg): for txoutput in msg.outputs: pages.extend(make_input_output_pages(txoutput, "output")) - return await hold_to_confirm(ctx, Paginated(pages), ButtonRequestType.ConfirmOutput) + return await require_hold_to_confirm( + ctx, Paginated(pages), ButtonRequestType.ConfirmOutput + ) async def require_confirm_cancel(ctx, msg: BinanceCancelMsg): @@ -52,7 +54,7 @@ async def require_confirm_cancel(ctx, msg: BinanceCancelMsg): page2.normal("Order ID:") page2.bold(msg.refid) - return await hold_to_confirm( + return await require_hold_to_confirm( ctx, Paginated([page1, page2]), ButtonRequestType.SignTx ) @@ -77,6 +79,6 @@ async def require_confirm_order(ctx, msg: BinanceOrderMsg): page3.normal("Price:") page3.bold(format_amount(msg.price, helpers.DECIMALS)) - return await hold_to_confirm( + return await require_hold_to_confirm( ctx, Paginated([page1, page2, page3]), ButtonRequestType.SignTx ) diff --git a/core/src/apps/cardano/layout/__init__.py b/core/src/apps/cardano/layout/__init__.py index 53c2a7fb4c..f5f8fae0ab 100644 --- a/core/src/apps/cardano/layout/__init__.py +++ b/core/src/apps/cardano/layout/__init__.py @@ -6,7 +6,7 @@ from trezor.ui.scroll import Paginated from trezor.ui.text import Text from trezor.utils import chunks -from apps.common.confirm import confirm, hold_to_confirm +from apps.common.confirm import require_confirm, require_hold_to_confirm def format_coin_amount(amount): @@ -32,7 +32,7 @@ async def confirm_sending(ctx, amount, to): t.bold(line) pages.append(t) - return await confirm(ctx, Paginated(pages)) + await require_confirm(ctx, Paginated(pages)) async def confirm_transaction(ctx, amount, fee, network_name): @@ -46,4 +46,4 @@ async def confirm_transaction(ctx, amount, fee, network_name): t2.normal("Network:") t2.bold(network_name) - return await hold_to_confirm(ctx, Paginated([t1, t2])) + await require_hold_to_confirm(ctx, Paginated([t1, t2])) diff --git a/core/src/apps/cardano/sign_tx.py b/core/src/apps/cardano/sign_tx.py index e32eaa1a9b..60dd41547b 100644 --- a/core/src/apps/cardano/sign_tx.py +++ b/core/src/apps/cardano/sign_tx.py @@ -47,19 +47,15 @@ async def show_tx( network_name: str, raw_inputs: list, raw_outputs: list, -) -> bool: +) -> None: for index, output in enumerate(outputs): if is_change(raw_outputs[index].address_n, raw_inputs): continue - if not await confirm_sending(ctx, outcoins[index], output): - return False + await confirm_sending(ctx, outcoins[index], output) total_amount = sum(outcoins) - if not await confirm_transaction(ctx, total_amount, fee, network_name): - return False - - return True + await confirm_transaction(ctx, total_amount, fee, network_name) async def request_transaction(ctx, tx_req: CardanoTxRequest, index: int): @@ -114,7 +110,7 @@ async def sign_tx(ctx, msg): raise wire.ProcessError("Signing failed") # display the transaction in UI - if not await show_tx( + await show_tx( ctx, transaction.output_addresses, transaction.outgoing_coins, @@ -122,8 +118,7 @@ async def sign_tx(ctx, msg): transaction.network_name, transaction.inputs, transaction.outputs, - ): - raise wire.ActionCancelled("Signing cancelled") + ) return tx diff --git a/core/src/apps/management/reset_device/layout.py b/core/src/apps/management/reset_device/layout.py index 93aa993543..8652c1c399 100644 --- a/core/src/apps/management/reset_device/layout.py +++ b/core/src/apps/management/reset_device/layout.py @@ -11,7 +11,7 @@ from trezor.ui.num_input import NumInput from trezor.ui.scroll import Paginated from trezor.ui.text import Text -from apps.common.confirm import confirm, hold_to_confirm, require_confirm +from apps.common.confirm import confirm, require_confirm, require_hold_to_confirm from apps.common.layout import show_success if __debug__: @@ -127,7 +127,7 @@ async def _show_share_words(ctx, share_words, share_index=None, group_index=None utils.ensure(share_words == shares_words_check) # confirm the share - await hold_to_confirm(ctx, paginated, ButtonRequestType.ResetDevice) + await require_hold_to_confirm(ctx, paginated, ButtonRequestType.ResetDevice) def _split_share_into_pages(share_words):