1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 03:30:02 +00:00

RSK checksum address encoding (#376)

This commit is contained in:
Ilan 2018-06-28 06:27:27 -03:00 committed by Pavol Rusnak
parent ffa6567125
commit 9ba3f3f28d
2 changed files with 19 additions and 2 deletions

View File

@ -294,7 +294,15 @@ static void layoutEthereumConfirmTx(const uint8_t *to, uint32_t to_len, const ui
if (to_len) {
char to_str[41];
ethereum_address_checksum(to, to_str, false, 0);
bool rskip60 = false;
// constants from trezor-common/defs/ethereum/networks.json
switch (chain_id) {
case 30: rskip60 = true; break;
case 31: rskip60 = true; break;
}
ethereum_address_checksum(to, to_str, rskip60, chain_id);
memcpy(_to1 + 5, to_str, 10);
memcpy(_to2, to_str + 10, 15);
memcpy(_to3, to_str + 25, 15);

View File

@ -35,8 +35,17 @@ void fsm_msgEthereumGetAddress(EthereumGetAddress *msg)
char desc[16];
strlcpy(desc, "Address:", sizeof(desc));
uint32_t slip44 = msg->address_n[1] & 0x7fffffff;
bool rskip60 = false;
uint32_t chain_id = 0;
// constants from trezor-common/defs/ethereum/networks.json
switch (slip44) {
case 137: rskip60 = true; chain_id = 30; break;
case 37310: rskip60 = true; chain_id = 31; break;
}
char address[43] = { '0', 'x' };
ethereum_address_checksum(resp->address.bytes, address + 2, false, 0);
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)) {
return;