diff --git a/app/Makefile.version b/app/Makefile.version index 865f1530..a18a2c13 100644 --- a/app/Makefile.version +++ b/app/Makefile.version @@ -3,4 +3,4 @@ APPVERSION_M=2 # This is the `spec_version` field of `Runtime` APPVERSION_N=36 # This is the patch version of this release -APPVERSION_P=6 +APPVERSION_P=7 diff --git a/app/src/common/parser_common.h b/app/src/common/parser_common.h index 1acf9cb9..521920ca 100644 --- a/app/src/common/parser_common.h +++ b/app/src/common/parser_common.h @@ -87,6 +87,7 @@ typedef enum { parser_swap_wrong_dest_address, parser_swap_wrong_amount, parser_swap_wrong_dest_coins, + parser_swap_wrong_source_coins, parser_swap_wrong_memo, parser_swap_wrong_fee, parser_swap_unexpected_number_of_items, diff --git a/app/src/parser_impl.c b/app/src/parser_impl.c index 15e71b69..6d033a14 100644 --- a/app/src/parser_impl.c +++ b/app/src/parser_impl.c @@ -117,6 +117,8 @@ const char *parser_getErrorDescription(parser_error_t err) { return "Swap wrong type"; case parser_swap_memo_not_present: return "Swap memo not present"; + case parser_swap_wrong_source_coins: + return "Swap wrong source coins"; default: return "Unrecognized error code"; diff --git a/app/src/swap/handle_sign_transaction.c b/app/src/swap/handle_sign_transaction.c index 3bb2db5c..ed10e3cb 100644 --- a/app/src/swap/handle_sign_transaction.c +++ b/app/src/swap/handle_sign_transaction.c @@ -290,21 +290,29 @@ parser_error_t parser_simple_transfer(parser_context_t *ctx_parsed_tx, uint8_t d return parser_swap_unexpected_field; } + // Check source coins are equal to the amount and equal to destination coins + char tmp_amount[100] = {0}; + zxerr_t zxerr = bytesAmountToStringBalance(G_swap_state.amount, G_swap_state.amount_length, tmp_amount, sizeof(tmp_amount)); + if (zxerr != zxerr_ok) { + return parser_swap_wrap_amount_computation_error; + } + + displayIdx += 1; + CHECK_PARSER_ERR(parser_getItem(ctx_parsed_tx, displayIdx, tmpKey, sizeof(tmpKey), tmpValue, sizeof(tmpValue), pageIdx, &pageCount)) + if (strcmp(tmpKey, "Source Coins") != 0 || strcmp(tmpValue, tmp_amount) != 0) { + ZEMU_LOGF(200, "Wrong swap tx source coins ('%s', should be : '%s').\n", tmpValue, tmpKey); + return parser_swap_wrong_source_coins; + } + // Check destination address - displayIdx += 2; + displayIdx += 1; CHECK_PARSER_ERR(parser_getItem(ctx_parsed_tx, displayIdx, tmpKey, sizeof(tmpKey), tmpValue, sizeof(tmpValue), pageIdx, &pageCount)) if (strcmp(tmpKey, "Dest Address") != 0 || strcmp(tmpValue, G_swap_state.destination_address) != 0) { ZEMU_LOGF(200, "Wrong swap tx destination address ('%s', should be : '%s').\n", tmpValue, G_swap_state.destination_address); return parser_swap_wrong_dest_address; } - // Check destination coins - char tmp_amount[100] = {0}; - zxerr_t zxerr = bytesAmountToStringBalance(G_swap_state.amount, G_swap_state.amount_length, tmp_amount, sizeof(tmp_amount)); - if (zxerr != zxerr_ok) { - return parser_swap_wrap_amount_computation_error; - } - + // Check destination coins displayIdx += 1; CHECK_PARSER_ERR(parser_getItem(ctx_parsed_tx, displayIdx, tmpKey, sizeof(tmpKey), tmpValue, sizeof(tmpValue), pageIdx, &pageCount)) if (strcmp(tmpKey, "Dest Coins") != 0 || strcmp(tmp_amount, tmpValue) != 0) { diff --git a/tests_zemu/snapshots/fl-mainmenu/00004.png b/tests_zemu/snapshots/fl-mainmenu/00004.png index 50f87a8a..92b496be 100644 Binary files a/tests_zemu/snapshots/fl-mainmenu/00004.png and b/tests_zemu/snapshots/fl-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/s-mainmenu/00004.png b/tests_zemu/snapshots/s-mainmenu/00004.png index e6299428..53a9188a 100644 Binary files a/tests_zemu/snapshots/s-mainmenu/00004.png and b/tests_zemu/snapshots/s-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/s-mainmenu/00010.png b/tests_zemu/snapshots/s-mainmenu/00010.png index e6299428..53a9188a 100644 Binary files a/tests_zemu/snapshots/s-mainmenu/00010.png and b/tests_zemu/snapshots/s-mainmenu/00010.png differ diff --git a/tests_zemu/snapshots/sp-mainmenu/00004.png b/tests_zemu/snapshots/sp-mainmenu/00004.png index b90112c1..29bb9b47 100644 Binary files a/tests_zemu/snapshots/sp-mainmenu/00004.png and b/tests_zemu/snapshots/sp-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/sp-mainmenu/00010.png b/tests_zemu/snapshots/sp-mainmenu/00010.png index b90112c1..29bb9b47 100644 Binary files a/tests_zemu/snapshots/sp-mainmenu/00010.png and b/tests_zemu/snapshots/sp-mainmenu/00010.png differ diff --git a/tests_zemu/snapshots/st-mainmenu/00004.png b/tests_zemu/snapshots/st-mainmenu/00004.png index 853d40c7..fdabfb9c 100644 Binary files a/tests_zemu/snapshots/st-mainmenu/00004.png and b/tests_zemu/snapshots/st-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00004.png b/tests_zemu/snapshots/x-mainmenu/00004.png index b90112c1..29bb9b47 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00004.png and b/tests_zemu/snapshots/x-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00010.png b/tests_zemu/snapshots/x-mainmenu/00010.png index b90112c1..29bb9b47 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00010.png and b/tests_zemu/snapshots/x-mainmenu/00010.png differ