firmware: update code to use new nested messages in trezor-common

pull/25/head
Pavol Rusnak 6 years ago
parent 4f512cff13
commit 0febd07dfc
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -82,8 +82,15 @@ OBJS += ../vendor/nanopb/pb_common.o
OBJS += ../vendor/nanopb/pb_decode.o
OBJS += ../vendor/nanopb/pb_encode.o
OBJS += protob/common.pb.o
OBJS += protob/messages.pb.o
OBJS += protob/types.pb.o
OBJS += protob/messages-bitcoin.pb.o
OBJS += protob/messages-crypto.pb.o
OBJS += protob/messages-debug.pb.o
OBJS += protob/messages-ethereum.pb.o
OBJS += protob/messages-management.pb.o
OBJS += protob/messages-nem.pb.o
OBJS += protob/messages-stellar.pb.o
OPTFLAGS ?= -Os

@ -335,7 +335,7 @@ int cryptoMessageDecrypt(curve_point *nonce, uint8_t *payload, size_t payload_le
}
*/
uint8_t *cryptoHDNodePathToPubkey(const CoinInfo *coin, const HDNodePathType *hdnodepath)
uint8_t *cryptoHDNodePathToPubkey(const CoinInfo *coin, const MultisigRedeemScriptType_HDNodePathType *hdnodepath)
{
if (!hdnodepath->node.has_public_key || hdnodepath->node.public_key.size != 33) return 0;
static HDNode node;
@ -365,7 +365,7 @@ int cryptoMultisigPubkeyIndex(const CoinInfo *coin, const MultisigRedeemScriptTy
int cryptoMultisigFingerprint(const MultisigRedeemScriptType *multisig, uint8_t *hash)
{
static const HDNodePathType *ptr[15], *swap;
static const MultisigRedeemScriptType_HDNodePathType *ptr[15], *swap;
const uint32_t n = multisig->pubkeys_count;
if (n < 1 || n > 15) {
return 0;

@ -29,7 +29,8 @@
#include <pb.h>
#include "coins.h"
#include "hasher.h"
#include "types.pb.h"
#include "messages-bitcoin.pb.h"
#include "messages-crypto.pb.h"
#define ser_length_size(len) ((len) < 253 ? 1 : (len) < 0x10000 ? 3 : 5)
@ -51,7 +52,7 @@ int cryptoMessageEncrypt(curve_point *pubkey, const uint8_t *msg, size_t msg_siz
int cryptoMessageDecrypt(curve_point *nonce, uint8_t *payload, size_t payload_len, const uint8_t *hmac, size_t hmac_len, const uint8_t *privkey, uint8_t *msg, size_t *msg_len, bool *display_only, bool *signing, uint8_t *address_raw);
*/
uint8_t *cryptoHDNodePathToPubkey(const CoinInfo *coin, const HDNodePathType *hdnodepath);
uint8_t *cryptoHDNodePathToPubkey(const CoinInfo *coin, const MultisigRedeemScriptType_HDNodePathType *hdnodepath);
int cryptoMultisigPubkeyIndex(const CoinInfo *coin, const MultisigRedeemScriptType *multisig, const uint8_t *pubkey);

@ -34,6 +34,7 @@
#include "gettext.h"
#include "ethereum_tokens.h"
#include "memzero.h"
#include "messages.pb.h"
/* maximum supported chain id. v must fit in an uint32_t. */
#define MAX_CHAIN_ID 2147483630
@ -190,7 +191,7 @@ static void send_signature(void)
keccak_Final(&keccak_ctx, hash);
if (ecdsa_sign_digest(&secp256k1, privkey, hash, sig, &v, ethereum_is_canonic) != 0) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Signing failed"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Signing failed"));
ethereum_signing_abort();
return;
}
@ -461,7 +462,7 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)
/* eip-155 chain id */
if (msg->has_chain_id) {
if (msg->chain_id < 1 || msg->chain_id > MAX_CHAIN_ID) {
fsm_sendFailure(FailureType_Failure_DataError, _("Chain Id out of bounds"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Chain Id out of bounds"));
ethereum_signing_abort();
return;
}
@ -475,7 +476,7 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)
if (msg->tx_type == 1 || msg->tx_type == 6) {
tx_type = msg->tx_type;
} else {
fsm_sendFailure(FailureType_Failure_DataError, _("Txtype out of bounds"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Txtype out of bounds"));
ethereum_signing_abort();
return;
}
@ -485,7 +486,7 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)
if (msg->has_data_length && msg->data_length > 0) {
if (!msg->has_data_initial_chunk || msg->data_initial_chunk.size == 0) {
fsm_sendFailure(FailureType_Failure_DataError, _("Data length provided, but no initial chunk"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Data length provided, but no initial chunk"));
ethereum_signing_abort();
return;
}
@ -493,7 +494,7 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)
* prevent exceeding the limit we use a stricter limit on data length.
*/
if (msg->data_length > 16000000) {
fsm_sendFailure(FailureType_Failure_DataError, _("Data length exceeds limit"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Data length exceeds limit"));
ethereum_signing_abort();
return;
}
@ -502,14 +503,14 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)
data_total = 0;
}
if (msg->data_initial_chunk.size > data_total) {
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid size of initial chunk"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Invalid size of initial chunk"));
ethereum_signing_abort();
return;
}
// safety checks
if (!ethereum_signing_check(msg)) {
fsm_sendFailure(FailureType_Failure_DataError, _("Safety check failed"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Safety check failed"));
ethereum_signing_abort();
return;
}
@ -528,16 +529,16 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)
layoutEthereumConfirmTx(msg->to.bytes, msg->to.size, msg->value.bytes, msg->value.size, NULL);
}
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
ethereum_signing_abort();
return;
}
if (token == NULL && data_total > 0) {
layoutEthereumData(msg->data_initial_chunk.bytes, msg->data_initial_chunk.size, data_total);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
ethereum_signing_abort();
return;
}
@ -546,8 +547,8 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)
layoutEthereumFee(msg->value.bytes, msg->value.size,
msg->gas_price.bytes, msg->gas_price.size,
msg->gas_limit.bytes, msg->gas_limit.size, token != NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
ethereum_signing_abort();
return;
}
@ -601,19 +602,19 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)
void ethereum_signing_txack(EthereumTxAck *tx)
{
if (!ethereum_signing) {
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Not in Ethereum signing mode"));
fsm_sendFailure(Failure_FailureType_Failure_UnexpectedMessage, _("Not in Ethereum signing mode"));
layoutHome();
return;
}
if (tx->data_chunk.size > data_left) {
fsm_sendFailure(FailureType_Failure_DataError, _("Too much data"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Too much data"));
ethereum_signing_abort();
return;
}
if (data_left > 0 && (!tx->has_data_chunk || tx->data_chunk.size == 0)) {
fsm_sendFailure(FailureType_Failure_DataError, _("Empty data chunk received"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Empty data chunk received"));
ethereum_signing_abort();
return;
}
@ -671,7 +672,7 @@ void ethereum_message_sign(EthereumSignMessage *msg, const HDNode *node, Ethereu
uint8_t v;
if (ecdsa_sign_digest(&secp256k1, node->private_key, hash, resp->signature.bytes, &v, ethereum_is_canonic) != 0) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Signing failed"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Signing failed"));
return;
}
@ -684,7 +685,7 @@ void ethereum_message_sign(EthereumSignMessage *msg, const HDNode *node, Ethereu
int ethereum_message_verify(EthereumVerifyMessage *msg)
{
if (msg->signature.size != 65 || msg->address.size != 20) {
fsm_sendFailure(FailureType_Failure_DataError, _("Malformed data"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Malformed data"));
return 1;
}

@ -23,7 +23,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "bip32.h"
#include "messages.pb.h"
#include "messages-ethereum.pb.h"
void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node);
void ethereum_signing_abort(void);

@ -58,6 +58,8 @@
#include "supervise.h"
#include "stellar.h"
#include "messages-management.pb.h"
// message methods
static uint8_t msg_resp[MSG_OUT_SIZE] __attribute__ ((aligned));
@ -69,13 +71,13 @@ static uint8_t msg_resp[MSG_OUT_SIZE] __attribute__ ((aligned));
#define CHECK_INITIALIZED \
if (!storage_isInitialized()) { \
fsm_sendFailure(FailureType_Failure_NotInitialized, NULL); \
fsm_sendFailure(Failure_FailureType_Failure_NotInitialized, NULL); \
return; \
}
#define CHECK_NOT_INITIALIZED \
if (storage_isInitialized()) { \
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Device is already initialized. Use Wipe first.")); \
fsm_sendFailure(Failure_FailureType_Failure_UnexpectedMessage, _("Device is already initialized. Use Wipe first.")); \
return; \
}
@ -93,7 +95,7 @@ static uint8_t msg_resp[MSG_OUT_SIZE] __attribute__ ((aligned));
#define CHECK_PARAM(cond, errormsg) \
if (!(cond)) { \
fsm_sendFailure(FailureType_Failure_DataError, (errormsg)); \
fsm_sendFailure(Failure_FailureType_Failure_DataError, (errormsg)); \
layoutHome(); \
return; \
}
@ -109,9 +111,9 @@ void fsm_sendSuccess(const char *text)
}
#if DEBUG_LINK
void fsm_sendFailureDebug(FailureType code, const char *text, const char *source)
void fsm_sendFailureDebug(Failure_FailureType code, const char *text, const char *source)
#else
void fsm_sendFailure(FailureType code, const char *text)
void fsm_sendFailure(Failure_FailureType code, const char *text)
#endif
{
if (protectAbortedByCancel) {
@ -127,43 +129,43 @@ void fsm_sendFailure(FailureType code, const char *text)
resp->code = code;
if (!text) {
switch (code) {
case FailureType_Failure_UnexpectedMessage:
case Failure_FailureType_Failure_UnexpectedMessage:
text = _("Unexpected message");
break;
case FailureType_Failure_ButtonExpected:
case Failure_FailureType_Failure_ButtonExpected:
text = _("Button expected");
break;
case FailureType_Failure_DataError:
case Failure_FailureType_Failure_DataError:
text = _("Data error");
break;
case FailureType_Failure_ActionCancelled:
case Failure_FailureType_Failure_ActionCancelled:
text = _("Action cancelled by user");
break;
case FailureType_Failure_PinExpected:
case Failure_FailureType_Failure_PinExpected:
text = _("PIN expected");
break;
case FailureType_Failure_PinCancelled:
case Failure_FailureType_Failure_PinCancelled:
text = _("PIN cancelled");
break;
case FailureType_Failure_PinInvalid:
case Failure_FailureType_Failure_PinInvalid:
text = _("PIN invalid");
break;
case FailureType_Failure_InvalidSignature:
case Failure_FailureType_Failure_InvalidSignature:
text = _("Invalid signature");
break;
case FailureType_Failure_ProcessError:
case Failure_FailureType_Failure_ProcessError:
text = _("Process error");
break;
case FailureType_Failure_NotEnoughFunds:
case Failure_FailureType_Failure_NotEnoughFunds:
text = _("Not enough funds");
break;
case FailureType_Failure_NotInitialized:
case Failure_FailureType_Failure_NotInitialized:
text = _("Device not initialized");
break;
case FailureType_Failure_PinMismatch:
case Failure_FailureType_Failure_PinMismatch:
text = _("PIN mismatch");
break;
case FailureType_Failure_FirmwareError:
case Failure_FailureType_Failure_FirmwareError:
text = _("Firmware error");
break;
}
@ -192,7 +194,7 @@ static const CoinInfo *fsm_getCoin(bool has_name, const char *name)
coin = coinByName("Bitcoin");
}
if (!coin) {
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid coin name"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Invalid coin name"));
layoutHome();
return 0;
}
@ -206,7 +208,7 @@ static HDNode *fsm_getDerivedNode(const char *curve, const uint32_t *address_n,
*fingerprint = 0;
}
if (!storage_getRootNode(&node, curve, true)) {
fsm_sendFailure(FailureType_Failure_NotInitialized, _("Device not initialized or passphrase request cancelled or unsupported curve"));
fsm_sendFailure(Failure_FailureType_Failure_NotInitialized, _("Device not initialized or passphrase request cancelled or unsupported curve"));
layoutHome();
return 0;
}
@ -214,7 +216,7 @@ static HDNode *fsm_getDerivedNode(const char *curve, const uint32_t *address_n,
return &node;
}
if (hdnode_private_ckd_cached(&node, address_n, address_n_count, fingerprint) == 0) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to derive private key"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to derive private key"));
layoutHome();
return 0;
}
@ -230,11 +232,11 @@ static bool fsm_layoutAddress(const char *address, const char *desc, bool ignore
display_addr += prefixlen;
}
layoutAddress(display_addr, desc, qrcode, ignorecase, address_n, address_n_count);
if (protectButton(ButtonRequestType_ButtonRequest_Address, false)) {
if (protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Address, false)) {
return true;
}
if (protectAbortedByCancel || protectAbortedByInitialize) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return false;
}

@ -20,18 +20,24 @@
#ifndef __FSM_H__
#define __FSM_H__
#include "messages.pb.h"
#include "messages-bitcoin.pb.h"
#include "messages-crypto.pb.h"
#include "messages-debug.pb.h"
#include "messages-ethereum.pb.h"
#include "messages-management.pb.h"
#include "messages-nem.pb.h"
#include "messages-stellar.pb.h"
// message functions
void fsm_sendSuccess(const char *text);
#if DEBUG_LINK
void fsm_sendFailureDebug(FailureType code, const char *text, const char *source);
void fsm_sendFailureDebug(Failure_FailureType code, const char *text, const char *source);
#define fsm_sendFailure(code, text) fsm_sendFailureDebug((code), (text), __FILE__ ":" VERSTR(__LINE__) ":")
#else
void fsm_sendFailure(FailureType code, const char *text);
void fsm_sendFailure(Failure_FailureType code, const char *text);
#endif
void fsm_msgInitialize(Initialize *msg);

@ -20,8 +20,8 @@ void fsm_msgGetPublicKey(GetPublicKey *msg)
if (msg->has_show_display && msg->show_display) {
layoutPublicKey(node->public_key);
if (!protectButton(ButtonRequestType_ButtonRequest_PublicKey, true)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_PublicKey, true)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -165,7 +165,7 @@ void fsm_msgGetAddress(GetAddress *msg)
layoutProgress(_("Computing address"), 0);
}
if (!compute_address(coin, msg->script_type, node, msg->has_multisig, &msg->multisig, address)) {
fsm_sendFailure(FailureType_Failure_DataError, _("Can't encode address"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Can't encode address"));
layoutHome();
return;
}
@ -188,8 +188,8 @@ void fsm_msgGetAddress(GetAddress *msg)
if (mismatch) {
layoutDialogSwipe(&bmp_icon_warning, _("Abort"), _("Continue"), NULL, _("Wrong address path"), _("for selected coin."), NULL, _("Continue at your"), _("own risk!"), NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -214,8 +214,8 @@ void fsm_msgSignMessage(SignMessage *msg)
CHECK_INITIALIZED
layoutSignMessage(msg->message.bytes, msg->message.size);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -232,7 +232,7 @@ void fsm_msgSignMessage(SignMessage *msg)
resp->has_address = true;
hdnode_fill_public_key(node);
if (!compute_address(coin, msg->script_type, node, false, NULL, resp->address)) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Error computing address"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Error computing address"));
layoutHome();
return;
}
@ -240,7 +240,7 @@ void fsm_msgSignMessage(SignMessage *msg)
resp->signature.size = 65;
msg_write(MessageType_MessageType_MessageSignature, resp);
} else {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Error signing message"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Error signing message"));
}
layoutHome();
}
@ -255,20 +255,20 @@ void fsm_msgVerifyMessage(VerifyMessage *msg)
layoutProgressSwipe(_("Verifying"), 0);
if (msg->signature.size == 65 && cryptoMessageVerify(coin, msg->message.bytes, msg->message.size, msg->address, msg->signature.bytes) == 0) {
layoutVerifyAddress(msg->address);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
layoutVerifyMessage(msg->message.bytes, msg->message.size);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
fsm_sendSuccess(_("Message verified"));
} else {
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid signature"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Invalid signature"));
}
layoutHome();
}

