mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
lightningd: deprecate p2sh-segwit addresses for newaddr addresstype
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Deprecated: JSON-RPC: `newaddr`: `addresstype` `p2sh-segwit` (use default, or `bech32`).
This commit is contained in:
1
cln-grpc/proto/node.proto
generated
1
cln-grpc/proto/node.proto
generated
@@ -941,7 +941,6 @@ message NewaddrRequest {
|
|||||||
// NewAddr.addresstype
|
// NewAddr.addresstype
|
||||||
enum NewaddrAddresstype {
|
enum NewaddrAddresstype {
|
||||||
BECH32 = 0;
|
BECH32 = 0;
|
||||||
P2SH_SEGWIT = 1;
|
|
||||||
ALL = 2;
|
ALL = 2;
|
||||||
}
|
}
|
||||||
optional NewaddrAddresstype addresstype = 1;
|
optional NewaddrAddresstype addresstype = 1;
|
||||||
|
|||||||
6
cln-rpc/src/model.rs
generated
6
cln-rpc/src/model.rs
generated
@@ -809,8 +809,6 @@ pub mod requests {
|
|||||||
pub enum NewaddrAddresstype {
|
pub enum NewaddrAddresstype {
|
||||||
#[serde(rename = "bech32")]
|
#[serde(rename = "bech32")]
|
||||||
BECH32,
|
BECH32,
|
||||||
#[serde(rename = "p2sh-segwit")]
|
|
||||||
P2SH_SEGWIT,
|
|
||||||
#[serde(rename = "all")]
|
#[serde(rename = "all")]
|
||||||
ALL,
|
ALL,
|
||||||
}
|
}
|
||||||
@@ -820,8 +818,7 @@ pub mod requests {
|
|||||||
fn try_from(c: i32) -> Result<NewaddrAddresstype, anyhow::Error> {
|
fn try_from(c: i32) -> Result<NewaddrAddresstype, anyhow::Error> {
|
||||||
match c {
|
match c {
|
||||||
0 => Ok(NewaddrAddresstype::BECH32),
|
0 => Ok(NewaddrAddresstype::BECH32),
|
||||||
1 => Ok(NewaddrAddresstype::P2SH_SEGWIT),
|
1 => Ok(NewaddrAddresstype::ALL),
|
||||||
2 => Ok(NewaddrAddresstype::ALL),
|
|
||||||
o => Err(anyhow::anyhow!("Unknown variant {} for enum NewaddrAddresstype", o)),
|
o => Err(anyhow::anyhow!("Unknown variant {} for enum NewaddrAddresstype", o)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3165,6 +3162,7 @@ pub mod responses {
|
|||||||
pub struct NewaddrResponse {
|
pub struct NewaddrResponse {
|
||||||
#[serde(alias = "bech32", skip_serializing_if = "Option::is_none")]
|
#[serde(alias = "bech32", skip_serializing_if = "Option::is_none")]
|
||||||
pub bech32: Option<String>,
|
pub bech32: Option<String>,
|
||||||
|
#[deprecated]
|
||||||
#[serde(alias = "p2sh-segwit", skip_serializing_if = "Option::is_none")]
|
#[serde(alias = "p2sh-segwit", skip_serializing_if = "Option::is_none")]
|
||||||
pub p2sh_segwit: Option<String>,
|
pub p2sh_segwit: Option<String>,
|
||||||
}
|
}
|
||||||
|
|||||||
234
contrib/pyln-testing/pyln/testing/node_pb2.py
generated
234
contrib/pyln-testing/pyln/testing/node_pb2.py
generated
File diff suppressed because one or more lines are too long
@@ -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.
|
The funding transaction needs to be confirmed before funds can be used.
|
||||||
|
|
||||||
*addresstype* specifies the type of address wanted; i.e. *p2sh-segwit*
|
*addresstype* specifies the type of address wanted; currently *bech32*
|
||||||
(e.g. `2MxaozoqWwiUcuD9KKgUSrLFDafLqimT9Ta` on bitcoin testnet or
|
|
||||||
`3MZxzq3jBSKNQ2e7dzneo9hy4FvNzmMmt3` on bitcoin mainnet) or *bech32*
|
|
||||||
(e.g. `tb1qu9j4lg5f9rgjyfhvfd905vw46eg39czmktxqgg` on bitcoin testnet
|
(e.g. `tb1qu9j4lg5f9rgjyfhvfd905vw46eg39czmktxqgg` on bitcoin testnet
|
||||||
or `bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej` on
|
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.
|
for the same underlying key.
|
||||||
|
|
||||||
If no *addresstype* is specified the address generated is a *bech32* address.
|
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:
|
On success, an object is returned, containing:
|
||||||
|
|
||||||
- **bech32** (string, optional): The bech32 (native segwit) address
|
- **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)
|
[comment]: # (GENERATE-FROM-SCHEMA-END)
|
||||||
|
|
||||||
@@ -58,4 +56,4 @@ RESOURCES
|
|||||||
|
|
||||||
Main web site: <https://github.com/ElementsProject/lightning>
|
Main web site: <https://github.com/ElementsProject/lightning>
|
||||||
|
|
||||||
[comment]: # ( SHA256STAMP:8ed49212ffddf29077007efe38a6b6446cc9c351cb24a1454030526c89407175)
|
[comment]: # ( SHA256STAMP:9d8dc613c005127a0807f2c8b26b0a96ddc5bf3ebdfa59c3f95a888476c0ce2a)
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"bech32",
|
"bech32",
|
||||||
"p2sh-segwit",
|
|
||||||
"all"
|
"all"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"description": "The bech32 (native segwit) address"
|
"description": "The bech32 (native segwit) address"
|
||||||
},
|
},
|
||||||
"p2sh-segwit": {
|
"p2sh-segwit": {
|
||||||
|
"deprecated": "v23.02",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The p2sh-wrapped address"
|
"description": "The p2sh-wrapped address"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1856,14 +1856,11 @@ def test_bad_onion_immediate_peer(node_factory, bitcoind):
|
|||||||
|
|
||||||
def test_newaddr(node_factory, chainparams):
|
def test_newaddr(node_factory, chainparams):
|
||||||
l1 = node_factory.get_node()
|
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')
|
bech32 = l1.rpc.newaddr('bech32')
|
||||||
assert 'p2sh-segwit' not in bech32
|
assert 'p2sh-segwit' not in bech32
|
||||||
assert bech32['bech32'].startswith(chainparams['bip173_prefix'])
|
assert bech32['bech32'].startswith(chainparams['bip173_prefix'])
|
||||||
both = l1.rpc.newaddr('all')
|
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'])
|
assert both['bech32'].startswith(chainparams['bip173_prefix'])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -77,12 +77,13 @@ encode_pubkey_to_addr(const tal_t *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum addrtype {
|
enum addrtype {
|
||||||
|
/* Deprecated! */
|
||||||
ADDR_P2SH_SEGWIT = 1,
|
ADDR_P2SH_SEGWIT = 1,
|
||||||
ADDR_BECH32 = 2,
|
ADDR_BECH32 = 2,
|
||||||
ADDR_ALL = (ADDR_P2SH_SEGWIT + ADDR_BECH32)
|
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,
|
static struct command_result *param_newaddr(struct command *cmd,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char *buffer,
|
const char *buffer,
|
||||||
@@ -90,7 +91,7 @@ static struct command_result *param_newaddr(struct command *cmd,
|
|||||||
enum addrtype **addrtype)
|
enum addrtype **addrtype)
|
||||||
{
|
{
|
||||||
*addrtype = tal(cmd, enum 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;
|
**addrtype = ADDR_P2SH_SEGWIT;
|
||||||
else if (json_tok_streq(buffer, tok, "bech32"))
|
else if (json_tok_streq(buffer, tok, "bech32"))
|
||||||
**addrtype = ADDR_BECH32;
|
**addrtype = ADDR_BECH32;
|
||||||
@@ -98,7 +99,7 @@ static struct command_result *param_newaddr(struct command *cmd,
|
|||||||
**addrtype = ADDR_ALL;
|
**addrtype = ADDR_ALL;
|
||||||
else
|
else
|
||||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
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);
|
name, tok->end - tok->start, buffer + tok->start);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -131,7 +132,7 @@ static struct command_result *json_newaddr(struct command *cmd,
|
|||||||
b32script = scriptpubkey_p2wpkh(tmpctx, &pubkey);
|
b32script = scriptpubkey_p2wpkh(tmpctx, &pubkey);
|
||||||
if (*addrtype & ADDR_BECH32)
|
if (*addrtype & ADDR_BECH32)
|
||||||
txfilter_add_scriptpubkey(cmd->ld->owned_txfilter, b32script);
|
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,
|
txfilter_add_scriptpubkey(cmd->ld->owned_txfilter,
|
||||||
scriptpubkey_p2sh(tmpctx, b32script));
|
scriptpubkey_p2sh(tmpctx, b32script));
|
||||||
|
|
||||||
@@ -145,7 +146,7 @@ static struct command_result *json_newaddr(struct command *cmd,
|
|||||||
response = json_stream_success(cmd);
|
response = json_stream_success(cmd);
|
||||||
if (*addrtype & ADDR_BECH32)
|
if (*addrtype & ADDR_BECH32)
|
||||||
json_add_string(response, "bech32", 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);
|
json_add_string(response, "p2sh-segwit", p2sh);
|
||||||
return command_success(cmd, response);
|
return command_success(cmd, response);
|
||||||
}
|
}
|
||||||
@@ -154,8 +155,8 @@ static const struct json_command newaddr_command = {
|
|||||||
"newaddr",
|
"newaddr",
|
||||||
"bitcoin",
|
"bitcoin",
|
||||||
json_newaddr,
|
json_newaddr,
|
||||||
"Get a new {bech32, p2sh-segwit} (or all) address to fund a channel (default is bech32)", false,
|
"Get a new {bech32} (or all) address to fund a channel", 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."
|
"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);
|
AUTODATA(json_command, &newaddr_command);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user