common/json_tok: allow non-v0 segwit addresses.

Only v0 has specific length restrictions: taproot is v1 32 bytes long,
but explicitly other lengths remain undefined.

I noticed that I added option_shutdown_anysegwit as EXPERIMENTAL in
the last release, but didn't CHANGELOG it.  Then I changed it to
non-experimental as a spec update, but didn't CHANGELOG it then
either, so let's do that now!

    Changelog-Added: Protocol: We now send and accept `option_shutdown_anysegwit` so you can close channels to v1+ segwit addresses.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `withdraw`, `close` (and others) now accept taproot (and other future) segwit addresses.
This commit is contained in:
Rusty Russell 2021-06-09 12:40:00 +09:30
parent 8d38050aa4
commit 8e74a507d7
1 changed files with 7 additions and 6 deletions

View File

@ -433,14 +433,15 @@ json_to_address_scriptpubkey(const tal_t *ctx,
bip173 = segwit_addr_net_decode(&witness_version, witness_program,
&witness_program_len, addrz, chainparams);
if (bip173) {
bool witness_ok = false;
if (witness_version == 0 && (witness_program_len == 20 ||
witness_program_len == 32)) {
bool witness_ok;
/* We know the rules for v0, rest remain undefined */
if (witness_version == 0) {
witness_ok = (witness_program_len == 20 ||
witness_program_len == 32);
} else
witness_ok = true;
}
/* Insert other witness versions here. */
if (witness_ok) {
*scriptpubkey = scriptpubkey_witness_raw(ctx, witness_version,