@ -61,8 +61,8 @@ void fsm_msgPing(Ping *msg)
if (msg->has_button_protection && msg->button_protection) {
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL, _("Do you really want to"), _("answer to ping?"), NULL, NULL, NULL, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -74,7 +74,7 @@ void fsm_msgPing(Ping *msg)
if (msg->has_passphrase_protection && msg->passphrase_protection) {
if (!protectPassphrase()) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
return;
}
}
@ -104,8 +104,8 @@ void fsm_msgChangePin(ChangePin *msg)
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL, _("Do you really want to"), _("set new PIN?"), NULL, NULL, NULL, NULL);
}
}
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -120,7 +120,7 @@ void fsm_msgChangePin(ChangePin *msg)
if (protectChangePin()) {
fsm_sendSuccess(_("PIN changed"));
} else {
fsm_sendFailure(FailureType_Failure_PinMismatch, NULL);
fsm_sendFailure(Failure_FailureType_Failure_PinMismatch, NULL);
}
}
layoutHome();
@ -130,8 +130,8 @@ void fsm_msgWipeDevice(WipeDevice *msg)
{
(void)msg;
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL, _("Do you really want to"), _("wipe the device?"), NULL, _("All data will be lost."), NULL, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_WipeDevice, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_WipeDevice, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -146,8 +146,8 @@ void fsm_msgGetEntropy(GetEntropy *msg)
{
#if !DEBUG_RNG
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL, _("Do you really want to"), _("send entropy?"), NULL, NULL, NULL, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -168,15 +168,15 @@ void fsm_msgLoadDevice(LoadDevice *msg)
CHECK_NOT_INITIALIZED
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("I take the risk"), NULL, _("Loading private seed"), _("is not recommended."), _("Continue only if you"), _("know what you are"), _("doing!"), NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
if (msg->has_mnemonic && !(msg->has_skip_checksum && msg->skip_checksum) ) {
if (!mnemonic_check(msg->mnemonic)) {
fsm_sendFailure(FailureType_Failure_DataError, _("Mnemonic with wrong checksum provided"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Mnemonic with wrong checksum provided"));
layoutHome();
return;
}
@ -230,7 +230,7 @@ void fsm_msgCancel(Cancel *msg)
recovery_abort();
signing_abort();
ethereum_signing_abort();
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
}
void fsm_msgClearSession(ClearSession *msg)
@ -250,32 +250,32 @@ void fsm_msgApplySettings(ApplySettings *msg)
if (msg->has_label) {
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL, _("Do you really want to"), _("change name to"), msg->label, "?", NULL, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
}
if (msg->has_language) {
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL, _("Do you really want to"), _("change language to"), msg->language, "?", NULL, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
}
if (msg->has_use_passphrase) {
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL, _("Do you really want to"), msg->use_passphrase ? _("enable passphrase") : _("disable passphrase"), _("protection?"), NULL, NULL, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
}
if (msg->has_homescreen) {
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL, _("Do you really want to"), _("change the home"), _("screen?"), NULL, NULL, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -283,8 +283,8 @@ void fsm_msgApplySettings(ApplySettings *msg)
if (msg->has_auto_lock_delay_ms) {
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL, _("Do you really want to"), _("change auto-lock"), _("delay?"), NULL, NULL, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -331,8 +331,8 @@ void fsm_msgRecoveryDevice(RecoveryDevice *msg)
if (!dry_run) {
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL, _("Do you really want to"), _("recover the device?"), NULL, NULL, NULL, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -359,8 +359,8 @@ void fsm_msgWordAck(WordAck *msg)
void fsm_msgSetU2FCounter(SetU2FCounter *msg)
{
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL, _("Do you want to set"), _("the U2F counter?"), NULL, NULL, NULL, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}

@ -16,8 +16,8 @@ void fsm_msgCipherKeyValue(CipherKeyValue *msg)
bool ask_on_decrypt = msg->has_ask_on_decrypt && msg->ask_on_decrypt;
if ((encrypt && ask_on_encrypt) || (!encrypt && ask_on_decrypt)) {
layoutCipherKeyValue(encrypt, msg->key);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -53,8 +53,8 @@ void fsm_msgSignIdentity(SignIdentity *msg)
CHECK_INITIALIZED
layoutSignIdentity(&(msg->identity), msg->has_challenge_visual ? msg->challenge_visual : 0);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -63,7 +63,7 @@ void fsm_msgSignIdentity(SignIdentity *msg)
uint8_t hash[32];
if (!msg->has_identity || cryptoIdentityFingerprint(&(msg->identity), hash) == 0) {
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid identity"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Invalid identity"));
layoutHome();
return;
}
@ -117,7 +117,7 @@ void fsm_msgSignIdentity(SignIdentity *msg)
resp->signature.size = 65;
msg_write(MessageType_MessageType_SignedIdentity, resp);
} else {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Error signing identity"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Error signing identity"));
}
layoutHome();
}
@ -129,8 +129,8 @@ void fsm_msgGetECDHSessionKey(GetECDHSessionKey *msg)
CHECK_INITIALIZED
layoutDecryptIdentity(&msg->identity);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -139,7 +139,7 @@ void fsm_msgGetECDHSessionKey(GetECDHSessionKey *msg)
uint8_t hash[32];
if (!msg->has_identity || cryptoIdentityFingerprint(&(msg->identity), hash) == 0) {
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid identity"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Invalid identity"));
layoutHome();
return;
}
@ -165,7 +165,7 @@ void fsm_msgGetECDHSessionKey(GetECDHSessionKey *msg)
resp->session_key.size = result_size;
msg_write(MessageType_MessageType_ECDHSessionKey, resp);
} else {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Error getting ECDH session key"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Error getting ECDH session key"));
}
layoutHome();
}
@ -197,14 +197,14 @@ void fsm_msgEncryptMessage(EncryptMessage *msg)
hdnode_get_address_raw(node, coin->address_type, address_raw);
}
layoutEncryptMessage(msg->message.bytes, msg->message.size, signing);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
layoutProgressSwipe(_("Encrypting"), 0);
if (cryptoMessageEncrypt(&pubkey, msg->message.bytes, msg->message.size, display_only, resp->nonce.bytes, &(resp->nonce.size), resp->message.bytes, &(resp->message.size), resp->hmac.bytes, &(resp->hmac.size), signing ? node->private_key : 0, signing ? address_raw : 0) != 0) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Error encrypting message"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Error encrypting message"));
layoutHome();
return;
}
@ -238,7 +238,7 @@ void fsm_msgDecryptMessage(DecryptMessage *msg)
bool signing = false;
uint8_t address_raw[MAX_ADDR_RAW_SIZE];
if (cryptoMessageDecrypt(&nonce_pubkey, msg->message.bytes, msg->message.size, msg->hmac.bytes, msg->hmac.size, node->private_key, resp->message.bytes, &(resp->message.size), &display_only, &signing, address_raw) != 0) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -246,7 +246,7 @@ void fsm_msgDecryptMessage(DecryptMessage *msg)
base58_encode_check(address_raw, 21, resp->address, sizeof(resp->address));
}
layoutDecryptMessage(resp->message.bytes, resp->message.size, signing ? resp->address : 0);
protectButton(ButtonRequestType_ButtonRequest_Other, true);
protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, true);
if (display_only) {
resp->has_address = false;
resp->has_message = false;
@ -270,8 +270,8 @@ void fsm_msgCosiCommit(CosiCommit *msg)
CHECK_PARAM(msg->has_data, _("No data provided"));
layoutCosiCommitSign(msg->address_n, msg->address_n_count, msg->data.bytes, msg->data.size, false);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -310,8 +310,8 @@ void fsm_msgCosiSign(CosiSign *msg)
CHECK_PARAM(msg->has_global_pubkey && msg->global_pubkey.size == 32, _("Invalid global pubkey"));
layoutCosiCommitSign(msg->address_n, msg->address_n_count, msg->data.bytes, msg->data.size, true);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}

@ -63,8 +63,8 @@ void fsm_msgEthereumSignMessage(EthereumSignMessage *msg)
CHECK_INITIALIZED
layoutSignMessage(msg->message.bytes, msg->message.size);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -84,21 +84,21 @@ void fsm_msgEthereumVerifyMessage(EthereumVerifyMessage *msg)
CHECK_PARAM(msg->has_message, _("No message provided"));
if (ethereum_message_verify(msg) != 0) {
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid signature"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Invalid signature"));
return;
}
char address[43] = { '0', 'x' };
ethereum_address_checksum(msg->address.bytes, address + 2, false, 0);
layoutVerifyAddress(address);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
layoutVerifyMessage(msg->message.bytes, msg->message.size);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}

@ -77,7 +77,7 @@ void fsm_msgNEMSignTx(NEMSignTx *msg) {
nem_get_address(msg->multisig.signer.bytes, msg->multisig.network, address);
if (!nem_askMultisig(address, network, cosigning, msg->transaction.fee)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
layoutHome();
return;
}
@ -90,7 +90,7 @@ void fsm_msgNEMSignTx(NEMSignTx *msg) {
hdnode_fill_public_key(node);
const NEMTransactionCommon *common = msg->has_multisig ? &msg->multisig : &msg->transaction;
const NEMSignTx_NEMTransactionCommon *common = msg->has_multisig ? &msg->multisig : &msg->transaction;
char address[NEM_ADDRESS_SIZE + 1];
hdnode_get_nem_address(node, common->network, address);
@ -100,37 +100,37 @@ void fsm_msgNEMSignTx(NEMSignTx *msg) {
}
if (msg->has_transfer && !nem_askTransfer(common, &msg->transfer, network)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
layoutHome();
return;
}
if (msg->has_provision_namespace && !nem_askProvisionNamespace(common, &msg->provision_namespace, network)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
layoutHome();
return;
}
if (msg->has_mosaic_creation && !nem_askMosaicCreation(common, &msg->mosaic_creation, network, address)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
layoutHome();
return;
}
if (msg->has_supply_change && !nem_askSupplyChange(common, &msg->supply_change, network)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
layoutHome();
return;
}
if (msg->has_aggregate_modification && !nem_askAggregateModification(common, &msg->aggregate_modification, network, !msg->has_multisig)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
layoutHome();
return;
}
if (msg->has_importance_transfer && !nem_askImportanceTransfer(common, &msg->importance_transfer, network)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
layoutHome();
return;
}
@ -241,8 +241,8 @@ void fsm_msgNEMDecryptMessage(NEMDecryptMessage *msg)
_("Decrypt message"),
_("Confirm address?"),
address);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -267,7 +267,7 @@ void fsm_msgNEMDecryptMessage(NEMDecryptMessage *msg)
size,
resp->payload.bytes);
if (!ret) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to decrypt payload"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to decrypt payload"));
layoutHome();
return;
}
@ -276,8 +276,8 @@ void fsm_msgNEMDecryptMessage(NEMDecryptMessage *msg)
resp->payload.size = NEM_DECRYPTED_SIZE(resp->payload.bytes, size);
layoutNEMTransferPayload(resp->payload.bytes, resp->payload.size, true);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}

@ -8,7 +8,7 @@ void fsm_msgStellarGetAddress(StellarGetAddress *msg)
HDNode *node = stellar_deriveNode(msg->address_n, msg->address_n_count);
if (!node) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to derive private key"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to derive private key"));
return;
}
@ -21,8 +21,8 @@ void fsm_msgStellarGetAddress(StellarGetAddress *msg)
NULL,
NULL, NULL
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -46,7 +46,7 @@ void fsm_msgStellarGetPublicKey(StellarGetPublicKey *msg)
HDNode *node = stellar_deriveNode(msg->address_n, msg->address_n_count);
if (!node) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to derive private key"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to derive private key"));
return;
}
@ -61,8 +61,8 @@ void fsm_msgStellarGetPublicKey(StellarGetPublicKey *msg)
str_pubkey_rows[3],
NULL, NULL
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}

