From 3312fa3aadceab08d2d2cd12f92c1a472c013642 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Mon, 17 Oct 2016 14:34:42 +0200 Subject: [PATCH] [Steem] Add 'account_update' operations --- firmware/fsm.c | 141 +++++++++++++++++++++++++------ firmware/protob/messages.options | 8 +- firmware/protob/messages.pb.c | 41 +++++++-- firmware/protob/messages.pb.h | 107 ++++++++++++++++++----- firmware/protob/types.pb.c | 3 +- firmware/protob/types.pb.h | 22 ++--- firmware/steem.c | 32 +++++++ firmware/steem.h | 3 + vendor/trezor-common | 2 +- 9 files changed, 288 insertions(+), 71 deletions(-) diff --git a/firmware/fsm.c b/firmware/fsm.c index 6b77adb82..15618e222 100644 --- a/firmware/fsm.c +++ b/firmware/fsm.c @@ -1087,18 +1087,28 @@ void fsm_msgSteemSignTx(SteemSignTx *msg) { RESP_INIT(SteemTxSignature); - layout_steem_confirm_transfer( - msg->transfer.from, - msg->transfer.to, - msg->transfer.asset, - msg->transfer.amount - ); - // true: right, false: left - if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) { - fsm_sendFailure(FailureType_Failure_ActionCancelled, "Signing Canceled"); - layoutHome(); - return; - } + if (msg->has_transfer) { + layout_steem_confirm_transfer( + msg->transfer.from, + msg->transfer.to, + msg->transfer.asset, + msg->transfer.amount + ); + // true: right, false: left + if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) { + fsm_sendFailure(FailureType_Failure_ActionCancelled, "Signing Canceled"); + layoutHome(); + return; + } + } else if (msg->has_account_update) { + layout_steem_confirm_account_update(msg->account_update.account); + // true: right, false: left + if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) { + fsm_sendFailure(FailureType_Failure_ActionCancelled, "Signing Canceled"); + layoutHome(); + return; + } + } const uint8_t chainid[32] = {0}; @@ -1112,22 +1122,101 @@ void fsm_msgSteemSignTx(SteemSignTx *msg) gph_ser_varint(&ctx, 1); // one operation - /** - * Transfer specific - */ - gph_ser_varint(&ctx, 2); // transfer operation - gph_ser_string(&ctx, msg->transfer.from); - gph_ser_string(&ctx, msg->transfer.to); - if(steem_ser_amount(&ctx, msg->transfer.amount, msg->transfer.asset)) - { - fsm_sendFailure(FailureType_Failure_Other, "Unknown Asset"); - } - if (msg->transfer.has_memo && msg->transfer.memo) { - gph_ser_string(&ctx, msg->transfer.memo); - } + /** + * transfer specific + */ + if (msg->has_transfer) { + gph_ser_varint(&ctx, 2); // transfer operation + gph_ser_string(&ctx, msg->transfer.from); + gph_ser_string(&ctx, msg->transfer.to); + if(steem_ser_amount(&ctx, msg->transfer.amount, msg->transfer.asset)) + { + fsm_sendFailure(FailureType_Failure_Other, "Unknown Asset"); + } + if (msg->transfer.has_memo) { + gph_ser_string(&ctx, msg->transfer.memo); + } else { + gph_ser_string(&ctx, ""); + } + + /** + * account_update specific + */ + } else if (msg->has_account_update) { + gph_ser_varint(&ctx, 10); // account_update + // account + gph_ser_string(&ctx, msg->account_update.account); + // owner + gph_ser_bool(&ctx, msg->account_update.has_owner); // Optional(owner) + if (msg->account_update.has_owner) + { + // weight_threshold + gph_ser_int32(&ctx, msg->account_update.owner.weight_threshold); + // account_auths + gph_ser_varint(&ctx, msg->account_update.owner.account_auths_count); + for ( uint8_t i = 0; i < msg->account_update.owner.account_auths_count; ++i) + { + gph_ser_string(&ctx, msg->account_update.owner.account_auths[i].account); + gph_ser_int16(&ctx, msg->account_update.owner.account_auths[i].weight); + } + // key_auths + gph_ser_varint(&ctx, msg->account_update.owner.key_auths_count); + for ( uint8_t i = 0; i < msg->account_update.owner.key_auths_count; ++i) + { + gph_ser_bytes(&ctx, msg->account_update.owner.key_auths[i].pubkey.bytes, 33); + gph_ser_int16(&ctx, msg->account_update.owner.key_auths[i].weight); + } + } + // active + gph_ser_bool(&ctx, msg->account_update.has_active); // Optional(active) + if (msg->account_update.has_active) + { + // weight_threshold + gph_ser_int32(&ctx, msg->account_update.active.weight_threshold); + // account_auths + gph_ser_varint(&ctx, msg->account_update.active.account_auths_count); + for ( uint8_t i = 0; i < msg->account_update.active.account_auths_count; ++i) + { + gph_ser_string(&ctx, msg->account_update.active.account_auths[i].account); + gph_ser_int16(&ctx, msg->account_update.active.account_auths[i].weight); + } + // key_auths + gph_ser_varint(&ctx, msg->account_update.active.key_auths_count); + for ( uint8_t i = 0; i < msg->account_update.active.key_auths_count; ++i) + { + gph_ser_bytes(&ctx, msg->account_update.active.key_auths[i].pubkey.bytes, 33); + gph_ser_int16(&ctx, msg->account_update.active.key_auths[i].weight); + } + } + // posting + gph_ser_bool(&ctx, msg->account_update.has_posting); // Optional(posting) + if (msg->account_update.has_posting) + { + // weight_threshold + gph_ser_int32(&ctx, msg->account_update.posting.weight_threshold); + // account_auths + gph_ser_varint(&ctx, msg->account_update.posting.account_auths_count); + for ( uint8_t i = 0; i < msg->account_update.posting.account_auths_count; ++i) + { + gph_ser_string(&ctx, msg->account_update.posting.account_auths[i].account); + gph_ser_int16(&ctx, msg->account_update.posting.account_auths[i].weight); + } + // key_auths + gph_ser_varint(&ctx, msg->account_update.posting.key_auths_count); + for ( uint8_t i = 0; i < msg->account_update.posting.key_auths_count; ++i) + { + gph_ser_bytes(&ctx, msg->account_update.posting.key_auths[i].pubkey.bytes, 33); + gph_ser_int16(&ctx, msg->account_update.posting.key_auths[i].weight); + } + } + // memo_key + gph_ser_bytes(&ctx, msg->account_update.memo_key.bytes, 33); + // json_metadata + gph_ser_string(&ctx, ""); + } /** - * End of transfer specific + * End of operation specific */ gph_ser_varint(&ctx, 0); // extension diff --git a/firmware/protob/messages.options b/firmware/protob/messages.options index e9d463b4e..7409a7576 100644 --- a/firmware/protob/messages.options +++ b/firmware/protob/messages.options @@ -42,8 +42,14 @@ SteemOperationTransfer.from max_size:16 SteemOperationTransfer.to max_size:16 SteemOperationTransfer.asset max_size:8 SteemOperationTransfer.memo max_size:64 +SteemOperationAccountUpdate.account max_size:16 +SteemOperationAccountUpdate.memo_key max_size:33 +SteemOperationAccountUpdate.json_metadata max_size:256 +SteemPermission.account_auths max_count:4 +SteemPermission.key_auths max_count:4 +SteemAccountKeyAuth.pubkey max_size:33 +SteemAccountAccountAuth.account max_size:16 SteemPublicKey.pubkey max_size:33 -SteemPublicKey.address max_size:20 SteemTxSignature.signature max_size:65 SteemTxSignature.digest max_size:32 diff --git a/firmware/protob/messages.pb.c b/firmware/protob/messages.pb.c index ff0d0cf1b..09d3ee477 100644 --- a/firmware/protob/messages.pb.c +++ b/firmware/protob/messages.pb.c @@ -4,7 +4,6 @@ #include "messages.pb.h" const char GetAddress_coin_name_default[17] = "Bitcoin"; -const InputScriptType GetAddress_script_type_default = InputScriptType_SPENDADDRESS; const char LoadDevice_language_default[17] = "english"; const uint32_t ResetDevice_strength_default = 256u; const char ResetDevice_language_default[17] = "english"; @@ -29,7 +28,7 @@ const pb_field_t GetFeatures_fields[1] = { PB_LAST_FIELD }; -const pb_field_t Features_fields[19] = { +const pb_field_t Features_fields[18] = { PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, Features, vendor, vendor, 0), PB_FIELD2( 2, UINT32 , OPTIONAL, STATIC , OTHER, Features, major_version, vendor, 0), PB_FIELD2( 3, UINT32 , OPTIONAL, STATIC , OTHER, Features, minor_version, major_version, 0), @@ -47,7 +46,6 @@ const pb_field_t Features_fields[19] = { PB_FIELD2( 15, BOOL , OPTIONAL, STATIC , OTHER, Features, imported, bootloader_hash, 0), PB_FIELD2( 16, BOOL , OPTIONAL, STATIC , OTHER, Features, pin_cached, imported, 0), PB_FIELD2( 17, BOOL , OPTIONAL, STATIC , OTHER, Features, passphrase_cached, pin_cached, 0), - PB_FIELD2( 18, BOOL , OPTIONAL, STATIC , OTHER, Features, firmware_present, passphrase_cached, 0), PB_LAST_FIELD }; @@ -143,12 +141,11 @@ const pb_field_t PublicKey_fields[3] = { PB_LAST_FIELD }; -const pb_field_t GetAddress_fields[6] = { +const pb_field_t GetAddress_fields[5] = { PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, GetAddress, address_n, address_n, 0), PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, GetAddress, coin_name, address_n, &GetAddress_coin_name_default), PB_FIELD2( 3, BOOL , OPTIONAL, STATIC , OTHER, GetAddress, show_display, coin_name, 0), PB_FIELD2( 4, MESSAGE , OPTIONAL, STATIC , OTHER, GetAddress, multisig, show_display, &MultisigRedeemScriptType_fields), - PB_FIELD2( 5, ENUM , OPTIONAL, STATIC , OTHER, GetAddress, script_type, multisig, &GetAddress_script_type_default), PB_LAST_FIELD }; @@ -454,6 +451,35 @@ const pb_field_t DebugLinkFlashErase_fields[2] = { PB_LAST_FIELD }; +const pb_field_t SteemAccountKeyAuth_fields[3] = { + PB_FIELD2( 1, BYTES , REQUIRED, STATIC , FIRST, SteemAccountKeyAuth, pubkey, pubkey, 0), + PB_FIELD2( 2, UINT32 , REQUIRED, STATIC , OTHER, SteemAccountKeyAuth, weight, pubkey, 0), + PB_LAST_FIELD +}; + +const pb_field_t SteemAccountAccountAuth_fields[3] = { + PB_FIELD2( 1, STRING , REQUIRED, STATIC , FIRST, SteemAccountAccountAuth, account, account, 0), + PB_FIELD2( 2, UINT32 , REQUIRED, STATIC , OTHER, SteemAccountAccountAuth, weight, account, 0), + PB_LAST_FIELD +}; + +const pb_field_t SteemPermission_fields[4] = { + PB_FIELD2( 1, UINT32 , REQUIRED, STATIC , FIRST, SteemPermission, weight_threshold, weight_threshold, 0), + PB_FIELD2( 2, MESSAGE , REPEATED, STATIC , OTHER, SteemPermission, account_auths, weight_threshold, &SteemAccountAccountAuth_fields), + PB_FIELD2( 3, MESSAGE , REPEATED, STATIC , OTHER, SteemPermission, key_auths, account_auths, &SteemAccountKeyAuth_fields), + PB_LAST_FIELD +}; + +const pb_field_t SteemOperationAccountUpdate_fields[7] = { + PB_FIELD2( 1, STRING , REQUIRED, STATIC , FIRST, SteemOperationAccountUpdate, account, account, 0), + PB_FIELD2( 2, BYTES , REQUIRED, STATIC , OTHER, SteemOperationAccountUpdate, memo_key, account, 0), + PB_FIELD2( 3, STRING , REQUIRED, STATIC , OTHER, SteemOperationAccountUpdate, json_metadata, memo_key, 0), + PB_FIELD2( 4, MESSAGE , OPTIONAL, STATIC , OTHER, SteemOperationAccountUpdate, owner, json_metadata, &SteemPermission_fields), + PB_FIELD2( 5, MESSAGE , OPTIONAL, STATIC , OTHER, SteemOperationAccountUpdate, active, owner, &SteemPermission_fields), + PB_FIELD2( 6, MESSAGE , OPTIONAL, STATIC , OTHER, SteemOperationAccountUpdate, posting, active, &SteemPermission_fields), + PB_LAST_FIELD +}; + const pb_field_t SteemOperationTransfer_fields[6] = { PB_FIELD2( 1, STRING , REQUIRED, STATIC , FIRST, SteemOperationTransfer, from, from, 0), PB_FIELD2( 2, STRING , REQUIRED, STATIC , OTHER, SteemOperationTransfer, to, from, 0), @@ -463,11 +489,12 @@ const pb_field_t SteemOperationTransfer_fields[6] = { PB_LAST_FIELD }; -const pb_field_t SteemSignTx_fields[5] = { +const pb_field_t SteemSignTx_fields[6] = { PB_FIELD2( 1, UINT32 , REQUIRED, STATIC , FIRST, SteemSignTx, ref_block_num, ref_block_num, 0), PB_FIELD2( 2, UINT32 , REQUIRED, STATIC , OTHER, SteemSignTx, ref_block_prefix, ref_block_num, 0), PB_FIELD2( 3, UINT32 , REQUIRED, STATIC , OTHER, SteemSignTx, expiration, ref_block_prefix, 0), PB_FIELD2( 4, MESSAGE , OPTIONAL, STATIC , OTHER, SteemSignTx, transfer, expiration, &SteemOperationTransfer_fields), + PB_FIELD2( 5, MESSAGE , OPTIONAL, STATIC , OTHER, SteemSignTx, account_update, transfer, &SteemOperationAccountUpdate_fields), PB_LAST_FIELD }; @@ -498,7 +525,7 @@ const pb_field_t SteemPublicKey_fields[2] = { * numbers or field sizes that are larger than what can fit in 8 or 16 bit * field descriptors. */ -STATIC_ASSERT((pb_membersize(Features, coins[0]) < 65536 && pb_membersize(PublicKey, node) < 65536 && pb_membersize(GetAddress, multisig) < 65536 && pb_membersize(LoadDevice, node) < 65536 && pb_membersize(SimpleSignTx, inputs[0]) < 65536 && pb_membersize(SimpleSignTx, outputs[0]) < 65536 && pb_membersize(SimpleSignTx, transactions[0]) < 65536 && pb_membersize(TxRequest, details) < 65536 && pb_membersize(TxRequest, serialized) < 65536 && pb_membersize(TxAck, tx) < 65536 && pb_membersize(SignIdentity, identity) < 65536 && pb_membersize(GetECDHSessionKey, identity) < 65536 && pb_membersize(DebugLinkState, node) < 65536 && pb_membersize(SteemSignTx, transfer) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_Initialize_GetFeatures_Features_ClearSession_ApplySettings_ChangePin_Ping_Success_Failure_ButtonRequest_ButtonAck_PinMatrixRequest_PinMatrixAck_Cancel_PassphraseRequest_PassphraseAck_GetEntropy_Entropy_GetPublicKey_PublicKey_GetAddress_EthereumGetAddress_Address_EthereumAddress_WipeDevice_LoadDevice_ResetDevice_EntropyRequest_EntropyAck_RecoveryDevice_WordRequest_WordAck_SignMessage_VerifyMessage_MessageSignature_EncryptMessage_EncryptedMessage_DecryptMessage_DecryptedMessage_CipherKeyValue_CipheredKeyValue_EstimateTxSize_TxSize_SignTx_SimpleSignTx_TxRequest_TxAck_EthereumSignTx_EthereumTxRequest_EthereumTxAck_SignIdentity_SignedIdentity_GetECDHSessionKey_ECDHSessionKey_SetU2FCounter_FirmwareErase_FirmwareUpload_DebugLinkDecision_DebugLinkGetState_DebugLinkState_DebugLinkStop_DebugLinkLog_DebugLinkMemoryRead_DebugLinkMemory_DebugLinkMemoryWrite_DebugLinkFlashErase_SteemOperationTransfer_SteemSignTx_SteemTxSignature_SteemGetPublicKey_SteemPublicKey) +STATIC_ASSERT((pb_membersize(Features, coins[0]) < 65536 && pb_membersize(PublicKey, node) < 65536 && pb_membersize(GetAddress, multisig) < 65536 && pb_membersize(LoadDevice, node) < 65536 && pb_membersize(SimpleSignTx, inputs[0]) < 65536 && pb_membersize(SimpleSignTx, outputs[0]) < 65536 && pb_membersize(SimpleSignTx, transactions[0]) < 65536 && pb_membersize(TxRequest, details) < 65536 && pb_membersize(TxRequest, serialized) < 65536 && pb_membersize(TxAck, tx) < 65536 && pb_membersize(SignIdentity, identity) < 65536 && pb_membersize(GetECDHSessionKey, identity) < 65536 && pb_membersize(DebugLinkState, node) < 65536 && pb_membersize(SteemPermission, account_auths[0]) < 65536 && pb_membersize(SteemPermission, key_auths[0]) < 65536 && pb_membersize(SteemOperationAccountUpdate, owner) < 65536 && pb_membersize(SteemOperationAccountUpdate, active) < 65536 && pb_membersize(SteemOperationAccountUpdate, posting) < 65536 && pb_membersize(SteemSignTx, transfer) < 65536 && pb_membersize(SteemSignTx, account_update) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_Initialize_GetFeatures_Features_ClearSession_ApplySettings_ChangePin_Ping_Success_Failure_ButtonRequest_ButtonAck_PinMatrixRequest_PinMatrixAck_Cancel_PassphraseRequest_PassphraseAck_GetEntropy_Entropy_GetPublicKey_PublicKey_GetAddress_EthereumGetAddress_Address_EthereumAddress_WipeDevice_LoadDevice_ResetDevice_EntropyRequest_EntropyAck_RecoveryDevice_WordRequest_WordAck_SignMessage_VerifyMessage_MessageSignature_EncryptMessage_EncryptedMessage_DecryptMessage_DecryptedMessage_CipherKeyValue_CipheredKeyValue_EstimateTxSize_TxSize_SignTx_SimpleSignTx_TxRequest_TxAck_EthereumSignTx_EthereumTxRequest_EthereumTxAck_SignIdentity_SignedIdentity_GetECDHSessionKey_ECDHSessionKey_SetU2FCounter_FirmwareErase_FirmwareUpload_DebugLinkDecision_DebugLinkGetState_DebugLinkState_DebugLinkStop_DebugLinkLog_DebugLinkMemoryRead_DebugLinkMemory_DebugLinkMemoryWrite_DebugLinkFlashErase_SteemAccountKeyAuth_SteemAccountAccountAuth_SteemPermission_SteemOperationAccountUpdate_SteemOperationTransfer_SteemSignTx_SteemTxSignature_SteemGetPublicKey_SteemPublicKey) #endif #if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) diff --git a/firmware/protob/messages.pb.h b/firmware/protob/messages.pb.h index 9d01610fb..cd154c48f 100644 --- a/firmware/protob/messages.pb.h +++ b/firmware/protob/messages.pb.h @@ -74,6 +74,10 @@ typedef enum _MessageType { MessageType_MessageType_SteemTxSignature = 66, MessageType_MessageType_SteemSignTx = 67, MessageType_MessageType_SteemOperationTransfer = 68, + MessageType_MessageType_SteemOperationAccountUpdate = 69, + MessageType_MessageType_SteemPermission = 70, + MessageType_MessageType_SteemAccountAccountAuth = 71, + MessageType_MessageType_SteemAccountKeyAuth = 72, MessageType_MessageType_DebugLinkDecision = 100, MessageType_MessageType_DebugLinkGetState = 101, MessageType_MessageType_DebugLinkState = 102, @@ -554,8 +558,6 @@ typedef struct _Features { bool pin_cached; bool has_passphrase_cached; bool passphrase_cached; - bool has_firmware_present; - bool firmware_present; } Features; typedef struct { @@ -576,8 +578,6 @@ typedef struct _GetAddress { bool show_display; bool has_multisig; MultisigRedeemScriptType multisig; - bool has_script_type; - InputScriptType script_type; } GetAddress; typedef struct { @@ -775,6 +775,21 @@ typedef struct _SimpleSignTx { uint32_t lock_time; } SimpleSignTx; +typedef struct _SteemAccountAccountAuth { + char account[16]; + uint32_t weight; +} SteemAccountAccountAuth; + +typedef struct { + size_t size; + uint8_t bytes[33]; +} SteemAccountKeyAuth_pubkey_t; + +typedef struct _SteemAccountKeyAuth { + SteemAccountKeyAuth_pubkey_t pubkey; + uint32_t weight; +} SteemAccountKeyAuth; + typedef struct _SteemGetPublicKey { size_t address_n_count; uint32_t address_n[8]; @@ -865,17 +880,43 @@ typedef struct _WordAck { char word[12]; } WordAck; +typedef struct _SteemPermission { + uint32_t weight_threshold; + size_t account_auths_count; + SteemAccountAccountAuth account_auths[4]; + size_t key_auths_count; + SteemAccountKeyAuth key_auths[4]; +} SteemPermission; + +typedef struct { + size_t size; + uint8_t bytes[33]; +} SteemOperationAccountUpdate_memo_key_t; + +typedef struct _SteemOperationAccountUpdate { + char account[16]; + SteemOperationAccountUpdate_memo_key_t memo_key; + char json_metadata[256]; + bool has_owner; + SteemPermission owner; + bool has_active; + SteemPermission active; + bool has_posting; + SteemPermission posting; +} SteemOperationAccountUpdate; + typedef struct _SteemSignTx { uint32_t ref_block_num; uint32_t ref_block_prefix; uint32_t expiration; bool has_transfer; SteemOperationTransfer transfer; + bool has_account_update; + SteemOperationAccountUpdate account_update; } SteemSignTx; /* Default values for struct fields */ extern const char GetAddress_coin_name_default[17]; -extern const InputScriptType GetAddress_script_type_default; extern const char LoadDevice_language_default[17]; extern const uint32_t ResetDevice_strength_default; extern const char ResetDevice_language_default[17]; @@ -894,7 +935,7 @@ extern const uint32_t SimpleSignTx_lock_time_default; /* Initializer values for message structs */ #define Initialize_init_default {0} #define GetFeatures_init_default {0} -#define Features_init_default {false, "", false, 0, false, 0, false, 0, false, 0, false, "", false, 0, false, 0, false, "", false, "", 0, {CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default}, false, 0, false, {0, {0}}, false, {0, {0}}, false, 0, false, 0, false, 0, false, 0} +#define Features_init_default {false, "", false, 0, false, 0, false, 0, false, 0, false, "", false, 0, false, 0, false, "", false, "", 0, {CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default, CoinType_init_default}, false, 0, false, {0, {0}}, false, {0, {0}}, false, 0, false, 0, false, 0} #define ClearSession_init_default {0} #define ApplySettings_init_default {false, "", false, "", false, 0, false, {0, {0}}} #define ChangePin_init_default {false, 0} @@ -912,7 +953,7 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define Entropy_init_default {{0, {0}}} #define GetPublicKey_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, "", false, 0} #define PublicKey_init_default {HDNodeType_init_default, false, ""} -#define GetAddress_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, "Bitcoin", false, 0, false, MultisigRedeemScriptType_init_default, false, InputScriptType_SPENDADDRESS} +#define GetAddress_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, "Bitcoin", false, 0, false, MultisigRedeemScriptType_init_default} #define EthereumGetAddress_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, 0} #define Address_init_default {""} #define EthereumAddress_init_default {{0, {0}}} @@ -958,14 +999,18 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define DebugLinkMemory_init_default {false, {0, {0}}} #define DebugLinkMemoryWrite_init_default {false, 0, false, {0, {0}}, false, 0} #define DebugLinkFlashErase_init_default {false, 0} +#define SteemAccountKeyAuth_init_default {{0, {0}}, 0} +#define SteemAccountAccountAuth_init_default {"", 0} +#define SteemPermission_init_default {0, 0, {SteemAccountAccountAuth_init_default, SteemAccountAccountAuth_init_default, SteemAccountAccountAuth_init_default, SteemAccountAccountAuth_init_default}, 0, {SteemAccountKeyAuth_init_default, SteemAccountKeyAuth_init_default, SteemAccountKeyAuth_init_default, SteemAccountKeyAuth_init_default}} +#define SteemOperationAccountUpdate_init_default {"", {0, {0}}, "", false, SteemPermission_init_default, false, SteemPermission_init_default, false, SteemPermission_init_default} #define SteemOperationTransfer_init_default {"", "", 0, "", false, ""} -#define SteemSignTx_init_default {0, 0, 0, false, SteemOperationTransfer_init_default} +#define SteemSignTx_init_default {0, 0, 0, false, SteemOperationTransfer_init_default, false, SteemOperationAccountUpdate_init_default} #define SteemTxSignature_init_default {{0, {0}}, false, {0, {0}}} #define SteemGetPublicKey_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, 0} #define SteemPublicKey_init_default {{0, {0}}} #define Initialize_init_zero {0} #define GetFeatures_init_zero {0} -#define Features_init_zero {false, "", false, 0, false, 0, false, 0, false, 0, false, "", false, 0, false, 0, false, "", false, "", 0, {CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero}, false, 0, false, {0, {0}}, false, {0, {0}}, false, 0, false, 0, false, 0, false, 0} +#define Features_init_zero {false, "", false, 0, false, 0, false, 0, false, 0, false, "", false, 0, false, 0, false, "", false, "", 0, {CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero, CoinType_init_zero}, false, 0, false, {0, {0}}, false, {0, {0}}, false, 0, false, 0, false, 0} #define ClearSession_init_zero {0} #define ApplySettings_init_zero {false, "", false, "", false, 0, false, {0, {0}}} #define ChangePin_init_zero {false, 0} @@ -983,7 +1028,7 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define Entropy_init_zero {{0, {0}}} #define GetPublicKey_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, "", false, 0} #define PublicKey_init_zero {HDNodeType_init_zero, false, ""} -#define GetAddress_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, "", false, 0, false, MultisigRedeemScriptType_init_zero, false, (InputScriptType)0} +#define GetAddress_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, "", false, 0, false, MultisigRedeemScriptType_init_zero} #define EthereumGetAddress_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, 0} #define Address_init_zero {""} #define EthereumAddress_init_zero {{0, {0}}} @@ -1029,8 +1074,12 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define DebugLinkMemory_init_zero {false, {0, {0}}} #define DebugLinkMemoryWrite_init_zero {false, 0, false, {0, {0}}, false, 0} #define DebugLinkFlashErase_init_zero {false, 0} +#define SteemAccountKeyAuth_init_zero {{0, {0}}, 0} +#define SteemAccountAccountAuth_init_zero {"", 0} +#define SteemPermission_init_zero {0, 0, {SteemAccountAccountAuth_init_zero, SteemAccountAccountAuth_init_zero, SteemAccountAccountAuth_init_zero, SteemAccountAccountAuth_init_zero}, 0, {SteemAccountKeyAuth_init_zero, SteemAccountKeyAuth_init_zero, SteemAccountKeyAuth_init_zero, SteemAccountKeyAuth_init_zero}} +#define SteemOperationAccountUpdate_init_zero {"", {0, {0}}, "", false, SteemPermission_init_zero, false, SteemPermission_init_zero, false, SteemPermission_init_zero} #define SteemOperationTransfer_init_zero {"", "", 0, "", false, ""} -#define SteemSignTx_init_zero {0, 0, 0, false, SteemOperationTransfer_init_zero} +#define SteemSignTx_init_zero {0, 0, 0, false, SteemOperationTransfer_init_zero, false, SteemOperationAccountUpdate_init_zero} #define SteemTxSignature_init_zero {{0, {0}}, false, {0, {0}}} #define SteemGetPublicKey_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, 0} #define SteemPublicKey_init_zero {{0, {0}}} @@ -1128,13 +1177,11 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define Features_imported_tag 15 #define Features_pin_cached_tag 16 #define Features_passphrase_cached_tag 17 -#define Features_firmware_present_tag 18 #define FirmwareUpload_payload_tag 1 #define GetAddress_address_n_tag 1 #define GetAddress_coin_name_tag 2 #define GetAddress_show_display_tag 3 #define GetAddress_multisig_tag 4 -#define GetAddress_script_type_tag 5 #define GetECDHSessionKey_identity_tag 1 #define GetECDHSessionKey_peer_public_key_tag 2 #define GetECDHSessionKey_ecdsa_curve_name_tag 3 @@ -1194,6 +1241,10 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define SimpleSignTx_coin_name_tag 4 #define SimpleSignTx_version_tag 5 #define SimpleSignTx_lock_time_tag 6 +#define SteemAccountAccountAuth_account_tag 1 +#define SteemAccountAccountAuth_weight_tag 2 +#define SteemAccountKeyAuth_pubkey_tag 1 +#define SteemAccountKeyAuth_weight_tag 2 #define SteemGetPublicKey_address_n_tag 1 #define SteemGetPublicKey_show_display_tag 2 #define SteemOperationTransfer_from_tag 1 @@ -1215,15 +1266,25 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define VerifyMessage_message_tag 3 #define VerifyMessage_coin_name_tag 4 #define WordAck_word_tag 1 +#define SteemPermission_weight_threshold_tag 1 +#define SteemPermission_account_auths_tag 2 +#define SteemPermission_key_auths_tag 3 +#define SteemOperationAccountUpdate_account_tag 1 +#define SteemOperationAccountUpdate_memo_key_tag 2 +#define SteemOperationAccountUpdate_json_metadata_tag 3 +#define SteemOperationAccountUpdate_owner_tag 4 +#define SteemOperationAccountUpdate_active_tag 5 +#define SteemOperationAccountUpdate_posting_tag 6 #define SteemSignTx_ref_block_num_tag 1 #define SteemSignTx_ref_block_prefix_tag 2 #define SteemSignTx_expiration_tag 3 #define SteemSignTx_transfer_tag 4 +#define SteemSignTx_account_update_tag 5 /* Struct field encoding specification for nanopb */ extern const pb_field_t Initialize_fields[1]; extern const pb_field_t GetFeatures_fields[1]; -extern const pb_field_t Features_fields[19]; +extern const pb_field_t Features_fields[18]; extern const pb_field_t ClearSession_fields[1]; extern const pb_field_t ApplySettings_fields[5]; extern const pb_field_t ChangePin_fields[2]; @@ -1241,7 +1302,7 @@ extern const pb_field_t GetEntropy_fields[2]; extern const pb_field_t Entropy_fields[2]; extern const pb_field_t GetPublicKey_fields[4]; extern const pb_field_t PublicKey_fields[3]; -extern const pb_field_t GetAddress_fields[6]; +extern const pb_field_t GetAddress_fields[5]; extern const pb_field_t EthereumGetAddress_fields[3]; extern const pb_field_t Address_fields[2]; extern const pb_field_t EthereumAddress_fields[2]; @@ -1287,8 +1348,12 @@ extern const pb_field_t DebugLinkMemoryRead_fields[3]; extern const pb_field_t DebugLinkMemory_fields[2]; extern const pb_field_t DebugLinkMemoryWrite_fields[4]; extern const pb_field_t DebugLinkFlashErase_fields[2]; +extern const pb_field_t SteemAccountKeyAuth_fields[3]; +extern const pb_field_t SteemAccountAccountAuth_fields[3]; +extern const pb_field_t SteemPermission_fields[4]; +extern const pb_field_t SteemOperationAccountUpdate_fields[7]; extern const pb_field_t SteemOperationTransfer_fields[6]; -extern const pb_field_t SteemSignTx_fields[5]; +extern const pb_field_t SteemSignTx_fields[6]; extern const pb_field_t SteemTxSignature_fields[3]; extern const pb_field_t SteemGetPublicKey_fields[3]; extern const pb_field_t SteemPublicKey_fields[2]; @@ -1296,7 +1361,7 @@ extern const pb_field_t SteemPublicKey_fields[2]; /* Maximum encoded size of messages (where known) */ #define Initialize_size 0 #define GetFeatures_size 0 -#define Features_size (257 + 8*CoinType_size) +#define Features_size (254 + 8*CoinType_size) #define ClearSession_size 0 #define ApplySettings_size 1083 #define ChangePin_size 2 @@ -1314,7 +1379,7 @@ extern const pb_field_t SteemPublicKey_fields[2]; #define Entropy_size 1027 #define GetPublicKey_size 84 #define PublicKey_size (121 + HDNodeType_size) -#define GetAddress_size (81 + MultisigRedeemScriptType_size) +#define GetAddress_size (75 + MultisigRedeemScriptType_size) #define EthereumGetAddress_size 50 #define Address_size 43 #define EthereumAddress_size 22 @@ -1360,8 +1425,12 @@ extern const pb_field_t SteemPublicKey_fields[2]; #define DebugLinkMemory_size 1027 #define DebugLinkMemoryWrite_size 1035 #define DebugLinkFlashErase_size 6 +#define SteemAccountKeyAuth_size 41 +#define SteemAccountAccountAuth_size 24 +#define SteemPermission_size 282 +#define SteemOperationAccountUpdate_size 1167 #define SteemOperationTransfer_size 123 -#define SteemSignTx_size 143 +#define SteemSignTx_size 1313 #define SteemTxSignature_size 101 #define SteemGetPublicKey_size 50 #define SteemPublicKey_size 35 diff --git a/firmware/protob/types.pb.c b/firmware/protob/types.pb.c index 04ef17f7b..89c11a18c 100644 --- a/firmware/protob/types.pb.c +++ b/firmware/protob/types.pb.c @@ -47,7 +47,7 @@ const pb_field_t MultisigRedeemScriptType_fields[4] = { PB_LAST_FIELD }; -const pb_field_t TxInputType_fields[9] = { +const pb_field_t TxInputType_fields[8] = { PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, TxInputType, address_n, address_n, 0), PB_FIELD2( 2, BYTES , REQUIRED, STATIC , OTHER, TxInputType, prev_hash, address_n, 0), PB_FIELD2( 3, UINT32 , REQUIRED, STATIC , OTHER, TxInputType, prev_index, prev_hash, 0), @@ -55,7 +55,6 @@ const pb_field_t TxInputType_fields[9] = { PB_FIELD2( 5, UINT32 , OPTIONAL, STATIC , OTHER, TxInputType, sequence, script_sig, &TxInputType_sequence_default), PB_FIELD2( 6, ENUM , OPTIONAL, STATIC , OTHER, TxInputType, script_type, sequence, &TxInputType_script_type_default), PB_FIELD2( 7, MESSAGE , OPTIONAL, STATIC , OTHER, TxInputType, multisig, script_type, &MultisigRedeemScriptType_fields), - PB_FIELD2( 8, UINT64 , OPTIONAL, STATIC , OTHER, TxInputType, amount, multisig, 0), PB_LAST_FIELD }; diff --git a/firmware/protob/types.pb.h b/firmware/protob/types.pb.h index de87ac94f..9a7d482c4 100644 --- a/firmware/protob/types.pb.h +++ b/firmware/protob/types.pb.h @@ -28,17 +28,12 @@ typedef enum _OutputScriptType { OutputScriptType_PAYTOADDRESS = 0, OutputScriptType_PAYTOSCRIPTHASH = 1, OutputScriptType_PAYTOMULTISIG = 2, - OutputScriptType_PAYTOOPRETURN = 3, - OutputScriptType_PAYTOWITNESS = 4, - OutputScriptType_PAYTOP2SHWITNESS = 5 + OutputScriptType_PAYTOOPRETURN = 3 } OutputScriptType; typedef enum _InputScriptType { InputScriptType_SPENDADDRESS = 0, - InputScriptType_SPENDMULTISIG = 1, - InputScriptType_EXTERNAL = 2, - InputScriptType_SPENDWITNESS = 3, - InputScriptType_SPENDP2SHWITNESS = 4 + InputScriptType_SPENDMULTISIG = 1 } InputScriptType; typedef enum _RequestType { @@ -213,8 +208,6 @@ typedef struct _TxInputType { InputScriptType script_type; bool has_multisig; MultisigRedeemScriptType multisig; - bool has_amount; - uint64_t amount; } TxInputType; typedef struct { @@ -272,7 +265,7 @@ extern const uint32_t IdentityType_index_default; #define HDNodePathType_init_default {HDNodeType_init_default, 0, {0, 0, 0, 0, 0, 0, 0, 0}} #define CoinType_init_default {false, "", false, "", false, 0u, false, 0, false, 5u, false, 6u, false, 10u, false, ""} #define MultisigRedeemScriptType_init_default {0, {HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default}, 0, {{0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}}, false, 0} -#define TxInputType_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, {0, {0}}, 0, false, {0, {0}}, false, 4294967295u, false, InputScriptType_SPENDADDRESS, false, MultisigRedeemScriptType_init_default, false, 0} +#define TxInputType_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, {0, {0}}, 0, false, {0, {0}}, false, 4294967295u, false, InputScriptType_SPENDADDRESS, false, MultisigRedeemScriptType_init_default} #define TxOutputType_init_default {false, "", 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, (OutputScriptType)0, false, MultisigRedeemScriptType_init_default, false, {0, {0}}} #define TxOutputBinType_init_default {0, {0, {0}}} #define TransactionType_init_default {false, 0, 0, {TxInputType_init_default}, 0, {TxOutputBinType_init_default}, false, 0, 0, {TxOutputType_init_default}, false, 0, false, 0} @@ -283,7 +276,7 @@ extern const uint32_t IdentityType_index_default; #define HDNodePathType_init_zero {HDNodeType_init_zero, 0, {0, 0, 0, 0, 0, 0, 0, 0}} #define CoinType_init_zero {false, "", false, "", false, 0, false, 0, false, 0, false, 0, false, 0, false, ""} #define MultisigRedeemScriptType_init_zero {0, {HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero}, 0, {{0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}}, false, 0} -#define TxInputType_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, {0, {0}}, 0, false, {0, {0}}, false, 0, false, (InputScriptType)0, false, MultisigRedeemScriptType_init_zero, false, 0} +#define TxInputType_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, {0, {0}}, 0, false, {0, {0}}, false, 0, false, (InputScriptType)0, false, MultisigRedeemScriptType_init_zero} #define TxOutputType_init_zero {false, "", 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, (OutputScriptType)0, false, MultisigRedeemScriptType_init_zero, false, {0, {0}}} #define TxOutputBinType_init_zero {0, {0, {0}}} #define TransactionType_init_zero {false, 0, 0, {TxInputType_init_zero}, 0, {TxOutputBinType_init_zero}, false, 0, 0, {TxOutputType_init_zero}, false, 0, false, 0} @@ -331,7 +324,6 @@ extern const uint32_t IdentityType_index_default; #define TxInputType_sequence_tag 5 #define TxInputType_script_type_tag 6 #define TxInputType_multisig_tag 7 -#define TxInputType_amount_tag 8 #define TxOutputType_address_tag 1 #define TxOutputType_address_n_tag 2 #define TxOutputType_amount_tag 3 @@ -355,7 +347,7 @@ extern const pb_field_t HDNodeType_fields[7]; extern const pb_field_t HDNodePathType_fields[3]; extern const pb_field_t CoinType_fields[9]; extern const pb_field_t MultisigRedeemScriptType_fields[4]; -extern const pb_field_t TxInputType_fields[9]; +extern const pb_field_t TxInputType_fields[8]; extern const pb_field_t TxOutputType_fields[7]; extern const pb_field_t TxOutputBinType_fields[3]; extern const pb_field_t TransactionType_fields[8]; @@ -368,10 +360,10 @@ extern const pb_field_t IdentityType_fields[7]; #define HDNodePathType_size 171 #define CoinType_size 99 #define MultisigRedeemScriptType_size 3741 -#define TxInputType_size 5508 +#define TxInputType_size 5497 #define TxOutputType_size 3934 #define TxOutputBinType_size 534 -#define TransactionType_size 10009 +#define TransactionType_size 9998 #define TxRequestDetailsType_size 40 #define TxRequestSerializedType_size 2132 #define IdentityType_size 416 diff --git a/firmware/steem.c b/firmware/steem.c index 83d0ff055..aea1f4f3e 100644 --- a/firmware/steem.c +++ b/firmware/steem.c @@ -70,6 +70,22 @@ void gph_ser_bytes(SHA256_CTX *ctx, uint8_t * msg, size_t msglen) sha256_Update(ctx, msg, msglen); } +void gph_ser_bool(SHA256_CTX *ctx, bool i) +{ + uint8_t _true = 0x01; + uint8_t _false = 0x00; + if (i) { + sha256_Update(ctx, (const uint8_t *) &_true, 1); + } else { + sha256_Update(ctx, (const uint8_t *) &_false, 1); + } +} + +void gph_ser_int8(SHA256_CTX *ctx, uint8_t i) +{ + sha256_Update(ctx, (const uint8_t *) &i, 1); +} + void gph_ser_int32(SHA256_CTX *ctx, uint32_t i) { sha256_Update(ctx, (const uint8_t *) &i, 4); @@ -150,5 +166,21 @@ void layout_steem_confirm_transfer(char * from, char * to, char * asset, uint64_ ); } +void layout_steem_confirm_account_update(char* account) +{ + layoutDialogSwipe(&bmp_icon_question, + "Cancel", + "Confirm", + NULL, + "Confirm", + " ACCOUNT UPDATE", + "for account:", + NULL, + account, + NULL + ); +} + + #endif // USE_STEEM diff --git a/firmware/steem.h b/firmware/steem.h index 55d550c92..879f4350b 100644 --- a/firmware/steem.h +++ b/firmware/steem.h @@ -36,10 +36,13 @@ void gph_ser_string(SHA256_CTX *ctx, const char *msg); void gph_ser_varint(SHA256_CTX *ctx, uint8_t i); void gph_ser_int32(SHA256_CTX *ctx, uint32_t i); void gph_ser_int16(SHA256_CTX *ctx, uint16_t i); +void gph_ser_int8(SHA256_CTX *ctx, uint8_t i); +void gph_ser_bool(SHA256_CTX *ctx, bool i); void gph_ser_bytes(SHA256_CTX *ctx, uint8_t * msg, size_t msglen); uint8_t steem_ser_amount(SHA256_CTX *ctx, uint64_t amount, char *asset); void layout_steem_confirm_transfer(char * from, char * to, char * asset, uint64_t amount); +void layout_steem_confirm_account_update(char* account); #endif #endif diff --git a/vendor/trezor-common b/vendor/trezor-common index cd1a963f3..4511aa7c0 160000 --- a/vendor/trezor-common +++ b/vendor/trezor-common @@ -1 +1 @@ -Subproject commit cd1a963f3189a7318e40daee27dab336ab66d50f +Subproject commit 4511aa7c00cc403af7c838d4977c91078297bb1b