diff --git a/legacy/firmware/ada.c b/legacy/firmware/ada.c index 8a1b6eb6fd..a64e277b6d 100644 --- a/legacy/firmware/ada.c +++ b/legacy/firmware/ada.c @@ -459,7 +459,7 @@ static bool layoutOutput(const CardanoTxOutput *output) { ret = true; break; } - if (key == KEY_CANCEL) { + if (key == KEY_CANCEL || key == KEY_NULL) { return false; } } @@ -488,7 +488,7 @@ static bool layoutOutput(const CardanoTxOutput *output) { ret = true; break; } - if (key == KEY_CANCEL) { + if (key == KEY_CANCEL || key == KEY_NULL) { return false; } } @@ -562,7 +562,7 @@ static bool layoutOutput(const CardanoTxOutput *output) { case KEY_CANCEL: return false; default: - goto refresh_addr; + return false; } } else { oledClear(); @@ -578,7 +578,7 @@ static bool layoutOutput(const CardanoTxOutput *output) { ret = true; break; } - if (key == KEY_CANCEL) { + if (key == KEY_CANCEL || key == KEY_NULL) { ret = false; break; } @@ -604,7 +604,7 @@ static bool layoutFinal(void) { return true; break; } - if (key == KEY_CANCEL) { + if (key == KEY_CANCEL || key == KEY_NULL) { return false; } } @@ -633,7 +633,7 @@ static bool layoutFee(void) { if (key == KEY_CONFIRM) { break; } - if (key == KEY_CANCEL) { + if (key == KEY_CANCEL || key == KEY_NULL) { return false; } } @@ -790,6 +790,7 @@ bool txHashBuilder_addToken(const CardanoToken *msg) { ret = false; break; default: + ret = false; break; } if (!ret) { @@ -863,7 +864,7 @@ static bool layoutCertificate(const CardanoTxCertificate *cert) { if (key == KEY_CONFIRM) { break; } - if (key == KEY_CANCEL) { + if (key == KEY_CANCEL || key == KEY_NULL) { return false; } } @@ -884,7 +885,7 @@ static bool layoutCertificate(const CardanoTxCertificate *cert) { if (key == KEY_CONFIRM) { break; } - if (key == KEY_CANCEL) { + if (key == KEY_CANCEL || key == KEY_NULL) { return false; } } @@ -907,7 +908,7 @@ static bool layoutCertificate(const CardanoTxCertificate *cert) { if (key == KEY_CONFIRM) { break; } - if (key == KEY_CANCEL) { + if (key == KEY_CANCEL || key == KEY_NULL) { return false; } } diff --git a/legacy/firmware/fsm.c b/legacy/firmware/fsm.c index 256fcc9159..ceba239605 100644 --- a/legacy/firmware/fsm.c +++ b/legacy/firmware/fsm.c @@ -536,8 +536,8 @@ bool fsm_layoutPathWarning(uint32_t address_n_count, &bmp_bottom_right_confirm, NULL, desc, NULL, NULL, NULL, NULL); - if (!protectButton(ButtonRequestType_ButtonRequest_UnknownDerivationPath, - false)) { + if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_UnknownDerivationPath, + true, 0, 1) != KEY_CONFIRM) { fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); return false; } diff --git a/legacy/firmware/language.c b/legacy/firmware/language.c index 0e6f27e728..177bd11e56 100644 --- a/legacy/firmware/language.c +++ b/legacy/firmware/language.c @@ -276,6 +276,7 @@ const char *languages[][2] = { {"Decrypted signed message", "解密签名消息"}, // cosmos.c {"Delegate", "委托"}, + {"Delegate Resource Contract", "资源委托合约"}, {"Delegator", "代理方"}, {"Deposit", "存款"}, {"Deposit Amount", "存款金额"}, @@ -419,6 +420,9 @@ const char *languages[][2] = { {"For more information", "了解更多"}, // layout2.c {"Format:", "格式:"}, + // tron.c + {"Freeze Balance V2 Contract", "冻结余额 V2 合约"}, + // layout2.c {"From", "发送方"}, // layout2.c {"GPG sign for:", ""}, @@ -793,6 +797,9 @@ const char *languages[][2] = { {"U2F Register", "U2F 注册"}, // menu_list.c {"USB Lock", "USB 锁"}, + // tron.c + {"UnDelegate Resource Contract", "取消资源委托合约"}, + {"UnFreeze Balance V2 Contract", "解冻余额 V2 合约"}, // fsm_msg_ethereum.h {"Unable to show EIP-712 data. Sign at your own risk.", "无法显示 EIP-712 数据.\n请谨慎甄别项目方后决定是否签名, 自负风险"}, @@ -848,6 +855,9 @@ const char *languages[][2] = { {"Warning!", "警告"}, // layout2.c {"Welcome to OneKey!", "感谢使用 OneKey!"}, + // tron.c + {"Withdraw Balance Contract", "余额提现合约"}, + {"Withdraw Expire Unfreeze Contract", "撤销到期解冻合约"}, // cosmos.c {"Withdraw Reward", "提取奖励"}, {"Withdraw Validator Commission", "提取验证者佣金"}, @@ -1012,7 +1022,7 @@ const char *languages[][2] = { // {"transaction is set to", "被设定为"}, // layout2.c layout2.c - {"transaction?", "交易?"}, + {"transaction?", "交易吗?"}, {"user: ", "用户:"}, // u2f.c {"was used to register", "注册"}, diff --git a/legacy/firmware/layout2.c b/legacy/firmware/layout2.c index 12c8a3623e..40f75d7c5b 100644 --- a/legacy/firmware/layout2.c +++ b/legacy/firmware/layout2.c @@ -81,7 +81,7 @@ void chargeDisTimer(void) { #endif #define LOCKTIME_TIMESTAMP_MIN_VALUE 500000000 -void hide_icons(void) { hide_icon = true; } +void hide_icons(bool hide) { hide_icon = hide; } const char *address_n_str(const uint32_t *address_n, size_t address_n_count, bool address_is_account) { @@ -271,6 +271,8 @@ uint8_t refreshBleIcon(bool force_flag) { if (sys_bleState() == true) { if (force_flag || false == ble_conn_status_old) { ble_conn_status_old = true; + oledClearBitmap(OLED_WIDTH - 2 * LOGO_WIDTH - 16, 0, + &bmp_status_ble_connect); if (usb_status) { oledDrawBitmap(OLED_WIDTH - 2 * LOGO_WIDTH - 16, 0, &bmp_status_ble_connect); @@ -285,6 +287,7 @@ uint8_t refreshBleIcon(bool force_flag) { ble_conn_status_old = false; ret = 1; } + oledClearBitmap(OLED_WIDTH - 2 * LOGO_WIDTH - 16, 0, &bmp_status_ble); if (usb_status) { oledDrawBitmap(OLED_WIDTH - 2 * LOGO_WIDTH - 16, 0, &bmp_status_ble); } else { @@ -448,7 +451,11 @@ uint8_t layoutStatusLogoEx(bool need_fresh, bool force_fresh) { refreshNfcIcon(force_fresh); - ret = refreshBleIcon(force_fresh); + if (layoutLast == layoutHome) { + refreshBleIcon(true); + } else { + refreshBleIcon(force_fresh); + } disLongPressBleTips(); @@ -962,7 +969,7 @@ bool layoutConfirmOutput(const CoinInfo *coin, AmountUnit amount_unit, case KEY_CANCEL: return false; default: - break; + return false; } return true; @@ -1120,7 +1127,7 @@ bool layoutConfirmTx(const CoinInfo *coin, AmountUnit amount_unit, if (key == KEY_CONFIRM) { break; } - if (key == KEY_CANCEL) { + if (key == KEY_CANCEL || key == KEY_NULL) { return false; } } @@ -1137,7 +1144,7 @@ bool layoutConfirmTx(const CoinInfo *coin, AmountUnit amount_unit, if (key == KEY_CONFIRM) { break; } - if (key == KEY_CANCEL) { + if (key == KEY_CANCEL || key == KEY_NULL) { return false; } } diff --git a/legacy/firmware/layout2.h b/legacy/firmware/layout2.h index 9d6897d5b8..8d6808bb2f 100644 --- a/legacy/firmware/layout2.h +++ b/legacy/firmware/layout2.h @@ -289,6 +289,6 @@ bool layoutSignHash(const char *chain_name, bool verify, const char *signer, bool layoutPaginated(const char *title, const uint8_t *data, uint16_t len); void onboarding(uint8_t key); -void hide_icons(void); +void hide_icons(bool hide); #endif diff --git a/legacy/firmware/menu_list.c b/legacy/firmware/menu_list.c index 8d6f66f065..6404f87f79 100644 --- a/legacy/firmware/menu_list.c +++ b/legacy/firmware/menu_list.c @@ -418,9 +418,13 @@ void menu_set_trezor_compatibility(int index) { } } + bool trezor_comp_mode = false; + config_getTrezorCompMode(&trezor_comp_mode); config_setTrezorCompMode(index ? false : true); #if !EMULATOR - svc_system_reset(); + if ((index && trezor_comp_mode) || (!index && !trezor_comp_mode)) { + svc_system_reset(); + } #endif } diff --git a/legacy/firmware/pinmatrix.c b/legacy/firmware/pinmatrix.c index 71f1180e99..b9c81570c3 100644 --- a/legacy/firmware/pinmatrix.c +++ b/legacy/firmware/pinmatrix.c @@ -33,7 +33,7 @@ void pinmatrix_draw(const char *text) { &bmp_digit5, &bmp_digit6, &bmp_digit7, &bmp_digit8, &bmp_digit9, }; oledClear(); - hide_icons(); + hide_icons(true); if (text) { oledDrawStringCenterAdapter(OLED_WIDTH / 2, 0, text, FONT_STANDARD); } diff --git a/legacy/firmware/protect.c b/legacy/firmware/protect.c index 373808a29f..4cdd753a02 100644 --- a/legacy/firmware/protect.c +++ b/legacy/firmware/protect.c @@ -771,6 +771,7 @@ uint8_t protectWaitKey(uint32_t time_out, uint8_t mode) { timer_out_set(timer_out_oper, time_out); while (1) { if (layoutEnterSleep(1)) { + key = KEY_NULL; protectAbortedBySleep = true; break; } @@ -1252,6 +1253,7 @@ void enter_sleep(void) { oledBufferRestore(oled_prev); oledRefresh(); device_sleep_state = SLEEP_NONE; + hide_icons(false); return; } } diff --git a/legacy/firmware/signing.c b/legacy/firmware/signing.c index 126395098b..8e1c8e3cdd 100644 --- a/legacy/firmware/signing.c +++ b/legacy/firmware/signing.c @@ -18,6 +18,7 @@ */ #include "signing.h" +#include "buttons.h" #include "config.h" #include "crypto.h" #include "ecdsa.h" @@ -793,7 +794,8 @@ void phase1_request_next_input(void) { // Confirm original TXID. layoutConfirmReplacement(description, orig_hash); - if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) { + if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0, + 1) != KEY_CONFIRM) { fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); signing_abort(); return; @@ -2055,8 +2057,8 @@ static bool compile_output(TxOutputType *in, TxOutputBinType *out, layoutConfirmOpReturn(in->op_return_data.bytes, in->op_return_data.size); } - if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, - false)) { + if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_ConfirmOutput, + true, 0, 1) != KEY_CONFIRM) { fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); signing_abort(); return false; @@ -2425,8 +2427,8 @@ static bool signing_add_orig_output(TxOutputType *orig_output) { for (int page = 0; page < 2; ++page) { layoutConfirmModifyOutput(coin, amount_unit, &output, orig_output, page); - if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, - false)) { + if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_ConfirmOutput, + true, 0, 1) != KEY_CONFIRM) { fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); signing_abort(); return false; @@ -2451,7 +2453,8 @@ static bool signing_add_orig_output(TxOutputType *orig_output) { static bool payment_confirm_tx(void) { if (has_unverified_external_input) { layoutConfirmUnverifiedExternalInputs(); - if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) { + if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0, + 1) != KEY_CONFIRM) { fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); signing_abort(); return false; @@ -2475,8 +2478,8 @@ static bool payment_confirm_tx(void) { fee = total_in - total_out; if (fee > ((uint64_t)tx_weight * coin->maxfee_kb) / 4000) { layoutFeeOverThreshold(coin, amount_unit, fee); - if (!protectButton(ButtonRequestType_ButtonRequest_FeeOverThreshold, - false)) { + if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_FeeOverThreshold, + true, 0, 1) != KEY_CONFIRM) { fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); signing_abort(); return false; @@ -2488,7 +2491,8 @@ static bool payment_confirm_tx(void) { if (change_count > MAX_SILENT_CHANGE_COUNT) { layoutChangeCountOverThreshold(change_count); - if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) { + if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0, + 1) != KEY_CONFIRM) { fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); signing_abort(); return false; @@ -2548,7 +2552,8 @@ static bool payment_confirm_tx(void) { // Fee modification. if (fee != orig_fee) { layoutConfirmModifyFee(coin, amount_unit, orig_fee, fee, tx_weight); - if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) { + if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0, + 1) != KEY_CONFIRM) { fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); signing_abort(); return false; @@ -2560,7 +2565,8 @@ static bool payment_confirm_tx(void) { if (info.lock_time != 0) { bool lock_time_disabled = (info.min_sequence == SEQUENCE_FINAL); layoutConfirmNondefaultLockTime(info.lock_time, lock_time_disabled); - if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) { + if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0, + 1) != KEY_CONFIRM) { fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); signing_abort(); return false; diff --git a/legacy/firmware/solana.c b/legacy/firmware/solana.c index 913e105b0f..5f2b87a337 100644 --- a/legacy/firmware/solana.c +++ b/legacy/firmware/solana.c @@ -138,8 +138,8 @@ void solana_sign_tx(const SolanaSignTx *msg, const HDNode *node, uint8_t key; button_scan: - key = protectButtonValue(ButtonRequestType_ButtonRequest_ProtectCall, - false, true, 0); + key = protectWaitKeyValue(ButtonRequestType_ButtonRequest_ProtectCall, + true, 0, 0); if (key == KEY_CANCEL) { fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); return; @@ -154,6 +154,9 @@ void solana_sign_tx(const SolanaSignTx *msg, const HDNode *node, if (i == num_summary_steps - 1) { goto button_scan; } + } else if (key == KEY_NULL) { + fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); + return; } } } diff --git a/legacy/firmware/tron.c b/legacy/firmware/tron.c index 783babbb4b..4d10b3853c 100644 --- a/legacy/firmware/tron.c +++ b/legacy/firmware/tron.c @@ -687,10 +687,10 @@ bool layoutFreezeV2Sign(TronSignTx *msg) { layoutHeader(tx_msg[0]); oledDrawStringAdapter(0, y, _("Type:"), FONT_STANDARD); if (msg->contract.has_freeze_balance_v2_contract) { - oledDrawStringAdapter(0, y + 10, "FreezeBalanceV2Contract", + oledDrawStringAdapter(0, y + 10, _("Freeze Balance V2 Contract"), FONT_STANDARD); } else { - oledDrawStringAdapter(0, y + 10, "UnfreezeBalanceV2Contract", + oledDrawStringAdapter(0, y + 10, _("UnFreeze Balance V2 Contract"), FONT_STANDARD); } layoutButtonNoAdapter(NULL, &bmp_bottom_left_close); @@ -789,10 +789,10 @@ bool layoutDelegateResourceSign(TronSignTx *msg) { layoutHeader(tx_msg[0]); oledDrawStringAdapter(0, y, _("Type:"), FONT_STANDARD); if (msg->contract.has_delegate_resource_contract) { - oledDrawStringAdapter(0, y + 10, "DelegateResourceContract", + oledDrawStringAdapter(0, y + 10, _("Delegate Resource Contract"), FONT_STANDARD); } else { - oledDrawStringAdapter(0, y + 10, "UnDelegateResourceContract", + oledDrawStringAdapter(0, y + 10, _("UnDelegate Resource Contract"), FONT_STANDARD); } layoutButtonNoAdapter(NULL, &bmp_bottom_left_close); @@ -946,7 +946,7 @@ bool tron_sign_tx(TronSignTx *msg, const char *owner_address, } else if (msg->contract.has_withdraw_balance_contract) { layoutDialogAdapterEx(tx_msg[0], &bmp_bottom_left_close, NULL, &bmp_bottom_right_arrow, NULL, NULL, _("Type:"), - "TronWithdrawBalanceContract", NULL, NULL); + _("Withdraw Balance Contract"), NULL, NULL); if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) { fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); return false; @@ -967,7 +967,7 @@ bool tron_sign_tx(TronSignTx *msg, const char *owner_address, } else if (msg->contract.has_withdraw_expire_unfreeze_contract) { layoutDialogAdapterEx(tx_msg[0], &bmp_bottom_left_close, NULL, &bmp_bottom_right_arrow, NULL, NULL, _("Type:"), - "WithdrawExpireUnfreezeContract", NULL, NULL); + _("Withdraw Expire Unfreeze Contract"), NULL, NULL); if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) { fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); return false;