1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-17 03:48:09 +00:00

fsm: Add NEMGetAddress

This commit is contained in:
Saleem Rashid 2017-05-29 17:07:55 +01:00
parent c331d7e8f0
commit 3057f78837
2 changed files with 42 additions and 0 deletions

View File

@ -50,6 +50,7 @@
#include "secp256k1.h"
#include <libopencm3/stm32/flash.h>
#include "ethereum.h"
#include "nem.h"
#include "gettext.h"
// message methods
@ -1104,6 +1105,45 @@ void fsm_msgSetU2FCounter(SetU2FCounter *msg)
layoutHome();
}
void fsm_msgNEMGetAddress(NEMGetAddress *msg)
{
if (!msg->has_network) {
msg->network = NEM_NETWORK_MAINNET;
}
const char *network;
CHECK_PARAM((network = nem_network_name(msg->network)), _("Invalid NEM network"));
CHECK_INITIALIZED
CHECK_PIN
RESP_INIT(NEMAddress);
HDNode *node = fsm_getDerivedNode(ED25519_KECCAK_NAME, msg->address_n, msg->address_n_count);
if (!node) return;
if (!hdnode_get_nem_address(node, msg->network, resp->address))
return;
if (msg->has_show_display && msg->show_display) {
char desc[16];
strlcpy(desc, network, sizeof(desc));
strlcat(desc, ":", sizeof(desc));
bool qrcode = false;
for (;;) {
layoutAddress(resp->address, desc, qrcode);
if (protectButton(ButtonRequestType_ButtonRequest_Address, false)) {
break;
}
qrcode = !qrcode;
}
}
msg_write(MessageType_MessageType_NEMAddress, resp);
layoutHome();
}
#if DEBUG_LINK
void fsm_msgDebugLinkGetState(DebugLinkGetState *msg)

View File

@ -66,6 +66,8 @@ void fsm_msgEthereumTxAck(EthereumTxAck *msg);
void fsm_msgEthereumSignMessage(EthereumSignMessage *msg);
void fsm_msgEthereumVerifyMessage(EthereumVerifyMessage *msg);
void fsm_msgNEMGetAddress(NEMGetAddress *msg);
// debug message functions
#if DEBUG_LINK
//void fsm_msgDebugLinkDecision(DebugLinkDecision *msg);