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-tron.proto
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ message TronSignTx {
optional uint64 balance = 3;
optional string receiver_address = 4;
optional bool lock = 5;
optional uint64 lock_period = 6;
}
message TronUnDelegateResourceContract {
optional TronResourceCode resource = 2;
Expand Down
4 changes: 3 additions & 1 deletion legacy/firmware/cosmos_networks.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const CosmosNetworkType cosmos_networks[COSMOS_NETWORK_COUNT] = {
{"osmosis-1", "osmo", "Osmosis", "OSMO", "uosmo", 6},
{"secret-4", "secret", "Secret Network", "SCRT", "uscrt", 6},
{"akashnet-2", "akash", "Akash", "AKT", "uakt", 6},
{"crypto-org-chain-mainnet-1", "cro", "Crypto.org", "CRO", "basecro", 8},
{"crypto-org-chain-mainnet-1", "cro", "Cronos POS Chain", "CRO", "basecro",
8},
{"iov-mainnet-ibc", "star", "Starname", "IOV", "uiov", 6},
{"sifchain-1", "sif", "Sifchain", "ROWAN", "rowan", 18},
{"shentu-2.2", "certik", "Shentu", "CTK", "uctk", 6},
Expand All @@ -32,6 +33,7 @@ const CosmosNetworkType cosmos_networks[COSMOS_NETWORK_COUNT] = {
{"quicksilver-1", "quick", "Quicksilver", "QCK", "uqck", 6},
{"fetchhub-4", "fetch", "Fetch.ai", "FET", "afet", 18},
{"celestia", "celestia", "Celestia", "TIA", "utia", 6},
{"bbn-1", "bbn", "BABYLON", "BABY", "ubbn", 6},
};

const CosmosNetworkType *cosmosnetworkByChainId(const char *chain_id) {
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/cosmos_networks.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <stdint.h>

#define COSMOS_NETWORK_COUNT 30
#define COSMOS_NETWORK_COUNT 31

typedef struct {
const char *const chain_id;
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/ethereum.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static bool eip1559;
struct SHA3_CTX keccak_ctx = {0};

static uint32_t signing_access_list_count;
static EthereumAccessList signing_access_list[8];
static EthereumAccessList signing_access_list[16];
_Static_assert(sizeof(signing_access_list) ==
sizeof(((EthereumSignTxEIP1559 *)NULL)->access_list),
"access_list buffer size mismatch");
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
4 changes: 4 additions & 0 deletions legacy/firmware/language.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ const char *const languages[][2] = {
{"Format:", "格式:"},
// layout2.c
{"From", "发送方"},
// solana.c
{"From (Token Account)", "发送方 (代币账户)"},
// layout2.c
{"GPG sign for:", ""},
{"Gas Fee Cap", "燃料单价上限"},
Expand Down Expand Up @@ -798,6 +800,8 @@ const char *const languages[][2] = {
{"Tip Amount", "小费金额"},
{"Tipper", "小费支付方"},
{"Title", "标题"},
// solana.c
{"To (Token Account)", "接收方 (代币账户)"},
// signing.c fsm_msg_coin.h
// ada.c
{"To Pool:", "目标质押池:"},
Expand Down
28 changes: 16 additions & 12 deletions legacy/firmware/pinmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "pinmatrix.h"
#include "rng.h"

static char pinmatrix_perm[10] = "XXXXXXXXX";
static char pinmatrix_perm[11] = "XXXXXXXXX";

void pinmatrix_draw(const char *text) {
const BITMAP *bmp_digits[10] = {
Expand All @@ -37,21 +37,23 @@ void pinmatrix_draw(const char *text) {
if (text) {
oledDrawStringCenterAdapter(OLED_WIDTH / 2, 0, text, FONT_STANDARD);
}
const int w = bmp_digit0.width, h = bmp_digit0.height, pad = 2;
const int w = bmp_digit0.width, h = bmp_digit0.height, pad = 1;
int k = 0;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
// use (2 - j) instead of j to achieve 789456123 layout
int k = pinmatrix_perm[i + (2 - j) * 3] - '0';
k = pinmatrix_perm[i + (2 - j) * 3] - '0';
oledDrawBitmap((OLED_WIDTH - 3 * w - 2 * pad) / 2 + i * (w + pad),
OLED_HEIGHT - 3 * h - 2 * pad + j * (h + pad),
OLED_HEIGHT - 4 * h - 3 * pad + j * (h + pad),
bmp_digits[k]);
}
}
for (int i = 0; i < 3; i++) {
// 36 is the maximum pixels used for a pin matrix pixel row
// but we use 56 pixels to add some extra
oledSCAInside(12 + i * (h + pad), 12 + i * (h + pad) + h - 1, 56, 38,
OLED_WIDTH - 38);
k = pinmatrix_perm[9] - '0';
oledBox(27, 52, 101, 64, true);
oledDrawBitmap(52, 52, bmp_digits[k]);
for (int i = 0; i < 4; i++) {
oledSCAInside(13 + i * (h + pad), 13 + i * (h + pad) + h - 1, 76, 27,
OLED_WIDTH - 27);
}
oledRefresh();
}
Expand All @@ -60,8 +62,9 @@ void pinmatrix_start(const char *text) {
for (int i = 0; i < 9; i++) {
pinmatrix_perm[i] = '1' + i;
}
pinmatrix_perm[9] = 0;
random_permute(pinmatrix_perm, 9);
pinmatrix_perm[9] = '0';
pinmatrix_perm[10] = 0;
random_permute(pinmatrix_perm, 10);
pinmatrix_draw(text);
}

Expand All @@ -70,7 +73,8 @@ secbool pinmatrix_done(bool clear, char *pin) {
secbool ret = sectrue;
while (pin && pin[i]) {
k = pin[i] - '1';
if (k >= 0 && k <= 8) {
if (k == -1) k = 9;
if (k >= 0 && k <= 9) {
pin[i] = pinmatrix_perm[k];
} else {
pin[i] = 'X';
Expand Down
16 changes: 7 additions & 9 deletions legacy/firmware/protect.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,9 +882,7 @@ const char *protectInputPin(const char *text, uint8_t min_pin_len,
if (counter >= DEFAULT_PIN_LEN) {
index = 10;
} else {
do {
index = random_uniform(10);
} while (index == 0);
index = random_uniform(10);
}
}

Expand All @@ -894,24 +892,24 @@ const char *protectInputPin(const char *text, uint8_t min_pin_len,
if (isLongPress(KEY_UP_OR_DOWN) && getLongPressStatus()) {
if (isLongPress(KEY_UP)) { // up
if (!d) { // default direction
if (index > 1)
if (index > 0)
index--;
else
index = max_index;
} else {
if (index < max_index)
index++;
else
index = 1;
index = 0;
}
} else if (isLongPress(KEY_DOWN)) { // down
if (!d) {
if (index < max_index)
index++;
else
index = 1;
index = 0;
} else {
if (index > 1)
if (index > 0)
index--;
else
index = max_index;
Expand All @@ -930,7 +928,7 @@ const char *protectInputPin(const char *text, uint8_t min_pin_len,
}
switch (key) {
case KEY_UP:
if (index > 1)
if (index > 0)
index--;
else
index = max_index;
Expand All @@ -939,7 +937,7 @@ const char *protectInputPin(const char *text, uint8_t min_pin_len,
if (index < max_index)
index++;
else
index = 1;
index = 0;
goto refresh_menu;
case KEY_CONFIRM:
(void)pin;
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/protob/messages-ethereum-onekey.options
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ EthereumSignTxEIP1559OneKey.gas_limit max_size:32
EthereumSignTxEIP1559OneKey.to max_size:43
EthereumSignTxEIP1559OneKey.value max_size:32
EthereumSignTxEIP1559OneKey.data_initial_chunk max_size:1024
EthereumSignTxEIP1559OneKey.access_list max_count:8
EthereumSignTxEIP1559OneKey.access_list max_count:16

EthereumAccessListOneKey.address max_size:43
EthereumAccessListOneKey.storage_keys max_count:8 max_size:32
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/protob/messages-ethereum.options
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ EthereumSignTxEIP1559.gas_limit max_size:32
EthereumSignTxEIP1559.to max_size:43
EthereumSignTxEIP1559.value max_size:32
EthereumSignTxEIP1559.data_initial_chunk max_size:1024
EthereumSignTxEIP1559.access_list max_count:8
EthereumSignTxEIP1559.access_list max_count:16

EthereumAccessList.address max_size:43
EthereumAccessList.storage_keys max_count:8 max_size:32
Expand Down
39 changes: 28 additions & 11 deletions legacy/firmware/solana.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ void solana_sign_tx(const SolanaSignTx *msg, const HDNode *node,
size_t num_summary_steps = 0;
size_t steps = 0;
uint8_t steps_list[MAX_TRANSACTION_SUMMARY_ITEMS];
char title_str[65] = {0};
snprintf(title_str, 65, "%s %s", "Solana", _("Transaction"));
const char **tx_msg = format_tx_message("Solana");
if (transaction_summary_finalize(summary_step_kinds, &num_summary_steps) ==
0) {
char desc[64];
for (size_t i = 0; i < num_summary_steps; i++) {
if (transaction_summary_display_item(i, DisplayFlagAll)) {
fsm_sendFailure(FailureType_Failure_DataError, "Parse error");
Expand All @@ -131,26 +131,33 @@ void solana_sign_tx(const SolanaSignTx *msg, const HDNode *node,
} else if (strcmp(title, "Funded by") == 0) {
continue;
} else if (strcmp(title, "Owner") == 0) {
title = "From";
continue;
} else if (strcmp(title, "Max fees") == 0) {
continue;
} else if (strcmp(title, "Owned by") == 0) {
title = "To";
continue;
} else if (strcmp(title, "Sender") == 0) {
title = "From";
} else if (strcmp(title, "Recipient") == 0) {
title = "Send to";
} else if (strcmp(title, "Transfer tokens") == 0 ||
strcmp(title, "Transfer") == 0) {
title = "Amount";
} else if (strcmp(title, "Token Sender") == 0) {
title = "From (Token Account)";
} else if (strcmp(title, "Token Recipient") == 0) {
title = "To (Token Account)";
}

char desc[64];
memset(desc, 0, sizeof(desc));
strcat(desc, _(title));
strcat(desc, ":");
snprintf(desc, sizeof(desc), "%s:", _(title));

steps_list[steps++] = i;

layoutDialogAdapterEx(title_str, &bmp_bottom_left_close, NULL,
layoutDialogAdapterEx(tx_msg[0], &bmp_bottom_left_close, NULL,
i < num_summary_steps - 1
? &bmp_bottom_right_arrow
: &bmp_bottom_right_confirm,
NULL, NULL, desc, _(text), NULL, NULL);
NULL, NULL, desc, text, NULL, NULL);

uint8_t key;
button_scan:
Expand All @@ -176,11 +183,21 @@ void solana_sign_tx(const SolanaSignTx *msg, const HDNode *node,
}
}
}
oledClear_ex();
layoutHeader(_("Sign Transaction"));
oledDrawStringAdapter(0, 13, tx_msg[1], FONT_STANDARD);
layoutButtonNoAdapter(NULL, &bmp_bottom_left_close);
layoutButtonYesAdapter(NULL, &bmp_bottom_right_confirm);
oledRefresh();
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
return;
}
ed25519_sign(msg->raw_tx.bytes, msg->raw_tx.size, node->private_key,
resp->signature.bytes);
resp->signature.size = 64;
} else {
fsm_sendFailure(FailureType_Failure_DataError, _("Parse error"));
fsm_sendFailure(FailureType_Failure_DataError, "Parse error");
return;
}
msg_write(MessageType_MessageType_SolanaSignedTx, resp);
Expand Down
30 changes: 21 additions & 9 deletions legacy/firmware/tron.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,13 @@ int pack_contract(TronSignTx *msg, uint8_t *buf, int *index,
MAX_ADDR_RAW_SIZE);
cmessage_len +=
write_bytes_with_length(cmessage, &cmessage_index, addr_raw, len);

cmessage_len += add_field(cmessage, &cmessage_index, 2, PROTO_TYPE_VARINT);
cmessage_len +=
write_varint(cmessage, &cmessage_index,
msg->contract.delegate_resource_contract.resource);
if (msg->contract.delegate_resource_contract.has_resource) {
cmessage_len +=
add_field(cmessage, &cmessage_index, 2, PROTO_TYPE_VARINT);
cmessage_len +=
write_varint(cmessage, &cmessage_index,
msg->contract.delegate_resource_contract.resource);
}
cmessage_len += add_field(cmessage, &cmessage_index, 3, PROTO_TYPE_VARINT);
cmessage_len +=
write_varint(cmessage, &cmessage_index,
Expand All @@ -434,6 +436,13 @@ int pack_contract(TronSignTx *msg, uint8_t *buf, int *index,
write_varint(cmessage, &cmessage_index,
msg->contract.delegate_resource_contract.lock);
}
if (msg->contract.delegate_resource_contract.has_lock_period) {
cmessage_len +=
add_field(cmessage, &cmessage_index, 6, PROTO_TYPE_VARINT);
cmessage_len +=
write_varint(cmessage, &cmessage_index,
msg->contract.delegate_resource_contract.lock_period);
}
}

if (msg->contract.has_undelegate_resource_contract) {
Expand All @@ -450,10 +459,13 @@ int pack_contract(TronSignTx *msg, uint8_t *buf, int *index,
cmessage_len +=
write_bytes_with_length(cmessage, &cmessage_index, addr_raw, len);

cmessage_len += add_field(cmessage, &cmessage_index, 2, PROTO_TYPE_VARINT);
cmessage_len +=
write_varint(cmessage, &cmessage_index,
msg->contract.undelegate_resource_contract.resource);
if (msg->contract.undelegate_resource_contract.has_resource) {
cmessage_len +=
add_field(cmessage, &cmessage_index, 2, PROTO_TYPE_VARINT);
cmessage_len +=
write_varint(cmessage, &cmessage_index,
msg->contract.undelegate_resource_contract.resource);
}
cmessage_len += add_field(cmessage, &cmessage_index, 3, PROTO_TYPE_VARINT);
cmessage_len +=
write_varint(cmessage, &cmessage_index,
Expand Down
4 changes: 2 additions & 2 deletions legacy/firmware/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
#define FIX_VERSION_MINOR 99
#define FIX_VERSION_PATCH 99

#define ONEKEY_VERSION "3.10.0"
#define ONEKEY_VERSION_HEX 0x3A00
#define ONEKEY_VERSION "3.11.0"
#define ONEKEY_VERSION_HEX 0x3B00
Loading
Loading