@ -244,7 +244,7 @@ void layoutHome(void)
system_millis_lock_start = timer_ms();
}
void layoutConfirmOutput(const CoinInfo *coin, const TxOutputType *out)
void layoutConfirmOutput(const CoinInfo *coin, const TxAck_TransactionType_TxOutputType *out)
{
char str_out[32 + 3];
bn_format_uint64(out->amount, NULL, coin->coin_shortcut, BITCOIN_DIVISIBILITY, 0, false, str_out, sizeof(str_out) - 3);
@ -713,7 +713,7 @@ void layoutNEMNetworkFee(const char *desc, bool confirm, const char *fee1_desc,
NULL);
}
void layoutNEMTransferMosaic(const NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, uint8_t network) {
void layoutNEMTransferMosaic(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, uint8_t network) {
char str_out[32], str_levy[32];
nem_mosaicFormatAmount(definition, quantity, multiplier, str_out, sizeof(str_out));
@ -782,8 +782,8 @@ void layoutNEMMosaicDescription(const char *description) {
str[0], str[1], str[2], str[3], NULL, NULL);
}
void layoutNEMLevy(const NEMMosaicDefinition *definition, uint8_t network) {
const NEMMosaicDefinition *mosaic;
void layoutNEMLevy(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint8_t network) {
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *mosaic;
if (nem_mosaicMatches(definition, definition->levy_namespace, definition->levy_mosaic, network)) {
mosaic = definition;
} else {
@ -798,7 +798,7 @@ void layoutNEMLevy(const NEMMosaicDefinition *definition, uint8_t network) {
char str_out[32];
switch (definition->levy) {
case NEMMosaicLevy_MosaicLevy_Percentile:
case NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition_NEMMosaicLevy_MosaicLevy_Percentile:
bn_format_uint64(definition->fee, NULL, NULL, 0, 0, false, str_out, sizeof(str_out));
layoutDialogSwipe(&bmp_icon_question,
@ -813,7 +813,7 @@ void layoutNEMLevy(const NEMMosaicDefinition *definition, uint8_t network) {
NULL);
break;
case NEMMosaicLevy_MosaicLevy_Absolute:
case NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition_NEMMosaicLevy_MosaicLevy_Absolute:
default:
nem_mosaicFormatAmount(mosaic, definition->fee, NULL, str_out, sizeof(str_out));
layoutDialogSwipe(&bmp_icon_question,

@ -21,12 +21,15 @@
#define __LAYOUT2_H__
#include "layout.h"
#include "types.pb.h"
#include "coins.h"
#include "bitmaps.h"
#include "bignum.h"
#include "trezor.h"
#include "messages-bitcoin.pb.h"
#include "messages-crypto.pb.h"
#include "messages-nem.pb.h"
extern void *layoutLast;
#if DEBUG_LINK
@ -40,7 +43,7 @@ void layoutProgressSwipe(const char *desc, int permil);
void layoutScreensaver(void);
void layoutHome(void);
void layoutConfirmOutput(const CoinInfo *coin, const TxOutputType *out);
void layoutConfirmOutput(const CoinInfo *coin, const TxAck_TransactionType_TxOutputType *out);
void layoutConfirmOpReturn(const uint8_t *data, uint32_t size);
void layoutConfirmTx(const CoinInfo *coin, uint64_t amount_out, uint64_t amount_fee);
void layoutFeeOverThreshold(const CoinInfo *coin, uint64_t fee);
@ -60,11 +63,11 @@ void layoutU2FDialog(const char *verb, const char *appname, const BITMAP *appico
void layoutNEMDialog(const BITMAP *icon, const char *btnNo, const char *btnYes, const char *desc, const char *line1, const char *address);
void layoutNEMTransferXEM(const char *desc, uint64_t quantity, const bignum256 *multiplier, uint64_t fee);
void layoutNEMNetworkFee(const char *desc, bool confirm, const char *fee1_desc, uint64_t fee1, const char *fee2_desc, uint64_t fee2);
void layoutNEMTransferMosaic(const NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, uint8_t network);
void layoutNEMTransferMosaic(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, uint8_t network);
void layoutNEMTransferUnknownMosaic(const char *namespace, const char *mosaic, uint64_t quantity, const bignum256 *multiplier);
void layoutNEMTransferPayload(const uint8_t *payload, size_t length, bool encrypted);
void layoutNEMMosaicDescription(const char *description);
void layoutNEMLevy(const NEMMosaicDefinition *definition, uint8_t network);
void layoutNEMLevy(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint8_t network);
void layoutCosiCommitSign(const uint32_t *address_n, size_t address_n_count, const uint8_t *data, uint32_t len, bool final_sign);

@ -229,7 +229,7 @@ void msg_process(char type, uint16_t msg_id, const pb_field_t *fields, uint8_t *
if (status) {
MessageProcessFunc(type, 'i', msg_id, msg_data);
} else {
fsm_sendFailure(FailureType_Failure_DataError, stream.errmsg);
fsm_sendFailure(Failure_FailureType_Failure_DataError, stream.errmsg);
}
}
@ -253,11 +253,11 @@ void msg_read_common(char type, const uint8_t *buf, uint32_t len)
fields = MessageFields(type, 'i', msg_id);
if (!fields) { // unknown message
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Unknown message"));
fsm_sendFailure(Failure_FailureType_Failure_UnexpectedMessage, _("Unknown message"));
return;
}
if (msg_size > MSG_IN_SIZE) { // message is too big :(
fsm_sendFailure(FailureType_Failure_DataError, _("Message too big"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Message too big"));
return;
}
@ -365,11 +365,11 @@ void msg_read_tiny(const uint8_t *buf, int len)
if (status) {
msg_tiny_id = msg_id;
} else {
fsm_sendFailure(FailureType_Failure_DataError, stream.errmsg);
fsm_sendFailure(Failure_FailureType_Failure_DataError, stream.errmsg);
msg_tiny_id = 0xFFFF;
}
} else {
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Unknown message"));
fsm_sendFailure(Failure_FailureType_Failure_UnexpectedMessage, _("Unknown message"));
msg_tiny_id = 0xFFFF;
}
}

@ -27,7 +27,7 @@
#include "rng.h"
#include "secp256k1.h"
const char *nem_validate_common(NEMTransactionCommon *common, bool inner) {
const char *nem_validate_common(NEMSignTx_NEMTransactionCommon *common, bool inner) {
if (!common->has_network) {
common->has_network = true;
common->network = NEM_NETWORK_MAINNET;
@ -60,7 +60,7 @@ const char *nem_validate_common(NEMTransactionCommon *common, bool inner) {
return NULL;
}
const char *nem_validate_transfer(const NEMTransfer *transfer, uint8_t network) {
const char *nem_validate_transfer(const NEMSignTx_NEMTransfer *transfer, uint8_t network) {
if (!transfer->has_recipient) return _("No recipient provided");
if (!transfer->has_amount) return _("No amount provided");
@ -71,7 +71,7 @@ const char *nem_validate_transfer(const NEMTransfer *transfer, uint8_t network)
if (!nem_validate_address(transfer->recipient, network)) return _("Invalid recipient address");
for (size_t i = 0; i < transfer->mosaics_count; i++) {
const NEMMosaic *mosaic = &transfer->mosaics[i];
const NEMSignTx_NEMTransfer_NEMMosaic *mosaic = &transfer->mosaics[i];
if (!mosaic->has_namespace) return _("No mosaic namespace provided");
if (!mosaic->has_mosaic) return _("No mosaic name provided");
@ -81,7 +81,7 @@ const char *nem_validate_transfer(const NEMTransfer *transfer, uint8_t network)
return NULL;
}
const char *nem_validate_provision_namespace(const NEMProvisionNamespace *provision_namespace, uint8_t network) {
const char *nem_validate_provision_namespace(const NEMSignTx_NEMProvisionNamespace *provision_namespace, uint8_t network) {
if (!provision_namespace->has_namespace) return _("No namespace provided");
if (!provision_namespace->has_sink) return _("No rental sink provided");
if (!provision_namespace->has_fee) return _("No rental sink fee provided");
@ -91,7 +91,7 @@ const char *nem_validate_provision_namespace(const NEMProvisionNamespace *provis
return NULL;
}
const char *nem_validate_mosaic_creation(const NEMMosaicCreation *mosaic_creation, uint8_t network) {
const char *nem_validate_mosaic_creation(const NEMSignTx_NEMMosaicCreation *mosaic_creation, uint8_t network) {
if (!mosaic_creation->has_definition) return _("No mosaic definition provided");
if (!mosaic_creation->has_sink) return _("No creation sink provided");
if (!mosaic_creation->has_fee) return _("No creation sink fee provided");
@ -126,7 +126,7 @@ const char *nem_validate_mosaic_creation(const NEMMosaicCreation *mosaic_creatio
return NULL;
}
const char *nem_validate_supply_change(const NEMMosaicSupplyChange *supply_change) {
const char *nem_validate_supply_change(const NEMSignTx_NEMMosaicSupplyChange *supply_change) {
if (!supply_change->has_namespace) return _("No namespace provided");
if (!supply_change->has_mosaic) return _("No mosaic provided");
if (!supply_change->has_type) return _("No type provided");
@ -135,19 +135,19 @@ const char *nem_validate_supply_change(const NEMMosaicSupplyChange *supply_chang
return NULL;
}
const char *nem_validate_aggregate_modification(const NEMAggregateModification *aggregate_modification, bool creation) {
const char *nem_validate_aggregate_modification(const NEMSignTx_NEMAggregateModification *aggregate_modification, bool creation) {
if (creation && aggregate_modification->modifications_count == 0) {
return _("No modifications provided");
}
for (size_t i = 0; i < aggregate_modification->modifications_count; i++) {
const NEMCosignatoryModification *modification = &aggregate_modification->modifications[i];
const NEMSignTx_NEMAggregateModification_NEMCosignatoryModification *modification = &aggregate_modification->modifications[i];
if (!modification->has_type) return _("No modification type provided");
if (!modification->has_public_key) return _("No cosignatory public key provided");
if (modification->public_key.size != 32) return _("Invalid cosignatory public key provided");
if (creation && modification->type == NEMModificationType_CosignatoryModification_Delete) {
if (creation && modification->type == NEMSignTx_NEMAggregateModification_NEMCosignatoryModification_NEMModificationType_CosignatoryModification_Delete) {
return _("Cannot remove cosignatory when converting account");
}
}
@ -155,7 +155,7 @@ const char *nem_validate_aggregate_modification(const NEMAggregateModification *
return NULL;
}
const char *nem_validate_importance_transfer(const NEMImportanceTransfer *importance_transfer) {
const char *nem_validate_importance_transfer(const NEMSignTx_NEMImportanceTransfer *importance_transfer) {
if (!importance_transfer->has_mode) return _("No mode provided");
if (!importance_transfer->has_public_key) return _("No remote account provided");
if (importance_transfer->public_key.size != 32) return _("Invalid remote account provided");
@ -163,15 +163,15 @@ const char *nem_validate_importance_transfer(const NEMImportanceTransfer *import
return NULL;
}
bool nem_askTransfer(const NEMTransactionCommon *common, const NEMTransfer *transfer, const char *desc) {
bool nem_askTransfer(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMTransfer *transfer, const char *desc) {
if (transfer->mosaics_count) {
const NEMMosaic *xem = NULL;
const NEMSignTx_NEMTransfer_NEMMosaic *xem = NULL;
bool unknownMosaic = false;
const NEMMosaicDefinition *definitions[transfer->mosaics_count];
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definitions[transfer->mosaics_count];
for (size_t i = 0; i < transfer->mosaics_count; i++) {
const NEMMosaic *mosaic = &transfer->mosaics[i];
const NEMSignTx_NEMTransfer_NEMMosaic *mosaic = &transfer->mosaics[i];
definitions[i] = nem_mosaicByName(mosaic->namespace, mosaic->mosaic, common->network);
@ -196,18 +196,18 @@ bool nem_askTransfer(const NEMTransactionCommon *common, const NEMTransfer *tran
NULL,
NULL,
NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
layoutNEMTransferXEM(desc, xem ? xem->quantity : 0, &multiplier, common->fee);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
for (size_t i = 0; i < transfer->mosaics_count; i++) {
const NEMMosaic *mosaic = &transfer->mosaics[i];
const NEMSignTx_NEMTransfer_NEMMosaic *mosaic = &transfer->mosaics[i];
if (mosaic == xem) {
continue;
@ -219,20 +219,20 @@ bool nem_askTransfer(const NEMTransactionCommon *common, const NEMTransfer *tran
layoutNEMTransferUnknownMosaic(mosaic->namespace, mosaic->mosaic, mosaic->quantity, &multiplier);
}
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
} else {
layoutNEMTransferXEM(desc, transfer->amount, NULL, common->fee);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
if (transfer->has_payload) {
layoutNEMTransferPayload(transfer->payload.bytes, transfer->payload.size, transfer->has_public_key);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
@ -243,14 +243,14 @@ bool nem_askTransfer(const NEMTransactionCommon *common, const NEMTransfer *tran
desc,
_("Confirm transfer to"),
transfer->recipient);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
return false;
}
return true;
}
bool nem_fsmTransfer(nem_transaction_ctx *context, const HDNode *node, const NEMTransactionCommon *common, const NEMTransfer *transfer) {
bool nem_fsmTransfer(nem_transaction_ctx *context, const HDNode *node, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMTransfer *transfer) {
static uint8_t encrypted[NEM_ENCRYPTED_PAYLOAD_SIZE(sizeof(transfer->payload.bytes))];
const uint8_t *payload = transfer->payload.bytes;
@ -258,7 +258,7 @@ bool nem_fsmTransfer(nem_transaction_ctx *context, const HDNode *node, const NEM
if (transfer->has_public_key) {
if (node == NULL) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Private key unavailable for encrypted message"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Private key unavailable for encrypted message"));
return false;
}
@ -277,7 +277,7 @@ bool nem_fsmTransfer(nem_transaction_ctx *context, const HDNode *node, const NEM
buffer);
if (!ret) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to encrypt payload"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to encrypt payload"));
return false;
}
@ -299,12 +299,12 @@ bool nem_fsmTransfer(nem_transaction_ctx *context, const HDNode *node, const NEM
transfer->mosaics_count);
if (!ret) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to create transfer transaction"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to create transfer transaction"));
return false;
}
for (size_t i = 0; i < transfer->mosaics_count; i++) {
const NEMMosaic *mosaic = &transfer->mosaics[i];
const NEMSignTx_NEMTransfer_NEMMosaic *mosaic = &transfer->mosaics[i];
ret = nem_transaction_write_mosaic(context,
mosaic->namespace,
@ -312,7 +312,7 @@ bool nem_fsmTransfer(nem_transaction_ctx *context, const HDNode *node, const NEM
mosaic->quantity);
if (!ret) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to attach mosaics"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to attach mosaics"));
return false;
}
}
@ -320,7 +320,7 @@ bool nem_fsmTransfer(nem_transaction_ctx *context, const HDNode *node, const NEM
return true;
}
bool nem_askProvisionNamespace(const NEMTransactionCommon *common, const NEMProvisionNamespace *provision_namespace, const char *desc) {
bool nem_askProvisionNamespace(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMProvisionNamespace *provision_namespace, const char *desc) {
layoutDialogSwipe(&bmp_icon_question,
_("Cancel"),
_("Next"),
@ -331,19 +331,19 @@ bool nem_askProvisionNamespace(const NEMTransactionCommon *common, const NEMProv
provision_namespace->has_parent ? provision_namespace->parent : NULL,
NULL,
NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
layoutNEMNetworkFee(desc, true, _("Confirm rental fee of"), provision_namespace->fee, _("and network fee of"), common->fee);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
return false;
}
return true;
}
bool nem_fsmProvisionNamespace(nem_transaction_ctx *context, const NEMTransactionCommon *common, const NEMProvisionNamespace *provision_namespace) {
bool nem_fsmProvisionNamespace(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMProvisionNamespace *provision_namespace) {
return nem_transaction_create_provision_namespace(context,
common->network,
common->timestamp,
@ -356,7 +356,7 @@ bool nem_fsmProvisionNamespace(nem_transaction_ctx *context, const NEMTransactio
provision_namespace->fee);
}
bool nem_askMosaicCreation(const NEMTransactionCommon *common, const NEMMosaicCreation *mosaic_creation, const char *desc, const char *address) {
bool nem_askMosaicCreation(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMMosaicCreation *mosaic_creation, const char *desc, const char *address) {
layoutDialogSwipe(&bmp_icon_question,
_("Cancel"),
_("Next"),
@ -367,12 +367,12 @@ bool nem_askMosaicCreation(const NEMTransactionCommon *common, const NEMMosaicCr
mosaic_creation->definition.namespace,
NULL,
NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
layoutNEMMosaicDescription(mosaic_creation->definition.description);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
@ -397,13 +397,13 @@ bool nem_askMosaicCreation(const NEMTransactionCommon *common, const NEMMosaicCr
mosaic_creation->definition.transferable ? _("transferable") : _("non-transferable"),
NULL,
NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
if (mosaic_creation->definition.has_levy) {
layoutNEMLevy(&mosaic_creation->definition, common->network);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
@ -427,20 +427,20 @@ bool nem_askMosaicCreation(const NEMTransactionCommon *common, const NEMMosaicCr
mosaic_creation->definition.levy_address);
}
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
layoutNEMNetworkFee(desc, true, _("Confirm creation fee"), mosaic_creation->fee, _("and network fee of"), common->fee);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
return false;
}
return true;
}
bool nem_fsmMosaicCreation(nem_transaction_ctx *context, const NEMTransactionCommon *common, const NEMMosaicCreation *mosaic_creation) {
bool nem_fsmMosaicCreation(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMMosaicCreation *mosaic_creation) {
return nem_transaction_create_mosaic_creation(context,
common->network,
common->timestamp,
@ -463,7 +463,7 @@ bool nem_fsmMosaicCreation(nem_transaction_ctx *context, const NEMTransactionCom
mosaic_creation->fee);
}
bool nem_askSupplyChange(const NEMTransactionCommon *common, const NEMMosaicSupplyChange *supply_change, const char *desc) {
bool nem_askSupplyChange(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMMosaicSupplyChange *supply_change, const char *desc) {
layoutDialogSwipe(&bmp_icon_question,
_("Cancel"),
_("Next"),
@ -474,7 +474,7 @@ bool nem_askSupplyChange(const NEMTransactionCommon *common, const NEMMosaicSupp
supply_change->namespace,
NULL,
NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
@ -485,25 +485,25 @@ bool nem_askSupplyChange(const NEMTransactionCommon *common, const NEMMosaicSupp
_("Cancel"),
_("Next"),
desc,
supply_change->type == NEMSupplyChangeType_SupplyChange_Increase ? _("Increase supply by") : _("Decrease supply by"),
supply_change->type == NEMSignTx_NEMMosaicSupplyChange_NEMSupplyChangeType_SupplyChange_Increase ? _("Increase supply by") : _("Decrease supply by"),
str_out,
_("whole units"),
NULL,
NULL,
NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
layoutNEMNetworkFee(desc, true, _("Confirm network fee"), common->fee, NULL, 0);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
return false;
}
return true;
}
bool nem_fsmSupplyChange(nem_transaction_ctx *context, const NEMTransactionCommon *common, const NEMMosaicSupplyChange *supply_change) {
bool nem_fsmSupplyChange(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMMosaicSupplyChange *supply_change) {
return nem_transaction_create_mosaic_supply_change(context,
common->network,
common->timestamp,
@ -516,7 +516,7 @@ bool nem_fsmSupplyChange(nem_transaction_ctx *context, const NEMTransactionCommo
supply_change->delta);
}
bool nem_askAggregateModification(const NEMTransactionCommon *common, const NEMAggregateModification *aggregate_modification, const char *desc, bool creation) {
bool nem_askAggregateModification(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMAggregateModification *aggregate_modification, const char *desc, bool creation) {
if (creation) {
layoutDialogSwipe(&bmp_icon_question,
_("Cancel"),
@ -528,7 +528,7 @@ bool nem_askAggregateModification(const NEMTransactionCommon *common, const NEMA
NULL,
NULL,
NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
@ -536,16 +536,16 @@ bool nem_askAggregateModification(const NEMTransactionCommon *common, const NEMA
char address[NEM_ADDRESS_SIZE + 1];
for (size_t i = 0; i < aggregate_modification->modifications_count; i++) {
const NEMCosignatoryModification *modification = &aggregate_modification->modifications[i];
const NEMSignTx_NEMAggregateModification_NEMCosignatoryModification *modification = &aggregate_modification->modifications[i];
nem_get_address(modification->public_key.bytes, common->network, address);
layoutNEMDialog(&bmp_icon_question,
_("Cancel"),
_("Next"),
desc,
modification->type == NEMModificationType_CosignatoryModification_Add ? _("Add cosignatory") : _("Remove cosignatory"),
modification->type == NEMSignTx_NEMAggregateModification_NEMCosignatoryModification_NEMModificationType_CosignatoryModification_Add ? _("Add cosignatory") : _("Remove cosignatory"),
address);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
@ -572,20 +572,20 @@ bool nem_askAggregateModification(const NEMTransactionCommon *common, const NEMA
NULL,
NULL,
NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
layoutNEMNetworkFee(desc, true, _("Confirm network fee"), common->fee, NULL, 0);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
return false;
}
return true;
}
bool nem_fsmAggregateModification(nem_transaction_ctx *context, const NEMTransactionCommon *common, const NEMAggregateModification *aggregate_modification) {
bool nem_fsmAggregateModification(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMAggregateModification *aggregate_modification) {
bool ret = nem_transaction_create_aggregate_modification(context,
common->network,
common->timestamp,
@ -597,7 +597,7 @@ bool nem_fsmAggregateModification(nem_transaction_ctx *context, const NEMTransac
if (!ret) return false;
for (size_t i = 0; i < aggregate_modification->modifications_count; i++) {
const NEMCosignatoryModification *modification = &aggregate_modification->modifications[i];
const NEMSignTx_NEMAggregateModification_NEMCosignatoryModification *modification = &aggregate_modification->modifications[i];
ret = nem_transaction_write_cosignatory_modification(context,
modification->type,
@ -613,30 +613,30 @@ bool nem_fsmAggregateModification(nem_transaction_ctx *context, const NEMTransac
return true;
}
bool nem_askImportanceTransfer(const NEMTransactionCommon *common, const NEMImportanceTransfer *importance_transfer, const char *desc) {
bool nem_askImportanceTransfer(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMImportanceTransfer *importance_transfer, const char *desc) {
layoutDialogSwipe(&bmp_icon_question,
_("Cancel"),
_("Next"),
desc,
importance_transfer->mode == NEMImportanceTransferMode_ImportanceTransfer_Activate ? _("Activate remote") : _("Deactivate remote"),
importance_transfer->mode == NEMSignTx_NEMImportanceTransfer_NEMImportanceTransferMode_ImportanceTransfer_Activate ? _("Activate remote") : _("Deactivate remote"),
_("harvesting?"),
NULL,
NULL,
NULL,
NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
layoutNEMNetworkFee(desc, true, _("Confirm network fee"), common->fee, NULL, 0);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
return false;
}
return true;
}
bool nem_fsmImportanceTransfer(nem_transaction_ctx *context, const NEMTransactionCommon *common, const NEMImportanceTransfer *importance_transfer) {
bool nem_fsmImportanceTransfer(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMImportanceTransfer *importance_transfer) {
return nem_transaction_create_importance_transfer(context,
common->network,
common->timestamp,
@ -654,19 +654,19 @@ bool nem_askMultisig(const char *address, const char *desc, bool cosigning, uint
desc,
cosigning ? _("Cosign transaction for") : _("Initiate transaction for"),
address);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
layoutNEMNetworkFee(desc, false, _("Confirm multisig fee"), fee, NULL, 0);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
return true;
}
bool nem_fsmMultisig(nem_transaction_ctx *context, const NEMTransactionCommon *common, const nem_transaction_ctx *inner, bool cosigning) {
bool nem_fsmMultisig(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const nem_transaction_ctx *inner, bool cosigning) {
bool ret;
if (cosigning) {
ret = nem_transaction_create_multisig_signature(context,
@ -687,16 +687,16 @@ bool nem_fsmMultisig(nem_transaction_ctx *context, const NEMTransactionCommon *c
}
if (!ret) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to create multisig transaction"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to create multisig transaction"));
return false;
}
return true;
}
const NEMMosaicDefinition *nem_mosaicByName(const char *namespace, const char *mosaic, uint8_t network) {
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *nem_mosaicByName(const char *namespace, const char *mosaic, uint8_t network) {
for (size_t i = 0; i < NEM_MOSAIC_DEFINITIONS_COUNT; i++) {
const NEMMosaicDefinition *definition = &NEM_MOSAIC_DEFINITIONS[i];
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition = &NEM_MOSAIC_DEFINITIONS[i];
if (nem_mosaicMatches(definition, namespace, mosaic, network)) {
return definition;
@ -706,7 +706,7 @@ const NEMMosaicDefinition *nem_mosaicByName(const char *namespace, const char *m
return NULL;
}
static inline size_t format_amount(const NEMMosaicDefinition *definition, const bignum256 *amnt, const bignum256 *multiplier, int divisor, char *str_out, size_t size) {
static inline size_t format_amount(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, const bignum256 *amnt, const bignum256 *multiplier, int divisor, char *str_out, size_t size) {
bignum256 val;
memcpy(&val, amnt, sizeof(bignum256));
@ -725,7 +725,7 @@ static inline size_t format_amount(const NEMMosaicDefinition *definition, const
size);
}
size_t nem_canonicalizeMosaics(NEMMosaic *mosaics, size_t mosaics_count) {
size_t nem_canonicalizeMosaics(NEMSignTx_NEMTransfer_NEMMosaic *mosaics, size_t mosaics_count) {
if (mosaics_count <= 1) {
return mosaics_count;
}
@ -739,16 +739,16 @@ size_t nem_canonicalizeMosaics(NEMMosaic *mosaics, size_t mosaics_count) {
for (size_t i = 0; i < mosaics_count; i++) {
if (skip[i]) continue;
NEMMosaic *mosaic = &mosaics[actual_count];
NEMSignTx_NEMTransfer_NEMMosaic *mosaic = &mosaics[actual_count];
if (actual_count++ != i) {
memcpy(mosaic, &mosaics[i], sizeof(NEMMosaic));
memcpy(mosaic, &mosaics[i], sizeof(NEMSignTx_NEMTransfer_NEMMosaic));
}
for (size_t j = i + 1; j < mosaics_count; j++) {
if (skip[j]) continue;
const NEMMosaic *new_mosaic = &mosaics[j];
const NEMSignTx_NEMTransfer_NEMMosaic *new_mosaic = &mosaics[j];
if (nem_mosaicCompare(mosaic, new_mosaic) == 0) {
skip[j] = true;
@ -757,19 +757,19 @@ size_t nem_canonicalizeMosaics(NEMMosaic *mosaics, size_t mosaics_count) {
}
}
NEMMosaic temp;
NEMSignTx_NEMTransfer_NEMMosaic temp;
// Sort mosaics
for (size_t i = 0; i < actual_count - 1; i++) {
NEMMosaic *a = &mosaics[i];
NEMSignTx_NEMTransfer_NEMMosaic *a = &mosaics[i];
for (size_t j = i + 1; j < actual_count; j++) {
NEMMosaic *b = &mosaics[j];
NEMSignTx_NEMTransfer_NEMMosaic *b = &mosaics[j];
if (nem_mosaicCompare(a, b) > 0) {
memcpy(&temp, a, sizeof(NEMMosaic));
memcpy(a, b, sizeof(NEMMosaic));
memcpy(b, &temp, sizeof(NEMMosaic));
memcpy(&temp, a, sizeof(NEMSignTx_NEMTransfer_NEMMosaic));
memcpy(a, b, sizeof(NEMSignTx_NEMTransfer_NEMMosaic));
memcpy(b, &temp, sizeof(NEMSignTx_NEMTransfer_NEMMosaic));
}
}
}
@ -777,14 +777,14 @@ size_t nem_canonicalizeMosaics(NEMMosaic *mosaics, size_t mosaics_count) {
return actual_count;
}
void nem_mosaicFormatAmount(const NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, char *str_out, size_t size) {
void nem_mosaicFormatAmount(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, char *str_out, size_t size) {
bignum256 amnt;
bn_read_uint64(quantity, &amnt);
format_amount(definition, &amnt, multiplier, 0, str_out, size);
}
bool nem_mosaicFormatLevy(const NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, uint8_t network, char *str_out, size_t size) {
bool nem_mosaicFormatLevy(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, uint8_t network, char *str_out, size_t size) {
if (!definition->has_levy || !definition->has_fee) {
return false;
}
@ -793,13 +793,13 @@ bool nem_mosaicFormatLevy(const NEMMosaicDefinition *definition, uint64_t quanti
bn_read_uint64(quantity, &amnt);
bn_read_uint64(definition->fee, &fee);
const NEMMosaicDefinition *mosaic = nem_mosaicByName(definition->levy_namespace, definition->levy_mosaic, network);
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *mosaic = nem_mosaicByName(definition->levy_namespace, definition->levy_mosaic, network);
switch (definition->levy) {
case NEMMosaicLevy_MosaicLevy_Absolute:
case NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition_NEMMosaicLevy_MosaicLevy_Absolute:
return format_amount(mosaic, &fee, NULL, 0, str_out, size);
case NEMMosaicLevy_MosaicLevy_Percentile:
case NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition_NEMMosaicLevy_MosaicLevy_Percentile:
bn_multiply(&fee, &amnt, &secp256k1.prime);
return format_amount(mosaic, &amnt, multiplier, NEM_LEVY_PERCENTILE_DIVISOR, str_out, size);

@ -23,45 +23,44 @@
#include "nem.h"
#include "nem_mosaics.h"
#include "messages.pb.h"
#include "types.pb.h"
#include "messages-nem.pb.h"
#include <stdbool.h>
const char *nem_validate_common(NEMTransactionCommon *common, bool inner);
const char *nem_validate_transfer(const NEMTransfer *transfer, uint8_t network);
const char *nem_validate_provision_namespace(const NEMProvisionNamespace *provision_namespace, uint8_t network);
const char *nem_validate_mosaic_creation(const NEMMosaicCreation *mosaic_creation, uint8_t network);
const char *nem_validate_supply_change(const NEMMosaicSupplyChange *supply_change);
const char *nem_validate_aggregate_modification(const NEMAggregateModification *aggregate_modification, bool creation);
const char *nem_validate_importance_transfer(const NEMImportanceTransfer *importance_transfer);
const char *nem_validate_common(NEMSignTx_NEMTransactionCommon *common, bool inner);
const char *nem_validate_transfer(const NEMSignTx_NEMTransfer *transfer, uint8_t network);
const char *nem_validate_provision_namespace(const NEMSignTx_NEMProvisionNamespace *provision_namespace, uint8_t network);
const char *nem_validate_mosaic_creation(const NEMSignTx_NEMMosaicCreation *mosaic_creation, uint8_t network);
const char *nem_validate_supply_change(const NEMSignTx_NEMMosaicSupplyChange *supply_change);
const char *nem_validate_aggregate_modification(const NEMSignTx_NEMAggregateModification *aggregate_modification, bool creation);
const char *nem_validate_importance_transfer(const NEMSignTx_NEMImportanceTransfer *importance_transfer);
bool nem_askTransfer(const NEMTransactionCommon *common, const NEMTransfer *transfer, const char *desc);
bool nem_fsmTransfer(nem_transaction_ctx *context, const HDNode *node, const NEMTransactionCommon *common, const NEMTransfer *transfer);
bool nem_askTransfer(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMTransfer *transfer, const char *desc);
bool nem_fsmTransfer(nem_transaction_ctx *context, const HDNode *node, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMTransfer *transfer);
bool nem_askProvisionNamespace(const NEMTransactionCommon *common, const NEMProvisionNamespace *provision_namespace, const char *desc);
bool nem_fsmProvisionNamespace(nem_transaction_ctx *context, const NEMTransactionCommon *common, const NEMProvisionNamespace *provision_namespace);
bool nem_askProvisionNamespace(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMProvisionNamespace *provision_namespace, const char *desc);
bool nem_fsmProvisionNamespace(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMProvisionNamespace *provision_namespace);
bool nem_askMosaicCreation(const NEMTransactionCommon *common, const NEMMosaicCreation *mosaic_creation, const char *desc, const char *address);
bool nem_fsmMosaicCreation(nem_transaction_ctx *context, const NEMTransactionCommon *common, const NEMMosaicCreation *mosaic_creation);
bool nem_askMosaicCreation(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMMosaicCreation *mosaic_creation, const char *desc, const char *address);
bool nem_fsmMosaicCreation(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMMosaicCreation *mosaic_creation);
bool nem_askSupplyChange(const NEMTransactionCommon *common, const NEMMosaicSupplyChange *supply_change, const char *desc);
bool nem_fsmSupplyChange(nem_transaction_ctx *context, const NEMTransactionCommon *common, const NEMMosaicSupplyChange *supply_change);
bool nem_askSupplyChange(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMMosaicSupplyChange *supply_change, const char *desc);
bool nem_fsmSupplyChange(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMMosaicSupplyChange *supply_change);
bool nem_askAggregateModification(const NEMTransactionCommon *common, const NEMAggregateModification *aggregate_modification, const char *desc, bool creation);
bool nem_fsmAggregateModification(nem_transaction_ctx *context, const NEMTransactionCommon *common, const NEMAggregateModification *aggregate_modification);
bool nem_askAggregateModification(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMAggregateModification *aggregate_modification, const char *desc, bool creation);
bool nem_fsmAggregateModification(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMAggregateModification *aggregate_modification);
bool nem_askImportanceTransfer(const NEMTransactionCommon *common, const NEMImportanceTransfer *importance_transfer, const char *desc);
bool nem_fsmImportanceTransfer(nem_transaction_ctx *context, const NEMTransactionCommon *common, const NEMImportanceTransfer *importance_transfer);
bool nem_askImportanceTransfer(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMImportanceTransfer *importance_transfer, const char *desc);
bool nem_fsmImportanceTransfer(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMImportanceTransfer *importance_transfer);
bool nem_askMultisig(const char *address, const char *desc, bool cosigning, uint64_t fee);
bool nem_fsmMultisig(nem_transaction_ctx *context, const NEMTransactionCommon *common, const nem_transaction_ctx *inner, bool cosigning);
bool nem_fsmMultisig(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const nem_transaction_ctx *inner, bool cosigning);
const NEMMosaicDefinition *nem_mosaicByName(const char *namespace, const char *mosaic, uint8_t network);
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *nem_mosaicByName(const char *namespace, const char *mosaic, uint8_t network);
size_t nem_canonicalizeMosaics(NEMMosaic *mosaics, size_t mosaics_count);
void nem_mosaicFormatAmount(const NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, char *str_out, size_t size);
bool nem_mosaicFormatLevy(const NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, uint8_t network, char *str_out, size_t size);
size_t nem_canonicalizeMosaics(NEMSignTx_NEMTransfer_NEMMosaic *mosaics, size_t mosaics_count);
void nem_mosaicFormatAmount(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, char *str_out, size_t size);
bool nem_mosaicFormatLevy(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, uint8_t network, char *str_out, size_t size);
static inline void nem_mosaicFormatName(const char *namespace, const char *mosaic, char *str_out, size_t size) {
strlcpy(str_out, namespace, size);
@ -69,7 +68,7 @@ static inline void nem_mosaicFormatName(const char *namespace, const char *mosai
strlcat(str_out, mosaic, size);
}
static inline bool nem_mosaicMatches(const NEMMosaicDefinition *definition, const char *namespace, const char *mosaic, uint8_t network) {
static inline bool nem_mosaicMatches(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, const char *namespace, const char *mosaic, uint8_t network) {
if (strcmp(namespace, definition->namespace) == 0 && strcmp(mosaic, definition->mosaic) == 0) {
if (definition->networks_count == 0) {
return true;
@ -85,7 +84,7 @@ static inline bool nem_mosaicMatches(const NEMMosaicDefinition *definition, cons
return false;
}
static inline int nem_mosaicCompare(const NEMMosaic *a, const NEMMosaic *b) {
static inline int nem_mosaicCompare(const NEMSignTx_NEMTransfer_NEMMosaic *a, const NEMSignTx_NEMTransfer_NEMMosaic *b) {
size_t namespace_length = strlen(a->namespace);
// Ensure that strlen(a->namespace) <= strlen(b->namespace)

@ -20,12 +20,12 @@ HEADER_TEMPLATE = """
#ifndef __NEM_MOSAICS_H__
#define __NEM_MOSAICS_H__
#include "types.pb.h"
#include "messages-nem.pb.h"
#define NEM_MOSAIC_DEFINITIONS_COUNT ({count})
extern const NEMMosaicDefinition NEM_MOSAIC_DEFINITIONS[NEM_MOSAIC_DEFINITIONS_COUNT];
extern const NEMMosaicDefinition *NEM_MOSAIC_DEFINITION_XEM;
extern const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition NEM_MOSAIC_DEFINITIONS[NEM_MOSAIC_DEFINITIONS_COUNT];
extern const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *NEM_MOSAIC_DEFINITION_XEM;
#endif
""".lstrip() # noqa: E501
@ -35,9 +35,9 @@ CODE_TEMPLATE = """
#include "nem_mosaics.h"
const NEMMosaicDefinition NEM_MOSAIC_DEFINITIONS[NEM_MOSAIC_DEFINITIONS_COUNT] = {code};
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition NEM_MOSAIC_DEFINITIONS[NEM_MOSAIC_DEFINITIONS_COUNT] = {code};
const NEMMosaicDefinition *NEM_MOSAIC_DEFINITION_XEM = NEM_MOSAIC_DEFINITIONS;
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *NEM_MOSAIC_DEFINITION_XEM = NEM_MOSAIC_DEFINITIONS;
""".lstrip() # noqa: E501
@ -67,7 +67,7 @@ def format_field(field, value):
if field.message_type is not None:
raise TypeError
elif field.enum_type:
type_name = field.enum_type.name
type_name = field.enum_type.full_name.replace('.', '_')
enum_name = field.enum_type.values_by_number[value].name
return "{0}_{1}".format(type_name, enum_name)
elif hasattr(value, "_values"):
@ -107,7 +107,7 @@ if __name__ == "__main__":
os.chdir(os.path.abspath(os.path.dirname(__file__)))
sys.path.insert(0, "protob")
import types_pb2 as types
import messages_nem_pb2
messages = json.load(open("defs/nem/nem_mosaics.json"))
@ -118,5 +118,5 @@ if __name__ == "__main__":
with open("nem_mosaics.c", "w+") as f:
f.write(CODE_TEMPLATE.format(
code=format_messages(messages, types.NEMMosaicDefinition))
code=format_messages(messages, messages_nem_pb2.NEMSignTx.NEMMosaicCreation.NEMMosaicDefinition))
)

@ -31,13 +31,14 @@
#include "debug.h"
#include "gettext.h"
#include "memzero.h"
#include "messages.pb.h"
#define MAX_WRONG_PINS 15
bool protectAbortedByCancel = false;
bool protectAbortedByInitialize = false;
bool protectButton(ButtonRequestType type, bool confirm_only)
bool protectButton(ButtonRequest_ButtonRequestType type, bool confirm_only)
{
ButtonRequest resp;
bool result = false;
@ -110,7 +111,7 @@ bool protectButton(ButtonRequestType type, bool confirm_only)
return result;
}
const char *requestPin(PinMatrixRequestType type, const char *text)
const char *requestPin(PinMatrixRequest_PinMatrixRequestType type, const char *text)
{
PinMatrixRequest resp;
memset(&resp, 0, sizeof(PinMatrixRequest));
@ -186,20 +187,20 @@ bool protectPin(bool use_cached)
protectAbortedByInitialize = true;
msg_tiny_id = 0xFFFF;
usbTiny(0);
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
fsm_sendFailure(Failure_FailureType_Failure_PinCancelled, NULL);
return false;
}
wait--;
}
usbTiny(0);
const char *pin;
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_Current, _("Please enter current PIN:"));
pin = requestPin(PinMatrixRequest_PinMatrixRequestType_PinMatrixRequestType_Current, _("Please enter current PIN:"));
if (!pin) {
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
fsm_sendFailure(Failure_FailureType_Failure_PinCancelled, NULL);
return false;
}
if (!storage_increasePinFails(fails)) {
fsm_sendFailure(FailureType_Failure_PinInvalid, NULL);
fsm_sendFailure(Failure_FailureType_Failure_PinInvalid, NULL);
return false;
}
if (storage_containsPin(pin)) {
@ -208,7 +209,7 @@ bool protectPin(bool use_cached)
return true;
} else {
protectCheckMaxTry(storage_getPinWait(fails));
fsm_sendFailure(FailureType_Failure_PinInvalid, NULL);
fsm_sendFailure(Failure_FailureType_Failure_PinInvalid, NULL);
return false;
}
}
@ -217,7 +218,7 @@ bool protectChangePin(void)
{
static CONFIDENTIAL char pin_compare[17];
const char *pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_NewFirst, _("Please enter new PIN:"));
const char *pin = requestPin(PinMatrixRequest_PinMatrixRequestType_PinMatrixRequestType_NewFirst, _("Please enter new PIN:"));
if (!pin) {
return false;
@ -225,7 +226,7 @@ bool protectChangePin(void)
strlcpy(pin_compare, pin, sizeof(pin_compare));
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_NewSecond, _("Please re-enter new PIN:"));
pin = requestPin(PinMatrixRequest_PinMatrixRequestType_PinMatrixRequestType_NewSecond, _("Please re-enter new PIN:"));
const bool result = pin && (strncmp(pin_compare, pin, sizeof(pin_compare)) == 0);

@ -21,9 +21,9 @@
#define __PROTECT_H__
#include <stdbool.h>
#include "types.pb.h"
#include "messages-management.pb.h"
bool protectButton(ButtonRequestType type, bool confirm_only);
bool protectButton(ButtonRequest_ButtonRequestType type, bool confirm_only);
bool protectPin(bool use_cached);
bool protectChangePin(void);
bool protectPassphrase(void);

@ -2,7 +2,7 @@ ifneq ($(V),1)
Q := @
endif
all: messages.pb.c types.pb.c messages_map.h
all: messages_map.h common.pb.c messages-bitcoin.pb.c messages-crypto.pb.c messages-debug.pb.c messages-ethereum.pb.c messages-management.pb.c messages-nem.pb.c messages.pb.c messages-stellar.pb.c messages_nem_pb2.py
PYTHON ?= python
@ -14,12 +14,16 @@ PYTHON ?= python
@printf " PROTOC $@\n"
$(Q)protoc -I/usr/include -I. $< -o $@
messages_%_pb2.py: messages-%.proto
@printf " PROTOC $@\n"
$(Q)protoc -I/usr/include -I. $< --python_out=.
%_pb2.py: %.proto
@printf " PROTOC $@\n"
$(Q)protoc -I/usr/include -I. $< --python_out=.
messages_map.h: messages_map.py messages_pb2.py types_pb2.py
$(Q)$(PYTHON) $< | grep -v -e MessageType_Lisk > $@
messages_map.h: messages_map.py messages_pb2.py
$(Q)$(PYTHON) $< | grep -v -e MessageType_Cardano -e MessageType_Lisk -e MessageType_Tezos > $@
clean:
rm -f *.pb *.o *.d *.pb.c *.pb.h *_pb2.py messages_map.h

@ -0,0 +1,3 @@
HDNodeType.chain_code max_size:32
HDNodeType.private_key max_size:32
HDNodeType.public_key max_size:33

@ -0,0 +1 @@
../../vendor/trezor-common/protob/common.proto

@ -0,0 +1,49 @@
GetPublicKey.address_n max_count:8
GetPublicKey.ecdsa_curve_name max_size:32
GetPublicKey.coin_name max_size:21
PublicKey.xpub max_size:113
GetAddress.address_n max_count:8
GetAddress.coin_name max_size:21
Address.address max_size:130
SignTx.coin_name max_size:21
SignMessage.address_n max_count:8
SignMessage.message max_size:1024
SignMessage.coin_name max_size:21
VerifyMessage.address max_size:130
VerifyMessage.signature max_size:65
VerifyMessage.message max_size:1024
VerifyMessage.coin_name max_size:21
MessageSignature.address max_size:130
MessageSignature.signature max_size:65
TxAck.TransactionType.inputs max_count:1
TxAck.TransactionType.bin_outputs max_count:1
TxAck.TransactionType.outputs max_count:1
TxAck.TransactionType.extra_data max_size:1024
TxAck.TransactionType.TxInputType.address_n max_count:8
TxAck.TransactionType.TxInputType.prev_hash max_size:32
TxAck.TransactionType.TxInputType.script_sig max_size:1650
TxAck.TransactionType.TxOutputType.address max_size:130
TxAck.TransactionType.TxOutputType.address_n max_count:8
TxAck.TransactionType.TxOutputType.op_return_data max_size:80
TxAck.TransactionType.TxOutputBinType.script_pubkey max_size:520
TxRequest.TxRequestDetailsType.tx_hash max_size:32
TxRequest.TxRequestSerializedType.signature max_size:73
TxRequest.TxRequestSerializedType.serialized_tx max_size:2048
MultisigRedeemScriptType.pubkeys max_count:15
MultisigRedeemScriptType.signatures max_count:15 max_size:73
MultisigRedeemScriptType.HDNodePathType.address_n max_count:8

@ -0,0 +1 @@
../../vendor/trezor-common/protob/messages-bitcoin.proto

@ -0,0 +1,38 @@
CipherKeyValue.address_n max_count:8
CipherKeyValue.key max_size:256
CipherKeyValue.value max_size:1024
CipherKeyValue.iv max_size:16
CipheredKeyValue.value max_size:1024
CosiCommit.address_n max_count:8
CosiCommit.data max_size:32
CosiCommitment.commitment max_size:32
CosiCommitment.pubkey max_size:32
CosiSign.address_n max_count:8
CosiSign.data max_size:32
CosiSign.global_commitment max_size:32
CosiSign.global_pubkey max_size:32
CosiSignature.signature max_size:32
SignIdentity.challenge_hidden max_size:256
SignIdentity.challenge_visual max_size:256
SignIdentity.ecdsa_curve_name max_size:32
SignedIdentity.address max_size:130
SignedIdentity.public_key max_size:33
SignedIdentity.signature max_size:65
IdentityType.proto max_size:9
IdentityType.user max_size:64
IdentityType.host max_size:64
IdentityType.port max_size:6
IdentityType.path max_size:256
GetECDHSessionKey.peer_public_key max_size:65
GetECDHSessionKey.ecdsa_curve_name max_size:32
ECDHSessionKey.session_key max_size:65

@ -0,0 +1 @@
../../vendor/trezor-common/protob/messages-crypto.proto

@ -0,0 +1,15 @@
DebugLinkDecision.input max_size:33
DebugLinkState.layout max_size:1024
DebugLinkState.pin max_size:10
DebugLinkState.matrix max_size:10
DebugLinkState.mnemonic max_size:241
DebugLinkState.reset_word max_size:12
DebugLinkState.reset_entropy max_size:128
DebugLinkState.recovery_fake_word max_size:12
DebugLinkLog.bucket max_size:33
DebugLinkLog.text max_size:256
DebugLinkMemory.memory max_size:1024
DebugLinkMemoryWrite.memory max_size:1024

@ -0,0 +1 @@
../../vendor/trezor-common/protob/messages-debug.proto

@ -0,0 +1,26 @@
EthereumSignTx.address_n max_count:8
EthereumSignTx.nonce max_size:32
EthereumSignTx.gas_price max_size:32
EthereumSignTx.gas_limit max_size:32
EthereumSignTx.to max_size:20
EthereumSignTx.value max_size:32
EthereumSignTx.data_initial_chunk max_size:1024
EthereumTxRequest.signature_r max_size:32
EthereumTxRequest.signature_s max_size:32
EthereumTxAck.data_chunk max_size:1024
EthereumSignMessage.address_n max_count:8
EthereumSignMessage.message max_size:1024
EthereumVerifyMessage.address max_size:20
EthereumVerifyMessage.signature max_size:65
EthereumVerifyMessage.message max_size:1024
EthereumMessageSignature.address max_size:20
EthereumMessageSignature.signature max_size:65
EthereumGetAddress.address_n max_count:8
EthereumAddress.address max_size:20

@ -0,0 +1 @@
../../vendor/trezor-common/protob/messages-ethereum.proto

@ -0,0 +1,47 @@
Initialize.state max_size:64
Features.vendor max_size:33
Features.device_id max_size:25
Features.language max_size:17
Features.label max_size:33
Features.revision max_size:20
Features.bootloader_hash max_size:32
Features.model max_size:17
Features.fw_vendor max_size:256
Features.fw_vendor_keys max_size:32
ApplySettings.language max_size:17
ApplySettings.label max_size:33
ApplySettings.homescreen max_size:1024
Ping.message max_size:256
Success.message max_size:256
Failure.message max_size:256
ButtonRequest.data max_size:256
PinMatrixAck.pin max_size:10
PassphraseAck.passphrase max_size:51
PassphraseAck.state max_size:64
PassphraseStateRequest.state max_size:64
LoadDevice.mnemonic max_size:241
LoadDevice.pin max_size:10
LoadDevice.language max_size:17
LoadDevice.label max_size:33
ResetDevice.language max_size:17
ResetDevice.label max_size:33
Entropy.entropy max_size:1024
EntropyAck.entropy max_size:128
RecoveryDevice.language max_size:17
RecoveryDevice.label max_size:33
WordAck.word max_size:12

@ -0,0 +1 @@
../../vendor/trezor-common/protob/messages-management.proto

@ -0,0 +1,48 @@
NEMGetAddress.address_n max_count:8
NEMAddress.address max_size:41
NEMDecryptMessage.address_n max_count:8
NEMDecryptMessage.public_key max_size:32
NEMDecryptMessage.payload max_size:1072
NEMDecryptedMessage.payload max_size:1024
NEMSignTx.NEMTransactionCommon.address_n max_count:8
NEMSignTx.NEMTransactionCommon.signer max_size:32
NEMSignTx.NEMTransfer.recipient max_size:41
NEMSignTx.NEMTransfer.public_key max_size:32
NEMSignTx.NEMTransfer.payload max_size:1024
NEMSignTx.NEMTransfer.mosaics max_count:16
NEMSignTx.NEMTransfer.NEMMosaic.namespace max_size:145
NEMSignTx.NEMTransfer.NEMMosaic.mosaic max_size:33
NEMSignTx.NEMProvisionNamespace.namespace max_size:65
NEMSignTx.NEMProvisionNamespace.parent max_size:81
NEMSignTx.NEMProvisionNamespace.sink max_size:41
NEMSignTx.NEMMosaicCreation.sink max_size:41
NEMSignTx.NEMMosaicCreation.NEMMosaicDefinition.name max_size:32
NEMSignTx.NEMMosaicCreation.NEMMosaicDefinition.ticker max_size:16
NEMSignTx.NEMMosaicCreation.NEMMosaicDefinition.namespace max_size:145
NEMSignTx.NEMMosaicCreation.NEMMosaicDefinition.mosaic max_size:33
NEMSignTx.NEMMosaicCreation.NEMMosaicDefinition.levy_address max_size:41
NEMSignTx.NEMMosaicCreation.NEMMosaicDefinition.levy_namespace max_size:145
NEMSignTx.NEMMosaicCreation.NEMMosaicDefinition.levy_mosaic max_size:33
NEMSignTx.NEMMosaicCreation.NEMMosaicDefinition.description max_size:513
NEMSignTx.NEMMosaicCreation.NEMMosaicDefinition.networks max_count:8
NEMSignTx.NEMMosaicSupplyChange.namespace max_size:145
NEMSignTx.NEMMosaicSupplyChange.mosaic max_size:33
NEMSignTx.NEMAggregateModification.modifications max_count:16
NEMSignTx.NEMAggregateModification.NEMCosignatoryModification.public_key max_size:32
NEMSignTx.NEMImportanceTransfer.public_key max_size:32
NEMSignedTx.data max_size:2048
NEMSignedTx.signature max_size:64

@ -0,0 +1 @@
../../vendor/trezor-common/protob/messages-nem.proto

@ -0,0 +1,36 @@
StellarAssetType.code max_size:13
StellarAssetType.issuer max_size:57
StellarGetAddress.address_n max_count:10
StellarAddress.address max_size:57
StellarGetPublicKey.address_n max_count:10
StellarPublicKey.public_key max_size:32
StellarSignTx.address_n max_count:10
StellarSignTx.network_passphrase max_size:1024
StellarSignTx.memo_text max_size:29
StellarSignTx.memo_hash max_size:32
StellarPaymentOp.destination_account max_size:57
StellarCreateAccountOp.new_account max_size:57
StellarPathPaymentOp.destination_account max_size:57
StellarPathPaymentOp.paths max_count:5
StellarSetOptionsOp.inflation_destination_account max_size:57
StellarSetOptionsOp.home_domain max_size:33
StellarSetOptionsOp.signer_key max_size:32
StellarAllowTrustOp.trusted_account max_size:57
StellarAllowTrustOp.asset_code max_size:13
StellarAccountMergeOp.destination_account max_size:57
StellarManageDataOp.key max_size:65
StellarManageDataOp.value max_size:65
StellarSignedTx.public_key max_size:32
StellarSignedTx.signature max_size:64 # ed25519 signatures are 64 bytes, this does not include the hint

@ -0,0 +1 @@
../../vendor/trezor-common/protob/messages-stellar.proto

@ -1,269 +0,0 @@
Initialize.state max_size:64
Features.vendor max_size:33
Features.device_id max_size:25
Features.language max_size:17
Features.label max_size:33
Features.revision max_size:20
Features.bootloader_hash max_size:32
Features.model max_size:17
Features.fw_vendor max_size:256
Features.fw_vendor_keys max_size:32
ApplySettings.language max_size:17
ApplySettings.label max_size:33
ApplySettings.homescreen max_size:1024
Ping.message max_size:256
Success.message max_size:256
Failure.message max_size:256
ButtonRequest.data max_size:256
PinMatrixAck.pin max_size:10
PassphraseAck.passphrase max_size:51
PassphraseAck.state max_size:64
PassphraseStateRequest.state max_size:64
Entropy.entropy max_size:1024
GetPublicKey.address_n max_count:8
GetPublicKey.ecdsa_curve_name max_size:32
GetPublicKey.coin_name max_size:21
PublicKey.xpub max_size:113
GetAddress.address_n max_count:8
GetAddress.coin_name max_size:21
Address.address max_size:130
EthereumGetAddress.address_n max_count:8
EthereumAddress.address max_size:20
LoadDevice.mnemonic max_size:241
LoadDevice.pin max_size:10
LoadDevice.language max_size:17
LoadDevice.label max_size:33
ResetDevice.language max_size:17
ResetDevice.label max_size:33
EntropyAck.entropy max_size:128
RecoveryDevice.language max_size:17
RecoveryDevice.label max_size:33
WordAck.word max_size:12
SignMessage.address_n max_count:8
SignMessage.message max_size:1024
SignMessage.coin_name max_size:21
VerifyMessage.address max_size:130
VerifyMessage.signature max_size:65
VerifyMessage.message max_size:1024
VerifyMessage.coin_name max_size:21
MessageSignature.address max_size:130
MessageSignature.signature max_size:65
EthereumSignMessage.address_n max_count:8
EthereumSignMessage.message max_size:1024
EthereumVerifyMessage.address max_size:20
EthereumVerifyMessage.signature max_size:65
EthereumVerifyMessage.message max_size:1024
EthereumMessageSignature.address max_size:20
EthereumMessageSignature.signature max_size:65
# deprecated
EncryptMessage skip_message:true
# EncryptMessage.pubkey max_size:33
# EncryptMessage.message max_size:1024
# EncryptMessage.address_n max_count:8
# EncryptMessage.coin_name max_size:21
# deprecated
EncryptedMessage skip_message:true
# EncryptedMessage.nonce max_size:33
# EncryptedMessage.message max_size:1120
# EncryptedMessage.hmac max_size:8
# deprecated
DecryptMessage skip_message:true
# DecryptMessage.address_n max_count:8
# DecryptMessage.nonce max_size:33
# DecryptMessage.message max_size:1120 # 1 + 9 + 1024 + 21 + 65
# DecryptMessage.hmac max_size:8
# deprecated
DecryptedMessage skip_message:true
# DecryptedMessage.address max_size:130
# DecryptedMessage.message max_size:1024
CipherKeyValue.address_n max_count:8
CipherKeyValue.key max_size:256
CipherKeyValue.value max_size:1024
CipherKeyValue.iv max_size:16
CipheredKeyValue.value max_size:1024
# deprecated
EstimateTxSize skip_message:true
# EstimateTxSize.coin_name max_size:21
# deprecated
TxSize skip_message:true
SignTx.coin_name max_size:21
EthereumSignTx.address_n max_count:8
EthereumSignTx.nonce max_size:32
EthereumSignTx.gas_price max_size:32
EthereumSignTx.gas_limit max_size:32
EthereumSignTx.to max_size:20
EthereumSignTx.value max_size:32
EthereumSignTx.data_initial_chunk max_size:1024
EthereumTxRequest.signature_r max_size:32
EthereumTxRequest.signature_s max_size:32
EthereumTxAck.data_chunk max_size:1024
SignIdentity.challenge_hidden max_size:256
SignIdentity.challenge_visual max_size:256
SignIdentity.ecdsa_curve_name max_size:32
SignedIdentity.address max_size:130
SignedIdentity.public_key max_size:33
SignedIdentity.signature max_size:65
GetECDHSessionKey.peer_public_key max_size:65
GetECDHSessionKey.ecdsa_curve_name max_size:32
ECDHSessionKey.session_key max_size:65
NEMGetAddress.address_n max_count:8
NEMAddress.address max_size:41
NEMSignedTx.data max_size:2048
NEMSignedTx.signature max_size:64
NEMDecryptMessage.address_n max_count:8
NEMDecryptMessage.public_key max_size:32
NEMDecryptMessage.payload max_size:1072
NEMDecryptedMessage.payload max_size:1024
CosiCommit.address_n max_count:8
CosiCommit.data max_size:32
CosiCommitment.commitment max_size:32
CosiCommitment.pubkey max_size:32
CosiSign.address_n max_count:8
CosiSign.data max_size:32
CosiSign.global_commitment max_size:32
CosiSign.global_pubkey max_size:32
CosiSignature.signature max_size:32
# Stellar
StellarGetAddress.address_n max_count:10
StellarAddress.address max_size:57
StellarGetPublicKey.address_n max_count:10
StellarPublicKey.public_key max_size:32
StellarSignTx.address_n max_count:10
StellarSignTx.network_passphrase max_size:1024
StellarSignTx.source_account max_size:57
StellarSignTx.memo_text max_size:29
StellarSignTx.memo_hash max_size:32
StellarPaymentOp.source_account max_size:57
StellarPaymentOp.destination_account max_size:57
StellarCreateAccountOp.source_account max_size:57
StellarCreateAccountOp.new_account max_size:57
StellarPathPaymentOp.source_account max_size:57
StellarPathPaymentOp.destination_account max_size:57
StellarPathPaymentOp.paths max_count:5
StellarManageOfferOp.source_account max_size:57
StellarCreatePassiveOfferOp.source_account max_size:57
StellarSetOptionsOp.source_account max_size:57
StellarSetOptionsOp.inflation_destination_account max_size:57
StellarSetOptionsOp.home_domain max_size:33
StellarSetOptionsOp.signer_key max_size:32
StellarChangeTrustOp.source_account max_size:57
StellarAllowTrustOp.source_account max_size:57
StellarAllowTrustOp.trusted_account max_size:57
StellarAllowTrustOp.asset_code max_size:13
StellarAccountMergeOp.source_account max_size:57
StellarAccountMergeOp.destination_account max_size:57
StellarManageDataOp.source_account max_size:57
StellarManageDataOp.key max_size:65
StellarManageDataOp.value max_size:65
StellarBumpSequenceOp.source_account max_size:57
StellarSignedTx.public_key max_size:32
StellarSignedTx.signature max_size:64 # ed25519 signatures are 64 bytes, this does not include the hint
# deprecated
SimpleSignTx skip_message:true
# not used in firmware, just in bootloader
FirmwareErase skip_message:true
FirmwareRequest skip_message:true
FirmwareUpload skip_message:true
SelfTest skip_message:true
# Lisk will be supported later
LiskGetAddress skip_message:true
LiskSignTx skip_message:true
LiskGetPublicKey skip_message:true
LiskAddress skip_message:true
LiskSignedTx skip_message:true
LiskPublicKey skip_message:true
LiskSignMessage skip_message:true
LiskMessageSignature skip_message:true
LiskVerifyMessage skip_message:true
# used only in debug firmware
DebugLinkDecision.input max_size:33
DebugLinkState.layout max_size:1024
DebugLinkState.pin max_size:10
DebugLinkState.matrix max_size:10
DebugLinkState.mnemonic max_size:241
DebugLinkState.reset_word max_size:12
DebugLinkState.reset_entropy max_size:128
DebugLinkState.recovery_fake_word max_size:12
DebugLinkLog.bucket max_size:33
DebugLinkLog.text max_size:256
DebugLinkMemory.memory max_size:1024
DebugLinkMemoryWrite.memory max_size:1024

@ -1,10 +1,9 @@
#!/usr/bin/env python
from collections import defaultdict
from messages_pb2 import MessageType
from types_pb2 import wire_in, wire_out
from types_pb2 import wire_debug_in, wire_debug_out
from types_pb2 import wire_bootloader, wire_tiny
from messages_pb2 import wire_in, wire_out
from messages_pb2 import wire_debug_in, wire_debug_out
from messages_pb2 import wire_bootloader, wire_no_fsm
# len("MessageType_MessageType_") - len("_fields") == 17
TEMPLATE = "\t{{ {type} {dir} {msg_id:46} {fields:29} {process_func} }},"
@ -27,14 +26,14 @@ def handle_message(message, extension):
options = message.GetOptions()
bootloader = options.Extensions[wire_bootloader]
tiny = options.Extensions[wire_tiny] and direction == "i"
no_fsm = options.Extensions[wire_no_fsm]
if getattr(options, 'deprecated', None):
return '\t// Message %s is deprecated' % short_name
if bootloader:
return '\t// Message %s is used in bootloader mode only' % short_name
if tiny:
return '\t// Message %s is used in tiny mode' % short_name
if no_fsm:
return '\t// Message %s is not used in FSM' % short_name
if direction == "i":
process_func = "(void (*)(void *)) fsm_msg%s" % short_name

@ -1,81 +0,0 @@
HDNodeType.chain_code max_size:32
HDNodeType.private_key max_size:32
HDNodeType.public_key max_size:33
HDNodePathType.address_n max_count:8
TxInputType.address_n max_count:8
TxInputType.prev_hash max_size:32
TxInputType.script_sig max_size:1650
TxOutputType.address max_size:130
TxOutputType.address_n max_count:8
TxOutputType.op_return_data max_size:80
TxOutputBinType.script_pubkey max_size:520
TransactionType.inputs max_count:1
TransactionType.bin_outputs max_count:1
TransactionType.outputs max_count:1
TransactionType.extra_data max_size:1024
TxRequestDetailsType.tx_hash max_size:32
TxRequestSerializedType.signature max_size:73
TxRequestSerializedType.serialized_tx max_size:2048
MultisigRedeemScriptType.pubkeys max_count:15
MultisigRedeemScriptType.signatures max_count:15 max_size:73
IdentityType.proto max_size:9
IdentityType.user max_size:64
IdentityType.host max_size:64
IdentityType.port max_size:6
IdentityType.path max_size:256
NEMTransactionCommon.address_n max_count:8
NEMTransactionCommon.signer max_size:32
NEMTransfer.recipient max_size:41
NEMTransfer.public_key max_size:32
NEMTransfer.payload max_size:1024
NEMTransfer.mosaics max_count:16
NEMMosaic.namespace max_size:145
NEMMosaic.mosaic max_size:33
NEMProvisionNamespace.namespace max_size:65
NEMProvisionNamespace.parent max_size:81
NEMProvisionNamespace.sink max_size:41
NEMMosaicCreation.sink max_size:41
NEMMosaicDefinition.name max_size:32
NEMMosaicDefinition.ticker max_size:16
NEMMosaicDefinition.namespace max_size:145
NEMMosaicDefinition.mosaic max_size:33
NEMMosaicDefinition.levy_address max_size:41
NEMMosaicDefinition.levy_namespace max_size:145
NEMMosaicDefinition.levy_mosaic max_size:33
NEMMosaicDefinition.description max_size:513
NEMMosaicDefinition.networks max_count:8
NEMMosaicSupplyChange.namespace max_size:145
NEMMosaicSupplyChange.mosaic max_size:33
NEMAggregateModification.modifications max_count:16
NEMCosignatoryModification.public_key max_size:32
NEMImportanceTransfer.public_key max_size:32
StellarAssetType.code max_size:13
StellarAssetType.issuer max_size:57
# Lisk will be supported later
LiskTransactionCommon skip_message:true
LiskTransactionAsset skip_message:true
LiskSignatureType skip_message:true
LiskDelegateType skip_message:true
LiskMultisignatureType skip_message:true

@ -1 +0,0 @@
../../vendor/trezor-common/protob/types.proto

@ -24,16 +24,15 @@
#include "storage.h"
#include "layout2.h"
#include "protect.h"
#include "types.pb.h"
#include "messages.h"
#include "rng.h"
#include "bip39.h"
#include "oled.h"
#include "usb.h"
#include "gettext.h"
#include "types.pb.h"
#include "recovery-table.h"
#include "memzero.h"
#include "messages.pb.h"
/* number of words expected in the new seed */
static uint32_t word_count;
@ -144,9 +143,9 @@ static void recovery_request(void) {
WordRequest resp;
memset(&resp, 0, sizeof(WordRequest));
resp.has_type = true;
resp.type = awaiting_word == 1 ? WordRequestType_WordRequestType_Plain
: (word_index % 4 == 3) ? WordRequestType_WordRequestType_Matrix6
: WordRequestType_WordRequestType_Matrix9;
resp.type = awaiting_word == 1 ? WordRequest_WordRequestType_WordRequestType_Plain
: (word_index % 4 == 3) ? WordRequest_WordRequestType_WordRequestType_Matrix6
: WordRequest_WordRequestType_WordRequestType_Matrix9;
msg_write(MessageType_MessageType_WordRequest, &resp);
}
@ -182,15 +181,15 @@ static void recovery_done(void) {
_("The seed is valid"),
_("and MATCHES"),
_("the one in the device."), NULL, NULL, NULL);
protectButton(ButtonRequestType_ButtonRequest_Other, true);
protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, true);
fsm_sendSuccess(_("The seed is valid and matches the one in the device"));
} else {
layoutDialog(&bmp_icon_error, NULL, _("Confirm"), NULL,
_("The seed is valid"),
_("but does NOT MATCH"),
_("the one in the device."), NULL, NULL, NULL);
protectButton(ButtonRequestType_ButtonRequest_Other, true);
fsm_sendFailure(FailureType_Failure_DataError,
protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, true);
fsm_sendFailure(Failure_FailureType_Failure_DataError,
_("The seed is valid but does not match the one in the device"));
}
}
@ -202,9 +201,9 @@ static void recovery_done(void) {
} else {
layoutDialog(&bmp_icon_error, NULL, _("Confirm"), NULL,
_("The seed is"), _("INVALID!"), NULL, NULL, NULL, NULL);
protectButton(ButtonRequestType_ButtonRequest_Other, true);
protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, true);
}
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid seed, are words in correct order?"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Invalid seed, are words in correct order?"));
}
awaiting_word = 0;
layoutHome();
@ -459,7 +458,7 @@ void recovery_init(uint32_t _word_count, bool passphrase_protection, bool pin_pr
if (!dry_run) {
if (pin_protection && !protectChangePin()) {
fsm_sendFailure(FailureType_Failure_PinMismatch, NULL);
fsm_sendFailure(Failure_FailureType_Failure_PinMismatch, NULL);
layoutHome();
return;
}
@ -471,7 +470,7 @@ void recovery_init(uint32_t _word_count, bool passphrase_protection, bool pin_pr
storage_update();
}
if ((type & RecoveryDeviceType_RecoveryDeviceType_Matrix) != 0) {
if ((type & RecoveryDevice_RecoveryDeviceType_RecoveryDeviceType_Matrix) != 0) {
awaiting_word = 2;
word_index = 0;
word_pincode = 0;
@ -497,7 +496,7 @@ static void recovery_scrambledword(const char *word)
if (!dry_run) {
session_clear(true);
}
fsm_sendFailure(FailureType_Failure_ProcessError, _("Wrong word retyped"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Wrong word retyped"));
layoutHome();
return;
}
@ -516,7 +515,7 @@ static void recovery_scrambledword(const char *word)
if (!dry_run) {
session_clear(true);
}
fsm_sendFailure(FailureType_Failure_DataError, _("Word not found in a wordlist"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Word not found in a wordlist"));
layoutHome();
return;
}
@ -545,7 +544,7 @@ void recovery_word(const char *word)
recovery_scrambledword(word);
break;
default:
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Not in Recovery mode"));
fsm_sendFailure(Failure_FailureType_Failure_UnexpectedMessage, _("Not in Recovery mode"));
break;
}
}

@ -24,11 +24,11 @@
#include "messages.h"
#include "fsm.h"
#include "layout2.h"
#include "types.pb.h"
#include "protect.h"
#include "bip39.h"
#include "util.h"
#include "gettext.h"
#include "messages.pb.h"
static uint32_t strength;
static uint8_t int_entropy[32];
@ -52,15 +52,15 @@ void reset_init(bool display_random, uint32_t _strength, bool passphrase_protect
if (display_random) {
layoutDialogSwipe(&bmp_icon_info, _("Cancel"), _("Continue"), NULL, _("Internal entropy:"), ent_str[0], ent_str[1], ent_str[2], ent_str[3], NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ResetDevice, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ResetDevice, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
}
if (pin_protection && !protectChangePin()) {
fsm_sendFailure(FailureType_Failure_PinMismatch, NULL);
fsm_sendFailure(Failure_FailureType_Failure_PinMismatch, NULL);
layoutHome();
return;
}
@ -80,7 +80,7 @@ void reset_init(bool display_random, uint32_t _strength, bool passphrase_protect
void reset_entropy(const uint8_t *ext_entropy, uint32_t len)
{
if (!awaiting_entropy) {
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Not in Reset mode"));
fsm_sendFailure(Failure_FailureType_Failure_UnexpectedMessage, _("Not in Reset mode"));
return;
}
SHA256_CTX ctx;
@ -109,7 +109,7 @@ static char current_word[10];
void reset_backup(bool separated)
{
if (!storage_needsBackup()) {
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Seed already backed up"));
fsm_sendFailure(Failure_FailureType_Failure_UnexpectedMessage, _("Seed already backed up"));
return;
}
@ -136,13 +136,13 @@ void reset_backup(bool separated)
i++;
}
layoutResetWord(current_word, pass, word_pos, mnemonic[i] == 0);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmWord, true)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmWord, true)) {
if (!separated) {
storage_clear_update();
session_clear(true);
}
layoutHome();
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
return;
}
word_pos++;

@ -27,6 +27,7 @@
#include "crypto.h"
#include "secp256k1.h"
#include "gettext.h"
#include "messages.pb.h"
static uint32_t inputs_count;
static uint32_t outputs_count;
@ -51,8 +52,8 @@ enum {
static uint32_t idx1, idx2;
static uint32_t signatures;
static TxRequest resp;
static TxInputType input;
static TxOutputBinType bin_output;
static TxAck_TransactionType_TxInputType input;
static TxAck_TransactionType_TxOutputBinType bin_output;
static TxStruct to, tp, ti;
static Hasher hasher_prevouts, hasher_sequence, hasher_outputs, hasher_check, hasher_preimage;
static uint8_t CONFIDENTIAL privkey[32];
@ -210,7 +211,7 @@ void send_req_1_input(void)
{
signing_stage = STAGE_REQUEST_1_INPUT;
resp.has_request_type = true;
resp.request_type = RequestType_TXINPUT;
resp.request_type = TxRequest_RequestType_TXINPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx1;
@ -221,7 +222,7 @@ void send_req_2_prev_meta(void)
{
signing_stage = STAGE_REQUEST_2_PREV_META;
resp.has_request_type = true;
resp.request_type = RequestType_TXMETA;
resp.request_type = TxRequest_RequestType_TXMETA;
resp.has_details = true;
resp.details.has_tx_hash = true;
resp.details.tx_hash.size = input.prev_hash.size;
@ -233,7 +234,7 @@ void send_req_2_prev_input(void)
{
signing_stage = STAGE_REQUEST_2_PREV_INPUT;
resp.has_request_type = true;
resp.request_type = RequestType_TXINPUT;
resp.request_type = TxRequest_RequestType_TXINPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx2;
@ -247,7 +248,7 @@ void send_req_2_prev_output(void)
{
signing_stage = STAGE_REQUEST_2_PREV_OUTPUT;
resp.has_request_type = true;
resp.request_type = RequestType_TXOUTPUT;
resp.request_type = TxRequest_RequestType_TXOUTPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx2;
@ -261,7 +262,7 @@ void send_req_2_prev_extradata(uint32_t chunk_offset, uint32_t chunk_len)
{
signing_stage = STAGE_REQUEST_2_PREV_EXTRADATA;
resp.has_request_type = true;
resp.request_type = RequestType_TXEXTRADATA;
resp.request_type = TxRequest_RequestType_TXEXTRADATA;
resp.has_details = true;
resp.details.has_extra_data_offset = true;
resp.details.extra_data_offset = chunk_offset;
@ -277,7 +278,7 @@ void send_req_3_output(void)
{
signing_stage = STAGE_REQUEST_3_OUTPUT;
resp.has_request_type = true;
resp.request_type = RequestType_TXOUTPUT;
resp.request_type = TxRequest_RequestType_TXOUTPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx1;
@ -288,7 +289,7 @@ void send_req_4_input(void)
{
signing_stage = STAGE_REQUEST_4_INPUT;
resp.has_request_type = true;
resp.request_type = RequestType_TXINPUT;
resp.request_type = TxRequest_RequestType_TXINPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx2;
@ -299,7 +300,7 @@ void send_req_4_output(void)
{
signing_stage = STAGE_REQUEST_4_OUTPUT;
resp.has_request_type = true;
resp.request_type = RequestType_TXOUTPUT;
resp.request_type = TxRequest_RequestType_TXOUTPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx2;
@ -310,7 +311,7 @@ void send_req_segwit_input(void)
{
signing_stage = STAGE_REQUEST_SEGWIT_INPUT;
resp.has_request_type = true;
resp.request_type = RequestType_TXINPUT;
resp.request_type = TxRequest_RequestType_TXINPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx1;
@ -321,7 +322,7 @@ void send_req_segwit_witness(void)
{
signing_stage = STAGE_REQUEST_SEGWIT_WITNESS;
resp.has_request_type = true;
resp.request_type = RequestType_TXINPUT;
resp.request_type = TxRequest_RequestType_TXINPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx1;
@ -332,7 +333,7 @@ void send_req_decred_witness(void)
{
signing_stage = STAGE_REQUEST_DECRED_WITNESS;
resp.has_request_type = true;
resp.request_type = RequestType_TXINPUT;
resp.request_type = TxRequest_RequestType_TXINPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx1;
@ -343,7 +344,7 @@ void send_req_5_output(void)
{
signing_stage = STAGE_REQUEST_5_OUTPUT;
resp.has_request_type = true;
resp.request_type = RequestType_TXOUTPUT;
resp.request_type = TxRequest_RequestType_TXOUTPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx1;
@ -353,7 +354,7 @@ void send_req_5_output(void)
void send_req_finished(void)
{
resp.has_request_type = true;
resp.request_type = RequestType_TXFINISHED;
resp.request_type = TxRequest_RequestType_TXFINISHED;
msg_write(MessageType_MessageType_TxRequest, &resp);
}
@ -384,7 +385,7 @@ void phase2_request_next_input(void)
}
}
void extract_input_bip32_path(const TxInputType *tinput)
void extract_input_bip32_path(const TxAck_TransactionType_TxInputType *tinput)
{
if (in_address_n_count == BIP32_NOCHANGEALLOWED) {
return;
@ -417,7 +418,7 @@ void extract_input_bip32_path(const TxInputType *tinput)
}
}
bool check_change_bip32_path(const TxOutputType *toutput)
bool check_change_bip32_path(const TxAck_TransactionType_TxOutputType *toutput)
{
size_t count = toutput->address_n_count;
@ -434,7 +435,7 @@ bool check_change_bip32_path(const TxOutputType *toutput)
&& toutput->address_n[count - 1] <= BIP32_MAX_LAST_ELEMENT);
}
bool compile_input_script_sig(TxInputType *tinput)
bool compile_input_script_sig(TxAck_TransactionType_TxInputType *tinput)
{
if (!multisig_fp_mismatch) {
// check that this is still multisig
@ -496,7 +497,7 @@ void signing_init(const SignTx *msg, const CoinInfo *_coin, const HDNode *_root)
spending = 0;
change_spend = 0;
authorized_amount = 0;
memset(&input, 0, sizeof(TxInputType));
memset(&input, 0, sizeof(TxAck_TransactionType_TxInputType));
memset(&resp, 0, sizeof(TxRequest));
signing = true;
@ -543,13 +544,13 @@ void signing_init(const SignTx *msg, const CoinInfo *_coin, const HDNode *_root)
#define MIN(a,b) (((a)<(b))?(a):(b))
static bool signing_check_input(TxInputType *txinput) {
static bool signing_check_input(TxAck_TransactionType_TxInputType *txinput) {
/* compute multisig fingerprint */
/* (if all input share the same fingerprint, outputs having the same fingerprint will be considered as change outputs) */
if (txinput->has_multisig && !multisig_fp_mismatch) {
uint8_t h[32];
if (cryptoMultisigFingerprint(&txinput->multisig, h) == 0) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Error computing multisig fingerprint"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Error computing multisig fingerprint"));
signing_abort();
return false;
}
@ -572,7 +573,7 @@ static bool signing_check_input(TxInputType *txinput) {
tx_sequence_hash(&hasher_sequence, txinput);
if (coin->decred) {
if (txinput->decred_script_version > 0) {
fsm_sendFailure(FailureType_Failure_DataError, _("Decred v1+ scripts are not supported"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Decred v1+ scripts are not supported"));
signing_abort();
return false;
}
@ -596,7 +597,7 @@ static bool signing_check_prevtx_hash(void) {
uint8_t hash[32];
tx_hash_final(&tp, hash, true);
if (memcmp(hash, input.prev_hash.bytes, 32) != 0) {
fsm_sendFailure(FailureType_Failure_DataError, _("Encountered invalid prevhash"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Encountered invalid prevhash"));
signing_abort();
return false;
}
@ -604,7 +605,7 @@ static bool signing_check_prevtx_hash(void) {
return true;
}
static bool signing_check_output(TxOutputType *txoutput) {
static bool signing_check_output(TxAck_TransactionType_TxOutputType *txoutput) {
// Phase1: Check outputs
// add it to hash_outputs
// ask user for permission
@ -613,7 +614,7 @@ static bool signing_check_output(TxOutputType *txoutput) {
bool is_change = false;
if (txoutput->address_n_count > 0) {
if (txoutput->has_address) {
fsm_sendFailure(FailureType_Failure_DataError, _("Address in change output"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Address in change output"));
signing_abort();
return false;
}
@ -636,8 +637,8 @@ static bool signing_check_output(TxOutputType *txoutput) {
* to make sure the user is not tricked to use witness change output
* instead of regular one therefore creating ANYONECANSPEND output
*/
if ((txoutput->script_type == OutputScriptType_PAYTOWITNESS
|| txoutput->script_type == OutputScriptType_PAYTOP2SHWITNESS)
if ((txoutput->script_type == TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOWITNESS
|| txoutput->script_type == TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOP2SHWITNESS)
&& txoutput->amount > authorized_amount) {
is_change = false;
}
@ -653,7 +654,7 @@ static bool signing_check_output(TxOutputType *txoutput) {
}
if (spending + txoutput->amount < spending) {
fsm_sendFailure(FailureType_Failure_DataError, _("Value overflow"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Value overflow"));
signing_abort();
return false;
}
@ -663,11 +664,11 @@ static bool signing_check_output(TxOutputType *txoutput) {
layoutProgress(_("Signing transaction"), progress);
}
if (co < 0) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return false;
} else if (co == 0) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile output"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to compile output"));
signing_abort();
return false;
}
@ -688,23 +689,23 @@ static bool signing_check_output(TxOutputType *txoutput) {
static bool signing_check_fee(void) {
// check fees
if (spending > to_spend) {
fsm_sendFailure(FailureType_Failure_NotEnoughFunds, _("Not enough funds"));
fsm_sendFailure(Failure_FailureType_Failure_NotEnoughFunds, _("Not enough funds"));
signing_abort();
return false;
}
uint64_t fee = to_spend - spending;
if (fee > ((uint64_t) tx_weight * coin->maxfee_kb)/4000) {
layoutFeeOverThreshold(coin, fee);
if (!protectButton(ButtonRequestType_ButtonRequest_FeeOverThreshold, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_FeeOverThreshold, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return false;
}
}
// last confirmation
layoutConfirmTx(coin, to_spend - change_spend, fee);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return false;
}
@ -747,7 +748,7 @@ static void phase1_request_next_output(void) {
}
}
static void signing_hash_bip143(const TxInputType *txinput, uint8_t *hash) {
static void signing_hash_bip143(const TxAck_TransactionType_TxInputType *txinput, uint8_t *hash) {
uint32_t hash_type = signing_hash_type();
hasher_Reset(&hasher_preimage);
hasher_Update(&hasher_preimage, (const uint8_t *)&version, 4); // nVersion
@ -763,7 +764,7 @@ static void signing_hash_bip143(const TxInputType *txinput, uint8_t *hash) {
hasher_Final(&hasher_preimage, hash);
}
static void signing_hash_zip143(const TxInputType *txinput, uint8_t *hash) {
static void signing_hash_zip143(const TxAck_TransactionType_TxInputType *txinput, uint8_t *hash) {
uint32_t hash_type = signing_hash_type();
hasher_Reset(&hasher_preimage);
uint32_t ver = version | TX_OVERWINTERED; // 1. nVersion | fOverwintered
@ -795,13 +796,13 @@ static void signing_hash_decred(const uint8_t *hash_witness, uint8_t *hash) {
hasher_Final(&hasher_preimage, hash);
}
static bool signing_sign_hash(TxInputType *txinput, const uint8_t* private_key, const uint8_t *public_key, const uint8_t *hash) {
static bool signing_sign_hash(TxAck_TransactionType_TxInputType *txinput, const uint8_t* private_key, const uint8_t *public_key, const uint8_t *hash) {
resp.serialized.has_signature_index = true;
resp.serialized.signature_index = idx1;
resp.serialized.has_signature = true;
resp.serialized.has_serialized_tx = true;
if (ecdsa_sign_digest(coin->curve->params, private_key, hash, sig, NULL, NULL) != 0) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Signing failed"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Signing failed"));
signing_abort();
return false;
}
@ -812,7 +813,7 @@ static bool signing_sign_hash(TxInputType *txinput, const uint8_t* private_key,
// fill in the signature
int pubkey_idx = cryptoMultisigPubkeyIndex(coin, &(txinput->multisig), public_key);
if (pubkey_idx < 0) {
fsm_sendFailure(FailureType_Failure_DataError, _("Pubkey not found in multisig script"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Pubkey not found in multisig script"));
signing_abort();
return false;
}
@ -820,7 +821,7 @@ static bool signing_sign_hash(TxInputType *txinput, const uint8_t* private_key,
txinput->multisig.signatures[pubkey_idx].size = resp.serialized.signature.size;
txinput->script_sig.size = serialize_script_multisig(coin, &(txinput->multisig), sighash, txinput->script_sig.bytes);
if (txinput->script_sig.size == 0) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to serialize multisig script"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to serialize multisig script"));
signing_abort();
return false;
}
@ -834,7 +835,7 @@ static bool signing_sign_input(void) {
uint8_t hash[32];
hasher_Final(&hasher_check, hash);
if (memcmp(hash, hash_outputs, 32) != 0) {
fsm_sendFailure(FailureType_Failure_DataError, _("Transaction has changed during signing"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Transaction has changed during signing"));
signing_abort();
return false;
}
@ -849,19 +850,19 @@ static bool signing_sign_input(void) {
return true;
}
static bool signing_sign_segwit_input(TxInputType *txinput) {
static bool signing_sign_segwit_input(TxAck_TransactionType_TxInputType *txinput) {
// idx1: index to sign
uint8_t hash[32];
if (txinput->script_type == InputScriptType_SPENDWITNESS
|| txinput->script_type == InputScriptType_SPENDP2SHWITNESS) {
if (!compile_input_script_sig(txinput)) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile input"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to compile input"));
signing_abort();
return false;
}
if (txinput->amount > authorized_amount) {
fsm_sendFailure(FailureType_Failure_DataError, _("Transaction has changed during signing"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Transaction has changed during signing"));
signing_abort();
return false;
}
@ -917,7 +918,7 @@ static bool signing_sign_segwit_input(TxInputType *txinput) {
return true;
}
static bool signing_sign_decred_input(TxInputType *txinput) {
static bool signing_sign_decred_input(TxAck_TransactionType_TxInputType *txinput) {
uint8_t hash[32], hash_witness[32];
tx_hash_final(&ti, hash_witness, false);
signing_hash_decred(hash_witness, hash);
@ -930,10 +931,10 @@ static bool signing_sign_decred_input(TxInputType *txinput) {
#define ENABLE_SEGWIT_NONSEGWIT_MIXING 1
void signing_txack(TransactionType *tx)
void signing_txack(TxAck_TransactionType *tx)
{
if (!signing) {
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Not in Signing mode"));
fsm_sendFailure(Failure_FailureType_Failure_UnexpectedMessage, _("Not in Signing mode"));
layoutHome();
return;
}
@ -957,11 +958,11 @@ void signing_txack(TransactionType *tx)
if (tx->inputs[0].script_type == InputScriptType_SPENDMULTISIG
|| tx->inputs[0].script_type == InputScriptType_SPENDADDRESS) {
memcpy(&input, tx->inputs, sizeof(TxInputType));
memcpy(&input, tx->inputs, sizeof(TxAck_TransactionType_TxInputType));
#if !ENABLE_SEGWIT_NONSEGWIT_MIXING
// don't mix segwit and non-segwit inputs
if (idx1 > 0 && to.is_segwit == true) {
fsm_sendFailure(FailureType_Failure_DataError, _("Mixing segwit and non-segwit inputs is not allowed"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Mixing segwit and non-segwit inputs is not allowed"));
signing_abort();
return;
}
@ -969,12 +970,12 @@ void signing_txack(TransactionType *tx)
if (coin->force_bip143 || overwintered) {
if (!tx->inputs[0].has_amount) {
fsm_sendFailure(FailureType_Failure_DataError, _("BIP/ZIP 143 input without amount"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("BIP/ZIP 143 input without amount"));
signing_abort();
return;
}
if (to_spend + tx->inputs[0].amount < to_spend) {
fsm_sendFailure(FailureType_Failure_DataError, _("Value overflow"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Value overflow"));
signing_abort();
return;
}
@ -991,22 +992,22 @@ void signing_txack(TransactionType *tx)
} else if (tx->inputs[0].script_type == InputScriptType_SPENDWITNESS
|| tx->inputs[0].script_type == InputScriptType_SPENDP2SHWITNESS) {
if (coin->decred) {
fsm_sendFailure(FailureType_Failure_DataError, _("Decred does not support Segwit"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Decred does not support Segwit"));
signing_abort();
return;
}
if (!coin->has_segwit) {
fsm_sendFailure(FailureType_Failure_DataError, _("Segwit not enabled on this coin"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Segwit not enabled on this coin"));
signing_abort();
return;
}
if (!tx->inputs[0].has_amount) {
fsm_sendFailure(FailureType_Failure_DataError, _("Segwit input without amount"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Segwit input without amount"));
signing_abort();
return;
}
if (to_spend + tx->inputs[0].amount < to_spend) {
fsm_sendFailure(FailureType_Failure_DataError, _("Value overflow"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Value overflow"));
signing_abort();
return;
}
@ -1018,7 +1019,7 @@ void signing_txack(TransactionType *tx)
if (idx1 == 0) {
to.is_segwit = true;
} else if (to.is_segwit == false) {
fsm_sendFailure(FailureType_Failure_DataError, _("Mixing segwit and non-segwit inputs is not allowed"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Mixing segwit and non-segwit inputs is not allowed"));
signing_abort();
return;
}
@ -1029,19 +1030,19 @@ void signing_txack(TransactionType *tx)
authorized_amount += tx->inputs[0].amount;
phase1_request_next_input();
} else {
fsm_sendFailure(FailureType_Failure_DataError, _("Wrong input script type"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Wrong input script type"));
signing_abort();
return;
}
return;
case STAGE_REQUEST_2_PREV_META:
if (tx->outputs_cnt <= input.prev_index) {
fsm_sendFailure(FailureType_Failure_DataError, _("Not enough outputs in previous transaction."));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Not enough outputs in previous transaction."));
signing_abort();
return;
}
if (tx->inputs_cnt + tx->outputs_cnt < tx->inputs_cnt) {
fsm_sendFailure(FailureType_Failure_DataError, _("Value overflow"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Value overflow"));
signing_abort();
return;
}
@ -1062,7 +1063,7 @@ void signing_txack(TransactionType *tx)
case STAGE_REQUEST_2_PREV_INPUT:
progress = (idx1 * progress_step + idx2 * progress_meta_step) >> PROGRESS_PRECISION;
if (!tx_serialize_input_hash(&tp, tx->inputs)) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to serialize input"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to serialize input"));
signing_abort();
return;
}
@ -1077,18 +1078,18 @@ void signing_txack(TransactionType *tx)
case STAGE_REQUEST_2_PREV_OUTPUT:
progress = (idx1 * progress_step + (tp.inputs_len + idx2) * progress_meta_step) >> PROGRESS_PRECISION;
if (!tx_serialize_output_hash(&tp, tx->bin_outputs)) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to serialize output"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to serialize output"));
signing_abort();
return;
}
if (idx2 == input.prev_index) {
if (to_spend + tx->bin_outputs[0].amount < to_spend) {
fsm_sendFailure(FailureType_Failure_DataError, _("Value overflow"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Value overflow"));
signing_abort();
return;
}
if (coin->decred && tx->bin_outputs[0].decred_script_version > 0) {
fsm_sendFailure(FailureType_Failure_DataError, _("Decred script version does not match previous output"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Decred script version does not match previous output"));
signing_abort();
return;
}
@ -1108,7 +1109,7 @@ void signing_txack(TransactionType *tx)
return;
case STAGE_REQUEST_2_PREV_EXTRADATA:
if (!tx_serialize_extra_data_hash(&tp, tx->extra_data.bytes, tx->extra_data.size)) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to serialize extra data"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to serialize extra data"));
signing_abort();
return;
}
@ -1136,7 +1137,7 @@ void signing_txack(TransactionType *tx)
hasher_Update(&hasher_check, (const uint8_t *) &tx->inputs[0].script_type, sizeof(&tx->inputs[0].script_type));
if (idx2 == idx1) {
if (!compile_input_script_sig(&tx->inputs[0])) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile input"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to compile input"));
signing_abort();
return;
}
@ -1152,7 +1153,7 @@ void signing_txack(TransactionType *tx)
tx->inputs[0].script_sig.size = 0;
}
if (!tx_serialize_input_hash(&ti, tx->inputs)) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to serialize input"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to serialize input"));
signing_abort();
return;
}
@ -1163,7 +1164,7 @@ void signing_txack(TransactionType *tx)
uint8_t hash[32];
hasher_Final(&hasher_check, hash);
if (memcmp(hash, hash_check, 32) != 0) {
fsm_sendFailure(FailureType_Failure_DataError, _("Transaction has changed during signing"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Transaction has changed during signing"));
signing_abort();
return;
}
@ -1175,14 +1176,14 @@ void signing_txack(TransactionType *tx)
case STAGE_REQUEST_4_OUTPUT:
progress = 500 + ((signatures * progress_step + (inputs_count + idx2) * progress_meta_step) >> PROGRESS_PRECISION);
if (compile_output(coin, root, tx->outputs, &bin_output, false) <= 0) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile output"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to compile output"));
signing_abort();
return;
}
// check hashOutputs
tx_output_hash(&hasher_check, &bin_output, coin->decred);
if (!tx_serialize_output_hash(&ti, &bin_output)) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to serialize output"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to serialize output"));
signing_abort();
return;
}
@ -1216,17 +1217,17 @@ void signing_txack(TransactionType *tx)
if (tx->inputs[0].script_type == InputScriptType_SPENDMULTISIG
|| tx->inputs[0].script_type == InputScriptType_SPENDADDRESS) {
if (!(coin->force_bip143 || overwintered)) {
fsm_sendFailure(FailureType_Failure_DataError, _("Transaction has changed during signing"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Transaction has changed during signing"));
signing_abort();
return;
}
if (!compile_input_script_sig(&tx->inputs[0])) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile input"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to compile input"));
signing_abort();
return;
}
if (tx->inputs[0].amount > authorized_amount) {
fsm_sendFailure(FailureType_Failure_DataError, _("Transaction has changed during signing"));
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Transaction has changed during signing"));
signing_abort();
return;
}
@ -1248,7 +1249,7 @@ void signing_txack(TransactionType *tx)
} else if (tx->inputs[0].script_type == InputScriptType_SPENDP2SHWITNESS
&& !tx->inputs[0].has_multisig) {
if (!compile_input_script_sig(&tx->inputs[0])) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile input"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to compile input"));
signing_abort();
return;
}
@ -1267,7 +1268,7 @@ void signing_txack(TransactionType *tx)
tx->inputs[0].script_sig.bytes[2] = 0x20; // push 32 bytes (digest)
// compute digest of multisig script
if (!compile_script_multisig_hash(coin, &tx->inputs[0].multisig, tx->inputs[0].script_sig.bytes + 3)) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile input"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to compile input"));
signing_abort();
return;
}
@ -1287,7 +1288,7 @@ void signing_txack(TransactionType *tx)
case STAGE_REQUEST_5_OUTPUT:
if (compile_output(coin, root, tx->outputs, &bin_output,false) <= 0) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile output"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to compile output"));
signing_abort();
return;
}
@ -1336,7 +1337,7 @@ void signing_txack(TransactionType *tx)
ti.version |= (DECRED_SERIALIZE_WITNESS_SIGNING << 16);
ti.is_decred = true;
if (!compile_input_script_sig(&tx->inputs[0])) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile input"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to compile input"));
signing_abort();
return;
}
@ -1350,7 +1351,7 @@ void signing_txack(TransactionType *tx)
}
if (!r) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to serialize input"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to serialize input"));
signing_abort();
return;
}
@ -1374,7 +1375,7 @@ void signing_txack(TransactionType *tx)
return;
}
fsm_sendFailure(FailureType_Failure_ProcessError, _("Signing error"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Signing error"));
signing_abort();
}

@ -25,11 +25,10 @@
#include "bip32.h"
#include "coins.h"
#include "hasher.h"
#include "messages.pb.h"
#include "types.pb.h"
#include "messages-bitcoin.pb.h"
void signing_init(const SignTx *msg, const CoinInfo *_coin, const HDNode *_root);
void signing_abort(void);
void signing_txack(TransactionType *tx);
void signing_txack(TxAck_TransactionType *tx);
#endif

@ -222,7 +222,7 @@ bool stellar_confirmCreateAccountOp(StellarCreateAccountOp *msg)
str_addr_rows[2],
str_amount_line
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -280,7 +280,7 @@ bool stellar_confirmPaymentOp(StellarPaymentOp *msg)
str_addr_rows[1],
str_addr_rows[2]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -349,7 +349,7 @@ bool stellar_confirmPathPaymentOp(StellarPathPaymentOp *msg)
str_dest_rows[1],
str_dest_rows[2]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -369,7 +369,7 @@ bool stellar_confirmPathPaymentOp(StellarPathPaymentOp *msg)
_("This is the amount debited"),
_("from your account.")
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -464,7 +464,7 @@ bool stellar_confirmManageOfferOp(StellarManageOfferOp *msg)
str_buying,
str_buying_asset
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -544,7 +544,7 @@ bool stellar_confirmCreatePassiveOfferOp(StellarCreatePassiveOfferOp *msg)
str_buying,
str_buying_asset
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -603,7 +603,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
str_addr_rows[1],
str_addr_rows[2]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -635,7 +635,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
rows[2],
rows[3]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -669,7 +669,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
rows[2],
rows[3]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -742,7 +742,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
rows[2],
rows[3]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -772,7 +772,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
NULL,
NULL
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -814,7 +814,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
str_addr_rows[1],
str_addr_rows[2]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -831,7 +831,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
_("(confirm hash on next"),
_("screen)")
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -848,7 +848,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
_("(confirm hash on next"),
_("screen)")
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -868,7 +868,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
rows[2],
rows[3]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -928,7 +928,7 @@ bool stellar_confirmChangeTrustOp(StellarChangeTrustOp *msg)
uint8_t asset_issuer_bytes[STELLAR_KEY_SIZE];
if (!stellar_getAddressBytes(msg->asset.issuer, asset_issuer_bytes)) {
stellar_signingAbort(_("User canceled"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Invalid asset issuer"));
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Invalid asset issuer"));
return false;
}
@ -942,7 +942,7 @@ bool stellar_confirmChangeTrustOp(StellarChangeTrustOp *msg)
str_addr_rows[1],
str_addr_rows[2]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -1003,7 +1003,7 @@ bool stellar_confirmAllowTrustOp(StellarAllowTrustOp *msg)
str_trustor_rows[1],
str_trustor_rows[2]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -1061,7 +1061,7 @@ bool stellar_confirmAccountMergeOp(StellarAccountMergeOp *msg)
str_destination_rows[1],
str_destination_rows[2]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -1104,7 +1104,7 @@ bool stellar_confirmManageDataOp(StellarManageDataOp *msg)
str_key_lines[2],
str_key_lines[3]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -1124,7 +1124,7 @@ bool stellar_confirmManageDataOp(StellarManageDataOp *msg)
str_hash_lines[2],
str_hash_lines[3]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -1170,7 +1170,7 @@ bool stellar_confirmBumpSequenceOp(StellarBumpSequenceOp *msg)
NULL,
NULL
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -1190,7 +1190,7 @@ void stellar_signingAbort(const char *reason)
}
stellar_signing = false;
fsm_sendFailure(FailureType_Failure_ProcessError, reason);
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, reason);
layoutHome();
}
@ -1680,7 +1680,7 @@ void stellar_layoutTransactionSummary(StellarSignTx *msg)
str_addr_rows[1],
str_addr_rows[2]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return;
}
@ -1734,7 +1734,7 @@ void stellar_layoutTransactionSummary(StellarSignTx *msg)
str_lines[3],
str_lines[4]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return;
}
@ -1782,7 +1782,7 @@ void stellar_layoutTransactionSummary(StellarSignTx *msg)
str_lines[2],
str_lines[3]
);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return;
}

@ -20,9 +20,8 @@
#ifndef __STORAGE_H__
#define __STORAGE_H__
#include "types.pb.h"
#include "messages.pb.h"
#include "bip32.h"
#include "messages-management.pb.h"
#define STORAGE_FIELD(TYPE, NAME) \
bool has_##NAME; \

@ -30,7 +30,6 @@
#include "base58.h"
#include "address.h"
#include "messages.pb.h"
#include "types.pb.h"
#include "segwit_addr.h"
#include "cash_addr.h"
@ -187,22 +186,22 @@ bool compute_address(const CoinInfo *coin,
return 1;
}
int compile_output(const CoinInfo *coin, const HDNode *root, TxOutputType *in, TxOutputBinType *out, bool needs_confirm)
int compile_output(const CoinInfo *coin, const HDNode *root, TxAck_TransactionType_TxOutputType *in, TxAck_TransactionType_TxOutputBinType *out, bool needs_confirm)
{
memset(out, 0, sizeof(TxOutputBinType));
memset(out, 0, sizeof(TxAck_TransactionType_TxOutputBinType));
out->amount = in->amount;
out->decred_script_version = in->decred_script_version;
uint8_t addr_raw[MAX_ADDR_RAW_SIZE];
size_t addr_raw_len;
if (in->script_type == OutputScriptType_PAYTOOPRETURN) {
if (in->script_type == TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOOPRETURN) {
// only 0 satoshi allowed for OP_RETURN
if (in->amount != 0) {
return 0; // failed to compile output
}
if (needs_confirm) {
layoutConfirmOpReturn(in->op_return_data.bytes, in->op_return_data.size);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return -1; // user aborted
}
}
@ -219,16 +218,16 @@ int compile_output(const CoinInfo *coin, const HDNode *root, TxOutputType *in, T
InputScriptType input_script_type;
switch (in->script_type) {
case OutputScriptType_PAYTOADDRESS:
case TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOADDRESS:
input_script_type = InputScriptType_SPENDADDRESS;
break;
case OutputScriptType_PAYTOMULTISIG:
case TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOMULTISIG:
input_script_type = InputScriptType_SPENDMULTISIG;
break;
case OutputScriptType_PAYTOWITNESS:
case TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOWITNESS:
input_script_type = InputScriptType_SPENDWITNESS;
break;
case OutputScriptType_PAYTOP2SHWITNESS:
case TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOP2SHWITNESS:
input_script_type = InputScriptType_SPENDP2SHWITNESS;
break;
default:
@ -308,7 +307,7 @@ int compile_output(const CoinInfo *coin, const HDNode *root, TxOutputType *in, T
if (needs_confirm) {
layoutConfirmOutput(coin, in);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return -1; // user aborted
}
}
@ -421,7 +420,7 @@ uint32_t serialize_script_multisig(const CoinInfo *coin, const MultisigRedeemScr
// tx methods
uint32_t tx_prevout_hash(Hasher *hasher, const TxInputType *input)
uint32_t tx_prevout_hash(Hasher *hasher, const TxAck_TransactionType_TxInputType *input)
{
for (int i = 0; i < 32; i++) {
hasher_Update(hasher, &(input->prev_hash.bytes[31 - i]), 1);
@ -437,13 +436,13 @@ uint32_t tx_script_hash(Hasher *hasher, uint32_t size, const uint8_t *data)
return r + size;
}
uint32_t tx_sequence_hash(Hasher *hasher, const TxInputType *input)
uint32_t tx_sequence_hash(Hasher *hasher, const TxAck_TransactionType_TxInputType *input)
{
hasher_Update(hasher, (const uint8_t *)&input->sequence, 4);
return 4;
}
uint32_t tx_output_hash(Hasher *hasher, const TxOutputBinType *output, bool decred)
uint32_t tx_output_hash(Hasher *hasher, const TxAck_TransactionType_TxOutputBinType *output, bool decred)
{
uint32_t r = 0;
hasher_Update(hasher, (const uint8_t *)&output->amount, 8); r += 8;
@ -500,7 +499,7 @@ uint32_t tx_serialize_header_hash(TxStruct *tx)
return r + ser_length_hash(&(tx->hasher), tx->inputs_len);
}
uint32_t tx_serialize_input(TxStruct *tx, const TxInputType *input, uint8_t *out)
uint32_t tx_serialize_input(TxStruct *tx, const TxAck_TransactionType_TxInputType *input, uint8_t *out)
{
if (tx->have_inputs >= tx->inputs_len) {
// already got all inputs
@ -529,7 +528,7 @@ uint32_t tx_serialize_input(TxStruct *tx, const TxInputType *input, uint8_t *out
return r;
}
uint32_t tx_serialize_input_hash(TxStruct *tx, const TxInputType *input)
uint32_t tx_serialize_input_hash(TxStruct *tx, const TxAck_TransactionType_TxInputType *input)
{
if (tx->have_inputs >= tx->inputs_len) {
// already got all inputs
@ -554,7 +553,7 @@ uint32_t tx_serialize_input_hash(TxStruct *tx, const TxInputType *input)
return r;
}
uint32_t tx_serialize_decred_witness(TxStruct *tx, const TxInputType *input, uint8_t *out)
uint32_t tx_serialize_decred_witness(TxStruct *tx, const TxAck_TransactionType_TxInputType *input, uint8_t *out)
{
static const uint64_t amount = 0;
static const uint32_t block_height = 0x00000000;
@ -579,7 +578,7 @@ uint32_t tx_serialize_decred_witness(TxStruct *tx, const TxInputType *input, uin
return r;
}
uint32_t tx_serialize_decred_witness_hash(TxStruct *tx, const TxInputType *input)
uint32_t tx_serialize_decred_witness_hash(TxStruct *tx, const TxAck_TransactionType_TxInputType *input)
{
if (tx->have_inputs >= tx->inputs_len) {
// already got all inputs
@ -641,7 +640,7 @@ uint32_t tx_serialize_footer_hash(TxStruct *tx)
return 4;
}
uint32_t tx_serialize_output(TxStruct *tx, const TxOutputBinType *output, uint8_t *out)
uint32_t tx_serialize_output(TxStruct *tx, const TxAck_TransactionType_TxOutputBinType *output, uint8_t *out)
{
if (tx->have_inputs < tx->inputs_len) {
// not all inputs provided
@ -670,7 +669,7 @@ uint32_t tx_serialize_output(TxStruct *tx, const TxOutputBinType *output, uint8_
return r;
}
uint32_t tx_serialize_output_hash(TxStruct *tx, const TxOutputBinType *output)
uint32_t tx_serialize_output_hash(TxStruct *tx, const TxAck_TransactionType_TxOutputBinType *output)
{
if (tx->have_inputs < tx->inputs_len) {
// not all inputs provided
@ -743,7 +742,7 @@ void tx_hash_final(TxStruct *t, uint8_t *hash, bool reverse)
}
}
static uint32_t tx_input_script_size(const TxInputType *txinput) {
static uint32_t tx_input_script_size(const TxAck_TransactionType_TxInputType *txinput) {
uint32_t input_script_size;
if (txinput->has_multisig) {
uint32_t multisig_script_size = TXSIZE_MULTISIGSCRIPT
@ -758,7 +757,7 @@ static uint32_t tx_input_script_size(const TxInputType *txinput) {
return input_script_size;
}
uint32_t tx_input_weight(const CoinInfo *coin, const TxInputType *txinput) {
uint32_t tx_input_weight(const CoinInfo *coin, const TxAck_TransactionType_TxInputType *txinput) {
if (coin->decred) {
return 4 * (TXSIZE_INPUT + 1); // Decred tree
}
@ -782,16 +781,16 @@ uint32_t tx_input_weight(const CoinInfo *coin, const TxInputType *txinput) {
return weight;
}
uint32_t tx_output_weight(const CoinInfo *coin, const TxOutputType *txoutput) {
uint32_t tx_output_weight(const CoinInfo *coin, const TxAck_TransactionType_TxOutputType *txoutput) {
uint32_t output_script_size = 0;
if (txoutput->script_type == OutputScriptType_PAYTOOPRETURN) {
if (txoutput->script_type == TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOOPRETURN) {
output_script_size = 1 + op_push_size(txoutput->op_return_data.size)
+ txoutput->op_return_data.size;
} else if (txoutput->address_n_count > 0) {
if (txoutput->script_type == OutputScriptType_PAYTOWITNESS) {
if (txoutput->script_type == TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOWITNESS) {
output_script_size = txoutput->has_multisig
? TXSIZE_WITNESSSCRIPT : TXSIZE_WITNESSPKHASH;
} else if (txoutput->script_type == OutputScriptType_PAYTOP2SHWITNESS) {
} else if (txoutput->script_type == TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOP2SHWITNESS) {
output_script_size = TXSIZE_P2SCRIPT;
} else {
output_script_size = txoutput->has_multisig
@ -834,7 +833,7 @@ uint32_t tx_output_weight(const CoinInfo *coin, const TxOutputType *txoutput) {
return 4 * (size + output_script_size);
}
uint32_t tx_decred_witness_weight(const TxInputType *txinput) {
uint32_t tx_decred_witness_weight(const TxAck_TransactionType_TxInputType *txinput) {
uint32_t input_script_size = tx_input_script_size(txinput);
uint32_t size = TXSIZE_DECRED_WITNESS + ser_length_size(input_script_size) + input_script_size;

@ -26,7 +26,7 @@
#include "bip32.h"
#include "coins.h"
#include "hasher.h"
#include "types.pb.h"
#include "messages-bitcoin.pb.h"
#define TX_OVERWINTERED 0x80000000
@ -58,29 +58,29 @@ uint32_t compile_script_multisig(const CoinInfo *coin, const MultisigRedeemScrip
uint32_t compile_script_multisig_hash(const CoinInfo *coin, const MultisigRedeemScriptType *multisig, uint8_t *hash);
uint32_t serialize_script_sig(const uint8_t *signature, uint32_t signature_len, const uint8_t *pubkey, uint32_t pubkey_len, uint8_t sighash, uint8_t *out);
uint32_t serialize_script_multisig(const CoinInfo *coin, const MultisigRedeemScriptType *multisig, uint8_t sighash, uint8_t *out);
int compile_output(const CoinInfo *coin, const HDNode *root, TxOutputType *in, TxOutputBinType *out, bool needs_confirm);
int compile_output(const CoinInfo *coin, const HDNode *root, TxAck_TransactionType_TxOutputType *in, TxAck_TransactionType_TxOutputBinType *out, bool needs_confirm);
uint32_t tx_prevout_hash(Hasher *hasher, const TxInputType *input);
uint32_t tx_prevout_hash(Hasher *hasher, const TxAck_TransactionType_TxInputType *input);
uint32_t tx_script_hash(Hasher *hasher, uint32_t size, const uint8_t *data);
uint32_t tx_sequence_hash(Hasher *hasher, const TxInputType *input);
uint32_t tx_output_hash(Hasher *hasher, const TxOutputBinType *output, bool decred);
uint32_t tx_sequence_hash(Hasher *hasher, const TxAck_TransactionType_TxInputType *input);
uint32_t tx_output_hash(Hasher *hasher, const TxAck_TransactionType_TxOutputBinType *output, bool decred);
uint32_t tx_serialize_script(uint32_t size, const uint8_t *data, uint8_t *out);
uint32_t tx_serialize_footer(TxStruct *tx, uint8_t *out);
uint32_t tx_serialize_input(TxStruct *tx, const TxInputType *input, uint8_t *out);
uint32_t tx_serialize_output(TxStruct *tx, const TxOutputBinType *output, uint8_t *out);
uint32_t tx_serialize_decred_witness(TxStruct *tx, const TxInputType *input, uint8_t *out);
uint32_t tx_serialize_input(TxStruct *tx, const TxAck_TransactionType_TxInputType *input, uint8_t *out);
uint32_t tx_serialize_output(TxStruct *tx, const TxAck_TransactionType_TxOutputBinType *output, uint8_t *out);
uint32_t tx_serialize_decred_witness(TxStruct *tx, const TxAck_TransactionType_TxInputType *input, uint8_t *out);
void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len, uint32_t version, uint32_t lock_time, uint32_t expiry, uint32_t extra_data_len, HasherType hasher_sign, bool overwintered);
uint32_t tx_serialize_header_hash(TxStruct *tx);
uint32_t tx_serialize_input_hash(TxStruct *tx, const TxInputType *input);
uint32_t tx_serialize_output_hash(TxStruct *tx, const TxOutputBinType *output);
uint32_t tx_serialize_input_hash(TxStruct *tx, const TxAck_TransactionType_TxInputType *input);
uint32_t tx_serialize_output_hash(TxStruct *tx, const TxAck_TransactionType_TxOutputBinType *output);
uint32_t tx_serialize_extra_data_hash(TxStruct *tx, const uint8_t *data, uint32_t datalen);
uint32_t tx_serialize_decred_witness_hash(TxStruct *tx, const TxInputType *input);
uint32_t tx_serialize_decred_witness_hash(TxStruct *tx, const TxAck_TransactionType_TxInputType *input);
void tx_hash_final(TxStruct *t, uint8_t *hash, bool reverse);
uint32_t tx_input_weight(const CoinInfo *coin, const TxInputType *txinput);
uint32_t tx_output_weight(const CoinInfo *coin, const TxOutputType *txoutput);
uint32_t tx_decred_witness_weight(const TxInputType *txinput);
uint32_t tx_input_weight(const CoinInfo *coin, const TxAck_TransactionType_TxInputType *txinput);
uint32_t tx_output_weight(const CoinInfo *coin, const TxAck_TransactionType_TxOutputType *txoutput);
uint32_t tx_decred_witness_weight(const TxAck_TransactionType_TxInputType *txinput);
#endif

@ -1 +1 @@
Subproject commit 2dad4dcd519662b9d69e276e737ac1bba655555d
Subproject commit 51eeb0ed5fedf1506eb607036e9f16ef43dd8580
Loading…
Cancel
Save