From 6bcb4bc9f86885345b2bdcf0ea98713c3221731c Mon Sep 17 00:00:00 2001 From: Charles-Edouard de la Vergne Date: Tue, 12 Mar 2024 18:56:10 +0100 Subject: [PATCH] Add 'sender' field --- src_bagl/ui_flow_signTx.c | 8 ++++++-- src_features/signTx/logic_signTx.c | 29 +++++++++++------------------ src_nbgl/ui_approve_tx.c | 2 +- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src_bagl/ui_flow_signTx.c b/src_bagl/ui_flow_signTx.c index 0d48ce2db2..d4ad2925b1 100644 --- a/src_bagl/ui_flow_signTx.c +++ b/src_bagl/ui_flow_signTx.c @@ -232,12 +232,16 @@ void ux_approve_tx(bool fromPlugin) { if (has_domain_name(&chain_id, tmpContent.txContent.destination)) { ux_approval_tx_flow[step++] = &ux_domain_name_step; if (N_storage.verbose_domain_name) { - ux_approval_tx_flow[step++] = &ux_approval_from_step; + if (strings.common.fromAddress[0] != 0) { + ux_approval_tx_flow[step++] = &ux_approval_from_step; + } ux_approval_tx_flow[step++] = &ux_approval_address_step; } } else { #endif // HAVE_DOMAIN_NAME - ux_approval_tx_flow[step++] = &ux_approval_from_step; + if (strings.common.fromAddress[0] != 0) { + ux_approval_tx_flow[step++] = &ux_approval_from_step; + } ux_approval_tx_flow[step++] = &ux_approval_address_step; #ifdef HAVE_DOMAIN_NAME } diff --git a/src_features/signTx/logic_signTx.c b/src_features/signTx/logic_signTx.c index df0cafa969..11ecf12d59 100644 --- a/src_features/signTx/logic_signTx.c +++ b/src_features/signTx/logic_signTx.c @@ -499,27 +499,20 @@ __attribute__((noinline)) static bool finalize_parsing_helper(bool direct, bool } PRINTF("Amount displayed: %s\n", strings.common.fullAmount); - // Format the from address in a temporary buffer, if in swap case compare it with validated - // address, else commit it - address_to_string(msg_sender, - ADDRESS_LENGTH, - displayBuffer, - sizeof(displayBuffer), - &global_sha3, - chainConfig->chainId); // TODO CHECK chainId here! - - // TODO CHECK swap case here! if (G_called_from_swap) { - PRINTF("CHECK FROM Address from swap...\n"); - // Ensure the values are the same that the ones that have been previously validated - if (strcasecmp_workaround(strings.common.fromAddress, displayBuffer) != 0) { - PRINTF("ERR_SILENT_MODE_CHECK_FAILED, FROM address check failed\n"); - THROW(ERR_SILENT_MODE_CHECK_FAILED); - } + // Transaction parameters are managed by the Exchange caller app! + explicit_bzero(strings.common.fromAddress, sizeof(strings.common.fromAddress)); } else { - strlcpy(strings.common.fromAddress, displayBuffer, sizeof(strings.common.fromAddress)); + // Format the from address in a temporary buffer, if in swap case compare it with validated + // address, else commit it + address_to_string(msg_sender, + ADDRESS_LENGTH, + strings.common.fromAddress, + sizeof(strings.common.fromAddress), + &global_sha3, + chainConfig->chainId); + PRINTF("FROM Address displayed: %s\n", strings.common.fromAddress); } - PRINTF("FROM Address displayed: %s\n", strings.common.fromAddress); } // Compute the max fee in a temporary buffer, if in swap case compare it with validated max fee, diff --git a/src_nbgl/ui_approve_tx.c b/src_nbgl/ui_approve_tx.c index e3fbe5bbb3..ebd6c846ec 100644 --- a/src_nbgl/ui_approve_tx.c +++ b/src_nbgl/ui_approve_tx.c @@ -103,7 +103,7 @@ static nbgl_layoutTagValue_t *getTagValuePair(uint8_t pairIndex) { pair.item = "Amount"; pair.value = strings.common.fullAmount; } - if (pairIndex == target_index++) { + if ((strings.common.fromAddress[0] != 0) && (pairIndex == target_index++)) { pair.item = "Address From"; pair.value = strings.common.fromAddress; }