Skip to content

Commit 72399b6

Browse files
committed
cleanup comments, variables with respect to bech32(m)
1 parent caf412d commit 72399b6

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

common/json_param.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -686,13 +686,14 @@ struct command_result *param_secrets_array(struct command *cmd,
686686
}
687687

688688
/**
689-
* segwit_addr_net_decode - Try to decode a Bech32 address and detect
689+
* segwit_addr_net_decode - Try to decode a Bech32(m) address and detect
690690
* testnet/mainnet/regtest/signet
691691
*
692692
* This processes the address and returns a string if it is a Bech32
693-
* address specified by BIP173. The string is set whether it is
694-
* testnet or signet (both "tb"), mainnet ("bc"), regtest ("bcrt")
695-
* It does not check, witness version and program size restrictions.
693+
* address specified by BIP173 or Bech32m as by BIP350. The string is
694+
* set whether it is testnet or signet (both "tb"), mainnet ("bc"),
695+
* regtest ("bcrt"). It does not check witness version and program size
696+
* restrictions.
696697
*
697698
* Out: witness_version: Pointer to an int that will be updated to contain
698699
* the witness program version (between 0 and 16 inclusive).
@@ -732,7 +733,7 @@ json_to_address_scriptpubkey(const tal_t *ctx,
732733
size_t witness_program_len;
733734

734735
char *addrz;
735-
const char *bip173;
736+
const char *bech32;
736737

737738
u8 addr_version;
738739

@@ -756,12 +757,12 @@ json_to_address_scriptpubkey(const tal_t *ctx,
756757
addrz = tal_dup_arr(tmpctx, char, buffer + tok->start, tok->end - tok->start, 1);
757758
addrz[tok->end - tok->start] = '\0';
758759

759-
bip173 = segwit_addr_net_decode(&witness_version, witness_program,
760+
bech32 = segwit_addr_net_decode(&witness_version, witness_program,
760761
&witness_program_len, addrz, chainparams);
761-
if (bip173) {
762+
if (bech32) {
762763
bool witness_ok;
763764

764-
/* We know the rules for v0, rest remain undefined */
765+
/* Only V0 has restricted lengths of witness programs */
765766
if (witness_version == 0) {
766767
witness_ok = (witness_program_len == 20 ||
767768
witness_program_len == 32);
@@ -771,7 +772,7 @@ json_to_address_scriptpubkey(const tal_t *ctx,
771772
if (!witness_ok)
772773
return ADDRESS_PARSE_UNRECOGNIZED;
773774

774-
if (!streq(bip173, chainparams->onchain_hrp))
775+
if (!streq(bech32, chainparams->onchain_hrp))
775776
return ADDRESS_PARSE_WRONG_NETWORK;
776777

777778
*scriptpubkey = scriptpubkey_witness_raw(ctx, witness_version,

0 commit comments

Comments
 (0)