Skip to content

Commit e86acbe

Browse files
feat: get address along with btc get pubkey
1 parent d92b103 commit e86acbe

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

apps/btc_family/btc_pub_key.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,14 @@ static size_t btc_get_address(const uint8_t *seed,
151151
char *address);
152152

153153
/**
154-
* @brief Takes and sends the uncompressed public key to the host as
154+
* @brief Takes and sends the uncompressed public key and address to the host as
155155
* btc_result_t
156156
*
157157
* @param public_key An immutable reference to uncompressed public key buffer
158+
* @param address An immutable reference to the address buffer
158159
*/
159-
static void send_public_key(const uint8_t *public_key);
160+
static void send_public_key_response(const uint8_t *public_key,
161+
const char *address);
160162

161163
/*****************************************************************************
162164
* STATIC VARIABLES
@@ -260,11 +262,13 @@ static size_t btc_get_address(const uint8_t *seed,
260262
return address_length;
261263
}
262264

263-
static void send_public_key(const uint8_t *public_key) {
265+
static void send_public_key_response(const uint8_t *public_key,
266+
const char *address) {
264267
btc_result_t response = init_btc_result(BTC_RESULT_GET_PUBLIC_KEY_TAG);
265268
response.get_public_key.which_response =
266269
BTC_GET_PUBLIC_KEY_RESPONSE_RESULT_TAG;
267270
memcpy(response.get_public_key.result.public_key, public_key, 65);
271+
memcpy(response.get_public_key.result.address, address, strnlen(address, 70));
268272
btc_send_result(&response);
269273
}
270274

@@ -328,7 +332,7 @@ void btc_get_pub_key(btc_query_t *query) {
328332
if (0 < length &&
329333
true == core_scroll_page(ui_text_receive_on, msg, btc_send_error)) {
330334
set_app_flow_status(BTC_GET_PUBLIC_KEY_STATUS_VERIFY);
331-
send_public_key(public_key);
335+
send_public_key_response(public_key, msg);
332336
delay_scr_init(ui_text_check_cysync_app, DELAY_TIME);
333337
}
334338
}

common/cypherock-common

common/proto-options/btc/get_public_key.options

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
btc.GetPublicKeyIntiateRequest.wallet_id type:FT_STATIC max_size:32 fixed_length:true
33
btc.GetPublicKeyIntiateRequest.derivation_path type:FT_STATIC max_count:5 fixed_length:true
44
btc.GetPublicKeyResultResponse.public_key type:FT_STATIC max_size:65 fixed_length:true
5+
btc.GetPublicKeyResultResponse.address type:FT_STATIC max_size:70 fixed_length:false

0 commit comments

Comments
 (0)