diff --git a/CMakeLists.txt b/CMakeLists.txt index 9123b96a..1e9a85c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.7.2) project( KeepKeyFirmware - VERSION 7.9.1 + VERSION 7.9.2 LANGUAGES C CXX ASM) set(BOOTLOADER_MAJOR_VERSION 2) diff --git a/deps/device-protocol b/deps/device-protocol index f534ff20..b664c9ce 160000 --- a/deps/device-protocol +++ b/deps/device-protocol @@ -1 +1 @@ -Subproject commit f534ff20fddb63d274eee866acdadad65ca35cf6 +Subproject commit b664c9cea29d8fdd75edeb550c1d0293b2ddeafb diff --git a/include/keepkey/firmware/mayachain.h b/include/keepkey/firmware/mayachain.h index f2942f21..6c2cf2b5 100644 --- a/include/keepkey/firmware/mayachain.h +++ b/include/keepkey/firmware/mayachain.h @@ -11,7 +11,7 @@ typedef struct _MayachainSignTx MayachainSignTx; typedef struct _MayachainMsgDeposit MayachainMsgDeposit; bool mayachain_signTxInit(const HDNode *_node, const MayachainSignTx *_msg); -bool mayachain_signTxUpdateMsgSend(const uint64_t amount, const char *to_address); +bool mayachain_signTxUpdateMsgSend(const uint64_t amount, const char *to_address, const char *denom); bool mayachain_signTxUpdateMsgDeposit(const MayachainMsgDeposit *depmsg); bool mayachain_signTxFinalize(uint8_t *public_key, uint8_t *signature); bool mayachain_signingIsInited(void); diff --git a/include/keepkey/transport/messages-mayachain.options b/include/keepkey/transport/messages-mayachain.options index eff57e25..05fab267 100644 --- a/include/keepkey/transport/messages-mayachain.options +++ b/include/keepkey/transport/messages-mayachain.options @@ -8,6 +8,7 @@ MayachainSignTx.memo max_size:256 MayachainMsgSend.from_address max_size:46 MayachainMsgSend.to_address max_size:46 +MayachainMsgSend.denom max_size:69 MayachainMsgDeposit.asset max_size:20 MayachainMsgDeposit.memo max_size:256 diff --git a/lib/firmware/fsm_msg_mayachain.h b/lib/firmware/fsm_msg_mayachain.h index 8d76e5d4..359e0e6d 100644 --- a/lib/firmware/fsm_msg_mayachain.h +++ b/lib/firmware/fsm_msg_mayachain.h @@ -119,7 +119,7 @@ void fsm_msgMayachainMsgAck(const MayachainMsgAck *msg) { // Confirm transaction basics // supports only 1 message ack CHECK_PARAM(mayachain_signingIsInited(), "Signing not in progress"); - if (msg->has_send && msg->send.has_to_address && msg->send.has_amount) { + if (msg->has_send && msg->send.has_to_address && msg->send.has_amount && msg->send.has_denom) { // pass } else if (msg->has_deposit && msg->deposit.has_asset && msg->deposit.has_amount && msg->deposit.has_memo && @@ -145,7 +145,9 @@ void fsm_msgMayachainMsgAck(const MayachainMsgAck *msg) { case OutputAddressType_TRANSFER: default: { char amount_str[32]; - bn_format_uint64(msg->send.amount, NULL, " cacao", 10, 0, false, + char denom_str[71]; + sprintf(denom_str, " %s", msg->send.denom); + bn_format_uint64(msg->send.amount, NULL, denom_str, 10, 0, false, amount_str, sizeof(amount_str)); if (!confirm_transaction_output( ButtonRequestType_ButtonRequest_ConfirmOutput, amount_str, @@ -160,7 +162,8 @@ void fsm_msgMayachainMsgAck(const MayachainMsgAck *msg) { } } if (!mayachain_signTxUpdateMsgSend(msg->send.amount, - msg->send.to_address)) { + msg->send.to_address, + msg->send.denom)) { mayachain_signAbort(); fsm_sendFailure(FailureType_Failure_SyntaxError, "Failed to include send message in transaction"); @@ -240,8 +243,8 @@ void fsm_msgMayachainMsgAck(const MayachainMsgAck *msg) { } if (!confirm(ButtonRequestType_ButtonRequest_SignTx, node_str, - "Sign this CACAO transaction on %s? " - "Additional network fees apply.", + "Sign this %s transaction on %s? " + "Additional network fees apply.", msg->has_send ? msg->send.denom : "CACAO", sign_tx->chain_id)) { mayachain_signAbort(); fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); diff --git a/lib/firmware/mayachain.c b/lib/firmware/mayachain.c index 669fdfd2..e0b8a08e 100644 --- a/lib/firmware/mayachain.c +++ b/lib/firmware/mayachain.c @@ -95,7 +95,8 @@ bool mayachain_signTxInit(const HDNode *_node, const MayachainSignTx *_msg) { } bool mayachain_signTxUpdateMsgSend(const uint64_t amount, - const char *to_address) { + const char *to_address, + const char *denom) { char mainnetp[] = "maya"; char testnetp[] = "smaya"; char *pfix; @@ -124,10 +125,10 @@ bool mayachain_signTxUpdateMsgSend(const uint64_t amount, const char *const prelude = "{\"type\":\"mayachain/MsgSend\",\"value\":{"; sha256_Update(&ctx, (uint8_t *)prelude, strlen(prelude)); - // 21 + ^20 + 19 = ^60 + // 21 + ^20 + 11 + ^69 + 3 = ^124 success &= tendermint_snprintf( &ctx, buffer, sizeof(buffer), - "\"amount\":[{\"amount\":\"%" PRIu64 "\",\"denom\":\"cacao\"}]", amount); + "\"amount\":[{\"amount\":\"%" PRIu64 "\",\"denom\":\"%s\"}]", amount, denom); // 17 + 45 + 1 = 63 success &= tendermint_snprintf(&ctx, buffer, sizeof(buffer),