|
19 | 19 |
|
20 | 20 | #include "bip39.h"
|
21 | 21 | #include "card_fetch_data.h"
|
| 22 | +#include "constant_texts.h" |
22 | 23 | #include "inheritance/core.pb.h"
|
23 | 24 | #include "inheritance_api.h"
|
24 | 25 | #include "inheritance_priv.h"
|
25 | 26 | #include "reconstruct_wallet_flow.h"
|
26 | 27 | #include "status_api.h"
|
| 28 | +#include "ui_core_confirm.h" |
27 | 29 | #include "ui_delay.h"
|
28 | 30 |
|
29 | 31 | /*****************************************************************************
|
@@ -130,6 +132,44 @@ static bool verify_auth_wallet_inputs() {
|
130 | 132 | return true;
|
131 | 133 | }
|
132 | 134 |
|
| 135 | +static bool check_which_request(const inheritance_query_t *query, |
| 136 | + pb_size_t which_request) { |
| 137 | + if (which_request != query->encrypt.which_request) { |
| 138 | + inheritance_send_error(ERROR_COMMON_ERROR_CORRUPT_DATA_TAG, |
| 139 | + ERROR_DATA_FLOW_INVALID_REQUEST); |
| 140 | + return false; |
| 141 | + } |
| 142 | + |
| 143 | + return true; |
| 144 | +} |
| 145 | + |
| 146 | +STATIC bool auth_wallet_handle_inititate_query(inheritance_query_t *query) { |
| 147 | + char wallet_name[NAME_SIZE] = ""; |
| 148 | + char msg[100] = ""; |
| 149 | + |
| 150 | + if (!check_which_request(query, |
| 151 | + INHERITANCE_AUTH_WALLET_REQUEST_INITIATE_TAG) || |
| 152 | + !get_wallet_name_by_id(query->auth_wallet.initiate.wallet_id, |
| 153 | + (uint8_t *)wallet_name, |
| 154 | + inheritance_send_error)) { |
| 155 | + // TODO: update this for nominee |
| 156 | + return false; |
| 157 | + } |
| 158 | + |
| 159 | + snprintf(msg, |
| 160 | + sizeof(msg), |
| 161 | + ui_text_inheritance_wallet_auth_flow_confirmation, |
| 162 | + wallet_name); |
| 163 | + |
| 164 | + if (!core_confirmation(msg, inheritance_send_error)) { |
| 165 | + return false; |
| 166 | + } |
| 167 | + |
| 168 | + // TODO: update flow status here |
| 169 | + |
| 170 | + return true; |
| 171 | +} |
| 172 | + |
133 | 173 | static bool auth_wallet_get_entropy() {
|
134 | 174 | if (auth->do_seed_based) {
|
135 | 175 | uint8_t seed[SIZE_SEED] = {0};
|
@@ -298,7 +338,8 @@ void inheritance_auth_wallet(inheritance_query_t *query) {
|
298 | 338 | auth->do_wallet_based = query->auth_wallet.initiate.do_wallet_based;
|
299 | 339 |
|
300 | 340 | set_app_flow_status(INHERITANCE_AUTH_WALLET_STATUS_INIT);
|
301 |
| - if (verify_auth_wallet_inputs() && auth_wallet_get_entropy() && |
| 341 | + if (verify_auth_wallet_inputs() && |
| 342 | + auth_wallet_handle_inititate_query(query) && auth_wallet_get_entropy() && |
302 | 343 | auth_wallet_get_pairs() && auth_wallet_get_signature() && send_result()) {
|
303 | 344 | delay_scr_init(ui_text_inheritance_wallet_auth_success, DELAY_TIME);
|
304 | 345 | }
|
|
0 commit comments