1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 12:28:09 +00:00

core: remove unimports from bitcoin sign_tx layouts

This commit is contained in:
Martin Milata 2020-07-24 15:32:10 +02:00 committed by Tomas Susanka
parent 47e7550423
commit 3021233eaf
2 changed files with 5 additions and 34 deletions

View File

@ -45,43 +45,29 @@ async def sign_tx(
break break
res = await ctx.call(req, TxAck, field_cache) res = await ctx.call(req, TxAck, field_cache)
elif isinstance(req, helpers.UiConfirmOutput): elif isinstance(req, helpers.UiConfirmOutput):
mods = utils.unimport_begin()
res = await layout.confirm_output(ctx, req.output, req.coin) res = await layout.confirm_output(ctx, req.output, req.coin)
utils.unimport_end(mods)
progress.report_init() progress.report_init()
elif isinstance(req, helpers.UiConfirmTotal): elif isinstance(req, helpers.UiConfirmTotal):
mods = utils.unimport_begin()
res = await layout.confirm_total(ctx, req.spending, req.fee, req.coin) res = await layout.confirm_total(ctx, req.spending, req.fee, req.coin)
utils.unimport_end(mods)
progress.report_init() progress.report_init()
elif isinstance(req, helpers.UiConfirmJointTotal): elif isinstance(req, helpers.UiConfirmJointTotal):
mods = utils.unimport_begin()
res = await layout.confirm_joint_total( res = await layout.confirm_joint_total(
ctx, req.spending, req.total, req.coin ctx, req.spending, req.total, req.coin
) )
utils.unimport_end(mods)
progress.report_init() progress.report_init()
elif isinstance(req, helpers.UiConfirmFeeOverThreshold): elif isinstance(req, helpers.UiConfirmFeeOverThreshold):
mods = utils.unimport_begin()
res = await layout.confirm_feeoverthreshold(ctx, req.fee, req.coin) res = await layout.confirm_feeoverthreshold(ctx, req.fee, req.coin)
utils.unimport_end(mods)
progress.report_init() progress.report_init()
elif isinstance(req, helpers.UiConfirmChangeCountOverThreshold): elif isinstance(req, helpers.UiConfirmChangeCountOverThreshold):
mods = utils.unimport_begin()
res = await layout.confirm_change_count_over_threshold( res = await layout.confirm_change_count_over_threshold(
ctx, req.change_count ctx, req.change_count
) )
utils.unimport_end(mods)
progress.report_init() progress.report_init()
elif isinstance(req, helpers.UiConfirmNonDefaultLocktime): elif isinstance(req, helpers.UiConfirmNonDefaultLocktime):
mods = utils.unimport_begin()
res = await layout.confirm_nondefault_locktime(ctx, req.lock_time) res = await layout.confirm_nondefault_locktime(ctx, req.lock_time)
utils.unimport_end(mods)
progress.report_init() progress.report_init()
elif isinstance(req, helpers.UiConfirmForeignAddress): elif isinstance(req, helpers.UiConfirmForeignAddress):
mods = utils.unimport_begin()
res = await paths.show_path_warning(ctx, req.address_n) res = await paths.show_path_warning(ctx, req.address_n)
utils.unimport_end(mods)
progress.report_init() progress.report_init()
else: else:
raise TypeError("Invalid signing instruction") raise TypeError("Invalid signing instruction")

View File

@ -5,9 +5,14 @@ from trezor import ui
from trezor.messages import ButtonRequestType, OutputScriptType from trezor.messages import ButtonRequestType, OutputScriptType
from trezor.messages.TxOutputType import TxOutputType from trezor.messages.TxOutputType import TxOutputType
from trezor.strings import format_amount from trezor.strings import format_amount
from trezor.ui.text import Text
from trezor.utils import chunks from trezor.utils import chunks
from apps.common import coininfo from apps.common import coininfo
from apps.common.confirm import require_confirm, require_hold_to_confirm
from .. import addresses
from . import omni
if False: if False:
from typing import Iterator from typing import Iterator
@ -31,11 +36,6 @@ def split_op_return(data: str) -> Iterator[str]:
async def confirm_output( async def confirm_output(
ctx: wire.Context, output: TxOutputType, coin: coininfo.CoinInfo ctx: wire.Context, output: TxOutputType, coin: coininfo.CoinInfo
) -> None: ) -> None:
from trezor.ui.text import Text
from apps.common.confirm import require_confirm
from . import omni
from .. import addresses
if output.script_type == OutputScriptType.PAYTOOPRETURN: if output.script_type == OutputScriptType.PAYTOOPRETURN:
data = output.op_return_data data = output.op_return_data
if omni.is_valid(data): if omni.is_valid(data):
@ -61,9 +61,6 @@ async def confirm_output(
async def confirm_joint_total( async def confirm_joint_total(
ctx: wire.Context, spending: int, total: int, coin: coininfo.CoinInfo ctx: wire.Context, spending: int, total: int, coin: coininfo.CoinInfo
) -> None: ) -> None:
from trezor.ui.text import Text
from apps.common.confirm import require_hold_to_confirm
text = Text("Joint transaction", ui.ICON_SEND, ui.GREEN) text = Text("Joint transaction", ui.ICON_SEND, ui.GREEN)
text.normal("You are contributing:") text.normal("You are contributing:")
text.bold(format_coin_amount(spending, coin)) text.bold(format_coin_amount(spending, coin))
@ -75,9 +72,6 @@ async def confirm_joint_total(
async def confirm_total( async def confirm_total(
ctx: wire.Context, spending: int, fee: int, coin: coininfo.CoinInfo ctx: wire.Context, spending: int, fee: int, coin: coininfo.CoinInfo
) -> None: ) -> None:
from trezor.ui.text import Text
from apps.common.confirm import require_hold_to_confirm
text = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN) text = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
text.normal("Total amount:") text.normal("Total amount:")
text.bold(format_coin_amount(spending, coin)) text.bold(format_coin_amount(spending, coin))
@ -89,9 +83,6 @@ async def confirm_total(
async def confirm_feeoverthreshold( async def confirm_feeoverthreshold(
ctx: wire.Context, fee: int, coin: coininfo.CoinInfo ctx: wire.Context, fee: int, coin: coininfo.CoinInfo
) -> None: ) -> None:
from trezor.ui.text import Text
from apps.common.confirm import require_confirm
text = Text("High fee", ui.ICON_SEND, ui.GREEN) text = Text("High fee", ui.ICON_SEND, ui.GREEN)
text.normal("The fee of") text.normal("The fee of")
text.bold(format_coin_amount(fee, coin)) text.bold(format_coin_amount(fee, coin))
@ -102,9 +93,6 @@ async def confirm_feeoverthreshold(
async def confirm_change_count_over_threshold( async def confirm_change_count_over_threshold(
ctx: wire.Context, change_count: int ctx: wire.Context, change_count: int
) -> None: ) -> None:
from trezor.ui.text import Text
from apps.common.confirm import require_confirm
text = Text("Warning", ui.ICON_SEND, ui.GREEN) text = Text("Warning", ui.ICON_SEND, ui.GREEN)
text.normal("There are {}".format(change_count)) text.normal("There are {}".format(change_count))
text.normal("change-outputs.") text.normal("change-outputs.")
@ -114,9 +102,6 @@ async def confirm_change_count_over_threshold(
async def confirm_nondefault_locktime(ctx: wire.Context, lock_time: int) -> None: async def confirm_nondefault_locktime(ctx: wire.Context, lock_time: int) -> None:
from trezor.ui.text import Text
from apps.common.confirm import require_confirm
text = Text("Confirm locktime", ui.ICON_SEND, ui.GREEN) text = Text("Confirm locktime", ui.ICON_SEND, ui.GREEN)
text.normal("Locktime for this transaction is set to") text.normal("Locktime for this transaction is set to")
if lock_time < _LOCKTIME_TIMESTAMP_MIN_VALUE: if lock_time < _LOCKTIME_TIMESTAMP_MIN_VALUE: