Skip to content

Commit c981946

Browse files
jgriffithsJamie C. Driver
authored andcommitted
network: make network function names/parameters consistent
1 parent b6c4b32 commit c981946

File tree

15 files changed

+91
-90
lines changed

15 files changed

+91
-90
lines changed

main/assets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ bool assets_get_allocate(const char* field, const CborValue* value, asset_info_t
193193
bool assets_get_info(const uint32_t network_id, const asset_info_t* assets, const size_t num_assets,
194194
const char* asset_id, asset_info_t* asset_info_out)
195195
{
196-
JADE_ASSERT(isLiquidNetworkId(network_id));
196+
JADE_ASSERT(network_is_liquid(network_id));
197197
JADE_ASSERT(assets || !num_assets);
198198
JADE_ASSERT(asset_id);
199199

main/keychain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ bool keychain_is_network_type_consistent(const network_type_t network_type)
241241

242242
bool keychain_is_network_id_consistent(const uint32_t network_id)
243243
{
244-
const network_type_t network_type = networkIdToType(network_id);
244+
const network_type_t network_type = network_to_type(network_id);
245245
return keychain_is_network_type_consistent(network_type);
246246
}
247247

main/process/auth_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ void auth_user_process(void* process_ptr)
442442
#ifndef CONFIG_DEBUG_MODE
443443
// If not a debug build, we restrict the hw to this network type
444444
// (In case it wasn't set at wallet creation/recovery time [older fw])
445-
keychain_set_network_type_restriction(networkIdToType(network_id));
445+
keychain_set_network_type_restriction(network_to_type(network_id));
446446
#endif
447447
JADE_LOGI("Success");
448448
}

main/process/get_receive_address.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void get_receive_address_process(void* process_ptr)
3131
ASSERT_KEYCHAIN_UNLOCKED_BY_MESSAGE_SOURCE(process);
3232
GET_MSG_PARAMS(process);
3333
CHECK_NETWORK_CONSISTENT(process);
34-
const bool isLiquid = isLiquidNetworkId(network_id);
34+
const bool isLiquid = network_is_liquid(network_id);
3535

3636
// Handle single-sig and generic multisig script variants
3737
// (Green-multisig is the default for backwards compatibility)
@@ -155,17 +155,17 @@ void get_receive_address_process(void* process_ptr)
155155
rpc_get_string("recovery_xpub", sizeof(xpubrecovery), &params, xpubrecovery, &written);
156156

157157
// Optional 'blocks' for csv outputs
158-
size_t csvBlocks = 0;
159-
rpc_get_sizet("csv_blocks", &params, &csvBlocks);
158+
size_t csv_blocks = 0;
159+
rpc_get_sizet("csv_blocks", &params, &csv_blocks);
160160

161-
if (csvBlocks && !csvBlocksExpectedForNetwork(network_id, csvBlocks)) {
161+
if (csv_blocks && !network_is_known_csv_blocks(network_id, csv_blocks)) {
162162
const int ret
163-
= snprintf(warning_msg, sizeof(warning_msg), "\nWarning:\nNon-standard csv:\n%u", csvBlocks);
163+
= snprintf(warning_msg, sizeof(warning_msg), "\nWarning:\nNon-standard csv:\n%u", csv_blocks);
164164
JADE_ASSERT(ret > 0 && ret < sizeof(warning_msg));
165165
}
166166

167167
// Build a script pubkey for the passed parameters
168-
if (!wallet_build_ga_script(network_id, written ? xpubrecovery : NULL, csvBlocks, path, path_len, script,
168+
if (!wallet_build_ga_script(network_id, written ? xpubrecovery : NULL, csv_blocks, path, path_len, script,
169169
sizeof(script), &script_len)) {
170170
jade_process_reject_message(
171171
process, CBOR_RPC_BAD_PARAMETERS, "Failed to generate valid green address script", NULL);

main/process/process_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bool jade_process_check_network(jade_process_t* process, CborValue* params, uint
2929
char network[MAX_NETWORK_NAME_LEN];
3030
size_t network_len;
3131
rpc_get_string("network", sizeof(network), params, network, &network_len);
32-
*network_id = networkToNetworkId(network_len ? network : NULL);
32+
*network_id = network_from_name(network_len ? network : NULL);
3333

3434
if (*network_id == WALLY_NETWORK_NONE) {
3535
jade_process_reject_message(

main/process/register_descriptor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static int register_descriptor(
3535
JADE_ASSERT(descriptor->num_values < MAX_ALLOWED_SIGNERS);
3636

3737
// Not valid for liquid wallets atm
38-
if (isLiquidNetworkId(network_id)) {
38+
if (network_is_liquid(network_id)) {
3939
*errmsg = "Descriptor wallets not supported on liquid network";
4040
return CBOR_RPC_BAD_PARAMETERS;
4141
}

main/process/sign_liquid_tx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ void sign_liquid_tx_process(void* process_ptr)
549549
GET_MSG_PARAMS(process);
550550
CHECK_NETWORK_CONSISTENT(process);
551551

552-
if (!isLiquidNetworkId(network_id)) {
552+
if (!network_is_liquid(network_id)) {
553553
jade_process_reject_message(
554554
process, CBOR_RPC_BAD_PARAMETERS, "sign_liquid_tx call only appropriate for liquid network", NULL);
555555
goto cleanup;
@@ -700,7 +700,7 @@ void sign_liquid_tx_process(void* process_ptr)
700700
// Can be null for unblinded outputs as we will skip them.
701701
// Populate an `output_index` -> (blinding_key, asset, value) map
702702
uint8_t policy_asset[ASSET_TAG_LEN];
703-
const char* policy_asset_hex = networkGetPolicyAsset(network_id);
703+
const char* policy_asset_hex = network_to_policy_asset_hex(network_id);
704704
JADE_WALLY_VERIFY(wally_hex_to_bytes(policy_asset_hex, policy_asset, sizeof(policy_asset), &written));
705705
JADE_ASSERT(written == sizeof(policy_asset));
706706

main/process/sign_psbt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static bool verify_ga_script_matches(const uint32_t network_id, const struct ext
155155
if (recovery_key) {
156156
// 2of2: fetch the number of csv blocks if this is a csv script
157157
int ret = wally_scriptpubkey_csv_blocks_from_csv_2of2_then_1(target_script, target_script_len, &csv_blocks);
158-
if (ret == WALLY_OK && !csvBlocksExpectedForNetwork(network_id, csv_blocks)) {
158+
if (ret == WALLY_OK && !network_is_known_csv_blocks(network_id, csv_blocks)) {
159159
return false; // csv script with an invalid csv_blocks
160160
}
161161
}
@@ -945,7 +945,7 @@ void sign_psbt_process(void* process_ptr)
945945
GET_MSG_PARAMS(process);
946946
CHECK_NETWORK_CONSISTENT(process);
947947

948-
if (isLiquidNetworkId(network_id)) {
948+
if (network_is_liquid(network_id)) {
949949
jade_process_reject_message(
950950
process, CBOR_RPC_BAD_PARAMETERS, "sign_psbt call not appropriate for liquid network", NULL);
951951
goto cleanup;

main/process/sign_tx.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool validate_wallet_outputs(jade_process_t* process, const uint32_t network_id,
6969
bool is_change = true;
7070
rpc_get_boolean("is_change", &arrayItem, &is_change);
7171

72-
size_t csvBlocks = 0;
72+
size_t csv_blocks = 0;
7373
size_t script_len = 0;
7474
uint8_t script[WALLY_SCRIPTPUBKEY_P2WSH_LEN]; // Sufficient
7575
size_t written = 0;
@@ -105,7 +105,7 @@ bool validate_wallet_outputs(jade_process_t* process, const uint32_t network_id,
105105
}
106106
} else if (rpc_has_field_data("descriptor_name", &arrayItem)) {
107107
// Not valid for liquid wallets atm
108-
if (isLiquidNetworkId(network_id)) {
108+
if (network_is_liquid(network_id)) {
109109
*errmsg = "Descriptor wallets not supported on liquid network";
110110
goto cleanup;
111111
}
@@ -164,21 +164,21 @@ bool validate_wallet_outputs(jade_process_t* process, const uint32_t network_id,
164164
rpc_get_string("recovery_xpub", sizeof(xpubrecovery), &arrayItem, xpubrecovery, &written);
165165

166166
// Optional 'blocks' for csv outputs
167-
rpc_get_sizet("csv_blocks", &arrayItem, &csvBlocks);
167+
rpc_get_sizet("csv_blocks", &arrayItem, &csv_blocks);
168168

169169
// If number of csv blocks unexpected show a warning message and ask the user to confirm
170-
if (csvBlocks && !csvBlocksExpectedForNetwork(network_id, csvBlocks)) {
171-
JADE_LOGW("Unexpected number of csv blocks in path for output: %u", csvBlocks);
170+
if (csv_blocks && !network_is_known_csv_blocks(network_id, csv_blocks)) {
171+
JADE_LOGW("Unexpected number of csv blocks in path for output: %u", csv_blocks);
172172
const int ret = snprintf(output_info[i].message, sizeof(output_info[i].message),
173173
"This wallet output has a non-standard csv value (%u), so it may be difficult to find. "
174174
"Proceed at your own risk.",
175-
csvBlocks);
175+
csv_blocks);
176176
JADE_ASSERT(
177177
ret > 0 && ret < sizeof(output_info[i].message)); // Keep message within size handled by gui
178178
}
179179

180180
// Build a script pubkey for the passed parameters
181-
if (!wallet_build_ga_script(network_id, written ? xpubrecovery : NULL, csvBlocks, path, path_len,
181+
if (!wallet_build_ga_script(network_id, written ? xpubrecovery : NULL, csv_blocks, path, path_len,
182182
script, sizeof(script), &script_len)) {
183183
JADE_LOGE("Output %u path/script failed to construct", i);
184184
*errmsg = "Receive script cannot be constructed";
@@ -409,7 +409,7 @@ void sign_tx_process(void* process_ptr)
409409
ASSERT_KEYCHAIN_UNLOCKED_BY_MESSAGE_SOURCE(process);
410410
GET_MSG_PARAMS(process);
411411
CHECK_NETWORK_CONSISTENT(process);
412-
if (isLiquidNetworkId(network_id)) {
412+
if (network_is_liquid(network_id)) {
413413
jade_process_reject_message(
414414
process, CBOR_RPC_BAD_PARAMETERS, "sign_tx call not appropriate for liquid network", NULL);
415415
goto cleanup;

main/qrmode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ static bool post_auth_msg_request(const jade_msg_source_t source, const bool sup
15981598
} else {
15991599
network_id = WALLY_NETWORK_BITCOIN_MAINNET;
16001600
}
1601-
add_string_to_map(&params_encoder, "network", networkIdToNetwork(network_id));
1601+
add_string_to_map(&params_encoder, "network", network_to_name(network_id));
16021602
add_boolean_to_map(&params_encoder, "suppress_pin_change_confirmation", suppress_pin_change_confirmation);
16031603
cberr = cbor_encoder_close_container(&root_map_encoder, &params_encoder);
16041604
JADE_ASSERT(cberr == CborNoError);

0 commit comments

Comments
 (0)