Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
address_book_common.h
Go to the documentation of this file.
1/*****************************************************************************
2 * (c) 2026 Ledger SAS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#ifndef ADDRESS_BOOK_COMMON_H
18#define ADDRESS_BOOK_COMMON_H
19
20#if defined(HAVE_ADDRESS_BOOK)
21
22#include <stdint.h>
23#include <stdbool.h>
24#include "tlv_library.h"
25#include "bip32.h"
26#include "lcx_sha256.h"
27#include "address_book.h"
28#include "identity.h"
29#include "ledger_account.h"
30#include "nbgl_use_case.h"
31
32bool address_book_handle_derivation_path(const tlv_data_t *data, path_bip32_t *bip32_path);
33
34bool address_book_handle_chain_id(const tlv_data_t *data, uint64_t *chain_id);
35
36bool address_book_handle_blockchain_family(const tlv_data_t *data, blockchain_family_e *family);
37
38bool address_book_handle_printable_string(const tlv_data_t *data,
39 char *output_buffer,
40 size_t buffer_size);
41
42void address_book_display_review(const nbgl_icon_details_t *icon,
43 const char *reviewTitle,
44 const char *confirmText,
45 nbgl_choiceCallback_t choiceCallback);
46
47void address_book_handle_review_rejected(nbgl_callback_t finalize);
48
49void address_book_finalize_review(bool success,
50 const char *successMsg,
51 const char *errorMsg,
52 nbgl_callback_t finalize);
53
54// Persistent state for the Register Identity flow (lives through the NBGL callback).
55typedef struct {
56 identity_t identity;
57 uint8_t group_handle[GROUP_HANDLE_SIZE];
58 uint8_t hmac_proof[CX_SHA256_SIZE];
59 uint8_t gid[GID_SIZE];
60 bool active;
61} s_register_state_t;
62
63// Union of all mutually-exclusive per-command payload buffers.
64// Only one command is processed at a time, so a single allocation covers every flow.
65typedef union {
66 s_register_state_t reg;
67 edit_contact_name_t edit_contact_name;
68 edit_scope_t edit_scope;
69 edit_identifier_t edit_identifier;
70 identity_t provide_contact;
71 ledger_account_t ledger_account;
73} ab_payload_u;
74
75// Shared UI buffers: all flows use at most 3 tag/value pairs and one list.
76typedef struct {
79} ab_ui_t;
80
81extern ab_payload_u g_ab_payload;
82extern ab_ui_t g_ab_ui;
83
84#endif // HAVE_ADDRESS_BOOK
85
86#endif // ADDRESS_BOOK_COMMON_H
blockchain_family_e
Register / Edit Contact Name / Edit Scope / Edit Identifier.
SHA-2 (Secure Hash Algorithm 2)
bolos_err_t edit_ledger_account(uint8_t *buffer_in, size_t buffer_in_length)
struct PACKED__ nbgl_icon_details_s nbgl_icon_details_t
Represents all information about an icon.
API of the Advanced BOLOS Graphical Library, for typical application use-cases.
void(* nbgl_callback_t)(void)
prototype of generic callback function
void(* nbgl_choiceCallback_t)(bool confirm)
prototype of choice callback function
Data extracted from a Rename Ledger Account TLV payload.
Data extracted from a Register Ledger Account TLV payload.
This structure contains a list of [tag,value] pairs.
This structure contains a [tag,value] pair and possible extensions.