fix(core): making sure last layouts before signing are always HoldToConfirm

[no changelog]
pull/2750/head
grdddj 1 year ago committed by Jiří Musil
parent 8f7cbf7b9d
commit 32d5beb762

@ -35,20 +35,23 @@ async def require_confirm_transfer(ctx: Context, msg: BinanceTransferMsg) -> Non
for txoutput in msg.outputs:
make_input_output_pages(txoutput, "Confirm output")
await confirm_transfer(ctx, items)
await _confirm_transfer(ctx, items)
async def confirm_transfer(
async def _confirm_transfer(
ctx: Context, inputs_outputs: Sequence[tuple[str, str, str]]
) -> None:
from trezor.ui.layouts import confirm_output
for title, amount, address in inputs_outputs:
for index, (title, amount, address) in enumerate(inputs_outputs):
# Having hold=True on the last item
hold = index == len(inputs_outputs) - 1
await confirm_output(
ctx,
address,
amount,
title,
hold=hold,
)

@ -232,7 +232,7 @@ async def confirm_sending(
to,
format_coin_amount(ada_amount, network_id),
title,
ButtonRequestType.Other,
br_code=ButtonRequestType.Other,
)

@ -7,7 +7,7 @@ if TYPE_CHECKING:
async def process_action(
ctx: wire.Context, sha: HashWriter, action: EosTxActionAck
ctx: wire.Context, sha: HashWriter, action: EosTxActionAck, is_last: bool
) -> None:
from .. import helpers, writers
from . import layout
@ -18,6 +18,10 @@ async def process_action(
if not _check_action(action, name, account):
raise ValueError("Invalid action")
# Little cheat, not having to create "is_last" argument for every action layout
# (not worth spending so many bytes in flash on this)
layout.is_last = is_last
w = bytearray()
if account == "eosio":
if name == "buyram":

@ -28,6 +28,10 @@ if TYPE_CHECKING:
from trezor.ui.layouts import PropertyType
# Whether action is last - and should be HoldToConfirm
is_last = False
# Because icon and br_code are almost always the same
# (and also calling with positional arguments takes less space)
async def _confirm_properties(
@ -41,6 +45,7 @@ async def _confirm_properties(
br_type,
title,
props,
hold=is_last,
br_code=ButtonRequestType.ConfirmOutput,
)
@ -265,6 +270,7 @@ async def confirm_action_unknown(
("Action Name:", eos_name_to_string(action.name)),
("Checksum:", checksum),
),
hold=is_last,
br_code=ButtonRequestType.ConfirmOutput,
)

@ -39,9 +39,10 @@ async def sign_tx(ctx: Context, msg: EosSignTx, keychain: Keychain) -> EosSigned
await require_sign_tx(ctx, num_actions)
# actions
for _ in range(num_actions):
for index in range(num_actions):
action = await ctx.call(EosTxActionRequest(), EosTxActionAck)
await process_action(ctx, sha, action)
is_last = index == num_actions - 1
await process_action(ctx, sha, action, is_last)
write_uvarint(sha, 0)
write_bytes_fixed(sha, bytearray(32), 32)

@ -35,4 +35,4 @@ async def require_confirm_destination_tag(ctx: Context, tag: int) -> None:
async def require_confirm_tx(ctx: Context, to: str, value: int) -> None:
from trezor.ui.layouts import confirm_output
await confirm_output(ctx, to, format_amount(value, DECIMALS) + " XRP")
await confirm_output(ctx, to, format_amount(value, DECIMALS) + " XRP", hold=True)

@ -90,6 +90,7 @@ async def require_confirm_register_delegate(
("Fee:", format_tezos_amount(fee)),
("Address:", address),
),
hold=True,
br_code=BR_SIGN_TX,
)
@ -111,6 +112,7 @@ async def require_confirm_ballot(ctx: Context, proposal: str, ballot: str) -> No
("Ballot:", ballot),
("Proposal:", proposal),
),
hold=True,
br_code=BR_SIGN_TX,
)
@ -121,6 +123,7 @@ async def require_confirm_proposals(ctx: Context, proposals: list[str]) -> None:
"confirm_proposals",
"Submit proposals" if len(proposals) > 1 else "Submit proposal",
[("Proposal " + str(i), proposal) for i, proposal in enumerate(proposals, 1)],
hold=True,
br_code=BR_SIGN_TX,
)

