firmware: use flattened protobuf symbols

pull/25/head
matejcik 6 years ago committed by Pavol Rusnak
parent 7b07926b3a
commit c17cec93f7
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -335,7 +335,7 @@ int cryptoMessageDecrypt(curve_point *nonce, uint8_t *payload, size_t payload_le
}
*/
uint8_t *cryptoHDNodePathToPubkey(const CoinInfo *coin, const MultisigRedeemScriptType_HDNodePathType *hdnodepath)
uint8_t *cryptoHDNodePathToPubkey(const CoinInfo *coin, const 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 MultisigRedeemScriptType_HDNodePathType *ptr[15], *swap;
static const HDNodePathType *ptr[15], *swap;
const uint32_t n = multisig->pubkeys_count;
if (n < 1 || n > 15) {
return 0;

@ -52,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 MultisigRedeemScriptType_HDNodePathType *hdnodepath);
uint8_t *cryptoHDNodePathToPubkey(const CoinInfo *coin, const HDNodePathType *hdnodepath);
int cryptoMultisigPubkeyIndex(const CoinInfo *coin, const MultisigRedeemScriptType *multisig, const uint8_t *pubkey);

@ -192,7 +192,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(Failure_FailureType_Failure_ProcessError, _("Signing failed"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Signing failed"));
ethereum_signing_abort();
return;
}
@ -446,7 +446,7 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)
/* eip-155 chain id */
if (msg->has_chain_id) {
if (msg->chain_id < 1) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Chain Id out of bounds"));
fsm_sendFailure(FailureType_Failure_DataError, _("Chain Id out of bounds"));
ethereum_signing_abort();
return;
}
@ -460,7 +460,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(Failure_FailureType_Failure_DataError, _("Txtype out of bounds"));
fsm_sendFailure(FailureType_Failure_DataError, _("Txtype out of bounds"));
ethereum_signing_abort();
return;
}
@ -470,7 +470,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(Failure_FailureType_Failure_DataError, _("Data length provided, but no initial chunk"));
fsm_sendFailure(FailureType_Failure_DataError, _("Data length provided, but no initial chunk"));
ethereum_signing_abort();
return;
}
@ -478,7 +478,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(Failure_FailureType_Failure_DataError, _("Data length exceeds limit"));
fsm_sendFailure(FailureType_Failure_DataError, _("Data length exceeds limit"));
ethereum_signing_abort();
return;
}
@ -487,14 +487,14 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)
data_total = 0;
}
if (msg->data_initial_chunk.size > data_total) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Invalid size of initial chunk"));
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid size of initial chunk"));
ethereum_signing_abort();
return;
}
// safety checks
if (!ethereum_signing_check(msg)) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Safety check failed"));
fsm_sendFailure(FailureType_Failure_DataError, _("Safety check failed"));
ethereum_signing_abort();
return;
}
@ -513,16 +513,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(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(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(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
ethereum_signing_abort();
return;
}
@ -531,8 +531,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(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
ethereum_signing_abort();
return;
}
@ -587,19 +587,19 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)
void ethereum_signing_txack(EthereumTxAck *tx)
{
if (!ethereum_signing) {
fsm_sendFailure(Failure_FailureType_Failure_UnexpectedMessage, _("Not in Ethereum signing mode"));
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Not in Ethereum signing mode"));
layoutHome();
return;
}
if (tx->data_chunk.size > data_left) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Too much data"));
fsm_sendFailure(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(Failure_FailureType_Failure_DataError, _("Empty data chunk received"));
fsm_sendFailure(FailureType_Failure_DataError, _("Empty data chunk received"));
ethereum_signing_abort();
return;
}
@ -657,7 +657,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(Failure_FailureType_Failure_ProcessError, _("Signing failed"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Signing failed"));
return;
}
@ -670,7 +670,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(Failure_FailureType_Failure_DataError, _("Malformed data"));
fsm_sendFailure(FailureType_Failure_DataError, _("Malformed data"));
return 1;
}

@ -70,13 +70,13 @@ static uint8_t msg_resp[MSG_OUT_SIZE] __attribute__ ((aligned));
#define CHECK_INITIALIZED \
if (!storage_isInitialized()) { \
fsm_sendFailure(Failure_FailureType_Failure_NotInitialized, NULL); \
fsm_sendFailure(FailureType_Failure_NotInitialized, NULL); \
return; \
}
#define CHECK_NOT_INITIALIZED \
if (storage_isInitialized()) { \
fsm_sendFailure(Failure_FailureType_Failure_UnexpectedMessage, _("Device is already initialized. Use Wipe first.")); \
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Device is already initialized. Use Wipe first.")); \
return; \
}
@ -94,7 +94,7 @@ static uint8_t msg_resp[MSG_OUT_SIZE] __attribute__ ((aligned));
#define CHECK_PARAM(cond, errormsg) \
if (!(cond)) { \
fsm_sendFailure(Failure_FailureType_Failure_DataError, (errormsg)); \
fsm_sendFailure(FailureType_Failure_DataError, (errormsg)); \
layoutHome(); \
return; \
}
@ -110,9 +110,9 @@ void fsm_sendSuccess(const char *text)
}
#if DEBUG_LINK
void fsm_sendFailureDebug(Failure_FailureType code, const char *text, const char *source)
void fsm_sendFailureDebug(FailureType code, const char *text, const char *source)
#else
void fsm_sendFailure(Failure_FailureType code, const char *text)
void fsm_sendFailure(FailureType code, const char *text)
#endif
{
if (protectAbortedByCancel) {
@ -128,43 +128,43 @@ void fsm_sendFailure(Failure_FailureType code, const char *text)
resp->code = code;
if (!text) {
switch (code) {
case Failure_FailureType_Failure_UnexpectedMessage:
case FailureType_Failure_UnexpectedMessage:
text = _("Unexpected message");
break;
case Failure_FailureType_Failure_ButtonExpected:
case FailureType_Failure_ButtonExpected:
text = _("Button expected");
break;
case Failure_FailureType_Failure_DataError:
case FailureType_Failure_DataError:
text = _("Data error");
break;
case Failure_FailureType_Failure_ActionCancelled:
case FailureType_Failure_ActionCancelled:
text = _("Action cancelled by user");
break;
case Failure_FailureType_Failure_PinExpected:
case FailureType_Failure_PinExpected:
text = _("PIN expected");
break;
case Failure_FailureType_Failure_PinCancelled:
case FailureType_Failure_PinCancelled:
text = _("PIN cancelled");
break;
case Failure_FailureType_Failure_PinInvalid:
case FailureType_Failure_PinInvalid:
text = _("PIN invalid");
break;
case Failure_FailureType_Failure_InvalidSignature:
case FailureType_Failure_InvalidSignature:
text = _("Invalid signature");
break;
case Failure_FailureType_Failure_ProcessError:
case FailureType_Failure_ProcessError:
text = _("Process error");
break;
case Failure_FailureType_Failure_NotEnoughFunds:
case FailureType_Failure_NotEnoughFunds:
text = _("Not enough funds");
break;
case Failure_FailureType_Failure_NotInitialized:
case FailureType_Failure_NotInitialized:
text = _("Device not initialized");
break;
case Failure_FailureType_Failure_PinMismatch:
case FailureType_Failure_PinMismatch:
text = _("PIN mismatch");
break;
case Failure_FailureType_Failure_FirmwareError:
case FailureType_Failure_FirmwareError:
text = _("Firmware error");
break;
}
@ -193,7 +193,7 @@ static const CoinInfo *fsm_getCoin(bool has_name, const char *name)
coin = coinByName("Bitcoin");
}
if (!coin) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Invalid coin name"));
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid coin name"));
layoutHome();
return 0;
}
@ -207,7 +207,7 @@ static HDNode *fsm_getDerivedNode(const char *curve, const uint32_t *address_n,
*fingerprint = 0;
}
if (!storage_getRootNode(&node, curve, true)) {
fsm_sendFailure(Failure_FailureType_Failure_NotInitialized, _("Device not initialized or passphrase request cancelled or unsupported curve"));
fsm_sendFailure(FailureType_Failure_NotInitialized, _("Device not initialized or passphrase request cancelled or unsupported curve"));
layoutHome();
return 0;
}
@ -215,7 +215,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(Failure_FailureType_Failure_ProcessError, _("Failed to derive private key"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to derive private key"));
layoutHome();
return 0;
}
@ -231,11 +231,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(ButtonRequest_ButtonRequestType_ButtonRequest_Address, false)) {
if (protectButton(ButtonRequestType_ButtonRequest_Address, false)) {
return true;
}
if (protectAbortedByCancel || protectAbortedByInitialize) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return false;
}

@ -33,11 +33,11 @@
void fsm_sendSuccess(const char *text);
#if DEBUG_LINK
void fsm_sendFailureDebug(Failure_FailureType code, const char *text, const char *source);
void fsm_sendFailureDebug(FailureType code, const char *text, const char *source);
#define fsm_sendFailure(code, text) fsm_sendFailureDebug((code), (text), __FILE__ ":" VERSTR(__LINE__) ":")
#else
void fsm_sendFailure(Failure_FailureType code, const char *text);
void fsm_sendFailure(FailureType code, const char *text);
#endif
void fsm_msgInitialize(Initialize *msg);
@ -89,7 +89,6 @@ void fsm_msgCosiSign(CosiSign *msg);
// Stellar
/*
void fsm_msgStellarGetAddress(StellarGetAddress *msg);
void fsm_msgStellarGetPublicKey(StellarGetPublicKey *msg);
void fsm_msgStellarSignTx(StellarSignTx *msg);
void fsm_msgStellarPaymentOp(StellarPaymentOp *msg);
void fsm_msgStellarCreateAccountOp(StellarCreateAccountOp *msg);

@ -39,8 +39,8 @@ void fsm_msgGetPublicKey(GetPublicKey *msg)
if (msg->has_show_display && msg->show_display) {
layoutPublicKey(node->public_key);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_PublicKey, true)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_PublicKey, true)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -184,7 +184,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(Failure_FailureType_Failure_DataError, _("Can't encode address"));
fsm_sendFailure(FailureType_Failure_DataError, _("Can't encode address"));
layoutHome();
return;
}
@ -207,8 +207,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(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -235,8 +235,8 @@ void fsm_msgSignMessage(SignMessage *msg)
CHECK_INITIALIZED
layoutSignMessage(msg->message.bytes, msg->message.size);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -253,7 +253,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(Failure_FailureType_Failure_ProcessError, _("Error computing address"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Error computing address"));
layoutHome();
return;
}
@ -261,7 +261,7 @@ void fsm_msgSignMessage(SignMessage *msg)
resp->signature.size = 65;
msg_write(MessageType_MessageType_MessageSignature, resp);
} else {
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Error signing message"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Error signing message"));
}
layoutHome();
}
@ -276,20 +276,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(coin, msg->address);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
layoutVerifyMessage(msg->message.bytes, msg->message.size);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
fsm_sendSuccess(_("Message verified"));
} else {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Invalid signature"));
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid signature"));
}
layoutHome();
}

@ -80,8 +80,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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -93,7 +93,7 @@ void fsm_msgPing(Ping *msg)
if (msg->has_passphrase_protection && msg->passphrase_protection) {
if (!protectPassphrase()) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
return;
}
}
@ -123,8 +123,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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -139,7 +139,7 @@ void fsm_msgChangePin(ChangePin *msg)
if (protectChangePin()) {
fsm_sendSuccess(_("PIN changed"));
} else {
fsm_sendFailure(Failure_FailureType_Failure_PinMismatch, NULL);
fsm_sendFailure(FailureType_Failure_PinMismatch, NULL);
}
}
layoutHome();
@ -149,8 +149,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(ButtonRequest_ButtonRequestType_ButtonRequest_WipeDevice, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_WipeDevice, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -165,8 +165,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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -187,15 +187,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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
if (msg->has_mnemonic && !(msg->has_skip_checksum && msg->skip_checksum) ) {
if (!mnemonic_check(msg->mnemonic)) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Mnemonic with wrong checksum provided"));
fsm_sendFailure(FailureType_Failure_DataError, _("Mnemonic with wrong checksum provided"));
layoutHome();
return;
}
@ -249,7 +249,7 @@ void fsm_msgCancel(Cancel *msg)
recovery_abort();
signing_abort();
ethereum_signing_abort();
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
}
void fsm_msgClearSession(ClearSession *msg)
@ -269,32 +269,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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -302,8 +302,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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -350,8 +350,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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -378,8 +378,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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}

@ -35,8 +35,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(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -72,8 +72,8 @@ void fsm_msgSignIdentity(SignIdentity *msg)
CHECK_INITIALIZED
layoutSignIdentity(&(msg->identity), msg->has_challenge_visual ? msg->challenge_visual : 0);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -82,7 +82,7 @@ void fsm_msgSignIdentity(SignIdentity *msg)
uint8_t hash[32];
if (!msg->has_identity || cryptoIdentityFingerprint(&(msg->identity), hash) == 0) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Invalid identity"));
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid identity"));
layoutHome();
return;
}
@ -136,7 +136,7 @@ void fsm_msgSignIdentity(SignIdentity *msg)
resp->signature.size = 65;
msg_write(MessageType_MessageType_SignedIdentity, resp);
} else {
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Error signing identity"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Error signing identity"));
}
layoutHome();
}
@ -148,8 +148,8 @@ void fsm_msgGetECDHSessionKey(GetECDHSessionKey *msg)
CHECK_INITIALIZED
layoutDecryptIdentity(&msg->identity);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -158,7 +158,7 @@ void fsm_msgGetECDHSessionKey(GetECDHSessionKey *msg)
uint8_t hash[32];
if (!msg->has_identity || cryptoIdentityFingerprint(&(msg->identity), hash) == 0) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Invalid identity"));
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid identity"));
layoutHome();
return;
}
@ -184,7 +184,7 @@ void fsm_msgGetECDHSessionKey(GetECDHSessionKey *msg)
resp->session_key.size = result_size;
msg_write(MessageType_MessageType_ECDHSessionKey, resp);
} else {
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Error getting ECDH session key"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Error getting ECDH session key"));
}
layoutHome();
}
@ -216,14 +216,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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(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(Failure_FailureType_Failure_ProcessError, _("Error encrypting message"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Error encrypting message"));
layoutHome();
return;
}
@ -257,7 +257,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(Failure_FailureType_Failure_ActionCancelled, NULL);
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -265,7 +265,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(ButtonRequest_ButtonRequestType_ButtonRequest_Other, true);
protectButton(ButtonRequestType_ButtonRequest_Other, true);
if (display_only) {
resp->has_address = false;
resp->has_message = false;
@ -289,8 +289,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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -329,8 +329,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(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}

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

@ -96,7 +96,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(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
layoutHome();
return;
}
@ -109,7 +109,7 @@ void fsm_msgNEMSignTx(NEMSignTx *msg) {
hdnode_fill_public_key(node);
const NEMSignTx_NEMTransactionCommon *common = msg->has_multisig ? &msg->multisig : &msg->transaction;
const NEMTransactionCommon *common = msg->has_multisig ? &msg->multisig : &msg->transaction;
char address[NEM_ADDRESS_SIZE + 1];
hdnode_get_nem_address(node, common->network, address);
@ -119,37 +119,37 @@ void fsm_msgNEMSignTx(NEMSignTx *msg) {
}
if (msg->has_transfer && !nem_askTransfer(common, &msg->transfer, network)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
layoutHome();
return;
}
if (msg->has_provision_namespace && !nem_askProvisionNamespace(common, &msg->provision_namespace, network)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
layoutHome();
return;
}
if (msg->has_mosaic_creation && !nem_askMosaicCreation(common, &msg->mosaic_creation, network, address)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
layoutHome();
return;
}
if (msg->has_supply_change && !nem_askSupplyChange(common, &msg->supply_change, network)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(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(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
layoutHome();
return;
}
if (msg->has_importance_transfer && !nem_askImportanceTransfer(common, &msg->importance_transfer, network)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
layoutHome();
return;
}
@ -260,8 +260,8 @@ void fsm_msgNEMDecryptMessage(NEMDecryptMessage *msg)
_("Decrypt message"),
_("Confirm address?"),
address);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -286,7 +286,7 @@ void fsm_msgNEMDecryptMessage(NEMDecryptMessage *msg)
size,
resp->payload.bytes);
if (!ret) {
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to decrypt payload"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to decrypt payload"));
layoutHome();
return;
}
@ -295,8 +295,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(ButtonRequest_ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}

@ -27,7 +27,7 @@ void fsm_msgStellarGetAddress(StellarGetAddress *msg)
HDNode *node = stellar_deriveNode(msg->address_n, msg->address_n_count);
if (!node) {
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to derive private key"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to derive private key"));
return;
}
@ -40,8 +40,8 @@ void fsm_msgStellarGetAddress(StellarGetAddress *msg)
NULL,
NULL, NULL
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
@ -55,47 +55,47 @@ void fsm_msgStellarGetAddress(StellarGetAddress *msg)
layoutHome();
}
void fsm_msgStellarGetPublicKey(StellarGetPublicKey *msg)
{
RESP_INIT(StellarPublicKey);
CHECK_INITIALIZED
CHECK_PIN
HDNode *node = stellar_deriveNode(msg->address_n, msg->address_n_count);
if (!node) {
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to derive private key"));
return;
}
if (msg->has_show_display && msg->show_display) {
char hex[32 * 2 + 1];
data2hex(node->public_key + 1, 32, hex);
const char **str_pubkey_rows = split_message((const uint8_t *)hex, 32 * 2, 16);
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), _("Share public account ID?"),
str_pubkey_rows[0],
str_pubkey_rows[1],
str_pubkey_rows[2],
str_pubkey_rows[3],
NULL, NULL
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
}
// Read public key and write it to the response
resp->has_public_key = true;
resp->public_key.size = 32;
memcpy(resp->public_key.bytes, node->public_key + 1, 32);
msg_write(MessageType_MessageType_StellarPublicKey, resp);
layoutHome();
}
// void fsm_msgStellarGetPublicKey(StellarGetPublicKey *msg)
// {
// RESP_INIT(StellarPublicKey);
// CHECK_INITIALIZED
// CHECK_PIN
// HDNode *node = stellar_deriveNode(msg->address_n, msg->address_n_count);
// if (!node) {
// fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to derive private key"));
// return;
// }
// if (msg->has_show_display && msg->show_display) {
// char hex[32 * 2 + 1];
// data2hex(node->public_key + 1, 32, hex);
// const char **str_pubkey_rows = split_message((const uint8_t *)hex, 32 * 2, 16);
// layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), _("Share public account ID?"),
// str_pubkey_rows[0],
// str_pubkey_rows[1],
// str_pubkey_rows[2],
// str_pubkey_rows[3],
// NULL, NULL
// );
// if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
// fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
// layoutHome();
// return;
// }
// }
// // Read public key and write it to the response
// resp->has_public_key = true;
// resp->public_key.size = 32;
// memcpy(resp->public_key.bytes, node->public_key + 1, 32);
// msg_write(MessageType_MessageType_StellarPublicKey, resp);
// layoutHome();
// }
void fsm_msgStellarSignTx(StellarSignTx *msg)
{

@ -286,7 +286,7 @@ static void render_address_dialog(const CoinInfo *coin, const char *address, con
oledRefresh();
}
void layoutConfirmOutput(const CoinInfo *coin, const TxAck_TransactionType_TxOutputType *out)
void layoutConfirmOutput(const CoinInfo *coin, const 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);
@ -718,7 +718,7 @@ void layoutNEMNetworkFee(const char *desc, bool confirm, const char *fee1_desc,
NULL);
}
void layoutNEMTransferMosaic(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, uint8_t network) {
void layoutNEMTransferMosaic(const 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));
@ -787,8 +787,8 @@ void layoutNEMMosaicDescription(const char *description) {
str[0], str[1], str[2], str[3], NULL, NULL);
}
void layoutNEMLevy(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint8_t network) {
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *mosaic;
void layoutNEMLevy(const NEMMosaicDefinition *definition, uint8_t network) {
const NEMMosaicDefinition *mosaic;
if (nem_mosaicMatches(definition, definition->levy_namespace, definition->levy_mosaic, network)) {
mosaic = definition;
} else {
@ -803,7 +803,7 @@ void layoutNEMLevy(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *defini
char str_out[32];
switch (definition->levy) {
case NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition_NEMMosaicLevy_MosaicLevy_Percentile:
case NEMMosaicLevy_MosaicLevy_Percentile:
bn_format_uint64(definition->fee, NULL, NULL, 0, 0, false, str_out, sizeof(str_out));
layoutDialogSwipe(&bmp_icon_question,
@ -818,7 +818,7 @@ void layoutNEMLevy(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *defini
NULL);
break;
case NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition_NEMMosaicLevy_MosaicLevy_Absolute:
case NEMMosaicLevy_MosaicLevy_Absolute:
default:
nem_mosaicFormatAmount(mosaic, definition->fee, NULL, str_out, sizeof(str_out));
layoutDialogSwipe(&bmp_icon_question,

@ -43,7 +43,7 @@ void layoutProgressSwipe(const char *desc, int permil);
void layoutScreensaver(void);
void layoutHome(void);
void layoutConfirmOutput(const CoinInfo *coin, const TxAck_TransactionType_TxOutputType *out);
void layoutConfirmOutput(const CoinInfo *coin, const 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);
@ -63,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 NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, uint8_t network);
void layoutNEMTransferMosaic(const 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 NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint8_t network);
void layoutNEMLevy(const 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);

@ -226,7 +226,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(Failure_FailureType_Failure_DataError, stream.errmsg);
fsm_sendFailure(FailureType_Failure_DataError, stream.errmsg);
}
}
@ -250,11 +250,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(Failure_FailureType_Failure_UnexpectedMessage, _("Unknown message"));
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Unknown message"));
return;
}
if (msg_size > MSG_IN_SIZE) { // message is too big :(
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Message too big"));
fsm_sendFailure(FailureType_Failure_DataError, _("Message too big"));
return;
}
@ -362,11 +362,11 @@ void msg_read_tiny(const uint8_t *buf, int len)
if (status) {
msg_tiny_id = msg_id;
} else {
fsm_sendFailure(Failure_FailureType_Failure_DataError, stream.errmsg);
fsm_sendFailure(FailureType_Failure_DataError, stream.errmsg);
msg_tiny_id = 0xFFFF;
}
} else {
fsm_sendFailure(Failure_FailureType_Failure_UnexpectedMessage, _("Unknown message"));
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Unknown message"));
msg_tiny_id = 0xFFFF;
}
}

@ -27,7 +27,7 @@
#include "rng.h"
#include "secp256k1.h"
const char *nem_validate_common(NEMSignTx_NEMTransactionCommon *common, bool inner) {
const char *nem_validate_common(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(NEMSignTx_NEMTransactionCommon *common, bool inn
return NULL;
}
const char *nem_validate_transfer(const NEMSignTx_NEMTransfer *transfer, uint8_t network) {
const char *nem_validate_transfer(const 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 NEMSignTx_NEMTransfer *transfer, uint8_t
if (!nem_validate_address(transfer->recipient, network)) return _("Invalid recipient address");
for (size_t i = 0; i < transfer->mosaics_count; i++) {
const NEMSignTx_NEMTransfer_NEMMosaic *mosaic = &transfer->mosaics[i];
const 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 NEMSignTx_NEMTransfer *transfer, uint8_t
return NULL;
}
const char *nem_validate_provision_namespace(const NEMSignTx_NEMProvisionNamespace *provision_namespace, uint8_t network) {
const char *nem_validate_provision_namespace(const 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 NEMSignTx_NEMProvisionNamespa
return NULL;
}
const char *nem_validate_mosaic_creation(const NEMSignTx_NEMMosaicCreation *mosaic_creation, uint8_t network) {
const char *nem_validate_mosaic_creation(const 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 NEMSignTx_NEMMosaicCreation *mosa
return NULL;
}
const char *nem_validate_supply_change(const NEMSignTx_NEMMosaicSupplyChange *supply_change) {
const char *nem_validate_supply_change(const 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 NEMSignTx_NEMMosaicSupplyChange *su
return NULL;
}
const char *nem_validate_aggregate_modification(const NEMSignTx_NEMAggregateModification *aggregate_modification, bool creation) {
const char *nem_validate_aggregate_modification(const 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 NEMSignTx_NEMAggregateModification_NEMCosignatoryModification *modification = &aggregate_modification->modifications[i];
const 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 == NEMSignTx_NEMAggregateModification_NEMCosignatoryModification_NEMModificationType_CosignatoryModification_Delete) {
if (creation && modification->type == NEMModificationType_CosignatoryModification_Delete) {
return _("Cannot remove cosignatory when converting account");
}
}
@ -155,7 +155,7 @@ const char *nem_validate_aggregate_modification(const NEMSignTx_NEMAggregateModi
return NULL;
}
const char *nem_validate_importance_transfer(const NEMSignTx_NEMImportanceTransfer *importance_transfer) {
const char *nem_validate_importance_transfer(const 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 NEMSignTx_NEMImportanceTransf
return NULL;
}
bool nem_askTransfer(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMTransfer *transfer, const char *desc) {
bool nem_askTransfer(const NEMTransactionCommon *common, const NEMTransfer *transfer, const char *desc) {
if (transfer->mosaics_count) {
const NEMSignTx_NEMTransfer_NEMMosaic *xem = NULL;
const NEMMosaic *xem = NULL;
bool unknownMosaic = false;
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definitions[transfer->mosaics_count];
const NEMMosaicDefinition *definitions[transfer->mosaics_count];
for (size_t i = 0; i < transfer->mosaics_count; i++) {
const NEMSignTx_NEMTransfer_NEMMosaic *mosaic = &transfer->mosaics[i];
const NEMMosaic *mosaic = &transfer->mosaics[i];
definitions[i] = nem_mosaicByName(mosaic->namespace, mosaic->mosaic, common->network);
@ -196,18 +196,18 @@ bool nem_askTransfer(const NEMSignTx_NEMTransactionCommon *common, const NEMSign
NULL,
NULL,
NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
layoutNEMTransferXEM(desc, xem ? xem->quantity : 0, &multiplier, common->fee);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
for (size_t i = 0; i < transfer->mosaics_count; i++) {
const NEMSignTx_NEMTransfer_NEMMosaic *mosaic = &transfer->mosaics[i];
const NEMMosaic *mosaic = &transfer->mosaics[i];
if (mosaic == xem) {
continue;
@ -219,20 +219,20 @@ bool nem_askTransfer(const NEMSignTx_NEMTransactionCommon *common, const NEMSign
layoutNEMTransferUnknownMosaic(mosaic->namespace, mosaic->mosaic, mosaic->quantity, &multiplier);
}
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
} else {
layoutNEMTransferXEM(desc, transfer->amount, NULL, common->fee);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
if (transfer->has_payload) {
layoutNEMTransferPayload(transfer->payload.bytes, transfer->payload.size, transfer->has_public_key);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
@ -243,14 +243,14 @@ bool nem_askTransfer(const NEMSignTx_NEMTransactionCommon *common, const NEMSign
desc,
_("Confirm transfer to"),
transfer->recipient);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
return false;
}
return true;
}
bool nem_fsmTransfer(nem_transaction_ctx *context, const HDNode *node, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMTransfer *transfer) {
bool nem_fsmTransfer(nem_transaction_ctx *context, const HDNode *node, const NEMTransactionCommon *common, const 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(Failure_FailureType_Failure_ProcessError, _("Private key unavailable for encrypted message"));
fsm_sendFailure(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(Failure_FailureType_Failure_ProcessError, _("Failed to encrypt payload"));
fsm_sendFailure(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(Failure_FailureType_Failure_ProcessError, _("Failed to create transfer transaction"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to create transfer transaction"));
return false;
}
for (size_t i = 0; i < transfer->mosaics_count; i++) {
const NEMSignTx_NEMTransfer_NEMMosaic *mosaic = &transfer->mosaics[i];
const 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(Failure_FailureType_Failure_ProcessError, _("Failed to attach mosaics"));
fsm_sendFailure(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 NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMProvisionNamespace *provision_namespace, const char *desc) {
bool nem_askProvisionNamespace(const NEMTransactionCommon *common, const NEMProvisionNamespace *provision_namespace, const char *desc) {
layoutDialogSwipe(&bmp_icon_question,
_("Cancel"),
_("Next"),
@ -331,19 +331,19 @@ bool nem_askProvisionNamespace(const NEMSignTx_NEMTransactionCommon *common, con
provision_namespace->has_parent ? provision_namespace->parent : NULL,
NULL,
NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
layoutNEMNetworkFee(desc, true, _("Confirm rental fee of"), provision_namespace->fee, _("and network fee of"), common->fee);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
return false;
}
return true;
}
bool nem_fsmProvisionNamespace(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMProvisionNamespace *provision_namespace) {
bool nem_fsmProvisionNamespace(nem_transaction_ctx *context, const NEMTransactionCommon *common, const 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 NEMSignTx_NEM
provision_namespace->fee);
}
bool nem_askMosaicCreation(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMMosaicCreation *mosaic_creation, const char *desc, const char *address) {
bool nem_askMosaicCreation(const NEMTransactionCommon *common, const NEMMosaicCreation *mosaic_creation, const char *desc, const char *address) {
layoutDialogSwipe(&bmp_icon_question,
_("Cancel"),
_("Next"),
@ -367,12 +367,12 @@ bool nem_askMosaicCreation(const NEMSignTx_NEMTransactionCommon *common, const N
mosaic_creation->definition.namespace,
NULL,
NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
layoutNEMMosaicDescription(mosaic_creation->definition.description);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
@ -397,13 +397,13 @@ bool nem_askMosaicCreation(const NEMSignTx_NEMTransactionCommon *common, const N
mosaic_creation->definition.transferable ? _("transferable") : _("non-transferable"),
NULL,
NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
if (mosaic_creation->definition.has_levy) {
layoutNEMLevy(&mosaic_creation->definition, common->network);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
@ -427,20 +427,20 @@ bool nem_askMosaicCreation(const NEMSignTx_NEMTransactionCommon *common, const N
mosaic_creation->definition.levy_address);
}
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
layoutNEMNetworkFee(desc, true, _("Confirm creation fee"), mosaic_creation->fee, _("and network fee of"), common->fee);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
return false;
}
return true;
}
bool nem_fsmMosaicCreation(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMMosaicCreation *mosaic_creation) {
bool nem_fsmMosaicCreation(nem_transaction_ctx *context, const NEMTransactionCommon *common, const 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 NEMSignTx_NEMTran
mosaic_creation->fee);
}
bool nem_askSupplyChange(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMMosaicSupplyChange *supply_change, const char *desc) {
bool nem_askSupplyChange(const NEMTransactionCommon *common, const NEMMosaicSupplyChange *supply_change, const char *desc) {
layoutDialogSwipe(&bmp_icon_question,
_("Cancel"),
_("Next"),
@ -474,7 +474,7 @@ bool nem_askSupplyChange(const NEMSignTx_NEMTransactionCommon *common, const NEM
supply_change->namespace,
NULL,
NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
@ -485,25 +485,25 @@ bool nem_askSupplyChange(const NEMSignTx_NEMTransactionCommon *common, const NEM
_("Cancel"),
_("Next"),
desc,
supply_change->type == NEMSignTx_NEMMosaicSupplyChange_NEMSupplyChangeType_SupplyChange_Increase ? _("Increase supply by") : _("Decrease supply by"),
supply_change->type == NEMSupplyChangeType_SupplyChange_Increase ? _("Increase supply by") : _("Decrease supply by"),
str_out,
_("whole units"),
NULL,
NULL,
NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
layoutNEMNetworkFee(desc, true, _("Confirm network fee"), common->fee, NULL, 0);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
return false;
}
return true;
}
bool nem_fsmSupplyChange(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMMosaicSupplyChange *supply_change) {
bool nem_fsmSupplyChange(nem_transaction_ctx *context, const NEMTransactionCommon *common, const 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 NEMSignTx_NEMTransa
supply_change->delta);
}
bool nem_askAggregateModification(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMAggregateModification *aggregate_modification, const char *desc, bool creation) {
bool nem_askAggregateModification(const NEMTransactionCommon *common, const NEMAggregateModification *aggregate_modification, const char *desc, bool creation) {
if (creation) {
layoutDialogSwipe(&bmp_icon_question,
_("Cancel"),
@ -528,7 +528,7 @@ bool nem_askAggregateModification(const NEMSignTx_NEMTransactionCommon *common,
NULL,
NULL,
NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
@ -536,16 +536,16 @@ bool nem_askAggregateModification(const NEMSignTx_NEMTransactionCommon *common,
char address[NEM_ADDRESS_SIZE + 1];
for (size_t i = 0; i < aggregate_modification->modifications_count; i++) {
const NEMSignTx_NEMAggregateModification_NEMCosignatoryModification *modification = &aggregate_modification->modifications[i];
const 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 == NEMSignTx_NEMAggregateModification_NEMCosignatoryModification_NEMModificationType_CosignatoryModification_Add ? _("Add cosignatory") : _("Remove cosignatory"),
modification->type == NEMModificationType_CosignatoryModification_Add ? _("Add cosignatory") : _("Remove cosignatory"),
address);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
@ -572,20 +572,20 @@ bool nem_askAggregateModification(const NEMSignTx_NEMTransactionCommon *common,
NULL,
NULL,
NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
}
layoutNEMNetworkFee(desc, true, _("Confirm network fee"), common->fee, NULL, 0);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
return false;
}
return true;
}
bool nem_fsmAggregateModification(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMAggregateModification *aggregate_modification) {
bool nem_fsmAggregateModification(nem_transaction_ctx *context, const NEMTransactionCommon *common, const 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 NEMSignTx_
if (!ret) return false;
for (size_t i = 0; i < aggregate_modification->modifications_count; i++) {
const NEMSignTx_NEMAggregateModification_NEMCosignatoryModification *modification = &aggregate_modification->modifications[i];
const 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 NEMSignTx_
return true;
}
bool nem_askImportanceTransfer(const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMImportanceTransfer *importance_transfer, const char *desc) {
bool nem_askImportanceTransfer(const NEMTransactionCommon *common, const NEMImportanceTransfer *importance_transfer, const char *desc) {
layoutDialogSwipe(&bmp_icon_question,
_("Cancel"),
_("Next"),
desc,
importance_transfer->mode == NEMSignTx_NEMImportanceTransfer_NEMImportanceTransferMode_ImportanceTransfer_Activate ? _("Activate remote") : _("Deactivate remote"),
importance_transfer->mode == NEMImportanceTransferMode_ImportanceTransfer_Activate ? _("Activate remote") : _("Deactivate remote"),
_("harvesting?"),
NULL,
NULL,
NULL,
NULL);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
layoutNEMNetworkFee(desc, true, _("Confirm network fee"), common->fee, NULL, 0);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
return false;
}
return true;
}
bool nem_fsmImportanceTransfer(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const NEMSignTx_NEMImportanceTransfer *importance_transfer) {
bool nem_fsmImportanceTransfer(nem_transaction_ctx *context, const NEMTransactionCommon *common, const 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(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
layoutNEMNetworkFee(desc, false, _("Confirm multisig fee"), fee, NULL, 0);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return false;
}
return true;
}
bool nem_fsmMultisig(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const nem_transaction_ctx *inner, bool cosigning) {
bool nem_fsmMultisig(nem_transaction_ctx *context, const 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 NEMSignTx_NEMTransactio
}
if (!ret) {
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to create multisig transaction"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to create multisig transaction"));
return false;
}
return true;
}
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *nem_mosaicByName(const char *namespace, const char *mosaic, uint8_t network) {
const NEMMosaicDefinition *nem_mosaicByName(const char *namespace, const char *mosaic, uint8_t network) {
for (size_t i = 0; i < NEM_MOSAIC_DEFINITIONS_COUNT; i++) {
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition = &NEM_MOSAIC_DEFINITIONS[i];
const NEMMosaicDefinition *definition = &NEM_MOSAIC_DEFINITIONS[i];
if (nem_mosaicMatches(definition, namespace, mosaic, network)) {
return definition;
@ -706,7 +706,7 @@ const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *nem_mosaicByName(const ch
return NULL;
}
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) {
static inline size_t format_amount(const 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 NEMSignTx_NEMMosaicCreation_NEMMosaicDe
size);
}
size_t nem_canonicalizeMosaics(NEMSignTx_NEMTransfer_NEMMosaic *mosaics, size_t mosaics_count) {
size_t nem_canonicalizeMosaics(NEMMosaic *mosaics, size_t mosaics_count) {
if (mosaics_count <= 1) {
return mosaics_count;
}
@ -739,16 +739,16 @@ size_t nem_canonicalizeMosaics(NEMSignTx_NEMTransfer_NEMMosaic *mosaics, size_t
for (size_t i = 0; i < mosaics_count; i++) {
if (skip[i]) continue;
NEMSignTx_NEMTransfer_NEMMosaic *mosaic = &mosaics[actual_count];
NEMMosaic *mosaic = &mosaics[actual_count];
if (actual_count++ != i) {
memcpy(mosaic, &mosaics[i], sizeof(NEMSignTx_NEMTransfer_NEMMosaic));
memcpy(mosaic, &mosaics[i], sizeof(NEMMosaic));
}
for (size_t j = i + 1; j < mosaics_count; j++) {
if (skip[j]) continue;
const NEMSignTx_NEMTransfer_NEMMosaic *new_mosaic = &mosaics[j];
const NEMMosaic *new_mosaic = &mosaics[j];
if (nem_mosaicCompare(mosaic, new_mosaic) == 0) {
skip[j] = true;
@ -757,19 +757,19 @@ size_t nem_canonicalizeMosaics(NEMSignTx_NEMTransfer_NEMMosaic *mosaics, size_t
}
}
NEMSignTx_NEMTransfer_NEMMosaic temp;
NEMMosaic temp;
// Sort mosaics
for (size_t i = 0; i < actual_count - 1; i++) {
NEMSignTx_NEMTransfer_NEMMosaic *a = &mosaics[i];
NEMMosaic *a = &mosaics[i];
for (size_t j = i + 1; j < actual_count; j++) {
NEMSignTx_NEMTransfer_NEMMosaic *b = &mosaics[j];
NEMMosaic *b = &mosaics[j];
if (nem_mosaicCompare(a, b) > 0) {
memcpy(&temp, a, sizeof(NEMSignTx_NEMTransfer_NEMMosaic));
memcpy(a, b, sizeof(NEMSignTx_NEMTransfer_NEMMosaic));
memcpy(b, &temp, sizeof(NEMSignTx_NEMTransfer_NEMMosaic));
memcpy(&temp, a, sizeof(NEMMosaic));
memcpy(a, b, sizeof(NEMMosaic));
memcpy(b, &temp, sizeof(NEMMosaic));
}
}
}
@ -777,14 +777,14 @@ size_t nem_canonicalizeMosaics(NEMSignTx_NEMTransfer_NEMMosaic *mosaics, size_t
return actual_count;
}
void nem_mosaicFormatAmount(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, char *str_out, size_t size) {
void nem_mosaicFormatAmount(const 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 NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, uint8_t network, 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) {
if (!definition->has_levy || !definition->has_fee) {
return false;
}
@ -793,13 +793,13 @@ bool nem_mosaicFormatLevy(const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition
bn_read_uint64(quantity, &amnt);
bn_read_uint64(definition->fee, &fee);
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *mosaic = nem_mosaicByName(definition->levy_namespace, definition->levy_mosaic, network);
const NEMMosaicDefinition *mosaic = nem_mosaicByName(definition->levy_namespace, definition->levy_mosaic, network);
switch (definition->levy) {
case NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition_NEMMosaicLevy_MosaicLevy_Absolute:
case NEMMosaicLevy_MosaicLevy_Absolute:
return format_amount(mosaic, &fee, NULL, 0, str_out, size);
case NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition_NEMMosaicLevy_MosaicLevy_Percentile:
case NEMMosaicLevy_MosaicLevy_Percentile:
bn_multiply(&fee, &amnt, &secp256k1.prime);
return format_amount(mosaic, &amnt, multiplier, NEM_LEVY_PERCENTILE_DIVISOR, str_out, size);

@ -27,40 +27,40 @@
#include <stdbool.h>
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);
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);
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_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_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_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_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_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_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_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_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_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_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_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_askMultisig(const char *address, const char *desc, bool cosigning, uint64_t fee);
bool nem_fsmMultisig(nem_transaction_ctx *context, const NEMSignTx_NEMTransactionCommon *common, const nem_transaction_ctx *inner, bool cosigning);
bool nem_fsmMultisig(nem_transaction_ctx *context, const NEMTransactionCommon *common, const nem_transaction_ctx *inner, bool cosigning);
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *nem_mosaicByName(const char *namespace, const char *mosaic, uint8_t network);
const NEMMosaicDefinition *nem_mosaicByName(const char *namespace, const char *mosaic, uint8_t network);
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);
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);
static inline void nem_mosaicFormatName(const char *namespace, const char *mosaic, char *str_out, size_t size) {
strlcpy(str_out, namespace, size);
@ -68,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 NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *definition, const char *namespace, const char *mosaic, uint8_t network) {
static inline bool nem_mosaicMatches(const 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;
@ -84,7 +84,7 @@ static inline bool nem_mosaicMatches(const NEMSignTx_NEMMosaicCreation_NEMMosaic
return false;
}
static inline int nem_mosaicCompare(const NEMSignTx_NEMTransfer_NEMMosaic *a, const NEMSignTx_NEMTransfer_NEMMosaic *b) {
static inline int nem_mosaicCompare(const NEMMosaic *a, const NEMMosaic *b) {
size_t namespace_length = strlen(a->namespace);
// Ensure that strlen(a->namespace) <= strlen(b->namespace)

@ -5,7 +5,7 @@ ATTRIBUTES = (
("namespace", c_str),
("mosaic", c_str),
("divisibility", int),
("levy", lambda s: "NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition_NEMMosaicLevy_" + s),
("levy", lambda s: "NEMMosaicLevy_" + s),
("fee", int),
("levy_namespace", c_str),
("levy_mosaic", c_str),
@ -16,7 +16,7 @@ ATTRIBUTES = (
#include "nem_mosaics.h"
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition NEM_MOSAIC_DEFINITIONS[NEM_MOSAIC_DEFINITIONS_COUNT] = {
const NEMMosaicDefinition NEM_MOSAIC_DEFINITIONS[NEM_MOSAIC_DEFINITIONS_COUNT] = {
% for m in supported_on("trezor1", nem):
{
% for attr, func in ATTRIBUTES:
@ -33,4 +33,4 @@ const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition NEM_MOSAIC_DEFINITIONS[NEM
% endfor
};
const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *NEM_MOSAIC_DEFINITION_XEM = NEM_MOSAIC_DEFINITIONS;
const NEMMosaicDefinition *NEM_MOSAIC_DEFINITION_XEM = NEM_MOSAIC_DEFINITIONS;

@ -9,7 +9,7 @@
<% nem_list = list(supported_on("trezor1", nem)) %>\
#define NEM_MOSAIC_DEFINITIONS_COUNT (${len(nem_list)})
extern const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition NEM_MOSAIC_DEFINITIONS[NEM_MOSAIC_DEFINITIONS_COUNT];
extern const NEMSignTx_NEMMosaicCreation_NEMMosaicDefinition *NEM_MOSAIC_DEFINITION_XEM;
extern const NEMMosaicDefinition NEM_MOSAIC_DEFINITIONS[NEM_MOSAIC_DEFINITIONS_COUNT];
extern const NEMMosaicDefinition *NEM_MOSAIC_DEFINITION_XEM;
#endif

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

@ -23,7 +23,7 @@
#include <stdbool.h>
#include "messages-common.pb.h"
bool protectButton(ButtonRequest_ButtonRequestType type, bool confirm_only);
bool protectButton(ButtonRequestType type, bool confirm_only);
bool protectPin(bool use_cached);
bool protectChangePin(void);
bool protectPassphrase(void);

@ -8,7 +8,10 @@ PYTHON ?= python
%.pb.c: %.pb %.options
@printf " NANOPB $@\n"
$(Q)$(PYTHON) ../../vendor/nanopb/generator/nanopb_generator.py $< -L '#include "%s"' -T
$(Q)$(PYTHON) ../../vendor/nanopb/generator/nanopb_generator.py $< \
-L '#include "%s"' \
-T \
-s "mangle_names:M_FLATTEN"
%.pb: %.proto
@printf " PROTOC $@\n"
@ -23,7 +26,7 @@ messages_%_pb2.py: messages-%.proto
$(Q)protoc -I/usr/include -I. $< --python_out=.
messages_map.h: messages_map.py messages_pb2.py
$(Q)$(PYTHON) $< | grep -v -e MessageType_Cardano -e MessageType_Lisk -e MessageType_Tezos -e MessageType_Ripple -e MessageType_Stellar -e MessageType_Monero -e MessageType_DebugMonero > $@
$(Q)$(PYTHON) $< | grep -v -e MessageType_Cardano -e MessageType_Lisk -e MessageType_Tezos -e MessageType_Ripple -e MessageType_Stellar -e MessageType_Monero -e MessageType_DebugMonero -e MessageType_Ontology > $@
clean:
rm -f *.pb *.o *.d *.pb.c *.pb.h *_pb2.py messages_map.h

@ -23,29 +23,29 @@ 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
TransactionType.inputs max_count:1
TransactionType.bin_outputs max_count:1
TransactionType.outputs max_count:1
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.TxInputType.prev_block_hash_bip115 max_size:32
TxInputType.address_n max_count:8
TxInputType.prev_hash max_size:32
TxInputType.script_sig max_size:1650
TxInputType.prev_block_hash_bip115 max_size:32
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.TxOutputType.block_hash_bip115 max_size:32
TxOutputType.address max_size:130
TxOutputType.address_n max_count:8
TxOutputType.op_return_data max_size:80
TxOutputType.block_hash_bip115 max_size:32
TxAck.TransactionType.TxOutputBinType.script_pubkey max_size:520
TxOutputBinType.script_pubkey max_size:520
TxRequest.TxRequestDetailsType.tx_hash max_size:32
TxRequestDetailsType.tx_hash max_size:32
TxRequest.TxRequestSerializedType.signature max_size:73
TxRequest.TxRequestSerializedType.serialized_tx max_size:2048
TxRequestSerializedType.signature max_size:73
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
HDNodePathType.address_n max_count:8

@ -8,41 +8,41 @@ NEMDecryptMessage.payload max_
NEMDecryptedMessage.payload max_size:1024
NEMSignTx.NEMTransactionCommon.address_n max_count:8
NEMSignTx.NEMTransactionCommon.signer max_size:32
NEMTransactionCommon.address_n max_count:8
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
NEMTransfer.recipient max_size:41
NEMTransfer.public_key max_size:32
NEMTransfer.payload max_size:1024
NEMTransfer.mosaics max_count:16
NEMSignTx.NEMTransfer.NEMMosaic.namespace max_size:145
NEMSignTx.NEMTransfer.NEMMosaic.mosaic max_size:33
NEMMosaic.namespace max_size:145
NEMMosaic.mosaic max_size:33
NEMSignTx.NEMProvisionNamespace.namespace max_size:65
NEMSignTx.NEMProvisionNamespace.parent max_size:81
NEMSignTx.NEMProvisionNamespace.sink max_size:41
NEMProvisionNamespace.namespace max_size:65
NEMProvisionNamespace.parent max_size:81
NEMProvisionNamespace.sink max_size:41
NEMSignTx.NEMMosaicCreation.sink max_size:41
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
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
NEMSignTx.NEMMosaicSupplyChange.namespace max_size:145
NEMSignTx.NEMMosaicSupplyChange.mosaic max_size:33
NEMMosaicSupplyChange.namespace max_size:145
NEMMosaicSupplyChange.mosaic max_size:33
NEMSignTx.NEMAggregateModification.modifications max_count:16
NEMAggregateModification.modifications max_count:16
NEMSignTx.NEMAggregateModification.NEMCosignatoryModification.public_key max_size:32
NEMCosignatoryModification.public_key max_size:32
NEMSignTx.NEMImportanceTransfer.public_key max_size:32
NEMImportanceTransfer.public_key max_size:32
NEMSignedTx.data max_size:2048
NEMSignedTx.signature max_size:64

@ -4,9 +4,6 @@ StellarGetAddress.address_n max_count:10
StellarAddress.address max_size:57
StellarGetPublicKey.address_n max_count:10
StellarPublicKey.public_key max_size:32
StellarSignTx.source_account max_size:57
StellarSignTx.address_n max_count:10

@ -143,9 +143,9 @@ static void recovery_request(void) {
WordRequest resp;
memset(&resp, 0, sizeof(WordRequest));
resp.has_type = true;
resp.type = awaiting_word == 1 ? WordRequest_WordRequestType_WordRequestType_Plain
: (word_index % 4 == 3) ? WordRequest_WordRequestType_WordRequestType_Matrix6
: WordRequest_WordRequestType_WordRequestType_Matrix9;
resp.type = awaiting_word == 1 ? WordRequestType_WordRequestType_Plain
: (word_index % 4 == 3) ? WordRequestType_WordRequestType_Matrix6
: WordRequestType_WordRequestType_Matrix9;
msg_write(MessageType_MessageType_WordRequest, &resp);
}
@ -181,15 +181,15 @@ static void recovery_done(void) {
_("The seed is valid"),
_("and MATCHES"),
_("the one in the device."), NULL, NULL, NULL);
protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_Other, true);
protectButton(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(ButtonRequest_ButtonRequestType_ButtonRequest_Other, true);
fsm_sendFailure(Failure_FailureType_Failure_DataError,
protectButton(ButtonRequestType_ButtonRequest_Other, true);
fsm_sendFailure(FailureType_Failure_DataError,
_("The seed is valid but does not match the one in the device"));
}
}
@ -201,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(ButtonRequest_ButtonRequestType_ButtonRequest_Other, true);
protectButton(ButtonRequestType_ButtonRequest_Other, true);
}
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Invalid seed, are words in correct order?"));
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid seed, are words in correct order?"));
}
awaiting_word = 0;
layoutHome();
@ -458,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(Failure_FailureType_Failure_PinMismatch, NULL);
fsm_sendFailure(FailureType_Failure_PinMismatch, NULL);
layoutHome();
return;
}
@ -470,7 +470,7 @@ void recovery_init(uint32_t _word_count, bool passphrase_protection, bool pin_pr
storage_update();
}
if ((type & RecoveryDevice_RecoveryDeviceType_RecoveryDeviceType_Matrix) != 0) {
if ((type & RecoveryDeviceType_RecoveryDeviceType_Matrix) != 0) {
awaiting_word = 2;
word_index = 0;
word_pincode = 0;
@ -496,7 +496,7 @@ static void recovery_scrambledword(const char *word)
if (!dry_run) {
session_clear(true);
}
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Wrong word retyped"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Wrong word retyped"));
layoutHome();
return;
}
@ -515,7 +515,7 @@ static void recovery_scrambledword(const char *word)
if (!dry_run) {
session_clear(true);
}
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Word not found in a wordlist"));
fsm_sendFailure(FailureType_Failure_DataError, _("Word not found in a wordlist"));
layoutHome();
return;
}
@ -544,7 +544,7 @@ void recovery_word(const char *word)
recovery_scrambledword(word);
break;
default:
fsm_sendFailure(Failure_FailureType_Failure_UnexpectedMessage, _("Not in Recovery mode"));
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Not in Recovery mode"));
break;
}
}

@ -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(ButtonRequest_ButtonRequestType_ButtonRequest_ResetDevice, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_ResetDevice, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
return;
}
}
if (pin_protection && !protectChangePin()) {
fsm_sendFailure(Failure_FailureType_Failure_PinMismatch, NULL);
fsm_sendFailure(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(Failure_FailureType_Failure_UnexpectedMessage, _("Not in Reset mode"));
fsm_sendFailure(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(Failure_FailureType_Failure_UnexpectedMessage, _("Seed already backed up"));
fsm_sendFailure(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(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmWord, true)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmWord, true)) {
if (!separated) {
storage_clear_update();
session_clear(true);
}
layoutHome();
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
return;
}
word_pos++;

@ -52,8 +52,8 @@ enum {
static uint32_t idx1, idx2;
static uint32_t signatures;
static TxRequest resp;
static TxAck_TransactionType_TxInputType input;
static TxAck_TransactionType_TxOutputBinType bin_output;
static TxInputType input;
static 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];
@ -211,7 +211,7 @@ void send_req_1_input(void)
{
signing_stage = STAGE_REQUEST_1_INPUT;
resp.has_request_type = true;
resp.request_type = TxRequest_RequestType_TXINPUT;
resp.request_type = RequestType_TXINPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx1;
@ -222,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 = TxRequest_RequestType_TXMETA;
resp.request_type = RequestType_TXMETA;
resp.has_details = true;
resp.details.has_tx_hash = true;
resp.details.tx_hash.size = input.prev_hash.size;
@ -234,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 = TxRequest_RequestType_TXINPUT;
resp.request_type = RequestType_TXINPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx2;
@ -248,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 = TxRequest_RequestType_TXOUTPUT;
resp.request_type = RequestType_TXOUTPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx2;
@ -262,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 = TxRequest_RequestType_TXEXTRADATA;
resp.request_type = RequestType_TXEXTRADATA;
resp.has_details = true;
resp.details.has_extra_data_offset = true;
resp.details.extra_data_offset = chunk_offset;
@ -278,7 +278,7 @@ void send_req_3_output(void)
{
signing_stage = STAGE_REQUEST_3_OUTPUT;
resp.has_request_type = true;
resp.request_type = TxRequest_RequestType_TXOUTPUT;
resp.request_type = RequestType_TXOUTPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx1;
@ -289,7 +289,7 @@ void send_req_4_input(void)
{
signing_stage = STAGE_REQUEST_4_INPUT;
resp.has_request_type = true;
resp.request_type = TxRequest_RequestType_TXINPUT;
resp.request_type = RequestType_TXINPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx2;
@ -300,7 +300,7 @@ void send_req_4_output(void)
{
signing_stage = STAGE_REQUEST_4_OUTPUT;
resp.has_request_type = true;
resp.request_type = TxRequest_RequestType_TXOUTPUT;
resp.request_type = RequestType_TXOUTPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx2;
@ -311,7 +311,7 @@ void send_req_segwit_input(void)
{
signing_stage = STAGE_REQUEST_SEGWIT_INPUT;
resp.has_request_type = true;
resp.request_type = TxRequest_RequestType_TXINPUT;
resp.request_type = RequestType_TXINPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx1;
@ -322,7 +322,7 @@ void send_req_segwit_witness(void)
{
signing_stage = STAGE_REQUEST_SEGWIT_WITNESS;
resp.has_request_type = true;
resp.request_type = TxRequest_RequestType_TXINPUT;
resp.request_type = RequestType_TXINPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx1;
@ -333,7 +333,7 @@ void send_req_decred_witness(void)
{
signing_stage = STAGE_REQUEST_DECRED_WITNESS;
resp.has_request_type = true;
resp.request_type = TxRequest_RequestType_TXINPUT;
resp.request_type = RequestType_TXINPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx1;
@ -344,7 +344,7 @@ void send_req_5_output(void)
{
signing_stage = STAGE_REQUEST_5_OUTPUT;
resp.has_request_type = true;
resp.request_type = TxRequest_RequestType_TXOUTPUT;
resp.request_type = RequestType_TXOUTPUT;
resp.has_details = true;
resp.details.has_request_index = true;
resp.details.request_index = idx1;
@ -354,7 +354,7 @@ void send_req_5_output(void)
void send_req_finished(void)
{
resp.has_request_type = true;
resp.request_type = TxRequest_RequestType_TXFINISHED;
resp.request_type = RequestType_TXFINISHED;
msg_write(MessageType_MessageType_TxRequest, &resp);
}
@ -385,7 +385,7 @@ void phase2_request_next_input(void)
}
}
void extract_input_bip32_path(const TxAck_TransactionType_TxInputType *tinput)
void extract_input_bip32_path(const TxInputType *tinput)
{
if (in_address_n_count == BIP32_NOCHANGEALLOWED) {
return;
@ -418,7 +418,7 @@ void extract_input_bip32_path(const TxAck_TransactionType_TxInputType *tinput)
}
}
bool check_change_bip32_path(const TxAck_TransactionType_TxOutputType *toutput)
bool check_change_bip32_path(const TxOutputType *toutput)
{
size_t count = toutput->address_n_count;
@ -435,7 +435,7 @@ bool check_change_bip32_path(const TxAck_TransactionType_TxOutputType *toutput)
&& toutput->address_n[count - 1] <= BIP32_MAX_LAST_ELEMENT);
}
bool compile_input_script_sig(TxAck_TransactionType_TxInputType *tinput)
bool compile_input_script_sig(TxInputType *tinput)
{
if (!multisig_fp_mismatch) {
// check that this is still multisig
@ -497,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(TxAck_TransactionType_TxInputType));
memset(&input, 0, sizeof(TxInputType));
memset(&resp, 0, sizeof(TxRequest));
signing = true;
@ -544,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(TxAck_TransactionType_TxInputType *txinput) {
static bool signing_check_input(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(Failure_FailureType_Failure_ProcessError, _("Error computing multisig fingerprint"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Error computing multisig fingerprint"));
signing_abort();
return false;
}
@ -573,7 +573,7 @@ static bool signing_check_input(TxAck_TransactionType_TxInputType *txinput) {
tx_sequence_hash(&hasher_sequence, txinput);
if (coin->decred) {
if (txinput->decred_script_version > 0) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Decred v1+ scripts are not supported"));
fsm_sendFailure(FailureType_Failure_DataError, _("Decred v1+ scripts are not supported"));
signing_abort();
return false;
}
@ -597,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(Failure_FailureType_Failure_DataError, _("Encountered invalid prevhash"));
fsm_sendFailure(FailureType_Failure_DataError, _("Encountered invalid prevhash"));
signing_abort();
return false;
}
@ -605,7 +605,7 @@ static bool signing_check_prevtx_hash(void) {
return true;
}
static bool signing_check_output(TxAck_TransactionType_TxOutputType *txoutput) {
static bool signing_check_output(TxOutputType *txoutput) {
// Phase1: Check outputs
// add it to hash_outputs
// ask user for permission
@ -614,7 +614,7 @@ static bool signing_check_output(TxAck_TransactionType_TxOutputType *txoutput) {
bool is_change = false;
if (txoutput->address_n_count > 0) {
if (txoutput->has_address) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Address in change output"));
fsm_sendFailure(FailureType_Failure_DataError, _("Address in change output"));
signing_abort();
return false;
}
@ -637,8 +637,8 @@ static bool signing_check_output(TxAck_TransactionType_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 == TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOWITNESS
|| txoutput->script_type == TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOP2SHWITNESS)
if ((txoutput->script_type == OutputScriptType_PAYTOWITNESS
|| txoutput->script_type == OutputScriptType_PAYTOP2SHWITNESS)
&& txoutput->amount > authorized_amount) {
is_change = false;
}
@ -654,7 +654,7 @@ static bool signing_check_output(TxAck_TransactionType_TxOutputType *txoutput) {
}
if (spending + txoutput->amount < spending) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Value overflow"));
fsm_sendFailure(FailureType_Failure_DataError, _("Value overflow"));
signing_abort();
return false;
}
@ -664,11 +664,11 @@ static bool signing_check_output(TxAck_TransactionType_TxOutputType *txoutput) {
layoutProgress(_("Signing transaction"), progress);
}
if (co < 0) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return false;
} else if (co == 0) {
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to compile output"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile output"));
signing_abort();
return false;
}
@ -689,23 +689,23 @@ static bool signing_check_output(TxAck_TransactionType_TxOutputType *txoutput) {
static bool signing_check_fee(void) {
// check fees
if (spending > to_spend) {
fsm_sendFailure(Failure_FailureType_Failure_NotEnoughFunds, _("Not enough funds"));
fsm_sendFailure(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(ButtonRequest_ButtonRequestType_ButtonRequest_FeeOverThreshold, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_FeeOverThreshold, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return false;
}
}
// last confirmation
layoutConfirmTx(coin, to_spend - change_spend, fee);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(Failure_FailureType_Failure_ActionCancelled, NULL);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return false;
}
@ -748,7 +748,7 @@ static void phase1_request_next_output(void) {
}
}
static void signing_hash_bip143(const TxAck_TransactionType_TxInputType *txinput, uint8_t *hash) {
static void signing_hash_bip143(const 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
@ -764,7 +764,7 @@ static void signing_hash_bip143(const TxAck_TransactionType_TxInputType *txinput
hasher_Final(&hasher_preimage, hash);
}
static void signing_hash_zip143(const TxAck_TransactionType_TxInputType *txinput, uint8_t *hash) {
static void signing_hash_zip143(const 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
@ -796,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(TxAck_TransactionType_TxInputType *txinput, const uint8_t* private_key, const uint8_t *public_key, const uint8_t *hash) {
static bool signing_sign_hash(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(Failure_FailureType_Failure_ProcessError, _("Signing failed"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Signing failed"));
signing_abort();
return false;
}
@ -813,7 +813,7 @@ static bool signing_sign_hash(TxAck_TransactionType_TxInputType *txinput, const
// fill in the signature
int pubkey_idx = cryptoMultisigPubkeyIndex(coin, &(txinput->multisig), public_key);
if (pubkey_idx < 0) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Pubkey not found in multisig script"));
fsm_sendFailure(FailureType_Failure_DataError, _("Pubkey not found in multisig script"));
signing_abort();
return false;
}
@ -821,7 +821,7 @@ static bool signing_sign_hash(TxAck_TransactionType_TxInputType *txinput, const
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(Failure_FailureType_Failure_ProcessError, _("Failed to serialize multisig script"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to serialize multisig script"));
signing_abort();
return false;
}
@ -835,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(Failure_FailureType_Failure_DataError, _("Transaction has changed during signing"));
fsm_sendFailure(FailureType_Failure_DataError, _("Transaction has changed during signing"));
signing_abort();
return false;
}
@ -850,19 +850,19 @@ static bool signing_sign_input(void) {
return true;
}
static bool signing_sign_segwit_input(TxAck_TransactionType_TxInputType *txinput) {
static bool signing_sign_segwit_input(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(Failure_FailureType_Failure_ProcessError, _("Failed to compile input"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile input"));
signing_abort();
return false;
}
if (txinput->amount > authorized_amount) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Transaction has changed during signing"));
fsm_sendFailure(FailureType_Failure_DataError, _("Transaction has changed during signing"));
signing_abort();
return false;
}
@ -918,7 +918,7 @@ static bool signing_sign_segwit_input(TxAck_TransactionType_TxInputType *txinput
return true;
}
static bool signing_sign_decred_input(TxAck_TransactionType_TxInputType *txinput) {
static bool signing_sign_decred_input(TxInputType *txinput) {
uint8_t hash[32], hash_witness[32];
tx_hash_final(&ti, hash_witness, false);
signing_hash_decred(hash_witness, hash);
@ -931,10 +931,10 @@ static bool signing_sign_decred_input(TxAck_TransactionType_TxInputType *txinput
#define ENABLE_SEGWIT_NONSEGWIT_MIXING 1
void signing_txack(TxAck_TransactionType *tx)
void signing_txack(TransactionType *tx)
{
if (!signing) {
fsm_sendFailure(Failure_FailureType_Failure_UnexpectedMessage, _("Not in Signing mode"));
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Not in Signing mode"));
layoutHome();
return;
}
@ -958,11 +958,11 @@ void signing_txack(TxAck_TransactionType *tx)
if (tx->inputs[0].script_type == InputScriptType_SPENDMULTISIG
|| tx->inputs[0].script_type == InputScriptType_SPENDADDRESS) {
memcpy(&input, tx->inputs, sizeof(TxAck_TransactionType_TxInputType));
memcpy(&input, tx->inputs, sizeof(TxInputType));
#if !ENABLE_SEGWIT_NONSEGWIT_MIXING
// don't mix segwit and non-segwit inputs
if (idx1 > 0 && to.is_segwit == true) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Mixing segwit and non-segwit inputs is not allowed"));
fsm_sendFailure(FailureType_Failure_DataError, _("Mixing segwit and non-segwit inputs is not allowed"));
signing_abort();
return;
}
@ -970,12 +970,12 @@ void signing_txack(TxAck_TransactionType *tx)
if (coin->force_bip143 || overwintered) {
if (!tx->inputs[0].has_amount) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("BIP/ZIP 143 input without amount"));
fsm_sendFailure(FailureType_Failure_DataError, _("BIP/ZIP 143 input without amount"));
signing_abort();
return;
}
if (to_spend + tx->inputs[0].amount < to_spend) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Value overflow"));
fsm_sendFailure(FailureType_Failure_DataError, _("Value overflow"));
signing_abort();
return;
}
@ -992,22 +992,22 @@ void signing_txack(TxAck_TransactionType *tx)
} else if (tx->inputs[0].script_type == InputScriptType_SPENDWITNESS
|| tx->inputs[0].script_type == InputScriptType_SPENDP2SHWITNESS) {
if (coin->decred) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Decred does not support Segwit"));
fsm_sendFailure(FailureType_Failure_DataError, _("Decred does not support Segwit"));
signing_abort();
return;
}
if (!coin->has_segwit) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Segwit not enabled on this coin"));
fsm_sendFailure(FailureType_Failure_DataError, _("Segwit not enabled on this coin"));
signing_abort();
return;
}
if (!tx->inputs[0].has_amount) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Segwit input without amount"));
fsm_sendFailure(FailureType_Failure_DataError, _("Segwit input without amount"));
signing_abort();
return;
}
if (to_spend + tx->inputs[0].amount < to_spend) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Value overflow"));
fsm_sendFailure(FailureType_Failure_DataError, _("Value overflow"));
signing_abort();
return;
}
@ -1019,7 +1019,7 @@ void signing_txack(TxAck_TransactionType *tx)
if (idx1 == 0) {
to.is_segwit = true;
} else if (to.is_segwit == false) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Mixing segwit and non-segwit inputs is not allowed"));
fsm_sendFailure(FailureType_Failure_DataError, _("Mixing segwit and non-segwit inputs is not allowed"));
signing_abort();
return;
}
@ -1030,19 +1030,19 @@ void signing_txack(TxAck_TransactionType *tx)
authorized_amount += tx->inputs[0].amount;
phase1_request_next_input();
} else {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Wrong input script type"));
fsm_sendFailure(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(Failure_FailureType_Failure_DataError, _("Not enough outputs in previous transaction."));
fsm_sendFailure(FailureType_Failure_DataError, _("Not enough outputs in previous transaction."));
signing_abort();
return;
}
if (tx->inputs_cnt + tx->outputs_cnt < tx->inputs_cnt) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Value overflow"));
fsm_sendFailure(FailureType_Failure_DataError, _("Value overflow"));
signing_abort();
return;
}
@ -1063,7 +1063,7 @@ void signing_txack(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(Failure_FailureType_Failure_ProcessError, _("Failed to serialize input"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to serialize input"));
signing_abort();
return;
}
@ -1078,18 +1078,18 @@ void signing_txack(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(Failure_FailureType_Failure_ProcessError, _("Failed to serialize output"));
fsm_sendFailure(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(Failure_FailureType_Failure_DataError, _("Value overflow"));
fsm_sendFailure(FailureType_Failure_DataError, _("Value overflow"));
signing_abort();
return;
}
if (coin->decred && tx->bin_outputs[0].decred_script_version > 0) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Decred script version does not match previous output"));
fsm_sendFailure(FailureType_Failure_DataError, _("Decred script version does not match previous output"));
signing_abort();
return;
}
@ -1109,7 +1109,7 @@ void signing_txack(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(Failure_FailureType_Failure_ProcessError, _("Failed to serialize extra data"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to serialize extra data"));
signing_abort();
return;
}
@ -1137,7 +1137,7 @@ void signing_txack(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(Failure_FailureType_Failure_ProcessError, _("Failed to compile input"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile input"));
signing_abort();
return;
}
@ -1153,7 +1153,7 @@ void signing_txack(TxAck_TransactionType *tx)
tx->inputs[0].script_sig.size = 0;
}
if (!tx_serialize_input_hash(&ti, tx->inputs)) {
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to serialize input"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to serialize input"));
signing_abort();
return;
}
@ -1164,7 +1164,7 @@ void signing_txack(TxAck_TransactionType *tx)
uint8_t hash[32];
hasher_Final(&hasher_check, hash);
if (memcmp(hash, hash_check, 32) != 0) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Transaction has changed during signing"));
fsm_sendFailure(FailureType_Failure_DataError, _("Transaction has changed during signing"));
signing_abort();
return;
}
@ -1176,14 +1176,14 @@ void signing_txack(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(Failure_FailureType_Failure_ProcessError, _("Failed to compile output"));
fsm_sendFailure(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(Failure_FailureType_Failure_ProcessError, _("Failed to serialize output"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to serialize output"));
signing_abort();
return;
}
@ -1217,17 +1217,17 @@ void signing_txack(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(Failure_FailureType_Failure_DataError, _("Transaction has changed during signing"));
fsm_sendFailure(FailureType_Failure_DataError, _("Transaction has changed during signing"));
signing_abort();
return;
}
if (!compile_input_script_sig(&tx->inputs[0])) {
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to compile input"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile input"));
signing_abort();
return;
}
if (tx->inputs[0].amount > authorized_amount) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Transaction has changed during signing"));
fsm_sendFailure(FailureType_Failure_DataError, _("Transaction has changed during signing"));
signing_abort();
return;
}
@ -1249,7 +1249,7 @@ void signing_txack(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(Failure_FailureType_Failure_ProcessError, _("Failed to compile input"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile input"));
signing_abort();
return;
}
@ -1268,7 +1268,7 @@ void signing_txack(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(Failure_FailureType_Failure_ProcessError, _("Failed to compile input"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile input"));
signing_abort();
return;
}
@ -1288,7 +1288,7 @@ void signing_txack(TxAck_TransactionType *tx)
case STAGE_REQUEST_5_OUTPUT:
if (compile_output(coin, root, tx->outputs, &bin_output,false) <= 0) {
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to compile output"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile output"));
signing_abort();
return;
}
@ -1337,7 +1337,7 @@ void signing_txack(TxAck_TransactionType *tx)
ti.version |= (DECRED_SERIALIZE_WITNESS_SIGNING << 16);
ti.is_decred = true;
if (!compile_input_script_sig(&tx->inputs[0])) {
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to compile input"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile input"));
signing_abort();
return;
}
@ -1351,7 +1351,7 @@ void signing_txack(TxAck_TransactionType *tx)
}
if (!r) {
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Failed to serialize input"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to serialize input"));
signing_abort();
return;
}
@ -1375,7 +1375,7 @@ void signing_txack(TxAck_TransactionType *tx)
return;
}
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, _("Signing error"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Signing error"));
signing_abort();
}

@ -29,6 +29,6 @@
void signing_init(const SignTx *msg, const CoinInfo *_coin, const HDNode *_root);
void signing_abort(void);
void signing_txack(TxAck_TransactionType *tx);
void signing_txack(TransactionType *tx);
#endif

@ -177,7 +177,7 @@ bool stellar_confirmSourceAccount(bool has_source_account, char *str_account)
str_addr_rows[1],
str_addr_rows[2]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -225,7 +225,7 @@ bool stellar_confirmCreateAccountOp(StellarCreateAccountOp *msg)
str_addr_rows[2],
str_amount_line
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -283,7 +283,7 @@ bool stellar_confirmPaymentOp(StellarPaymentOp *msg)
str_addr_rows[1],
str_addr_rows[2]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -352,7 +352,7 @@ bool stellar_confirmPathPaymentOp(StellarPathPaymentOp *msg)
str_dest_rows[1],
str_dest_rows[2]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -372,7 +372,7 @@ bool stellar_confirmPathPaymentOp(StellarPathPaymentOp *msg)
_("This is the amount debited"),
_("from your account.")
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -467,7 +467,7 @@ bool stellar_confirmManageOfferOp(StellarManageOfferOp *msg)
str_buying,
str_buying_asset
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -547,7 +547,7 @@ bool stellar_confirmCreatePassiveOfferOp(StellarCreatePassiveOfferOp *msg)
str_buying,
str_buying_asset
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -606,7 +606,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
str_addr_rows[1],
str_addr_rows[2]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -638,7 +638,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
rows[2],
rows[3]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -672,7 +672,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
rows[2],
rows[3]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -745,7 +745,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
rows[2],
rows[3]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -775,7 +775,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
NULL,
NULL
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -817,7 +817,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
str_addr_rows[1],
str_addr_rows[2]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -834,7 +834,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
_("(confirm hash on next"),
_("screen)")
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -851,7 +851,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
_("(confirm hash on next"),
_("screen)")
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -871,7 +871,7 @@ bool stellar_confirmSetOptionsOp(StellarSetOptionsOp *msg)
rows[2],
rows[3]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -931,7 +931,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(Failure_FailureType_Failure_ProcessError, _("Invalid asset issuer"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Invalid asset issuer"));
return false;
}
@ -945,7 +945,7 @@ bool stellar_confirmChangeTrustOp(StellarChangeTrustOp *msg)
str_addr_rows[1],
str_addr_rows[2]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -1006,7 +1006,7 @@ bool stellar_confirmAllowTrustOp(StellarAllowTrustOp *msg)
str_trustor_rows[1],
str_trustor_rows[2]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -1064,7 +1064,7 @@ bool stellar_confirmAccountMergeOp(StellarAccountMergeOp *msg)
str_destination_rows[1],
str_destination_rows[2]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -1107,7 +1107,7 @@ bool stellar_confirmManageDataOp(StellarManageDataOp *msg)
str_key_lines[2],
str_key_lines[3]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -1127,7 +1127,7 @@ bool stellar_confirmManageDataOp(StellarManageDataOp *msg)
str_hash_lines[2],
str_hash_lines[3]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -1173,7 +1173,7 @@ bool stellar_confirmBumpSequenceOp(StellarBumpSequenceOp *msg)
NULL,
NULL
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return false;
}
@ -1193,7 +1193,7 @@ void stellar_signingAbort(const char *reason)
}
stellar_signing = false;
fsm_sendFailure(Failure_FailureType_Failure_ProcessError, reason);
fsm_sendFailure(FailureType_Failure_ProcessError, reason);
layoutHome();
}
@ -1676,7 +1676,7 @@ void stellar_layoutTransactionSummary(StellarSignTx *msg)
str_addr_rows[1],
str_addr_rows[2]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return;
}
@ -1730,7 +1730,7 @@ void stellar_layoutTransactionSummary(StellarSignTx *msg)
str_lines[3],
str_lines[4]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return;
}
@ -1778,7 +1778,7 @@ void stellar_layoutTransactionSummary(StellarSignTx *msg)
str_lines[2],
str_lines[3]
);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ProtectCall, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
stellar_signingAbort(_("User canceled"));
return;
}

@ -186,22 +186,22 @@ bool compute_address(const CoinInfo *coin,
return 1;
}
int compile_output(const CoinInfo *coin, const HDNode *root, TxAck_TransactionType_TxOutputType *in, TxAck_TransactionType_TxOutputBinType *out, bool needs_confirm)
int compile_output(const CoinInfo *coin, const HDNode *root, TxOutputType *in, TxOutputBinType *out, bool needs_confirm)
{
memset(out, 0, sizeof(TxAck_TransactionType_TxOutputBinType));
memset(out, 0, sizeof(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 == TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOOPRETURN) {
if (in->script_type == 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(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return -1; // user aborted
}
}
@ -218,16 +218,16 @@ int compile_output(const CoinInfo *coin, const HDNode *root, TxAck_TransactionTy
InputScriptType input_script_type;
switch (in->script_type) {
case TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOADDRESS:
case OutputScriptType_PAYTOADDRESS:
input_script_type = InputScriptType_SPENDADDRESS;
break;
case TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOMULTISIG:
case OutputScriptType_PAYTOMULTISIG:
input_script_type = InputScriptType_SPENDMULTISIG;
break;
case TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOWITNESS:
case OutputScriptType_PAYTOWITNESS:
input_script_type = InputScriptType_SPENDWITNESS;
break;
case TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOP2SHWITNESS:
case OutputScriptType_PAYTOP2SHWITNESS:
input_script_type = InputScriptType_SPENDP2SHWITNESS;
break;
default:
@ -307,7 +307,7 @@ int compile_output(const CoinInfo *coin, const HDNode *root, TxAck_TransactionTy
if (needs_confirm) {
layoutConfirmOutput(coin, in);
if (!protectButton(ButtonRequest_ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
return -1; // user aborted
}
}
@ -420,7 +420,7 @@ uint32_t serialize_script_multisig(const CoinInfo *coin, const MultisigRedeemScr
// tx methods
uint32_t tx_prevout_hash(Hasher *hasher, const TxAck_TransactionType_TxInputType *input)
uint32_t tx_prevout_hash(Hasher *hasher, const TxInputType *input)
{
for (int i = 0; i < 32; i++) {
hasher_Update(hasher, &(input->prev_hash.bytes[31 - i]), 1);
@ -436,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 TxAck_TransactionType_TxInputType *input)
uint32_t tx_sequence_hash(Hasher *hasher, const TxInputType *input)
{
hasher_Update(hasher, (const uint8_t *)&input->sequence, 4);
return 4;
}
uint32_t tx_output_hash(Hasher *hasher, const TxAck_TransactionType_TxOutputBinType *output, bool decred)
uint32_t tx_output_hash(Hasher *hasher, const TxOutputBinType *output, bool decred)
{
uint32_t r = 0;
hasher_Update(hasher, (const uint8_t *)&output->amount, 8); r += 8;
@ -497,7 +497,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 TxAck_TransactionType_TxInputType *input, uint8_t *out)
uint32_t tx_serialize_input(TxStruct *tx, const TxInputType *input, uint8_t *out)
{
if (tx->have_inputs >= tx->inputs_len) {
// already got all inputs
@ -526,7 +526,7 @@ uint32_t tx_serialize_input(TxStruct *tx, const TxAck_TransactionType_TxInputTyp
return r;
}
uint32_t tx_serialize_input_hash(TxStruct *tx, const TxAck_TransactionType_TxInputType *input)
uint32_t tx_serialize_input_hash(TxStruct *tx, const TxInputType *input)
{
if (tx->have_inputs >= tx->inputs_len) {
// already got all inputs
@ -551,7 +551,7 @@ uint32_t tx_serialize_input_hash(TxStruct *tx, const TxAck_TransactionType_TxInp
return r;
}
uint32_t tx_serialize_decred_witness(TxStruct *tx, const TxAck_TransactionType_TxInputType *input, uint8_t *out)
uint32_t tx_serialize_decred_witness(TxStruct *tx, const TxInputType *input, uint8_t *out)
{
static const uint64_t amount = 0;
static const uint32_t block_height = 0x00000000;
@ -576,7 +576,7 @@ uint32_t tx_serialize_decred_witness(TxStruct *tx, const TxAck_TransactionType_T
return r;
}
uint32_t tx_serialize_decred_witness_hash(TxStruct *tx, const TxAck_TransactionType_TxInputType *input)
uint32_t tx_serialize_decred_witness_hash(TxStruct *tx, const TxInputType *input)
{
if (tx->have_inputs >= tx->inputs_len) {
// already got all inputs
@ -638,7 +638,7 @@ uint32_t tx_serialize_footer_hash(TxStruct *tx)
return 4;
}
uint32_t tx_serialize_output(TxStruct *tx, const TxAck_TransactionType_TxOutputBinType *output, uint8_t *out)
uint32_t tx_serialize_output(TxStruct *tx, const TxOutputBinType *output, uint8_t *out)
{
if (tx->have_inputs < tx->inputs_len) {
// not all inputs provided
@ -667,7 +667,7 @@ uint32_t tx_serialize_output(TxStruct *tx, const TxAck_TransactionType_TxOutputB
return r;
}
uint32_t tx_serialize_output_hash(TxStruct *tx, const TxAck_TransactionType_TxOutputBinType *output)
uint32_t tx_serialize_output_hash(TxStruct *tx, const TxOutputBinType *output)
{
if (tx->have_inputs < tx->inputs_len) {
// not all inputs provided
@ -741,7 +741,7 @@ void tx_hash_final(TxStruct *t, uint8_t *hash, bool reverse)
}
}
static uint32_t tx_input_script_size(const TxAck_TransactionType_TxInputType *txinput) {
static uint32_t tx_input_script_size(const TxInputType *txinput) {
uint32_t input_script_size;
if (txinput->has_multisig) {
uint32_t multisig_script_size = TXSIZE_MULTISIGSCRIPT
@ -756,7 +756,7 @@ static uint32_t tx_input_script_size(const TxAck_TransactionType_TxInputType *tx
return input_script_size;
}
uint32_t tx_input_weight(const CoinInfo *coin, const TxAck_TransactionType_TxInputType *txinput) {
uint32_t tx_input_weight(const CoinInfo *coin, const TxInputType *txinput) {
if (coin->decred) {
return 4 * (TXSIZE_INPUT + 1); // Decred tree
}
@ -780,16 +780,16 @@ uint32_t tx_input_weight(const CoinInfo *coin, const TxAck_TransactionType_TxInp
return weight;
}
uint32_t tx_output_weight(const CoinInfo *coin, const TxAck_TransactionType_TxOutputType *txoutput) {
uint32_t tx_output_weight(const CoinInfo *coin, const TxOutputType *txoutput) {
uint32_t output_script_size = 0;
if (txoutput->script_type == TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOOPRETURN) {
if (txoutput->script_type == 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 == TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOWITNESS) {
if (txoutput->script_type == OutputScriptType_PAYTOWITNESS) {
output_script_size = txoutput->has_multisig
? TXSIZE_WITNESSSCRIPT : TXSIZE_WITNESSPKHASH;
} else if (txoutput->script_type == TxAck_TransactionType_TxOutputType_OutputScriptType_PAYTOP2SHWITNESS) {
} else if (txoutput->script_type == OutputScriptType_PAYTOP2SHWITNESS) {
output_script_size = TXSIZE_P2SCRIPT;
} else {
output_script_size = txoutput->has_multisig
@ -832,7 +832,7 @@ uint32_t tx_output_weight(const CoinInfo *coin, const TxAck_TransactionType_TxOu
return 4 * (size + output_script_size);
}
uint32_t tx_decred_witness_weight(const TxAck_TransactionType_TxInputType *txinput) {
uint32_t tx_decred_witness_weight(const 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;

@ -59,29 +59,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, TxAck_TransactionType_TxOutputType *in, TxAck_TransactionType_TxOutputBinType *out, bool needs_confirm);
int compile_output(const CoinInfo *coin, const HDNode *root, TxOutputType *in, TxOutputBinType *out, bool needs_confirm);
uint32_t tx_prevout_hash(Hasher *hasher, const TxAck_TransactionType_TxInputType *input);
uint32_t tx_prevout_hash(Hasher *hasher, const TxInputType *input);
uint32_t tx_script_hash(Hasher *hasher, uint32_t size, const uint8_t *data);
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_sequence_hash(Hasher *hasher, const TxInputType *input);
uint32_t tx_output_hash(Hasher *hasher, const 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 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);
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);
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 version_group_id);
uint32_t tx_serialize_header_hash(TxStruct *tx);
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_input_hash(TxStruct *tx, const TxInputType *input);
uint32_t tx_serialize_output_hash(TxStruct *tx, const 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 TxAck_TransactionType_TxInputType *input);
uint32_t tx_serialize_decred_witness_hash(TxStruct *tx, const TxInputType *input);
void tx_hash_final(TxStruct *t, uint8_t *hash, bool reverse);
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);
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);
#endif

2
vendor/nanopb vendored

@ -1 +1 @@
Subproject commit 71ba4e68da4b3c986d454e34c4666a82fbdf4176
Subproject commit 37cdb0df67b2adc1c70b3b5e6bc26657f844c1dd
Loading…
Cancel
Save