From a617200c9c45a1726348b08e765201de4e20ae74 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 25 May 2016 15:33:23 +0100 Subject: [PATCH] Add confirmation dialog to EthereumSignTx --- firmware/ethereum.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/firmware/ethereum.c b/firmware/ethereum.c index 840a5e007..4a25b38f4 100644 --- a/firmware/ethereum.c +++ b/firmware/ethereum.c @@ -27,6 +27,7 @@ #include "crypto.h" #include "secp256k1.h" #include "sha3.h" +#include "util.h" static bool signing = false; static size_t data_left; @@ -156,6 +157,30 @@ static void send_signature(void) ethereum_signing_abort(); } +/* FIXME */ +static void layoutEthereumConfirmTx(const uint8_t *to, const uint8_t *value) +{ + static char _value[21] = {0}; + static char _to1[21] = {0}; + static char _to2[21] = {0}; + + data2hex(value, 10, _value); + data2hex(to, 10, _to1); + data2hex(to + 10, 10, _to2); + + layoutDialogSwipe(DIALOG_ICON_QUESTION, + "Cancel", + "Confirm", + NULL, + "Really send", + _value, + "from your wallet?", + "To:", + _to1, + _to2 + ); +} + /* * RLP fields: * - nonce (0 .. 32) @@ -188,6 +213,14 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node) return; } + /* FIXME: include default values (0 / 0) */ + layoutEthereumConfirmTx(msg->has_to ? msg->to.bytes : NULL, msg->has_value ? msg->value.bytes : NULL); + if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) { + fsm_sendFailure(FailureType_Failure_ActionCancelled, "Signing cancelled by user"); + ethereum_signing_abort(); + return; + } + /* Stage 1: Calculate total RLP length */ int total_rlp_length = 0; int total_data_length = 0;