diff --git a/src/apdu_pubkey.h b/src/apdu_pubkey.h index 06266785..c157a5f3 100644 --- a/src/apdu_pubkey.h +++ b/src/apdu_pubkey.h @@ -5,9 +5,6 @@ size_t handle_apdu_get_public_key(uint8_t instruction, volatile uint32_t* flags); void prompt_address( -#ifndef BAKING_APP - __attribute__((unused)) -#endif bool baking, ui_callback_t ok_cb, ui_callback_t cxl_cb); diff --git a/src/apdu_sign.c b/src/apdu_sign.c index 5f18cf09..6b9aa77b 100644 --- a/src/apdu_sign.c +++ b/src/apdu_sign.c @@ -99,20 +99,6 @@ static bool is_operation_allowed(enum operation_tag tag) { return true; case OPERATION_TAG_BABYLON_REVEAL: return true; -#ifndef BAKING_APP - case OPERATION_TAG_PROPOSAL: - return true; - case OPERATION_TAG_BALLOT: - return true; - case OPERATION_TAG_ATHENS_ORIGINATION: - return true; - case OPERATION_TAG_ATHENS_TRANSACTION: - return true; - case OPERATION_TAG_BABYLON_ORIGINATION: - return true; - case OPERATION_TAG_BABYLON_TRANSACTION: - return true; -#endif default: return false; } @@ -131,18 +117,6 @@ static bool parse_allowed_operations(struct parsed_operation_group *const out, &is_operation_allowed); } -#else - -static bool parse_allowed_operation_packet(struct parsed_operation_group *const out, - uint8_t const *const in, - size_t const in_size) { - return parse_operations_packet(out, in, in_size, &is_operation_allowed); -} - -#endif - -#ifdef BAKING_APP // ---------------------------------------------------------- - size_t baking_sign_complete(bool const send_hash, volatile uint32_t *flags) { switch (G.magic_byte) { case MAGIC_BYTE_TENDERBAKE_BLOCK: @@ -194,9 +168,6 @@ static uint8_t get_magic_byte_or_throw(uint8_t const *const buff, size_t const b case MAGIC_BYTE_BLOCK: case MAGIC_BYTE_BAKING_OP: case MAGIC_BYTE_UNSAFE_OP: // Only for self-delegations -#else - case MAGIC_BYTE_UNSAFE_OP: - case MAGIC_BYTE_UNSAFE_OP3: #endif return magic_byte; @@ -223,12 +194,6 @@ static size_t handle_apdu(bool const enable_hashing, global.path_with_curve.derivation_type = parse_derivation_type(G_io_apdu_buffer[OFFSET_CURVE]); return finalize_successful_send(0); -#ifndef BAKING_APP - case P1_HASH_ONLY_NEXT: - // This is a debugging Easter egg - G.hash_only = true; - __attribute__((fallthrough)); -#endif case P1_NEXT: if (global.path_with_curve.bip32_path.length == 0) THROW(EXC_WRONG_LENGTH_FOR_INS); @@ -254,31 +219,6 @@ static size_t handle_apdu(bool const enable_hashing, // This should be a baking operation so parse it. if (!parse_baking_data(&G.parsed_baking_data, buff, buff_size)) PARSE_ERROR(); } -#else - if (G.packet_index == 1) { - G.maybe_ops.is_valid = false; - G.magic_byte = get_magic_byte_or_throw(buff, buff_size); - - // If it is an "operation" (starting with the 0x03 magic byte), set up parsing - // If it is arbitrary Michelson (starting with 0x05), dont bother parsing and show - // the "Sign Hash" prompt - if (G.magic_byte == MAGIC_BYTE_UNSAFE_OP) { - parse_operations_init(&G.maybe_ops.v, - global.path_with_curve.derivation_type, - &global.path_with_curve.bip32_path, - &G.parse_state); - } - // If magic byte is not 0x03 or 0x05, fail - else if (G.magic_byte != MAGIC_BYTE_UNSAFE_OP3) { - PARSE_ERROR(); - } - } - - // Only parse if the message is an "Operation" - if (G.magic_byte == MAGIC_BYTE_UNSAFE_OP) { - parse_allowed_operation_packet(&G.maybe_ops.v, buff, buff_size); - } - #endif } @@ -315,8 +255,6 @@ static size_t handle_apdu(bool const enable_hashing, return #ifdef BAKING_APP baking_sign_complete(instruction == INS_SIGN_WITH_HASH, flags); -#else - wallet_sign_complete(instruction, G.magic_byte, flags); #endif } else { return finalize_successful_send(0); @@ -338,12 +276,6 @@ size_t handle_apdu_sign_with_hash(uint8_t instruction, volatile uint32_t *flags) int perform_signature(bool const on_hash, bool const send_hash) { #ifdef BAKING_APP write_high_water_mark(&G.parsed_baking_data); -#else - if (on_hash && G.hash_only) { - memcpy(G_io_apdu_buffer, G.final_hash, sizeof(G.final_hash)); - clear_data(); - return finalize_successful_send(sizeof(G.final_hash)); - } #endif size_t tx = 0; diff --git a/src/apdu_sign.h b/src/apdu_sign.h index 22215d73..d29cefc8 100644 --- a/src/apdu_sign.h +++ b/src/apdu_sign.h @@ -9,13 +9,6 @@ size_t handle_apdu_sign_with_hash(uint8_t instruction, volatile uint32_t* flags) void prompt_register_delegate(ui_callback_t const ok_cb, ui_callback_t const cxl_cb); -#else // ifdef BAKING_APP ----------------------------------------------------- -bool prompt_transaction(struct parsed_operation_group const* const ops, - bip32_path_with_curve_t const* const key, - ui_callback_t ok, - ui_callback_t cxl); - -size_t wallet_sign_complete(uint8_t instruction, uint8_t magic_byte, volatile uint32_t* flags); #endif // ifdef BAKING_APP ---------------------------------------------------- int perform_signature(bool const on_hash, bool const send_hash); diff --git a/src/boot.c b/src/boot.c index afe705de..1d7f39fd 100644 --- a/src/boot.c +++ b/src/boot.c @@ -81,7 +81,5 @@ __attribute__((section(".boot"))) int main(arg0) { false #endif ); // Should not be allowed dashboard access -#else - exit_app(); #endif } diff --git a/src/main.c b/src/main.c index 7c5081e6..a63b0619 100644 --- a/src/main.c +++ b/src/main.c @@ -32,8 +32,6 @@ __attribute__((noreturn)) void app_main(void) { global.handlers[APDU_INS(INS_QUERY_AUTH_KEY_WITH_CURVE)] = handle_apdu_query_auth_key_with_curve; global.handlers[APDU_INS(INS_HMAC)] = handle_apdu_hmac; -#else - global.handlers[APDU_INS(INS_SIGN_UNSAFE)] = handle_apdu_sign; #endif main_loop(global.handlers, NUM_ELEMENTS(global.handlers)); } diff --git a/src/operations.c b/src/operations.c index 1945c590..ed6f7a23 100644 --- a/src/operations.c +++ b/src/operations.c @@ -962,34 +962,4 @@ bool parse_operations(struct parsed_operation_group *const out, END_TRY; return true; } - -#else - -bool parse_operations_packet(struct parsed_operation_group *const out, - uint8_t const *const data, - size_t length, - is_operation_allowed_t is_operation_allowed) { - BEGIN_TRY { - TRY { - size_t ix = 0; - while (ix < length) { - uint8_t byte = ((uint8_t *) data)[ix]; - parse_byte(byte, &G.parse_state, out, is_operation_allowed); - PRINTF("Byte: %x - Next op_step state: %d\n", byte, G.parse_state.op_step); - ix++; - } - } - CATCH(EXC_PARSE_ERROR) { - return false; - } - CATCH_OTHER(e) { - THROW(e); - } - FINALLY { - } - } - END_TRY; - return true; -} - #endif diff --git a/src/ui_bagl.c b/src/ui_bagl.c index cdd498f8..0f7416cd 100644 --- a/src/ui_bagl.c +++ b/src/ui_bagl.c @@ -232,8 +232,6 @@ void ui_initial_screen(void) { init_screen_stack(); #ifdef BAKING_APP calculate_baking_idle_screens_data(); -#else - push_ui_callback("Tezos Wallet", copy_string, VERSION); #endif ux_idle_screen(NULL, NULL); diff --git a/src/ui_nbgl.c b/src/ui_nbgl.c index add7991b..f891c1a0 100644 --- a/src/ui_nbgl.c +++ b/src/ui_nbgl.c @@ -73,31 +73,6 @@ void ui_menu_about_baking(void) { navigation_cb_baking, NULL); } - -#else -static bool navigation_cb_wallet(uint8_t page, nbgl_pageContent_t* content) { - UNUSED(page); - - if (page == 0) { - content->type = INFOS_LIST; - content->infosList.nbInfos = 3; - content->infosList.infoTypes = infoTypes; - content->infosList.infoContents = infoContents; - } - - return true; -} - -void ui_menu_about_wallet(void) { - nbgl_useCaseSettings("Tezos wallet", - 0, - 1, - false, - ui_initial_screen, - navigation_cb_wallet, - NULL); -} - #endif void ux_idle_screen(ui_callback_t ok_c, ui_callback_t cxl_c) { @@ -106,8 +81,6 @@ void ux_idle_screen(ui_callback_t ok_c, ui_callback_t cxl_c) { #ifdef BAKING_APP nbgl_useCaseHome("Tezos Baking", &C_tezos, NULL, false, ui_menu_about_baking, exit_app); -#else - nbgl_useCaseHome("Tezos", &C_tezos, NULL, false, ui_menu_about_wallet, exit_app); #endif } diff --git a/src/ui_pubkey_bagl.c b/src/ui_pubkey_bagl.c index 1101c67e..29b337ad 100644 --- a/src/ui_pubkey_bagl.c +++ b/src/ui_pubkey_bagl.c @@ -15,9 +15,6 @@ #include __attribute__((noreturn)) void prompt_address( -#ifndef BAKING_APP - __attribute__((unused)) -#endif bool baking, ui_callback_t ok_cb, ui_callback_t cxl_cb) { diff --git a/src/ui_pubkey_nbgl.c b/src/ui_pubkey_nbgl.c index 01aacb8f..86977c8d 100644 --- a/src/ui_pubkey_nbgl.c +++ b/src/ui_pubkey_nbgl.c @@ -48,9 +48,6 @@ static void verify_address(void) { } void prompt_address( -#ifndef BAKING_APP - __attribute__((unused)) -#endif bool baking, ui_callback_t ok_cb, ui_callback_t cxl_cb) { diff --git a/src/ui_sign_bagl.c b/src/ui_sign_bagl.c index 80e79e42..a7f9f9e2 100644 --- a/src/ui_sign_bagl.c +++ b/src/ui_sign_bagl.c @@ -38,253 +38,5 @@ __attribute__((noreturn)) void prompt_register_delegate(ui_callback_t const ok_c __builtin_unreachable(); } -#else // ifdef BAKING_APP ----------------------------------------------------- - -static inline void clear_data(void) { - memset(&G, 0, sizeof(G)); -} - -static bool sign_without_hash_ok(void) { - delayed_send(perform_signature(true, false)); - return true; -} - -static bool sign_with_hash_ok(void) { - delayed_send(perform_signature(true, true)); - return true; -} - -static bool sign_reject(void) { - clear_data(); - delay_reject(); - return true; // Return to idle -} - -static bool sign_unsafe_ok(void) { - delayed_send(perform_signature(false, false)); - return true; -} - -#define MAX_NUMBER_CHARS (MAX_INT_DIGITS + 2) // include decimal point and terminating null - -bool prompt_transaction(struct parsed_operation_group const *const ops, - bip32_path_with_curve_t const *const key, - ui_callback_t ok, - ui_callback_t cxl) { - check_null(ops); - check_null(key); - - if (called_from_swap) { - bool valid = is_safe_to_swap(); - if (valid) { - // We're called from swap and we've verified that the data is correct. Sign it. - ok(); - // Clear all data. - clear_data(); - } else { - // Send the error message back in response. - cxl(); - } - finalize_exchange_sign_transaction(valid); - } - - switch (ops->operation.tag) { - default: - PARSE_ERROR(); - - case OPERATION_TAG_PROPOSAL: { - init_screen_stack(); - push_ui_callback("Confirm", copy_string, "Proposal"); - push_ui_callback("Source", parsed_contract_to_string, &ops->operation.source); - push_ui_callback("Period", - number_to_string_indirect32, - &ops->operation.proposal.voting_period); - push_ui_callback("Protocol", - protocol_hash_to_string, - ops->operation.proposal.protocol_hash); - - ux_confirm_screen(ok, cxl); - __builtin_unreachable(); - } - - case OPERATION_TAG_BALLOT: { - char *vote; - - switch (ops->operation.ballot.vote) { - case BALLOT_VOTE_YEA: - vote = "Yea"; - break; - case BALLOT_VOTE_NAY: - vote = "Nay"; - break; - case BALLOT_VOTE_PASS: - vote = "Pass"; - break; - } - - init_screen_stack(); - push_ui_callback("Confirm Vote", copy_string, vote); - push_ui_callback("Source", parsed_contract_to_string, &ops->operation.source); - push_ui_callback("Protocol", - protocol_hash_to_string, - ops->operation.ballot.protocol_hash); - push_ui_callback("Period", - number_to_string_indirect32, - &ops->operation.ballot.voting_period); - - ux_confirm_screen(ok, cxl); - __builtin_unreachable(); - } - - case OPERATION_TAG_ATHENS_ORIGINATION: - case OPERATION_TAG_BABYLON_ORIGINATION: { - if (!(ops->operation.flags & ORIGINATION_FLAG_SPENDABLE)) return false; - - init_screen_stack(); - push_ui_callback("Confirm", copy_string, "Origination"); - push_ui_callback("Amount", microtez_to_string_indirect, &ops->operation.amount); - push_ui_callback("Fee", microtez_to_string_indirect, &ops->total_fee); - push_ui_callback("Source", parsed_contract_to_string, &ops->operation.source); - push_ui_callback("Manager", parsed_contract_to_string, &ops->operation.destination); - - bool const delegatable = ops->operation.flags & ORIGINATION_FLAG_DELEGATABLE; - bool const has_delegate = - ops->operation.delegate.signature_type != SIGNATURE_TYPE_UNSET; - if (delegatable && has_delegate) { - push_ui_callback("Delegate", parsed_contract_to_string, &ops->operation.delegate); - } else if (delegatable && !has_delegate) { - push_ui_callback("Delegate", copy_string, "Any"); - } else if (!delegatable && has_delegate) { - push_ui_callback("Fixed Delegate", - parsed_contract_to_string, - &ops->operation.delegate); - } else if (!delegatable && !has_delegate) { - push_ui_callback("Delegation", copy_string, "Disabled"); - } - push_ui_callback("Storage Limit", - number_to_string_indirect64, - &ops->total_storage_limit); - - ux_confirm_screen(ok, cxl); - __builtin_unreachable(); - } - case OPERATION_TAG_ATHENS_DELEGATION: - case OPERATION_TAG_BABYLON_DELEGATION: { - bool const withdrawal = - ops->operation.destination.originated == 0 && - ops->operation.destination.signature_type == SIGNATURE_TYPE_UNSET; - - char *type_msg; - if (withdrawal) { - type_msg = "Withdraw"; - } else { - type_msg = "Confirm"; - } - init_screen_stack(); - push_ui_callback(type_msg, copy_string, "Delegation"); - - push_ui_callback("Fee", microtez_to_string_indirect, &ops->total_fee); - push_ui_callback("Source", parsed_contract_to_string, &ops->operation.source); - if (withdrawal) { - push_ui_callback("Delegate", - parsed_contract_to_string, - &ops->operation.destination); - } else { - push_ui_callback("Operation", copy_string, "Withdraw delegation"); - } - push_ui_callback("Delegate Name", - lookup_parsed_contract_name, - &ops->operation.destination); - push_ui_callback("Storage Limit", - number_to_string_indirect64, - &ops->total_storage_limit); - - ux_confirm_screen(ok, cxl); - __builtin_unreachable(); - } - - case OPERATION_TAG_ATHENS_TRANSACTION: - case OPERATION_TAG_BABYLON_TRANSACTION: { - init_screen_stack(); - push_ui_callback("Confirm", copy_string, "Transaction"); - push_ui_callback("Amount", microtez_to_string_indirect, &ops->operation.amount); - push_ui_callback("Fee", microtez_to_string_indirect, &ops->total_fee); - push_ui_callback("Source", parsed_contract_to_string, &ops->operation.source); - push_ui_callback("Destination", parsed_contract_to_string, &ops->operation.destination); - push_ui_callback("Storage Limit", - number_to_string_indirect64, - &ops->total_storage_limit); - - ux_confirm_screen(ok, cxl); - __builtin_unreachable(); - } - case OPERATION_TAG_NONE: { - init_screen_stack(); - push_ui_callback("Reveal Key", copy_string, "To Blockchain"); - push_ui_callback("Key", parsed_contract_to_string, &ops->operation.source); - push_ui_callback("Fee", microtez_to_string_indirect, &ops->total_fee); - push_ui_callback("Storage Limit", - number_to_string_indirect64, - &ops->total_storage_limit); - - ux_confirm_screen(ok, cxl); - __builtin_unreachable(); - } - } -} - -size_t wallet_sign_complete(uint8_t instruction, uint8_t magic_byte, volatile uint32_t *flags) { - (void) flags; - char *ops; - if (magic_byte == MAGIC_BYTE_UNSAFE_OP3) { - ops = "Michelson"; - } else { - ops = "Operation"; - } - - if (instruction == INS_SIGN_UNSAFE) { - G.message_data_as_buffer.bytes = (uint8_t *) &G.message_data; - G.message_data_as_buffer.size = sizeof(G.message_data); - G.message_data_as_buffer.length = G.message_data_length; - init_screen_stack(); - push_ui_callback("Pre-hashed", copy_string, ops); - // Base58 encoding of 32-byte hash is 43 bytes long. - push_ui_callback("Sign Hash", buffer_to_base58, &G.message_data_as_buffer); - ux_confirm_screen(sign_unsafe_ok, sign_reject); - } else { - ui_callback_t const ok_c = - instruction == INS_SIGN_WITH_HASH ? sign_with_hash_ok : sign_without_hash_ok; - - switch (G.magic_byte) { - case MAGIC_BYTE_BLOCK: - case MAGIC_BYTE_BAKING_OP: - default: - PARSE_ERROR(); - case MAGIC_BYTE_UNSAFE_OP: - if (!G.maybe_ops.is_valid || !prompt_transaction(&G.maybe_ops.v, - &global.path_with_curve, - ok_c, - sign_reject)) { - goto unsafe; - } - - __attribute__((fallthrough)); - case MAGIC_BYTE_UNSAFE_OP2: - case MAGIC_BYTE_UNSAFE_OP3: - goto unsafe; - } - unsafe: - G.message_data_as_buffer.bytes = (uint8_t *) &G.final_hash; - G.message_data_as_buffer.size = sizeof(G.final_hash); - G.message_data_as_buffer.length = sizeof(G.final_hash); - init_screen_stack(); - // Base58 encoding of 32-byte hash is 43 bytes long. - push_ui_callback("Unrecognized", copy_string, ops); - push_ui_callback("Sign Hash", buffer_to_base58, &G.message_data_as_buffer); - ux_confirm_screen(ok_c, sign_reject); - } - return 0; -} - #endif // ifdef BAKING_APP ---------------------------------------------------- #endif // HAVE_BAGL diff --git a/src/ui_sign_nbgl.c b/src/ui_sign_nbgl.c index 74d23a77..61cbc5bd 100644 --- a/src/ui_sign_nbgl.c +++ b/src/ui_sign_nbgl.c @@ -103,519 +103,5 @@ void prompt_register_delegate(ui_callback_t const ok_cb, ui_callback_t const cxl cancel_callback); } -#else // ifdef BAKING_APP ----------------------------------------------------- -static void prompt_cancel(void) { - nbgl_useCaseConfirm("Reject transaction?", - NULL, - "Yes, Reject", - "Go back to transaction", - cancel_callback); -} - -static void prompt_confirmation_callback(bool confirm) { - if (confirm) { - approve_callback(); - } else { - prompt_cancel(); - } -} - -static void continue_callback(void) { - transactionContext.infoLongPress.icon = &C_tezos; - transactionContext.infoLongPress.longPressText = "Hold to sign"; - transactionContext.infoLongPress.tuneId = TUNE_TAP_CASUAL; - - nbgl_useCaseStaticReview(&transactionContext.tagValueList, - &transactionContext.infoLongPress, - "Cancel", - prompt_confirmation_callback); -} - -static bool sign_without_hash_ok(void) { - delayed_send(perform_signature(true, false)); - return true; -} - -static bool sign_with_hash_ok(void) { - delayed_send(perform_signature(true, true)); - return true; -} - -static bool sign_reject(void) { - delay_reject(); - return true; // Return to idle -} - -static bool sign_unsafe_ok(void) { - delayed_send(perform_signature(false, false)); - return true; -} - -#define MAX_NUMBER_CHARS (MAX_INT_DIGITS + 2) // include decimal point and terminating null -bool prompt_transaction(struct parsed_operation_group const *const ops, - bip32_path_with_curve_t const *const key, - ui_callback_t ok, - ui_callback_t cxl) { - check_null(ops); - check_null(key); - - if (called_from_swap) { - bool valid = is_safe_to_swap(); - if (valid) { - // We're called from swap and we've verified that the data is correct. Sign it. - ok(); - } else { - // Send the error message back in response. - cxl(); - } - finalize_exchange_sign_transaction(valid); - } - - switch (ops->operation.tag) { - default: - PARSE_ERROR(); - - case OPERATION_TAG_PROPOSAL: { - transactionContext.ok_cb = ok; - transactionContext.cxl_cb = cxl; - - parsed_contract_to_string(transactionContext.buffer[0], - sizeof(transactionContext.buffer[0]), - &ops->operation.source); - number_to_string_indirect32(transactionContext.buffer[1], - sizeof(transactionContext.buffer[1]), - &ops->operation.proposal.voting_period); - protocol_hash_to_string(transactionContext.buffer[2], - sizeof(transactionContext.buffer[2]), - ops->operation.proposal.protocol_hash); - - transactionContext.tagValuePair[0].item = "Source"; - transactionContext.tagValuePair[0].value = transactionContext.buffer[0]; - - transactionContext.tagValuePair[1].item = "Period"; - transactionContext.tagValuePair[1].value = transactionContext.buffer[1]; - - transactionContext.tagValuePair[2].item = "Protocol"; - transactionContext.tagValuePair[2].value = transactionContext.buffer[2]; - - transactionContext.tagValueList.nbPairs = 3; - transactionContext.tagValueList.pairs = transactionContext.tagValuePair; - - transactionContext.infoLongPress.text = "Confirm proposal"; - - transactionContext.confirmed_status = "PROPOSAL\nCONFIRMED"; - transactionContext.cancelled_status = "Proposal\ncancelled"; - - nbgl_useCaseReviewStart(&C_tezos, - "Review proposal", - NULL, - "Cancel", - continue_light_callback, - cancel_callback); - break; - } - - case OPERATION_TAG_BALLOT: { - char *vote; - - switch (ops->operation.ballot.vote) { - case BALLOT_VOTE_YEA: - vote = "Yea"; - break; - case BALLOT_VOTE_NAY: - vote = "Nay"; - break; - case BALLOT_VOTE_PASS: - vote = "Pass"; - break; - } - - transactionContext.ok_cb = ok; - transactionContext.cxl_cb = cxl; - - parsed_contract_to_string(transactionContext.buffer[0], - sizeof(transactionContext.buffer[0]), - &ops->operation.source); - protocol_hash_to_string(transactionContext.buffer[1], - sizeof(transactionContext.buffer[1]), - ops->operation.ballot.protocol_hash); - number_to_string_indirect32(transactionContext.buffer[2], - sizeof(transactionContext.buffer[2]), - &ops->operation.ballot.voting_period); - - transactionContext.tagValuePair[0].item = "Vote"; - transactionContext.tagValuePair[0].value = vote; - - transactionContext.tagValuePair[1].item = "Source"; - transactionContext.tagValuePair[1].value = transactionContext.buffer[0]; - - transactionContext.tagValuePair[2].item = "Protocol"; - transactionContext.tagValuePair[2].value = transactionContext.buffer[1]; - - transactionContext.tagValuePair[3].item = "Period"; - transactionContext.tagValuePair[3].value = transactionContext.buffer[2]; - - transactionContext.tagValueList.nbPairs = 4; - transactionContext.tagValueList.pairs = transactionContext.tagValuePair; - - transactionContext.infoLongPress.text = "Confirm vote"; - - transactionContext.confirmed_status = "VOTE\nCONFIRMED"; - transactionContext.cancelled_status = "Vote\ncancelled"; - - nbgl_useCaseReviewStart(&C_tezos, - "Review vote", - NULL, - "Cancel", - continue_light_callback, - cancel_callback); - break; - } - - case OPERATION_TAG_ATHENS_ORIGINATION: - case OPERATION_TAG_BABYLON_ORIGINATION: { - if (!(ops->operation.flags & ORIGINATION_FLAG_SPENDABLE)) return false; - - transactionContext.ok_cb = ok; - transactionContext.cxl_cb = cxl; - - microtez_to_string_indirect(transactionContext.buffer[0], - sizeof(transactionContext.buffer[0]), - &ops->operation.amount); - microtez_to_string_indirect(transactionContext.buffer[1], - sizeof(transactionContext.buffer[1]), - &ops->total_fee); - parsed_contract_to_string(transactionContext.buffer[2], - sizeof(transactionContext.buffer[2]), - &ops->operation.source); - parsed_contract_to_string(transactionContext.buffer[3], - sizeof(transactionContext.buffer[3]), - &ops->operation.destination); - - transactionContext.tagValuePair[0].item = "Amount"; - transactionContext.tagValuePair[0].value = transactionContext.buffer[0]; - - transactionContext.tagValuePair[1].item = "Fee"; - transactionContext.tagValuePair[1].value = transactionContext.buffer[1]; - - transactionContext.tagValuePair[2].item = "Source"; - transactionContext.tagValuePair[2].value = transactionContext.buffer[2]; - - transactionContext.tagValuePair[3].item = "Manager"; - transactionContext.tagValuePair[3].value = transactionContext.buffer[3]; - - transactionContext.tagValuePair[4].value = transactionContext.buffer[4]; - - bool const delegatable = ops->operation.flags & ORIGINATION_FLAG_DELEGATABLE; - bool const has_delegate = - ops->operation.delegate.signature_type != SIGNATURE_TYPE_UNSET; - if (delegatable && has_delegate) { - transactionContext.tagValuePair[4].item = "Delegate"; - parsed_contract_to_string(transactionContext.buffer[4], - sizeof(transactionContext.buffer[4]), - &ops->operation.delegate); - } else if (delegatable && !has_delegate) { - transactionContext.tagValuePair[4].item = "Delegate"; - transactionContext.tagValuePair[4].value = "Any"; - } else if (!delegatable && has_delegate) { - transactionContext.tagValuePair[4].item = "Fixed Delegate"; - parsed_contract_to_string(transactionContext.buffer[4], - sizeof(transactionContext.buffer[4]), - &ops->operation.delegate); - } else if (!delegatable && !has_delegate) { - transactionContext.tagValuePair[4].item = "Delegation Disabled"; - transactionContext.tagValuePair[4].value = "No delegation"; - } - - number_to_string_indirect64(transactionContext.buffer[5], - sizeof(transactionContext.buffer[5]), - &ops->total_storage_limit); - - transactionContext.tagValuePair[5].item = "Storage Limit"; - transactionContext.tagValuePair[5].value = transactionContext.buffer[5]; - - transactionContext.tagValueList.nbPairs = 6; - transactionContext.tagValueList.pairs = transactionContext.tagValuePair; - - transactionContext.infoLongPress.text = "Confirm origination"; - - transactionContext.confirmed_status = "ORIGINATION\nCONFIRMED"; - transactionContext.cancelled_status = "Origination\ncancelled"; - - nbgl_useCaseReviewStart(&C_tezos, - "Review origination", - NULL, - "Cancel", - continue_light_callback, - cancel_callback); - break; - } - case OPERATION_TAG_ATHENS_DELEGATION: - case OPERATION_TAG_BABYLON_DELEGATION: { - bool const withdrawal = - ops->operation.destination.originated == 0 && - ops->operation.destination.signature_type == SIGNATURE_TYPE_UNSET; - - char *type_msg; - if (withdrawal) { - transactionContext.confirmed_status = "DELEGATION\nWITHDRAWN"; - transactionContext.cancelled_status = "Delegation withdrawal\ncancelled"; - - type_msg = "Withdraw Delegation"; - } else { - transactionContext.confirmed_status = "DELEGATION\nCONFIRMED"; - transactionContext.cancelled_status = "Delegation\ncancelled"; - - type_msg = "Confirm Delegation"; - } - - transactionContext.ok_cb = ok; - transactionContext.cxl_cb = cxl; - - microtez_to_string_indirect(transactionContext.buffer[0], - sizeof(transactionContext.buffer[0]), - &ops->total_fee); - parsed_contract_to_string(transactionContext.buffer[1], - sizeof(transactionContext.buffer[1]), - &ops->operation.source); - parsed_contract_to_string(transactionContext.buffer[2], - sizeof(transactionContext.buffer[2]), - &ops->operation.destination); - lookup_parsed_contract_name(transactionContext.buffer[3], - sizeof(transactionContext.buffer[3]), - &ops->operation.destination); - number_to_string_indirect64(transactionContext.buffer[4], - sizeof(transactionContext.buffer[4]), - &ops->total_storage_limit); - - transactionContext.tagValuePair[0].item = "Fee"; - transactionContext.tagValuePair[0].value = transactionContext.buffer[0]; - - transactionContext.tagValuePair[1].item = "Source"; - transactionContext.tagValuePair[1].value = transactionContext.buffer[1]; - - if (withdrawal) { - transactionContext.tagValuePair[2].item = "Operation"; - transactionContext.tagValuePair[2].value = "Withdraw delegation"; - } else { - transactionContext.tagValuePair[2].item = "Delegate"; - transactionContext.tagValuePair[2].value = transactionContext.buffer[2]; - } - - transactionContext.tagValuePair[3].item = "Delegate Name"; - transactionContext.tagValuePair[3].value = transactionContext.buffer[3]; - - transactionContext.tagValuePair[4].item = "Storage limit"; - transactionContext.tagValuePair[4].value = transactionContext.buffer[4]; - transactionContext.tagValueList.nbPairs = 5; - transactionContext.tagValueList.pairs = transactionContext.tagValuePair; - - transactionContext.infoLongPress.text = type_msg; - - nbgl_useCaseReviewStart(&C_tezos, - type_msg, - NULL, - "Cancel", - continue_light_callback, - cancel_callback); - break; - } - - case OPERATION_TAG_ATHENS_TRANSACTION: - case OPERATION_TAG_BABYLON_TRANSACTION: { - transactionContext.ok_cb = ok; - transactionContext.cxl_cb = cxl; - - microtez_to_string_indirect(transactionContext.buffer[0], - sizeof(transactionContext.buffer[0]), - &ops->operation.amount); - microtez_to_string_indirect(transactionContext.buffer[1], - sizeof(transactionContext.buffer[1]), - &ops->total_fee); - parsed_contract_to_string(transactionContext.buffer[2], - sizeof(transactionContext.buffer[2]), - &ops->operation.source); - parsed_contract_to_string(transactionContext.buffer[3], - sizeof(transactionContext.buffer[3]), - &ops->operation.destination); - number_to_string_indirect64(transactionContext.buffer[4], - sizeof(transactionContext.buffer[4]), - &ops->total_storage_limit); - - transactionContext.tagValuePair[0].item = "Amount"; - transactionContext.tagValuePair[0].value = transactionContext.buffer[0]; - - transactionContext.tagValuePair[1].item = "Fee"; - transactionContext.tagValuePair[1].value = transactionContext.buffer[1]; - - transactionContext.tagValuePair[2].item = "Source"; - transactionContext.tagValuePair[2].value = transactionContext.buffer[2]; - - transactionContext.tagValuePair[3].item = "Destination"; - transactionContext.tagValuePair[3].value = transactionContext.buffer[3]; - - transactionContext.tagValuePair[4].item = "Storage limit"; - transactionContext.tagValuePair[4].value = transactionContext.buffer[4]; - - transactionContext.tagValueList.nbPairs = 5; - transactionContext.tagValueList.pairs = transactionContext.tagValuePair; - - transactionContext.infoLongPress.text = "Sign transaction to\nsend Tezos?"; - - transactionContext.confirmed_status = "TRANSACTION\nSIGNED"; - transactionContext.cancelled_status = "Transaction\nrejected"; - - nbgl_useCaseReviewStart(&C_tezos, - "Review Transaction", - NULL, - "Cancel", - continue_callback, - prompt_cancel); - break; - } - case OPERATION_TAG_NONE: { - transactionContext.ok_cb = ok; - transactionContext.cxl_cb = cxl; - - parsed_contract_to_string(transactionContext.buffer[0], - sizeof(transactionContext.buffer[0]), - &ops->operation.source); - microtez_to_string_indirect(transactionContext.buffer[1], - sizeof(transactionContext.buffer[1]), - &ops->total_fee); - number_to_string_indirect64(transactionContext.buffer[2], - sizeof(transactionContext.buffer[2]), - &ops->total_storage_limit); - - transactionContext.tagValuePair[0].item = "Key"; - transactionContext.tagValuePair[0].value = transactionContext.buffer[0]; - - transactionContext.tagValuePair[1].item = "Fee"; - transactionContext.tagValuePair[1].value = transactionContext.buffer[1]; - - transactionContext.tagValuePair[2].item = "Storage limit"; - transactionContext.tagValuePair[2].value = transactionContext.buffer[2]; - - transactionContext.tagValueList.nbPairs = 3; - transactionContext.tagValueList.pairs = transactionContext.tagValuePair; - - transactionContext.infoLongPress.text = "Confirm key revelation"; - - transactionContext.confirmed_status = "KEY REVELATION\nCONFIRMED"; - transactionContext.cancelled_status = "Key revelation\nrejected"; - - nbgl_useCaseReviewStart(&C_tezos, - "Reveal key to\nBlockchain", - NULL, - "Cancel", - continue_light_callback, - cancel_callback); - break; - } - } - return 0; -} - -size_t wallet_sign_complete(uint8_t instruction, uint8_t magic_byte, volatile uint32_t *flags) { - char *ops; - if (magic_byte == MAGIC_BYTE_UNSAFE_OP3) { - ops = "Michelson"; - } else { - ops = "Operation"; - } - - if (instruction == INS_SIGN_UNSAFE) { - G.message_data_as_buffer.bytes = (uint8_t *) &G.message_data; - G.message_data_as_buffer.size = sizeof(G.message_data); - G.message_data_as_buffer.length = G.message_data_length; - - buffer_to_base58(transactionContext.buffer[0], - sizeof(transactionContext.buffer[0]), - &G.message_data_as_buffer); - - transactionContext.tagValuePair[0].item = "Sign Hash"; - transactionContext.tagValuePair[0].value = transactionContext.buffer[0]; - transactionContext.tagValueList.nbPairs = 1; - transactionContext.tagValueList.pairs = transactionContext.tagValuePair; - - transactionContext.ok_cb = sign_unsafe_ok; - transactionContext.cxl_cb = sign_reject; - - transactionContext.infoLongPress.text = "Confirm"; - - nbgl_useCaseReviewStart(&C_tezos, - "Review pre-hashed", - ops, - "Cancel", - continue_light_callback, - cancel_callback); - *flags = IO_ASYNCH_REPLY; - return 0; - } else { - ui_callback_t const ok_c = - instruction == INS_SIGN_WITH_HASH ? sign_with_hash_ok : sign_without_hash_ok; - - switch (G.magic_byte) { - case MAGIC_BYTE_BLOCK: - case MAGIC_BYTE_BAKING_OP: - default: - PARSE_ERROR(); - case MAGIC_BYTE_UNSAFE_OP: - if (!G.maybe_ops.is_valid || prompt_transaction(&G.maybe_ops.v, - &global.path_with_curve, - ok_c, - sign_reject)) { - goto unsafe; - } - *flags = IO_ASYNCH_REPLY; - return 0; - - case MAGIC_BYTE_UNSAFE_OP2: - case MAGIC_BYTE_UNSAFE_OP3: - goto unsafe; - } - unsafe: - G.message_data_as_buffer.bytes = (uint8_t *) &G.final_hash; - G.message_data_as_buffer.size = sizeof(G.final_hash); - G.message_data_as_buffer.length = sizeof(G.final_hash); - - if (magic_byte == MAGIC_BYTE_UNSAFE_OP3) { - ops = "Review unrecognized\nPre-hashed Michelson"; - transactionContext.infoLongPress.text = "Confirm unrecognized\nPre-hashed Michelson"; - transactionContext.confirmed_status = "PRE-HASHED\nMICHELSON\nCONFIRMED"; - transactionContext.cancelled_status = "Pre-hashed michelson\nrejected"; - - } else { - ops = "Review unrecognized\nPre-hashed Operation"; - transactionContext.infoLongPress.text = "Confirm unrecognized\nPre-hashed Operation"; - transactionContext.confirmed_status = "PRE-HASHED\nOPERATION\nCONFIRMED"; - transactionContext.cancelled_status = "Pre-hashed operation\nrejected"; - } - - buffer_to_base58(transactionContext.buffer[0], - sizeof(transactionContext.buffer[0]), - &G.message_data_as_buffer); - - transactionContext.tagValuePair[0].item = "Sign Hash"; - transactionContext.tagValuePair[0].value = transactionContext.buffer[0]; - - transactionContext.tagValueList.nbPairs = 1; - transactionContext.tagValueList.pairs = transactionContext.tagValuePair; - - transactionContext.ok_cb = ok_c; - transactionContext.cxl_cb = sign_reject; - - nbgl_useCaseReviewStart(&C_tezos, - ops, - NULL, - "Cancel", - continue_light_callback, - cancel_callback); - - *flags = IO_ASYNCH_REPLY; - return 0; - } -} - #endif // ifdef BAKING_APP ---------------------------------------------------- #endif // HAVE_NBGL diff --git a/src/version.h b/src/version.h index 037bfb9c..0662ec09 100644 --- a/src/version.h +++ b/src/version.h @@ -1,7 +1,5 @@ #ifdef BAKING_APP #define CLASS 1 -#else -#define CLASS 0 #endif #define MAJOR APPVERSION_M