Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/protob/messages-cardano.proto
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ message CardanoSignMessage {
required CardanoDerivationType derivation_type = 3;
required uint32 network_id = 4; // network id - mainnet or testnet
optional CardanoAddressType address_type = 5; // one of the CardanoAddressType
optional uint32 protocol_magic = 6; // network's protocol magic - needed for Byron addresses on testnets
}

/**
Expand Down
1 change: 1 addition & 0 deletions common/protob/messages-polkadot.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ message PolkadotSignTx {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
required bytes raw_tx = 2; // serialized raw transaction
required string network = 3; // Network name
optional uint32 prefix = 4; // SS58 address-type
}

/**
Expand Down
12 changes: 11 additions & 1 deletion common/protob/messages-tron.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ message TronSignTx {
required bytes ref_block_bytes = 2; // Reference block number
required bytes ref_block_hash = 3; // Reference block hash
required uint64 expiration = 4; // Transaction expiration
optional string data = 5; // Extra transaction info
optional bytes data = 5; // Extra transaction info
required TronContract contract = 6; // Contract messages
required uint64 timestamp = 7; // UTC timestamp
optional uint64 fee_limit = 8; // Fee limit for smartcontracts
Expand Down Expand Up @@ -63,6 +63,7 @@ message TronSignTx {
enum TronResourceCode {
BANDWIDTH = 0x00;
ENERGY = 0x01;
TRON_POWER = 0x02;
}

// Freeze TRX balance
Expand Down Expand Up @@ -116,6 +117,9 @@ message TronSignTx {
optional TronWithdrawExpireUnfreezeContract withdraw_expire_unfreeze_contract = 56;
optional TronDelegateResourceContract delegate_resource_contract = 57;
optional TronUnDelegateResourceContract undelegate_resource_contract = 58;
optional bytes provider = 3;
optional bytes contract_name = 5;
optional uint32 permission_id = 6;
}
}

Expand All @@ -128,6 +132,11 @@ message TronSignedTx {
optional bytes serialized_tx = 2; // Serialized transaction
}

enum TronMessageType {
V1 = 1 [deprecated = true];
V2 = 2;
}

/**
* Request: Ask device to sign message
* @next TronMessageSignature
Expand All @@ -136,6 +145,7 @@ message TronSignedTx {
message TronSignMessage {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
required bytes message = 2; // message to be signed
optional TronMessageType message_type = 3[default = V1]; // message type
}

/**
Expand Down
3 changes: 3 additions & 0 deletions legacy/buttons.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ bool waitButtonResponse(uint8_t btn, uint32_t time_out) {
timer_out_set(timer_out_oper, 0);
return flag;
}
#else
// stub implementations
void enableLongPress(bool on) { (void)on; }
#endif

void buttonUpdate() {
Expand Down
4 changes: 3 additions & 1 deletion legacy/firmware/ada.c
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,9 @@ bool ada_sign_messages(const CardanoSignMessage *msg,
fsm_sendFailure(FailureType_Failure_ProcessError, "Deriving root failed");
return false;
}
if (!derive_bytes(&address_params, msg->network_id, MAINNET_PROTOCOL_MAGIC,
if (!derive_bytes(&address_params, msg->network_id,
msg->has_protocol_magic ? msg->protocol_magic
: MAINNET_PROTOCOL_MAGIC,
address_bytes, &address_bytes_len)) {
return false;
}
Expand Down
8 changes: 8 additions & 0 deletions legacy/firmware/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,14 @@ void config_init(void) {
config_upgrade_v10();

storage_init(&protectPinUiCallback, HW_ENTROPY_DATA, HW_ENTROPY_LEN);
// Restore safetyCheckLevel from soft reset if preserved
uint16_t preserved_level = soft_reset_get_preserved_data();
if (preserved_level != PRESERVED_RESET_DATA_INVALID) {
if (preserved_level == SafetyCheckLevel_PromptTemporarily) {
safetyCheckLevel = (SafetyCheckLevel)preserved_level;
}
soft_reset_clear_preserved_data();
}
memzero(HW_ENTROPY_DATA, sizeof(HW_ENTROPY_DATA));

// get whether use se flag
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/ethereum_onekey.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static bool eip1559;
static struct SHA3_CTX keccak_ctx = {0};

static uint32_t signing_access_list_count;
static EthereumAccessListOneKey signing_access_list[8];
static EthereumAccessListOneKey signing_access_list[16];
_Static_assert(sizeof(signing_access_list) ==
sizeof(((EthereumSignTxEIP1559OneKey *)NULL)->access_list),
"access_list buffer size mismatch");
Expand Down
5 changes: 2 additions & 3 deletions legacy/firmware/fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,8 @@ static const CoinInfo *fsm_getCoin(bool has_name, const char *name) {
return coin;
}

static HDNode *fsm_getDerivedNode(const char *curve, const uint32_t *address_n,
size_t address_n_count,
uint32_t *fingerprint) {
HDNode *fsm_getDerivedNode(const char *curve, const uint32_t *address_n,
size_t address_n_count, uint32_t *fingerprint) {
static CONFIDENTIAL HDNode node;
if (fingerprint) {
*fingerprint = 0;
Expand Down
11 changes: 6 additions & 5 deletions legacy/firmware/fsm_msg_ada.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ void fsm_msgCardanoGetAddress(CardanoGetAddress *msg) {
if (msg->has_show_display && msg->show_display) {
char desc[20] = {0};
char addr_type[32] = {0};
snprintf(desc, 20, "Cardano %s", _("Address:"));
snprintf(desc, 20, "Cardano %s", _("Address"));
if (msg->address_parameters.address_type == CardanoAddressType_BASE) {
snprintf(addr_type, 32, "Base %s", _("Address:"));
snprintf(addr_type, 32, "Base %s", _("Address"));
} else if (msg->address_parameters.address_type ==
CardanoAddressType_REWARD) {
snprintf(addr_type, 32, "Reward %s", _("Address:"));
snprintf(addr_type, 32, "Reward %s", _("Address"));
}
if (msg->address_parameters.address_n_count > 0) {
if (!fsm_layoutAddress(resp->address, addr_type, desc, false, 0,
Expand Down Expand Up @@ -268,8 +268,9 @@ void fsm_msgCardanoSignMessage(CardanoSignMessage *msg) {
"Invalid path");
CHECK_PIN

if ((msg->network_id != 0) && (msg->network_id != 1)) {
fsm_sendFailure(FailureType_Failure_ProcessError, "Invalid Networ ID");
if (!msg->has_protocol_magic && (msg->network_id != 1)) {
fsm_sendFailure(FailureType_Failure_ProcessError,
"Invalid Network ID, need protocol magic provide");
return;
}
if (!ada_sign_messages(msg, resp)) {
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/fsm_msg_algorand.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void fsm_msgAlgorandGetAddress(AlgorandGetAddress *msg) {

if (msg->has_show_display && msg->show_display) {
char desc[20] = {0};
snprintf(desc, 20, "%s %s", "Algorand", _("Address:"));
snprintf(desc, 20, "%s %s", "Algorand", _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, true, NULL, 0, 0, NULL)) {
return;
Expand Down
4 changes: 2 additions & 2 deletions legacy/firmware/fsm_msg_aptos.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void fsm_msgAptosGetAddress(const AptosGetAddress *msg) {

if (msg->has_show_display && msg->show_display) {
char desc[16] = {0};
strcat(desc, "Aptos");
strcat(desc, _("Address:"));
strcat(desc, "Aptos ");
strcat(desc, _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, true, NULL, 0, 0, NULL)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/fsm_msg_coin.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ void fsm_msgGetAddress(const GetAddress *msg) {
} else {
strcat(desc, coin->coin_name);
strcat(desc, " ");
strlcpy(desc + strlen(desc), _("Address:"), sizeof(desc));
strlcpy(desc + strlen(desc), _("Address"), sizeof(desc));
}

uint32_t multisig_xpub_magic = coin->xpub_magic;
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/fsm_msg_conflux.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void fsm_msgConfluxGetAddress(const ConfluxGetAddress *msg) {
}
if (msg->has_show_display && msg->show_display) {
char desc[20] = {0};
snprintf(desc, 20, "%s %s", "Conflux", _("Address:"));
snprintf(desc, 20, "%s %s", "Conflux", _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, false, NULL, 0, 0, NULL)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/fsm_msg_cosmos.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void fsm_msgCosmosGetAddress(CosmosGetAddress *msg) {
strcat(desc, "Cosmos");
}
strcat(desc, " ");
strcat(desc, _("Address:"));
strcat(desc, _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, true, NULL, 0, 0, NULL)) {
return;
Expand Down
4 changes: 2 additions & 2 deletions legacy/firmware/fsm_msg_dynex.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void fsm_msgDnxGetAddress(const DnxGetAddress* msg) {
resp->has_address = true;
if (msg->has_show_display && msg->show_display) {
char desc[12] = {0};
strcat(desc, "Dnx");
strcat(desc, _("Address:"));
strcat(desc, "Dnx ");
strcat(desc, _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, true, NULL, 0, 0, NULL)) {
return;
Expand Down
6 changes: 3 additions & 3 deletions legacy/firmware/fsm_msg_ethereum.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ void fsm_msgEthereumGetAddress(const EthereumGetAddress *msg) {
if (msg->has_show_display && msg->show_display) {
char desc[257] = {0};
const char *chain_name = NULL;
strlcpy(desc, "Address:", sizeof(desc));
// strlcpy(desc, "Address:", sizeof(desc));
if (strlen(network->name) == 0) {
ASSIGN_ETHEREUM_NAME(chain_name, network->chain_id)
snprintf(desc, 257, "%s %s", chain_name, _("Address:"));
snprintf(desc, 257, "%s %s", chain_name, _("Address"));
} else {
snprintf(desc, 257, "%s %s", network->name, _("Address:"));
snprintf(desc, 257, "%s %s", network->name, _("Address"));
}

if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/fsm_msg_ethereum_onekey.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void fsm_msgEthereumGetAddressOneKey(const EthereumGetAddressOneKey *msg) {
} else {
ASSIGN_ETHEREUM_NAME(chain_name, 0); // unknown chain
}
snprintf(desc, 32, "%s %s", chain_name, _("Address:"));
snprintf(desc, 32, "%s %s", chain_name, _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, true, NULL, 0, 0, NULL)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/fsm_msg_filecoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void fsm_msgFilecoinGetAddress(const FilecoinGetAddress *msg) {
if (!get_filecoin_addr(pk, resp)) return;
if (msg->has_show_display && msg->show_display) {
char desc[20] = {0};
snprintf(desc, 20, "%s %s", "Filecoin", _("Address:"));
snprintf(desc, 20, "%s %s", "Filecoin", _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, true, NULL, 0, 0, NULL)) {
return;
Expand Down
4 changes: 2 additions & 2 deletions legacy/firmware/fsm_msg_kaspa.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void fsm_msgKaspaGetAddress(const KaspaGetAddress *msg) {

if (msg->has_show_display && msg->show_display) {
char desc[16] = {0};
strcat(desc, "Kaspa");
strcat(desc, _("Address:"));
strcat(desc, "Kaspa ");
strcat(desc, _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, true, NULL, 0, 0, NULL)) {
return;
Expand Down
4 changes: 2 additions & 2 deletions legacy/firmware/fsm_msg_near.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ void fsm_msgNearGetAddress(NearGetAddress *msg) {

if (msg->has_show_display && msg->show_display) {
char desc[16] = {0};
strcat(desc, "Near");
strcat(desc, _("Address:"));
strcat(desc, "Near ");
strcat(desc, _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, true, NULL, 0, 0, NULL)) {
return;
Expand Down
4 changes: 1 addition & 3 deletions legacy/firmware/fsm_msg_nem.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ void fsm_msgNEMGetAddress(NEMGetAddress *msg) {

if (msg->has_show_display && msg->show_display) {
char desc[16];
strlcpy(desc, network, sizeof(desc));
strlcat(desc, ":", sizeof(desc));

snprintf(desc, 16, "%s %s", network, _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, true, 0, msg->address_n,
msg->address_n_count, false, NULL, 0, 0, NULL)) {
return;
Expand Down
4 changes: 2 additions & 2 deletions legacy/firmware/fsm_msg_nervos.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ void fsm_msgNervosGetAddress(const NervosGetAddress *msg) {
msg->network);
if (msg->has_show_display && msg->show_display) {
char desc[16] = {0};
strcat(desc, "Nervos");
strcat(desc, _("Address:"));
strcat(desc, "Nervos ");
strcat(desc, _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, false, NULL, 0, 0, NULL)) {
return;
Expand Down
4 changes: 2 additions & 2 deletions legacy/firmware/fsm_msg_nexa.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void fsm_msgNexaGetAddress(const NexaGetAddress *msg) {

if (msg->has_show_display && msg->show_display) {
char desc[16] = {0};
strcat(desc, "Nexa");
strcat(desc, _("Address:"));
strcat(desc, "Nexa ");
strcat(desc, _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, true, NULL, 0, 0, NULL)) {
return;
Expand Down
16 changes: 8 additions & 8 deletions legacy/firmware/fsm_msg_polkadot.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ void fsm_msgPolkadotGetAddress(PolkadotGetAddress *msg) {
res = secret_from_seed_cardano_ledger(seed, 64, ledger_secret);
if (res != 1) {
fsm_sendFailure(FailureType_Failure_ProcessError,
_("Unexpected failure in Ledger derivation"));
"Unexpected failure in Ledger derivation");
return;
}
res = hdnode_from_secret_cardano(ledger_secret, &node);
if (res != 1) {
fsm_sendFailure(FailureType_Failure_ProcessError,
_("Unexpected failure in constructing polkadot node"));
"Unexpected failure in constructing polkadot node");
return;
}

if (hdnode_private_ckd_cached(&node, msg->address_n, msg->address_n_count,
NULL) == 0) {
fsm_sendFailure(FailureType_Failure_ProcessError,
_("Failed to derive private key"));
"Failed to derive private key");
return;
}
ed25519_publickey(node.private_key, node.public_key + 1);
Expand All @@ -68,7 +68,7 @@ void fsm_msgPolkadotGetAddress(PolkadotGetAddress *msg) {
strcat(desc, msg->network);
desc[0] = desc[0] - ('a' - 'A');
strcat(desc, " ");
strcat(desc, _("Address:"));
strcat(desc, _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, true, NULL, 0, 0, NULL)) {
return;
Expand Down Expand Up @@ -99,27 +99,27 @@ void fsm_msgPolkadotSignTx(const PolkadotSignTx *msg) {
res = secret_from_seed_cardano_ledger(seed, 64, ledger_secret);
if (res != 1) {
fsm_sendFailure(FailureType_Failure_ProcessError,
_("Unexpected failure in Ledger derivation"));
"Unexpected failure in Ledger derivation");
return;
}

res = hdnode_from_secret_cardano(ledger_secret, &node);
if (res != 1) {
fsm_sendFailure(FailureType_Failure_ProcessError,
_("Unexpected failure in constructing Polkadot node"));
"Unexpected failure in constructing Polkadot node");
return;
}

if (hdnode_private_ckd_cached(&node, msg->address_n, msg->address_n_count,
NULL) == 0) {
fsm_sendFailure(FailureType_Failure_ProcessError,
_("Failed to derive private key"));
"Failed to derive private key");
return;
}
ed25519_publickey(node.private_key, node.public_key + 1);

if (!polkadot_sign_tx(msg, &node, resp)) {
fsm_sendFailure(FailureType_Failure_DataError, _("Signing failed"));
fsm_sendFailure(FailureType_Failure_DataError, "Signing failed");
layoutHome();
return;
}
Expand Down
4 changes: 2 additions & 2 deletions legacy/firmware/fsm_msg_ripple.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ void fsm_msgRippleGetAddress(RippleGetAddress *msg) {
}
if (msg->has_show_display && msg->show_display) {
char desc[16] = {0};
strcat(desc, "Ripple");
strcat(desc, _("Address:"));
strcat(desc, "Ripple ");
strcat(desc, _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, false, NULL, 0, 0, NULL)) {
return;
Expand Down
3 changes: 1 addition & 2 deletions legacy/firmware/fsm_msg_solana.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ void fsm_msgSolanaGetAddress(const SolanaGetAddress *msg) {

if (msg->has_show_display && msg->show_display) {
char desc[16] = {0};
strcat(desc, "Solana");
strcat(desc, _("Address:"));
snprintf(desc, 16, "%s %s", "Solana", _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, false, NULL, 0, 0, NULL)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/fsm_msg_starcoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void fsm_msgStarcoinGetAddress(const StarcoinGetAddress *msg) {

if (msg->has_show_display && msg->show_display) {
char desc[20] = {0};
snprintf(desc, 20, "%s %s", "Starcoin", _("Address:"));
snprintf(desc, 20, "%s %s", "Starcoin", _("Address"));
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
msg->address_n_count, true, NULL, 0, 0, NULL)) {
return;
Expand Down
Loading
Loading