From 932ca9e91fb0d8ddcf69d18db0799f4e4fae6f94 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 13 Jan 2023 11:10:35 +1030 Subject: [PATCH] lightningd: deprecate p2sh-segwit addresses for `newaddr` `addresstype` Signed-off-by: Rusty Russell Changelog-Deprecated: JSON-RPC: `newaddr`: `addresstype` `p2sh-segwit` (use default, or `bech32`). --- cln-grpc/proto/node.proto | Bin 31712 -> 31693 bytes cln-rpc/src/model.rs | Bin 132674 -> 132590 bytes contrib/pyln-testing/pyln/testing/node_pb2.py | Bin 125993 -> 125960 bytes doc/lightning-newaddr.7.md | 12 +++++------- doc/schemas/newaddr.request.json | 1 - doc/schemas/newaddr.schema.json | 1 + tests/test_misc.py | 5 +---- wallet/walletrpc.c | 15 ++++++++------- 8 files changed, 15 insertions(+), 19 deletions(-) diff --git a/cln-grpc/proto/node.proto b/cln-grpc/proto/node.proto index e2a8d0b72c11de2689587d74a6b16cf71a208e86..dca6d7e71952f27ca3e95275af6fffc35cc7a257 100644 GIT binary patch delta 14 WcmaFxo$>5<#tk>3H@}YlDh~idG6;?U delta 30 mcmX^6o$3`2&oCJ>r91-NQXY6l@g?H(!bVDGvbBKMaQe diff --git a/cln-rpc/src/model.rs b/cln-rpc/src/model.rs index 9d8150536759aabaf236e08a1949226b07240eab..3c7124b5fb367295a90730c2c1549dab0977e800 100644 GIT binary patch delta 33 pcmX@q!||@0V}ow`=G1f!#^yO0+vj93nz&7#a#m^k{dJ7V;Q;pG4t4+l delta 94 zcmaFY&2gxQV}owGe1TDMhHi0cdU4-e_x?VR7TorM6?Gv+k!}-31Q8_SLaPfa zfgaMXTaw^BIr5)KOMx?_kZU<_dLIQzpa-(ua_3z zn-}q&x%cNkgYmh)=g-W|+$(*0`TDKP*WuR}L{RwRGJGJM!_8%=;KNlY<&_GC=?UR2 z9;m~(@PV;{GfgPumGud}S%;H+ny`AU4n^TKHrb_e7m5X~oYA;ehvT4dssYtb;6y8w z4LF|DiNZG;5QK7!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43MMRkZkUl{zyH`v4mfKH<|# zh(1}sVp9o2f(~Yk4E*^Ljq%kxF>aKO)MTtod36b$ETZ^$0raZY!M=9`$Wg2P? zYIUmk<7N0h<&T!Pw{8v2Vrv<51s$<1vrSFPudJY(pXc$fpgvMGsrbVcIwr6lpyI^> zb>ytG9;)-!KHS0!H)(gLw$4W*G(*K->HeIPMzKfE+i7|eX(sZ+BBb2CP7m_wH7FT^ zk8DuDnp5ip?c>S&M2ARS{IvYCP6wLK^eK!BdI&;#?%P0-W^r$ojC@cS$x|EAHu2KD z#r=SehyWosa7WM?IM5Q0l((;QXhw zhqpHIxr%?@2t&5*aF4)wAFa204hGi(IuJMdX1&!ie_N-W{8pX%GbucI4RQSN{6n4g R!^f(Nm-=Zx|5c}Z{{@dS>f8VT diff --git a/doc/lightning-newaddr.7.md b/doc/lightning-newaddr.7.md index 164c4325f..3de7419b4 100644 --- a/doc/lightning-newaddr.7.md +++ b/doc/lightning-newaddr.7.md @@ -4,7 +4,7 @@ lightning-newaddr -- Command for generating a new address to be used by Core Lig SYNOPSIS -------- -**newaddr** [ *addresstype* ] +**newaddr** [*addresstype*] DESCRIPTION ----------- @@ -14,12 +14,10 @@ subsequently be used to fund channels managed by the Core Lightning node. The funding transaction needs to be confirmed before funds can be used. -*addresstype* specifies the type of address wanted; i.e. *p2sh-segwit* -(e.g. `2MxaozoqWwiUcuD9KKgUSrLFDafLqimT9Ta` on bitcoin testnet or -`3MZxzq3jBSKNQ2e7dzneo9hy4FvNzmMmt3` on bitcoin mainnet) or *bech32* +*addresstype* specifies the type of address wanted; currently *bech32* (e.g. `tb1qu9j4lg5f9rgjyfhvfd905vw46eg39czmktxqgg` on bitcoin testnet or `bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej` on -bitcoin mainnet). The special value *all* generates both address types +bitcoin mainnet). The special value *all* generates all known address types for the same underlying key. If no *addresstype* is specified the address generated is a *bech32* address. @@ -33,7 +31,7 @@ RETURN VALUE On success, an object is returned, containing: - **bech32** (string, optional): The bech32 (native segwit) address -- **p2sh-segwit** (string, optional): The p2sh-wrapped address +- **p2sh-segwit** (string, optional): The p2sh-wrapped address **deprecated, removal in v23.11** [comment]: # (GENERATE-FROM-SCHEMA-END) @@ -58,4 +56,4 @@ RESOURCES Main web site: -[comment]: # ( SHA256STAMP:8ed49212ffddf29077007efe38a6b6446cc9c351cb24a1454030526c89407175) +[comment]: # ( SHA256STAMP:9d8dc613c005127a0807f2c8b26b0a96ddc5bf3ebdfa59c3f95a888476c0ce2a) diff --git a/doc/schemas/newaddr.request.json b/doc/schemas/newaddr.request.json index 7140f97bf..add617e4b 100644 --- a/doc/schemas/newaddr.request.json +++ b/doc/schemas/newaddr.request.json @@ -8,7 +8,6 @@ "type": "string", "enum": [ "bech32", - "p2sh-segwit", "all" ] } diff --git a/doc/schemas/newaddr.schema.json b/doc/schemas/newaddr.schema.json index 8bfa737a9..7f0212760 100644 --- a/doc/schemas/newaddr.schema.json +++ b/doc/schemas/newaddr.schema.json @@ -9,6 +9,7 @@ "description": "The bech32 (native segwit) address" }, "p2sh-segwit": { + "deprecated": "v23.02", "type": "string", "description": "The p2sh-wrapped address" } diff --git a/tests/test_misc.py b/tests/test_misc.py index e8ee161e6..ca5a47d32 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -1856,14 +1856,11 @@ def test_bad_onion_immediate_peer(node_factory, bitcoind): def test_newaddr(node_factory, chainparams): l1 = node_factory.get_node() - p2sh = l1.rpc.newaddr('p2sh-segwit') - assert 'bech32' not in p2sh - assert p2sh['p2sh-segwit'].startswith(chainparams['p2sh_prefix']) bech32 = l1.rpc.newaddr('bech32') assert 'p2sh-segwit' not in bech32 assert bech32['bech32'].startswith(chainparams['bip173_prefix']) both = l1.rpc.newaddr('all') - assert both['p2sh-segwit'].startswith(chainparams['p2sh_prefix']) + assert 'p2sh-segwit' not in both assert both['bech32'].startswith(chainparams['bip173_prefix']) diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c index 30b737880..f02d380ec 100644 --- a/wallet/walletrpc.c +++ b/wallet/walletrpc.c @@ -77,12 +77,13 @@ encode_pubkey_to_addr(const tal_t *ctx, } enum addrtype { + /* Deprecated! */ ADDR_P2SH_SEGWIT = 1, ADDR_BECH32 = 2, ADDR_ALL = (ADDR_P2SH_SEGWIT + ADDR_BECH32) }; -/* Extract bool indicating "p2sh-segwit" or "bech32" */ +/* Extract bool indicating "bech32" */ static struct command_result *param_newaddr(struct command *cmd, const char *name, const char *buffer, @@ -90,7 +91,7 @@ static struct command_result *param_newaddr(struct command *cmd, enum addrtype **addrtype) { *addrtype = tal(cmd, enum addrtype); - if (json_tok_streq(buffer, tok, "p2sh-segwit")) + if (deprecated_apis && json_tok_streq(buffer, tok, "p2sh-segwit")) **addrtype = ADDR_P2SH_SEGWIT; else if (json_tok_streq(buffer, tok, "bech32")) **addrtype = ADDR_BECH32; @@ -98,7 +99,7 @@ static struct command_result *param_newaddr(struct command *cmd, **addrtype = ADDR_ALL; else return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "'%s' should be 'bech32', 'p2sh-segwit' or 'all', not '%.*s'", + "'%s' should be 'bech32', or 'all', not '%.*s'", name, tok->end - tok->start, buffer + tok->start); return NULL; } @@ -131,7 +132,7 @@ static struct command_result *json_newaddr(struct command *cmd, b32script = scriptpubkey_p2wpkh(tmpctx, &pubkey); if (*addrtype & ADDR_BECH32) txfilter_add_scriptpubkey(cmd->ld->owned_txfilter, b32script); - if (*addrtype & ADDR_P2SH_SEGWIT) + if (deprecated_apis && (*addrtype & ADDR_P2SH_SEGWIT)) txfilter_add_scriptpubkey(cmd->ld->owned_txfilter, scriptpubkey_p2sh(tmpctx, b32script)); @@ -145,7 +146,7 @@ static struct command_result *json_newaddr(struct command *cmd, response = json_stream_success(cmd); if (*addrtype & ADDR_BECH32) json_add_string(response, "bech32", bech32); - if (*addrtype & ADDR_P2SH_SEGWIT) + if (deprecated_apis && (*addrtype & ADDR_P2SH_SEGWIT)) json_add_string(response, "p2sh-segwit", p2sh); return command_success(cmd, response); } @@ -154,8 +155,8 @@ static const struct json_command newaddr_command = { "newaddr", "bitcoin", json_newaddr, - "Get a new {bech32, p2sh-segwit} (or all) address to fund a channel (default is bech32)", false, - "Generates a new address (or both) that belongs to the internal wallet. Funds sent to these addresses will be managed by lightningd. Use `withdraw` to withdraw funds to an external wallet." + "Get a new {bech32} (or all) address to fund a channel", false, + "Generates a new address that belongs to the internal wallet. Funds sent to these addresses will be managed by lightningd. Use `withdraw` to withdraw funds to an external wallet." }; AUTODATA(json_command, &newaddr_command);