1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-12 18:49:07 +00:00

layout: treat address as accounts for EthereumGetAddress dialogs

This commit is contained in:
Pavol Rusnak 2018-10-22 15:15:15 +02:00
parent 3f1d7b09f1
commit 8e6369e1ba
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
7 changed files with 12 additions and 12 deletions

View File

@ -222,7 +222,7 @@ static HDNode *fsm_getDerivedNode(const char *curve, const uint32_t *address_n,
return &node;
}
static bool fsm_layoutAddress(const char *address, const char *desc, bool ignorecase, size_t prefixlen, const uint32_t *address_n, size_t address_n_count)
static bool fsm_layoutAddress(const char *address, const char *desc, bool ignorecase, size_t prefixlen, const uint32_t *address_n, size_t address_n_count, bool address_is_account)
{
bool qrcode = false;
for (;;) {
@ -230,7 +230,7 @@ static bool fsm_layoutAddress(const char *address, const char *desc, bool ignore
if (prefixlen && !qrcode) {
display_addr += prefixlen;
}
layoutAddress(display_addr, desc, qrcode, ignorecase, address_n, address_n_count);
layoutAddress(display_addr, desc, qrcode, ignorecase, address_n, address_n_count, address_is_account);
if (protectButton(ButtonRequestType_ButtonRequest_Address, false)) {
return true;
}

View File

@ -232,7 +232,7 @@ void fsm_msgGetAddress(const GetAddress *msg)
bool is_cashaddr = coin->cashaddr_prefix != NULL;
bool is_bech32 = msg->script_type == InputScriptType_SPENDWITNESS;
if (!fsm_layoutAddress(address, desc, is_cashaddr || is_bech32, is_cashaddr ? strlen(coin->cashaddr_prefix) + 1 : 0, msg->address_n, msg->address_n_count)) {
if (!fsm_layoutAddress(address, desc, is_cashaddr || is_bech32, is_cashaddr ? strlen(coin->cashaddr_prefix) + 1 : 0, msg->address_n, msg->address_n_count, false)) {
return;
}
}

View File

@ -66,7 +66,7 @@ void fsm_msgEthereumGetAddress(const EthereumGetAddress *msg)
char address[43] = { '0', 'x' };
ethereum_address_checksum(resp->address.bytes, address + 2, rskip60, chain_id);
if (!fsm_layoutAddress(address, desc, false, 0, msg->address_n, msg->address_n_count)) {
if (!fsm_layoutAddress(address, desc, false, 0, msg->address_n, msg->address_n_count, true)) {
return;
}
}

View File

@ -33,7 +33,7 @@ void fsm_msgLiskGetAddress(const LiskGetAddress *msg)
lisk_get_address_from_public_key(&node->public_key[1], resp->address);
if (msg->has_show_display && msg->show_display) {
if (!fsm_layoutAddress(resp->address, _("Address:"), true, 0, msg->address_n, msg->address_n_count)) {
if (!fsm_layoutAddress(resp->address, _("Address:"), true, 0, msg->address_n, msg->address_n_count, false)) {
return;
}
}

View File

@ -42,7 +42,7 @@ void fsm_msgNEMGetAddress(NEMGetAddress *msg)
strlcpy(desc, network, sizeof(desc));
strlcat(desc, ":", sizeof(desc));
if (!fsm_layoutAddress(resp->address, desc, true, 0, msg->address_n, msg->address_n_count)) {
if (!fsm_layoutAddress(resp->address, desc, true, 0, msg->address_n, msg->address_n_count, false)) {
return;
}
}

View File

@ -55,7 +55,7 @@ static const char *slip44_extras(uint32_t coin_type)
#define BIP32_MAX_LAST_ELEMENT 1000000
static const char *address_n_str(const uint32_t *address_n, size_t address_n_count)
static const char *address_n_str(const uint32_t *address_n, size_t address_n_count, bool address_is_account)
{
if (address_n_count > 8) {
return _("Unknown long path");
@ -96,7 +96,7 @@ static const char *address_n_str(const uint32_t *address_n, size_t address_n_cou
abbr = slip44_extras(address_n[1]);
}
}
uint32_t accnum = (address_n[2] & 0x7fffffff) + 1;
const uint32_t accnum = address_is_account ? ((address_n[4] & 0x7fffffff) + 1) : (address_n[2] & 0x7fffffff) + 1;
if (abbr && accnum < 100) {
memset(path, 0, sizeof(path));
strlcpy(path, abbr, sizeof(path));
@ -312,7 +312,7 @@ void layoutConfirmOutput(const CoinInfo *coin, const TxOutputType *out)
bn_format_uint64(out->amount, NULL, coin->coin_shortcut, BITCOIN_DIVISIBILITY, 0, false, str_out, sizeof(str_out) - 3);
strlcat(str_out, " to", sizeof(str_out));
const char *address = out->address;
const char *extra_line = (out->address_n_count > 0) ? address_n_str(out->address_n, out->address_n_count) : 0;
const char *extra_line = (out->address_n_count > 0) ? address_n_str(out->address_n, out->address_n_count, false) : 0;
render_address_dialog(coin, address, _("Confirm sending"), str_out, extra_line);
}
@ -496,7 +496,7 @@ void layoutResetWord(const char *word, int pass, int word_pos, bool last)
oledRefresh();
}
void layoutAddress(const char *address, const char *desc, bool qrcode, bool ignorecase, const uint32_t *address_n, size_t address_n_count)
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) {
layoutSwipe();
@ -550,7 +550,7 @@ void layoutAddress(const char *address, const char *desc, bool qrcode, bool igno
for (int i = 0; i < 4; i++) {
oledDrawString(0, (i + 1) * 9 + 4, str[i], FONT_FIXED);
}
oledDrawString(0, 42, address_n_str(address_n, address_n_count), FONT_STANDARD);
oledDrawString(0, 42, address_n_str(address_n, address_n_count, address_is_account), FONT_STANDARD);
}
if (!qrcode) {

View File

@ -54,7 +54,7 @@ void layoutCipherKeyValue(bool encrypt, const char *key);
void layoutEncryptMessage(const uint8_t *msg, uint32_t len, bool signing);
void layoutDecryptMessage(const uint8_t *msg, uint32_t len, const char *address);
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);
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 layoutSignIdentity(const IdentityType *identity, const char *challenge);
void layoutDecryptIdentity(const IdentityType *identity);