diff --git a/src/commands/signtx/operations/stx_op_p2pk.c b/src/commands/signtx/operations/stx_op_p2pk.c index 5ad8ec6d..d698b045 100644 --- a/src/commands/signtx/operations/stx_op_p2pk.c +++ b/src/commands/signtx/operations/stx_op_p2pk.c @@ -309,9 +309,8 @@ bool stx_operation_p2pk_should_show_output_confirm_screen( // if change index is < 20 then we approve it automatically if (ctx->transaction.ui.output.bip32_path.path[4] < 20) return false; // Check was it already approved then approve automatically - if (memcmp(&ctx->transaction.ui.output.bip32_path, - &ctx->transaction.last_approved_change, - sizeof(sign_transaction_bip32_path_t)) == 0) + if (stx_bip32_path_is_equal(&ctx->transaction.ui.output.bip32_path, + &ctx->transaction.last_approved_change)) return false; } return true; diff --git a/src/commands/signtx/stx_output.h b/src/commands/signtx/stx_output.h index 6f95ccd2..ff0b3abc 100644 --- a/src/commands/signtx/stx_output.h +++ b/src/commands/signtx/stx_output.h @@ -82,4 +82,9 @@ static inline sign_transaction_output_info_type_e stx_output_info_type( static inline bool stx_output_info_is_finished(const sign_transaction_output_info_ctx_t* ctx) { return STX_OUTPUT_INFO_IS_TREE_SET(ctx) && STX_OUTPUT_INFO_IS_BOX_FINISHED(ctx); +} + +static inline bool stx_bip32_path_is_equal(const sign_transaction_bip32_path_t* p1, + const sign_transaction_bip32_path_t* p2) { + return bip32_path_is_equal(p1->path, p1->len, p2->path, p2->len); } \ No newline at end of file diff --git a/src/common/bip32_ext.h b/src/common/bip32_ext.h index 1ca16a8b..32fbaf3a 100644 --- a/src/common/bip32_ext.h +++ b/src/common/bip32_ext.h @@ -20,3 +20,11 @@ bool bip32_path_validate(const uint32_t *bip32_path, uint32_t type, uint32_t coin, bip32_path_validation_type_e vtype); + +static inline bool bip32_path_is_equal(const uint32_t *bip32_path_1, + uint8_t bip32_path_1_len, + const uint32_t *bip32_path_2, + uint8_t bip32_path_2_len) { + return bip32_path_1_len == bip32_path_2_len && + memcmp(bip32_path_1, bip32_path_2, bip32_path_1_len) == 0; +} \ No newline at end of file