From 09fa08741377e80a25144fbdd149dd99fd3367c2 Mon Sep 17 00:00:00 2001 From: Greg Sanders Date: Mon, 22 May 2023 11:18:54 -0400 Subject: [PATCH] cleanup comments, variables with respect to bech32(m) --- common/json_param.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/common/json_param.c b/common/json_param.c index 7aa2174645eb..db2660fb70c1 100644 --- a/common/json_param.c +++ b/common/json_param.c @@ -686,13 +686,14 @@ struct command_result *param_secrets_array(struct command *cmd, } /** - * segwit_addr_net_decode - Try to decode a Bech32 address and detect + * segwit_addr_net_decode - Try to decode a Bech32(m) address and detect * testnet/mainnet/regtest/signet * * This processes the address and returns a string if it is a Bech32 - * address specified by BIP173. The string is set whether it is - * testnet or signet (both "tb"), mainnet ("bc"), regtest ("bcrt") - * It does not check, witness version and program size restrictions. + * address specified by BIP173 or Bech32m as by BIP350. The string is + * set whether it is testnet or signet (both "tb"), mainnet ("bc"), + * regtest ("bcrt"). It does not check witness version and program size + * restrictions. * * Out: witness_version: Pointer to an int that will be updated to contain * the witness program version (between 0 and 16 inclusive). @@ -732,7 +733,7 @@ json_to_address_scriptpubkey(const tal_t *ctx, size_t witness_program_len; char *addrz; - const char *bip173; + const char *bech32; u8 addr_version; @@ -756,12 +757,12 @@ json_to_address_scriptpubkey(const tal_t *ctx, addrz = tal_dup_arr(tmpctx, char, buffer + tok->start, tok->end - tok->start, 1); addrz[tok->end - tok->start] = '\0'; - bip173 = segwit_addr_net_decode(&witness_version, witness_program, + bech32 = segwit_addr_net_decode(&witness_version, witness_program, &witness_program_len, addrz, chainparams); - if (bip173) { + if (bech32) { bool witness_ok; - /* We know the rules for v0, rest remain undefined */ + /* Only V0 has restricted lengths of witness programs */ if (witness_version == 0) { witness_ok = (witness_program_len == 20 || witness_program_len == 32); @@ -771,7 +772,7 @@ json_to_address_scriptpubkey(const tal_t *ctx, if (!witness_ok) return ADDRESS_PARSE_UNRECOGNIZED; - if (!streq(bip173, chainparams->onchain_hrp)) + if (!streq(bech32, chainparams->onchain_hrp)) return ADDRESS_PARSE_WRONG_NETWORK; *scriptpubkey = scriptpubkey_witness_raw(ctx, witness_version,