@ -530,6 +530,7 @@ async def confirm_output(
address: str,
amount: str,
title: str = "SENDING",
hold: bool = False,
br_code: ButtonRequestType = ButtonRequestType.ConfirmOutput,
) -> None:
title = title.upper()
@ -546,6 +547,7 @@ async def confirm_output(
verb="NEXT",
)
# Second screen could be HoldToConfirm if requested
await confirm_value(
ctx,
title,
@ -553,7 +555,8 @@ async def confirm_output(
"Amount:",
"confirm_output",
br_code,
verb="NEXT",
verb=None if hold else "NEXT",
hold=hold,
)

@ -646,7 +646,7 @@
"TT_binance-test_get_public_key.py::test_binance_get_public_key": "9ef5e6a9bbf83a72367ee2020dc841985ce15967d5a7285c022ff7c245a01780",
"TT_binance-test_sign_tx.py::test_binance_sign_message[message0-expected_response0]": "839873f4db4c5e2f268f11db80a690529b4dba6342fedb726de9007def9d99ff",
"TT_binance-test_sign_tx.py::test_binance_sign_message[message1-expected_response1]": "0f8f0cb90960d0069d3adc2f78891c2bc74422420bdc72a3e809fac3a6396e2a",
"TT_binance-test_sign_tx.py::test_binance_sign_message[message2-expected_response2]": "8101b0224bc34eaa066b1934e69230f945116f96d0f7c9d766889bbb44fb5778",
"TT_binance-test_sign_tx.py::test_binance_sign_message[message2-expected_response2]": "bfda5e585a303deb898f4ae61ad696c75cca9d88436e3b1ee48dd015b4180815",
"TT_bitcoin-test_authorize_coinjoin.py::test_cancel_authorization": "0a37e7e07f7a7ed8cb00b311046e9e91e0fd211e6c2f22b6ebeb69ec22bdda55",
"TT_bitcoin-test_authorize_coinjoin.py::test_get_address": "eda238e95c759391b5cd746720f2319f4f5b0b23327909457c79d0735eaa002d",
"TT_bitcoin-test_authorize_coinjoin.py::test_get_public_key": "a29b9f19da5cb70a24c2cc89a8c8425d9f085a1f614affdacde891a531180223",
@ -1341,22 +1341,22 @@
"TT_cardano-test_sign_tx.py::test_cardano_sign_tx_show_details[transaction_with_cip36_governanc-36bf9253": "fae55547740e58526335381e6cecf83c16f7992f405deebdce94ef3745d5d7be",
"TT_cardano-test_sign_tx.py::test_cardano_sign_tx_show_details[transaction_with_stake_deregistr-6e84da2f": "4d5905d7446c1088e27c31a81366aaaa1222345945fd1fa066190a3ac21b24e5",
"TT_eos-test_get_public_key.py::test_eos_get_public_key": "1ae52c69bf8f5d6ded30b23b07ac1dddf4f5b5491d3b528fd51938c6f994ee55",
"TT_eos-test_signtx.py::test_eos_signtx_buyram": "750b2ac05bb2ca372e886965bf9dcf9dfa5590f45f647bfbac1c619ce8b3a68b",
"TT_eos-test_signtx.py::test_eos_signtx_buyrambytes": "7a90ba5b3b3ed6524695ee58e2f31cd37dc69ebeff82e6a0f043b3ceaee5e898",
"TT_eos-test_signtx.py::test_eos_signtx_delegate": "10de3306a9ed77369a349f647f9e4b9805e09513bca6512ab3362fad481333dd",
"TT_eos-test_signtx.py::test_eos_signtx_deleteauth": "62889798aa1d566015b9ffca8862a1cfec28919abcaddf7e52b3d3906faac4bd",
"TT_eos-test_signtx.py::test_eos_signtx_linkauth": "6483922b39cf6ee94f91b0ae219cd8b89f28acac09229ab6764c1f0a1cad2363",
"TT_eos-test_signtx.py::test_eos_signtx_newaccount": "732f6ef72996e1d62a3e9f9ea3fdd83c9ba1b6707afa79d46fbfa4632137db6a",
"TT_eos-test_signtx.py::test_eos_signtx_refund": "458405d407d1ee092fc56458444a4abb46a26cc069faea5c25412b7cd938037e",
"TT_eos-test_signtx.py::test_eos_signtx_sellram": "88a6939b14835ae92320fa2f8314608e98f2bf1c00e925c16725d6b58b9fc470",
"TT_eos-test_signtx.py::test_eos_signtx_setcontract": "d421933686183bc1306b8134accd9393f223a215adf4a899e6d38c59ae26ee3a",
"TT_eos-test_signtx.py::test_eos_signtx_transfer_token": "72d6e628a90bff66516b4776f64c3b868dcc187d978d2bac0412051ad4b6cfc4",
"TT_eos-test_signtx.py::test_eos_signtx_undelegate": "0061585cfe23fd1f3ed7cd0914543b320430837c81be1f7560781547c0bf813c",
"TT_eos-test_signtx.py::test_eos_signtx_unknown": "0de49ab6dd2e918fa2b69c3236f7b2767aab29e9f82ef5210052bde65d98f383",
"TT_eos-test_signtx.py::test_eos_signtx_unlinkauth": "d865fa3f7c08fbc43632e77ca9d84dce2c6f7cb85d3676d75ff58420b59659ab",
"TT_eos-test_signtx.py::test_eos_signtx_updateauth": "84c7882bef870512537097c3330e1ef14665ce80d28e888283ee3e122ca0bf54",
"TT_eos-test_signtx.py::test_eos_signtx_vote": "c60c330edb40ac6dd2c0d40b1cbdf7fd9c03c51e4ad243c3776b07bd77007f57",
"TT_eos-test_signtx.py::test_eos_signtx_vote_proxy": "f648146a2755437bc2fe5fd0e2a53d381316a85d75f39f6dfa9b6adc9c76b829",
"TT_eos-test_signtx.py::test_eos_signtx_buyram": "918381bb52ff9afbe4708365a6cfdd8170b6425b442ece654e6f29ea18f5e03f",
"TT_eos-test_signtx.py::test_eos_signtx_buyrambytes": "ef8d6ec55432fd65bf8430802e0092959c887ffd5819162bed4cdb16010e5025",
"TT_eos-test_signtx.py::test_eos_signtx_delegate": "d6aee3fe249d7b3a18706d3d38fbc60ad0760dfab139f5ef05aa9a52c4f34773",
"TT_eos-test_signtx.py::test_eos_signtx_deleteauth": "15c07a440b5810004d2399d1b5a0c42516fbb274a5e95a0bfa70b03e63e972f5",
"TT_eos-test_signtx.py::test_eos_signtx_linkauth": "84fb8ad6218ef99f35b3958abe0e047d3e9806a767b7ef1ef3989cd453008dc0",
"TT_eos-test_signtx.py::test_eos_signtx_newaccount": "ae80fcaf9c313432e7f24d6a4e695da0155979085cb677655c6b40a9172292f8",
"TT_eos-test_signtx.py::test_eos_signtx_refund": "b2e57cb544e02416ae4e8160f299d2c50d2903911512f0ef913083acfc72b15b",
"TT_eos-test_signtx.py::test_eos_signtx_sellram": "0e4560a452b58d200c2a333a36060e69d35f1faab2f50f162ab43e9bdfce3223",
"TT_eos-test_signtx.py::test_eos_signtx_setcontract": "f20cc749f52f34e511d1f919027c2de0a082ebc4be64de79b4ed712843947c9e",
"TT_eos-test_signtx.py::test_eos_signtx_transfer_token": "d0f26b8d6b6aed9e1262e050f2ee8db982b11917e4c491770e75e48ec9e51280",
"TT_eos-test_signtx.py::test_eos_signtx_undelegate": "38d6caebbae413d9e5a5f29ffde078e2bf3090fe9339711fb2ceba03448a98f0",
"TT_eos-test_signtx.py::test_eos_signtx_unknown": "04112c636a5b9f23db814069ab6cb0931bdfa8714a15633e62c8150b5342f0f0",
"TT_eos-test_signtx.py::test_eos_signtx_unlinkauth": "3f93d26616bc17455302bebe2c72b1a9935425bc1f6118048b6fae27d346c5e6",
"TT_eos-test_signtx.py::test_eos_signtx_updateauth": "7e549fd8286e0413b6081ba656b87e4785bcf90ee3bde3635e6092c8e14652e5",
"TT_eos-test_signtx.py::test_eos_signtx_vote": "6651484337dd67fdde8c0022e2b6f9406e2e7c6129c83b73147464e36333fb2b",
"TT_eos-test_signtx.py::test_eos_signtx_vote_proxy": "bcdaf30ff8dd72bf34bbbb2464536f9e82549b994b6cb22164d43d4c74eb5551",
"TT_ethereum-test_getaddress.py::test_getaddress[ETC]": "a4ecdfc2bed7623cc1dda09dcefb077c09a8d8e9aec596f94bc14351fe94b50b",
"TT_ethereum-test_getaddress.py::test_getaddress[GoChain]": "a4ecdfc2bed7623cc1dda09dcefb077c09a8d8e9aec596f94bc14351fe94b50b",
"TT_ethereum-test_getaddress.py::test_getaddress[Ledger Live legacy path]": "a4ecdfc2bed7623cc1dda09dcefb077c09a8d8e9aec596f94bc14351fe94b50b",
@ -1543,7 +1543,7 @@
"TT_ripple-test_get_address.py::test_ripple_get_address": "bd83a31d0fc4c23953dfd0d138e4441984e34698ace96aad5308a4ae51b712ae",
"TT_ripple-test_get_address.py::test_ripple_get_address_other": "bd83a31d0fc4c23953dfd0d138e4441984e34698ace96aad5308a4ae51b712ae",
"TT_ripple-test_sign_tx.py::test_ripple_sign_invalid_fee": "bd83a31d0fc4c23953dfd0d138e4441984e34698ace96aad5308a4ae51b712ae",
"TT_ripple-test_sign_tx.py::test_ripple_sign_simple_tx": "d86c4b758cccbf9677311c81f089134917fe1eb0ef71061c0f68ce0fecea7337",
"TT_ripple-test_sign_tx.py::test_ripple_sign_simple_tx": "9aa45811c9e4055119fb78aa2d69a835f92dcce52496036f8f3cbb9f10743496",
"TT_stellar-test_stellar.py::test_get_address[parameters0-result0]": "c9f051657d17fa6167ce4e38be664dc287a6d578333d095dc90ee76e93474cba",
"TT_stellar-test_stellar.py::test_get_address[parameters1-result1]": "f77e8d5bd0e34fef7e4713db30e55603fa68b83a34692f8b8633041d9e1616be",
"TT_stellar-test_stellar.py::test_get_address[parameters2-result2]": "4d2ed314132535b07936d98d2eb135473226fd40bd44bc7af2f72e9b6b044372",
@ -1699,14 +1699,14 @@
"TT_tezos-test_getpublickey.py::test_tezos_get_public_key": "bd83a31d0fc4c23953dfd0d138e4441984e34698ace96aad5308a4ae51b712ae",
"TT_tezos-test_sign_tx.py::test_tezos_kt_remove_delegation": "9f9b82e59e3898e0e4acda21492bd686927d239977071fa1dd8753c8cc6866ad",
"TT_tezos-test_sign_tx.py::test_tezos_sign_tx_delegation": "46e59e9de90d0182c6b4ca796afb2f06f97899f758d55ee55e901ed0ac8565a4",
"TT_tezos-test_sign_tx.py::test_tezos_sign_tx_multiple_proposals": "2d0ca8bf739f132c0bf1699b2fce67aba7cb2d7ee6aed09c4f4d66842d0c8aab",
"TT_tezos-test_sign_tx.py::test_tezos_sign_tx_multiple_proposals": "46cda97a0333ec4d30f5ae0b88ee7ec54130e91f1f9ee2c54cb104154b517552",
"TT_tezos-test_sign_tx.py::test_tezos_sign_tx_origination": "7a73d93083123748773c3a3ba623e5ba7a25424a44b2b47a2541c595e991e75b",
"TT_tezos-test_sign_tx.py::test_tezos_sign_tx_proposal": "fb93a87cd54d909f46332f2bf196674bbb93da29ca1409a416bb32f3be3ee89f",
"TT_tezos-test_sign_tx.py::test_tezos_sign_tx_proposal": "11abc524c17137d4f905ba36525162e355183bc5b8e59d57bd577165535183e8",
"TT_tezos-test_sign_tx.py::test_tezos_sign_tx_reveal": "13789ebf1b54305e366200e33bd0cd93ed5733d624be00fa80d8e01002e93d3d",
"TT_tezos-test_sign_tx.py::test_tezos_sign_tx_tranasaction": "33aa6551e484338866ebad6dc6bed340f1fc5b13d89d647e7c29ce68b5ef681a",
"TT_tezos-test_sign_tx.py::test_tezos_sing_tx_ballot_nay": "c5a0eb57e0976eefda6e847d61756c577ca970dba797bee41ad229d521b889be",
"TT_tezos-test_sign_tx.py::test_tezos_sing_tx_ballot_pass": "77508740843021f02f41afbfe781aaf72dc64875bfad671e465f64e8385290ae",
"TT_tezos-test_sign_tx.py::test_tezos_sing_tx_ballot_yay": "8ad2e969e8b991740e1a6d7d9b2ed8b458cf9b32c7eddee46e47b598c6c9e0c1",
"TT_tezos-test_sign_tx.py::test_tezos_sing_tx_ballot_nay": "e526937f008fec4ad79b7fdfc328f30498728611e395a1ebfa9e5cbad7168322",
"TT_tezos-test_sign_tx.py::test_tezos_sing_tx_ballot_pass": "ef196800f29b85ff23559774b9aaf8d54f34de82072086a4268f4005033be319",
"TT_tezos-test_sign_tx.py::test_tezos_sing_tx_ballot_yay": "559b81878d868c95ac40490427f34a3581ec3cc0db91939b47a7e009378653aa",
"TT_tezos-test_sign_tx.py::test_tezos_smart_contract_delegation": "40495fa3cdc28344964ed1326e4affd89691e64862a4b48009b302c7ab2562a4",
"TT_tezos-test_sign_tx.py::test_tezos_smart_contract_transfer": "70526a90135e320368b1ef147dc6eae84409143226b4e6276b3840d7cabcb84b",
"TT_tezos-test_sign_tx.py::test_tezos_smart_contract_transfer_to_contract": "cf949dfe6fe0846c1d9c57e182a4dbfb2d95ff92b23fce02b2cc103b9d530740",

Loading…
Cancel
Save