Skip to content

Commit 796cdd5

Browse files
authored
fix(legacy): fix OK-20989 & OK-21003 & OK-20988 & OK-20993 & OK-20994 (#438)
1 parent e49355c commit 796cdd5

File tree

11 files changed

+72
-39
lines changed

11 files changed

+72
-39
lines changed

legacy/firmware/ada.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ static bool layoutOutput(const CardanoTxOutput *output) {
459459
ret = true;
460460
break;
461461
}
462-
if (key == KEY_CANCEL) {
462+
if (key == KEY_CANCEL || key == KEY_NULL) {
463463
return false;
464464
}
465465
}
@@ -488,7 +488,7 @@ static bool layoutOutput(const CardanoTxOutput *output) {
488488
ret = true;
489489
break;
490490
}
491-
if (key == KEY_CANCEL) {
491+
if (key == KEY_CANCEL || key == KEY_NULL) {
492492
return false;
493493
}
494494
}
@@ -562,7 +562,7 @@ static bool layoutOutput(const CardanoTxOutput *output) {
562562
case KEY_CANCEL:
563563
return false;
564564
default:
565-
goto refresh_addr;
565+
return false;
566566
}
567567
} else {
568568
oledClear();
@@ -578,7 +578,7 @@ static bool layoutOutput(const CardanoTxOutput *output) {
578578
ret = true;
579579
break;
580580
}
581-
if (key == KEY_CANCEL) {
581+
if (key == KEY_CANCEL || key == KEY_NULL) {
582582
ret = false;
583583
break;
584584
}
@@ -604,7 +604,7 @@ static bool layoutFinal(void) {
604604
return true;
605605
break;
606606
}
607-
if (key == KEY_CANCEL) {
607+
if (key == KEY_CANCEL || key == KEY_NULL) {
608608
return false;
609609
}
610610
}
@@ -633,7 +633,7 @@ static bool layoutFee(void) {
633633
if (key == KEY_CONFIRM) {
634634
break;
635635
}
636-
if (key == KEY_CANCEL) {
636+
if (key == KEY_CANCEL || key == KEY_NULL) {
637637
return false;
638638
}
639639
}
@@ -790,6 +790,7 @@ bool txHashBuilder_addToken(const CardanoToken *msg) {
790790
ret = false;
791791
break;
792792
default:
793+
ret = false;
793794
break;
794795
}
795796
if (!ret) {
@@ -863,7 +864,7 @@ static bool layoutCertificate(const CardanoTxCertificate *cert) {
863864
if (key == KEY_CONFIRM) {
864865
break;
865866
}
866-
if (key == KEY_CANCEL) {
867+
if (key == KEY_CANCEL || key == KEY_NULL) {
867868
return false;
868869
}
869870
}
@@ -884,7 +885,7 @@ static bool layoutCertificate(const CardanoTxCertificate *cert) {
884885
if (key == KEY_CONFIRM) {
885886
break;
886887
}
887-
if (key == KEY_CANCEL) {
888+
if (key == KEY_CANCEL || key == KEY_NULL) {
888889
return false;
889890
}
890891
}
@@ -907,7 +908,7 @@ static bool layoutCertificate(const CardanoTxCertificate *cert) {
907908
if (key == KEY_CONFIRM) {
908909
break;
909910
}
910-
if (key == KEY_CANCEL) {
911+
if (key == KEY_CANCEL || key == KEY_NULL) {
911912
return false;
912913
}
913914
}

legacy/firmware/fsm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ bool fsm_layoutPathWarning(uint32_t address_n_count,
536536
&bmp_bottom_right_confirm, NULL, desc, NULL, NULL, NULL,
537537
NULL);
538538

539-
if (!protectButton(ButtonRequestType_ButtonRequest_UnknownDerivationPath,
540-
false)) {
539+
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_UnknownDerivationPath,
540+
true, 0, 1) != KEY_CONFIRM) {
541541
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
542542
return false;
543543
}

legacy/firmware/language.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ const char *languages[][2] = {
276276
{"Decrypted signed message", "解密签名消息"},
277277
// cosmos.c
278278
{"Delegate", "委托"},
279+
{"Delegate Resource Contract", "资源委托合约"},
279280
{"Delegator", "代理方"},
280281
{"Deposit", "存款"},
281282
{"Deposit Amount", "存款金额"},
@@ -419,6 +420,9 @@ const char *languages[][2] = {
419420
{"For more information", "了解更多"},
420421
// layout2.c
421422
{"Format:", "格式:"},
423+
// tron.c
424+
{"Freeze Balance V2 Contract", "冻结余额 V2 合约"},
425+
// layout2.c
422426
{"From", "发送方"},
423427
// layout2.c
424428
{"GPG sign for:", ""},
@@ -793,6 +797,9 @@ const char *languages[][2] = {
793797
{"U2F Register", "U2F 注册"},
794798
// menu_list.c
795799
{"USB Lock", "USB 锁"},
800+
// tron.c
801+
{"UnDelegate Resource Contract", "取消资源委托合约"},
802+
{"UnFreeze Balance V2 Contract", "解冻余额 V2 合约"},
796803
// fsm_msg_ethereum.h
797804
{"Unable to show EIP-712 data. Sign at your own risk.",
798805
"无法显示 EIP-712 数据.\n请谨慎甄别项目方后决定是否签名, 自负风险"},
@@ -848,6 +855,9 @@ const char *languages[][2] = {
848855
{"Warning!", "警告"},
849856
// layout2.c
850857
{"Welcome to OneKey!", "感谢使用 OneKey!"},
858+
// tron.c
859+
{"Withdraw Balance Contract", "余额提现合约"},
860+
{"Withdraw Expire Unfreeze Contract", "撤销到期解冻合约"},
851861
// cosmos.c
852862
{"Withdraw Reward", "提取奖励"},
853863
{"Withdraw Validator Commission", "提取验证者佣金"},
@@ -1012,7 +1022,7 @@ const char *languages[][2] = {
10121022
//
10131023
{"transaction is set to", "被设定为"},
10141024
// layout2.c layout2.c
1015-
{"transaction?", "交易?"},
1025+
{"transaction?", "交易吗?"},
10161026
{"user: ", "用户:"},
10171027
// u2f.c
10181028
{"was used to register", "注册"},

legacy/firmware/layout2.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void chargeDisTimer(void) {
8181
#endif
8282
#define LOCKTIME_TIMESTAMP_MIN_VALUE 500000000
8383

84-
void hide_icons(void) { hide_icon = true; }
84+
void hide_icons(bool hide) { hide_icon = hide; }
8585

8686
const char *address_n_str(const uint32_t *address_n, size_t address_n_count,
8787
bool address_is_account) {
@@ -271,6 +271,8 @@ uint8_t refreshBleIcon(bool force_flag) {
271271
if (sys_bleState() == true) {
272272
if (force_flag || false == ble_conn_status_old) {
273273
ble_conn_status_old = true;
274+
oledClearBitmap(OLED_WIDTH - 2 * LOGO_WIDTH - 16, 0,
275+
&bmp_status_ble_connect);
274276
if (usb_status) {
275277
oledDrawBitmap(OLED_WIDTH - 2 * LOGO_WIDTH - 16, 0,
276278
&bmp_status_ble_connect);
@@ -285,6 +287,7 @@ uint8_t refreshBleIcon(bool force_flag) {
285287
ble_conn_status_old = false;
286288
ret = 1;
287289
}
290+
oledClearBitmap(OLED_WIDTH - 2 * LOGO_WIDTH - 16, 0, &bmp_status_ble);
288291
if (usb_status) {
289292
oledDrawBitmap(OLED_WIDTH - 2 * LOGO_WIDTH - 16, 0, &bmp_status_ble);
290293
} else {
@@ -448,7 +451,11 @@ uint8_t layoutStatusLogoEx(bool need_fresh, bool force_fresh) {
448451

449452
refreshNfcIcon(force_fresh);
450453

451-
ret = refreshBleIcon(force_fresh);
454+
if (layoutLast == layoutHome) {
455+
refreshBleIcon(true);
456+
} else {
457+
refreshBleIcon(force_fresh);
458+
}
452459

453460
disLongPressBleTips();
454461

@@ -962,7 +969,7 @@ bool layoutConfirmOutput(const CoinInfo *coin, AmountUnit amount_unit,
962969
case KEY_CANCEL:
963970
return false;
964971
default:
965-
break;
972+
return false;
966973
}
967974

968975
return true;
@@ -1120,7 +1127,7 @@ bool layoutConfirmTx(const CoinInfo *coin, AmountUnit amount_unit,
11201127
if (key == KEY_CONFIRM) {
11211128
break;
11221129
}
1123-
if (key == KEY_CANCEL) {
1130+
if (key == KEY_CANCEL || key == KEY_NULL) {
11241131
return false;
11251132
}
11261133
}
@@ -1137,7 +1144,7 @@ bool layoutConfirmTx(const CoinInfo *coin, AmountUnit amount_unit,
11371144
if (key == KEY_CONFIRM) {
11381145
break;
11391146
}
1140-
if (key == KEY_CANCEL) {
1147+
if (key == KEY_CANCEL || key == KEY_NULL) {
11411148
return false;
11421149
}
11431150
}

legacy/firmware/layout2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,6 @@ bool layoutSignHash(const char *chain_name, bool verify, const char *signer,
289289
bool layoutPaginated(const char *title, const uint8_t *data, uint16_t len);
290290

291291
void onboarding(uint8_t key);
292-
void hide_icons(void);
292+
void hide_icons(bool hide);
293293

294294
#endif

legacy/firmware/menu_list.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,13 @@ void menu_set_trezor_compatibility(int index) {
418418
}
419419
}
420420

421+
bool trezor_comp_mode = false;
422+
config_getTrezorCompMode(&trezor_comp_mode);
421423
config_setTrezorCompMode(index ? false : true);
422424
#if !EMULATOR
423-
svc_system_reset();
425+
if ((index && trezor_comp_mode) || (!index && !trezor_comp_mode)) {
426+
svc_system_reset();
427+
}
424428
#endif
425429
}
426430

legacy/firmware/pinmatrix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void pinmatrix_draw(const char *text) {
3333
&bmp_digit5, &bmp_digit6, &bmp_digit7, &bmp_digit8, &bmp_digit9,
3434
};
3535
oledClear();
36-
hide_icons();
36+
hide_icons(true);
3737
if (text) {
3838
oledDrawStringCenterAdapter(OLED_WIDTH / 2, 0, text, FONT_STANDARD);
3939
}

legacy/firmware/protect.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,7 @@ uint8_t protectWaitKey(uint32_t time_out, uint8_t mode) {
771771
timer_out_set(timer_out_oper, time_out);
772772
while (1) {
773773
if (layoutEnterSleep(1)) {
774+
key = KEY_NULL;
774775
protectAbortedBySleep = true;
775776
break;
776777
}
@@ -1252,6 +1253,7 @@ void enter_sleep(void) {
12521253
oledBufferRestore(oled_prev);
12531254
oledRefresh();
12541255
device_sleep_state = SLEEP_NONE;
1256+
hide_icons(false);
12551257
return;
12561258
}
12571259
}

legacy/firmware/signing.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
#include "signing.h"
21+
#include "buttons.h"
2122
#include "config.h"
2223
#include "crypto.h"
2324
#include "ecdsa.h"
@@ -793,7 +794,8 @@ void phase1_request_next_input(void) {
793794

794795
// Confirm original TXID.
795796
layoutConfirmReplacement(description, orig_hash);
796-
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
797+
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0,
798+
1) != KEY_CONFIRM) {
797799
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
798800
signing_abort();
799801
return;
@@ -2055,8 +2057,8 @@ static bool compile_output(TxOutputType *in, TxOutputBinType *out,
20552057
layoutConfirmOpReturn(in->op_return_data.bytes,
20562058
in->op_return_data.size);
20572059
}
2058-
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput,
2059-
false)) {
2060+
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_ConfirmOutput,
2061+
true, 0, 1) != KEY_CONFIRM) {
20602062
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
20612063
signing_abort();
20622064
return false;
@@ -2425,8 +2427,8 @@ static bool signing_add_orig_output(TxOutputType *orig_output) {
24252427
for (int page = 0; page < 2; ++page) {
24262428
layoutConfirmModifyOutput(coin, amount_unit, &output, orig_output,
24272429
page);
2428-
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput,
2429-
false)) {
2430+
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_ConfirmOutput,
2431+
true, 0, 1) != KEY_CONFIRM) {
24302432
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
24312433
signing_abort();
24322434
return false;
@@ -2451,7 +2453,8 @@ static bool signing_add_orig_output(TxOutputType *orig_output) {
24512453
static bool payment_confirm_tx(void) {
24522454
if (has_unverified_external_input) {
24532455
layoutConfirmUnverifiedExternalInputs();
2454-
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
2456+
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0,
2457+
1) != KEY_CONFIRM) {
24552458
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
24562459
signing_abort();
24572460
return false;
@@ -2475,8 +2478,8 @@ static bool payment_confirm_tx(void) {
24752478
fee = total_in - total_out;
24762479
if (fee > ((uint64_t)tx_weight * coin->maxfee_kb) / 4000) {
24772480
layoutFeeOverThreshold(coin, amount_unit, fee);
2478-
if (!protectButton(ButtonRequestType_ButtonRequest_FeeOverThreshold,
2479-
false)) {
2481+
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_FeeOverThreshold,
2482+
true, 0, 1) != KEY_CONFIRM) {
24802483
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
24812484
signing_abort();
24822485
return false;
@@ -2488,7 +2491,8 @@ static bool payment_confirm_tx(void) {
24882491

24892492
if (change_count > MAX_SILENT_CHANGE_COUNT) {
24902493
layoutChangeCountOverThreshold(change_count);
2491-
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
2494+
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0,
2495+
1) != KEY_CONFIRM) {
24922496
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
24932497
signing_abort();
24942498
return false;
@@ -2548,7 +2552,8 @@ static bool payment_confirm_tx(void) {
25482552
// Fee modification.
25492553
if (fee != orig_fee) {
25502554
layoutConfirmModifyFee(coin, amount_unit, orig_fee, fee, tx_weight);
2551-
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
2555+
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0,
2556+
1) != KEY_CONFIRM) {
25522557
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
25532558
signing_abort();
25542559
return false;
@@ -2560,7 +2565,8 @@ static bool payment_confirm_tx(void) {
25602565
if (info.lock_time != 0) {
25612566
bool lock_time_disabled = (info.min_sequence == SEQUENCE_FINAL);
25622567
layoutConfirmNondefaultLockTime(info.lock_time, lock_time_disabled);
2563-
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
2568+
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0,
2569+
1) != KEY_CONFIRM) {
25642570
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
25652571
signing_abort();
25662572
return false;

legacy/firmware/solana.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ void solana_sign_tx(const SolanaSignTx *msg, const HDNode *node,
138138

139139
uint8_t key;
140140
button_scan:
141-
key = protectButtonValue(ButtonRequestType_ButtonRequest_ProtectCall,
142-
false, true, 0);
141+
key = protectWaitKeyValue(ButtonRequestType_ButtonRequest_ProtectCall,
142+
true, 0, 0);
143143
if (key == KEY_CANCEL) {
144144
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
145145
return;
@@ -154,6 +154,9 @@ void solana_sign_tx(const SolanaSignTx *msg, const HDNode *node,
154154
if (i == num_summary_steps - 1) {
155155
goto button_scan;
156156
}
157+
} else if (key == KEY_NULL) {
158+
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
159+
return;
157160
}
158161
}
159162
}

0 commit comments

Comments
 (0)