Skip to content

Commit a365c67

Browse files
committed
Merge branch 'params-name'
2 parents cab0fe5 + 5f2876b commit a365c67

File tree

17 files changed

+55
-75
lines changed

17 files changed

+55
-75
lines changed

src/apps/btc/btc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ app_btc_result_t app_btc_address_multisig(
9090

9191
const char* title = "Receive to";
9292

93-
if (!apps_btc_confirm_multisig_basic(title, coin, multisig_registered_name, multisig)) {
93+
if (!apps_btc_confirm_multisig_basic(title, params, multisig_registered_name, multisig)) {
9494
return APP_BTC_ERR_USER_ABORT;
9595
}
9696

@@ -209,7 +209,7 @@ app_btc_result_t app_btc_register_script_config(
209209
}
210210

211211
if (!apps_btc_confirm_multisig_extended(
212-
"Register", coin, name, multisig, xpub_type, keypath, keypath_len)) {
212+
"Register", params, name, multisig, xpub_type, keypath, keypath_len)) {
213213
return APP_BTC_ERR_USER_ABORT;
214214
}
215215

src/apps/btc/btc_common.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,6 @@
2727

2828
#define MULTISIG_P2WSH_MAX_SIGNERS 15
2929

30-
const char* btc_common_coin_name(BTCCoin coin)
31-
{
32-
static const char* _coin_btc = "Bitcoin";
33-
static const char* _coin_tbtc = "BTC Testnet";
34-
static const char* _coin_ltc = "Litecoin";
35-
static const char* _coin_tltc = "LTC Testnet";
36-
37-
switch (coin) {
38-
case BTCCoin_BTC:
39-
return _coin_btc;
40-
case BTCCoin_TBTC:
41-
return _coin_tbtc;
42-
case BTCCoin_LTC:
43-
return _coin_ltc;
44-
case BTCCoin_TLTC:
45-
return _coin_tltc;
46-
default:
47-
Abort("btc_common_coin_name");
48-
}
49-
}
50-
5130
bool btc_common_is_valid_keypath_account_simple(
5231
BTCScriptConfig_SimpleType script_type,
5332
const uint32_t* keypath,

src/apps/btc/btc_common.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@
3636
// is technically possible to extend to if needed.
3737
#define MAX_PK_SCRIPT_SIZE (700)
3838

39-
/**
40-
* Returns the coin name to be used in confirm dialogs ("Bitcoin", "Litecoin", etc.). Aborts for an
41-
* invalid coin.
42-
*/
43-
USE_RESULT const char* btc_common_coin_name(BTCCoin coin);
44-
4539
/**
4640
* Does limit checks the keypath, whitelisting bip44 purposes and accounts.
4741
* @return true if the keypath is valid, false if it is invalid.

src/apps/btc/btc_params.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,45 @@
1818
// Keep these in sync with hww/api/bitcoin/params.rs
1919

2020
static const app_btc_coin_params_t _params_btc = {
21+
.coin = BTCCoin_BTC,
2122
.bip44_coin = 0 + BIP32_INITIAL_HARDENED_CHILD,
2223
.base58_version_p2pkh = 0x00, // starts with 1
2324
.base58_version_p2sh = 0x05, // starts with 3
2425
.bech32_hrp = "bc",
26+
.name = "Bitcoin",
2527
.unit = "BTC",
2628
.rbf_support = true,
2729
};
2830

2931
static const app_btc_coin_params_t _params_tbtc = {
32+
.coin = BTCCoin_TBTC,
3033
.bip44_coin = 1 + BIP32_INITIAL_HARDENED_CHILD,
3134
.base58_version_p2pkh = 0x6f, // starts with m or n
3235
.base58_version_p2sh = 0xc4, // starts with 2
3336
.bech32_hrp = "tb",
37+
.name = "BTC Testnet",
3438
.unit = "TBTC",
3539
.rbf_support = true,
3640
};
3741

3842
static const app_btc_coin_params_t _params_ltc = {
43+
.coin = BTCCoin_LTC,
3944
.bip44_coin = 2 + BIP32_INITIAL_HARDENED_CHILD,
4045
.base58_version_p2pkh = 0x30, // starts with L
4146
.base58_version_p2sh = 0x32, // starts with M
4247
.bech32_hrp = "ltc",
48+
.name = "Litecoin",
4349
.unit = "LTC",
4450
.rbf_support = false,
4551
};
4652

4753
static const app_btc_coin_params_t _params_tltc = {
54+
.coin = BTCCoin_TLTC,
4855
.bip44_coin = 1 + BIP32_INITIAL_HARDENED_CHILD,
4956
.base58_version_p2pkh = 0x6f, // starts with m or n
5057
.base58_version_p2sh = 0xc4, // starts with 2
5158
.bech32_hrp = "tltc",
59+
.name = "LTC testnet",
5260
.unit = "TLTC",
5361
.rbf_support = false,
5462
};

src/apps/btc/btc_params.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
#include <hww.pb.h>
1919

2020
typedef struct {
21+
BTCCoin coin;
2122
uint32_t bip44_coin;
2223
uint8_t base58_version_p2pkh;
2324
uint8_t base58_version_p2sh;
2425
const char* bech32_hrp;
26+
const char* name;
2527
// unit to use in formatted amounts, e.g. "BTC".
2628
const char* unit;
2729
bool rbf_support;

src/apps/btc/btc_sign_validate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ app_btc_result_t app_btc_sign_validate_init_script_configs(
6262
return APP_BTC_ERR_INVALID_INPUT;
6363
}
6464
if (!apps_btc_confirm_multisig_basic(
65-
"Spend from", coin, multisig_registered_name, multisig)) {
65+
"Spend from", coin_params, multisig_registered_name, multisig)) {
6666
return APP_BTC_ERR_USER_ABORT;
6767
}
6868
return APP_BTC_OK;

src/apps/btc/confirm_multisig.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
bool apps_btc_confirm_multisig_basic(
2727
const char* title,
28-
BTCCoin coin,
28+
const app_btc_coin_params_t* params,
2929
const char* name,
3030
const BTCScriptConfig_Multisig* multisig)
3131
{
@@ -36,7 +36,7 @@ bool apps_btc_confirm_multisig_basic(
3636
"%lu-of-%lu\n%s multisig",
3737
(unsigned long)multisig->threshold,
3838
(unsigned long)multisig->xpubs_count,
39-
btc_common_coin_name(coin));
39+
params->name);
4040
if (snprintf_result < 0 || snprintf_result >= (int)sizeof(basic_info)) {
4141
Abort("apps_btc_confirm_multisig/0");
4242
}
@@ -60,7 +60,7 @@ bool apps_btc_confirm_multisig_basic(
6060

6161
bool apps_btc_confirm_multisig_extended(
6262
const char* title,
63-
BTCCoin coin,
63+
const app_btc_coin_params_t* params,
6464
const char* name,
6565
const BTCScriptConfig_Multisig* multisig,
6666
BTCRegisterScriptConfigRequest_XPubType xpub_type,
@@ -82,7 +82,7 @@ bool apps_btc_confirm_multisig_extended(
8282
rust_bip32_to_string(
8383
keypath, keypath_len, rust_util_cstr_mut(keypath_string, sizeof(keypath_string)));
8484

85-
if (!apps_btc_confirm_multisig_basic(title, coin, name, multisig)) {
85+
if (!apps_btc_confirm_multisig_basic(title, params, name, multisig)) {
8686
return false;
8787
}
8888

@@ -92,19 +92,19 @@ bool apps_btc_confirm_multisig_extended(
9292
if (snprintf_result < 0 || snprintf_result >= (int)sizeof(info)) {
9393
Abort("apps_btc_confirm_multisig/0");
9494
}
95-
const confirm_params_t params = {
95+
const confirm_params_t confirm_params = {
9696
.title = title,
9797
.body = info,
9898
.accept_is_nextarrow = true,
9999
};
100-
if (!workflow_confirm_blocking(&params)) {
100+
if (!workflow_confirm_blocking(&confirm_params)) {
101101
return false;
102102
}
103103

104104
xpub_type_t output_xpub_type;
105105
switch (xpub_type) {
106106
case BTCRegisterScriptConfigRequest_XPubType_AUTO_ELECTRUM:
107-
switch (coin) {
107+
switch (params->coin) {
108108
case BTCCoin_BTC:
109109
case BTCCoin_LTC:
110110
switch (multisig->script_type) {
@@ -136,7 +136,7 @@ bool apps_btc_confirm_multisig_extended(
136136
}
137137
break;
138138
case BTCRegisterScriptConfigRequest_XPubType_AUTO_XPUB_TPUB:
139-
switch (coin) {
139+
switch (params->coin) {
140140
case BTCCoin_BTC:
141141
case BTCCoin_LTC:
142142
output_xpub_type = XPUB;

src/apps/btc/confirm_multisig.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#ifndef _APPS_BTC_CONFIRM_MULTISIG_H_
1616
#define _APPS_BTC_CONFIRM_MULTISIG_H_
1717

18+
#include "btc_params.h"
19+
1820
#include <btc.pb.h>
1921
#include <compiler_util.h>
2022
#include <stdbool.h>
@@ -26,13 +28,13 @@
2628
* - multisig type (m-of-n)
2729
* - name given by the user
2830
* @param[in] title the title shown in each confirmation screen
29-
* @param[in] coin coin to be confirmed
31+
* @param[in] params Coin params of the coin to be confirmed.
3032
* @param[in] name User given name of the multisig account.
3133
* @param[in] multisig multisig details
3234
*/
3335
USE_RESULT bool apps_btc_confirm_multisig_basic(
3436
const char* title,
35-
BTCCoin coin,
37+
const app_btc_coin_params_t* params,
3638
const char* name,
3739
const BTCScriptConfig_Multisig* multisig);
3840

@@ -46,7 +48,7 @@ USE_RESULT bool apps_btc_confirm_multisig_basic(
4648
* - account keypath
4749
* - all xpubs (formatted according to `xpub_type`).
4850
* @param[in] title the title shown in each confirmation screen
49-
* @param[in] coin coin to be confirmed
51+
* @param[in] params Coin params of the coin to be confirmed.
5052
* @param[in] name User given name of the multisig account.
5153
* @param[in] multisig multisig details
5254
* @param[in] xpub_type: if AUTO_ELECTRUM, will automatically format xpubs as `Zpub/Vpub`,
@@ -56,7 +58,7 @@ USE_RESULT bool apps_btc_confirm_multisig_basic(
5658
*/
5759
USE_RESULT bool apps_btc_confirm_multisig_extended(
5860
const char* title,
59-
BTCCoin coin,
61+
const app_btc_coin_params_t* params,
6062
const char* name,
6163
const BTCScriptConfig_Multisig* multisig,
6264
BTCRegisterScriptConfigRequest_XPubType xpub_type,

src/apps/eth/eth_params.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,21 @@
2121
static const app_eth_coin_params_t _params_eth = {
2222
.bip44_coin = 60 + BIP32_INITIAL_HARDENED_CHILD,
2323
.chain_id = 1,
24+
.name = "Ethereum",
2425
.unit = "ETH",
2526
};
2627

2728
static const app_eth_coin_params_t _params_ropsten_eth = {
2829
.bip44_coin = 1 + BIP32_INITIAL_HARDENED_CHILD,
2930
.chain_id = 3,
31+
.name = "Ropsten",
3032
.unit = "TETH",
3133
};
3234

3335
static const app_eth_coin_params_t _params_rinkeby_eth = {
3436
.bip44_coin = 1 + BIP32_INITIAL_HARDENED_CHILD,
3537
.chain_id = 4,
38+
.name = "Rinkeby",
3639
.unit = "TETH",
3740
};
3841

src/apps/eth/eth_params.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ typedef struct {
2121
uint32_t bip44_coin;
2222
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md#list-of-chain-ids
2323
uint8_t chain_id;
24+
const char* name;
2425
const char* unit;
2526
} app_eth_coin_params_t;
2627

0 commit comments

Comments
 (0)