mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-16 01:22:02 +00:00
fix(legacy): show xpub instead of pubkey in GetPublicKey dialog
This commit is contained in:
parent
88889472eb
commit
91e60036e0
@ -284,7 +284,7 @@ static bool fsm_layoutAddress(const char *address, const char *desc,
|
||||
coin->xpub_magic, xpub, sizeof(xpub));
|
||||
}
|
||||
}
|
||||
layoutXPUB(xpub, index, page, multisig_index == index);
|
||||
layoutXPUBMultisig(xpub, index, page, multisig_index == index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -40,15 +40,6 @@ void fsm_msgGetPublicKey(const GetPublicKey *msg) {
|
||||
if (!node) return;
|
||||
hdnode_fill_public_key(node);
|
||||
|
||||
if (msg->has_show_display && msg->show_display) {
|
||||
layoutPublicKey(node->public_key);
|
||||
if (!protectButton(ButtonRequestType_ButtonRequest_PublicKey, true)) {
|
||||
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
resp->has_node = true;
|
||||
resp->node.depth = node->depth;
|
||||
resp->node.fingerprint = fingerprint;
|
||||
@ -83,6 +74,18 @@ void fsm_msgGetPublicKey(const GetPublicKey *msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg->has_show_display && msg->show_display) {
|
||||
for (int page = 0; page < 2; page++) {
|
||||
layoutXPUB(resp->xpub, page);
|
||||
if (!protectButton(ButtonRequestType_ButtonRequest_PublicKey, true)) {
|
||||
memzero(resp, sizeof(PublicKey));
|
||||
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msg_write(MessageType_MessageType_PublicKey, resp);
|
||||
layoutHome();
|
||||
}
|
||||
|
@ -641,7 +641,7 @@ void layoutResetWord(const char *word, int pass, int word_pos, bool last) {
|
||||
void layoutAddress(const char *address, const char *desc, bool qrcode,
|
||||
bool ignorecase, const uint32_t *address_n,
|
||||
size_t address_n_count, bool address_is_account) {
|
||||
if (layoutLast != layoutAddress && layoutLast != layoutXPUB) {
|
||||
if (layoutLast != layoutAddress && layoutLast != layoutXPUBMultisig) {
|
||||
layoutSwipe();
|
||||
} else {
|
||||
oledClear();
|
||||
@ -734,13 +734,39 @@ void layoutPublicKey(const uint8_t *pubkey) {
|
||||
str[1], str[2], str[3], NULL);
|
||||
}
|
||||
|
||||
void layoutXPUB(const char *xpub, int index, int page, bool ours) {
|
||||
static void _layout_xpub(const char *xpub, const char *desc, int page) {
|
||||
// 21 characters per line, 4 lines, minus 3 chars for "..." = 81
|
||||
// skip 81 characters per page
|
||||
xpub += page * 81;
|
||||
const char **str = split_message((const uint8_t *)xpub, strlen(xpub), 21);
|
||||
oledDrawString(0, 0 * 9, desc, FONT_STANDARD);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
oledDrawString(0, (i + 1) * 9 + 4, str[i], FONT_FIXED);
|
||||
}
|
||||
}
|
||||
|
||||
void layoutXPUB(const char *xpub, int page) {
|
||||
if (layoutLast != layoutAddress && layoutLast != layoutXPUB) {
|
||||
layoutSwipe();
|
||||
} else {
|
||||
oledClear();
|
||||
}
|
||||
layoutLast = layoutXPUB;
|
||||
char desc[] = "XPUB _/2";
|
||||
desc[5] = '1' + page;
|
||||
_layout_xpub(xpub, desc, page);
|
||||
layoutButtonNo(_("Cancel"), &bmp_btn_cancel);
|
||||
layoutButtonYes(_("Confirm"), &bmp_btn_confirm);
|
||||
oledRefresh();
|
||||
}
|
||||
|
||||
void layoutXPUBMultisig(const char *xpub, int index, int page, bool ours) {
|
||||
if (layoutLast != layoutAddress && layoutLast != layoutXPUBMultisig) {
|
||||
layoutSwipe();
|
||||
} else {
|
||||
oledClear();
|
||||
}
|
||||
layoutLast = layoutXPUBMultisig;
|
||||
char desc[] = "XPUB #__ _/2 (______)";
|
||||
if (index + 1 >= 10) {
|
||||
desc[6] = '0' + (((index + 1) / 10) % 10);
|
||||
@ -766,15 +792,7 @@ void layoutXPUB(const char *xpub, int index, int page, bool ours) {
|
||||
desc[18] = 'r';
|
||||
desc[19] = 's';
|
||||
}
|
||||
|
||||
// 21 characters per line, 4 lines, minus 3 chars for "..." = 81
|
||||
// skip 81 characters per page
|
||||
xpub += page * 81;
|
||||
const char **str = split_message((const uint8_t *)xpub, strlen(xpub), 21);
|
||||
oledDrawString(0, 0 * 9, desc, FONT_STANDARD);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
oledDrawString(0, (i + 1) * 9 + 4, str[i], FONT_FIXED);
|
||||
}
|
||||
_layout_xpub(xpub, desc, page);
|
||||
layoutButtonNo(_("Next"), NULL);
|
||||
layoutButtonYes(_("Confirm"), &bmp_btn_confirm);
|
||||
oledRefresh();
|
||||
|
@ -70,7 +70,8 @@ void layoutAddress(const char *address, const char *desc, bool qrcode,
|
||||
bool ignorecase, const uint32_t *address_n,
|
||||
size_t address_n_count, bool address_is_account);
|
||||
void layoutPublicKey(const uint8_t *pubkey);
|
||||
void layoutXPUB(const char *xpub, int index, int page, bool ours);
|
||||
void layoutXPUB(const char *xpub, int page);
|
||||
void layoutXPUBMultisig(const char *xpub, int index, int page, bool ours);
|
||||
void layoutSignIdentity(const IdentityType *identity, const char *challenge);
|
||||
void layoutDecryptIdentity(const IdentityType *identity);
|
||||
void layoutU2FDialog(const char *verb, const char *appname);
|
||||
|
Loading…
Reference in New Issue
Block a user