wallet: remove P2SH support.
Seriously, it's taproot time, let's get rid of p2sh wrapped segwit. Changelog-Removed: wallet: removal of p2sh-segwit addresses; newaddr won't issue them, we won't watch them for new funds (deprecated in *23.02*) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
222ca17333
commit
f342630b92
|
@ -1004,7 +1004,6 @@ message NewaddrRequest {
|
|||
message NewaddrResponse {
|
||||
optional string p2tr = 3;
|
||||
optional string bech32 = 1;
|
||||
optional string p2sh_segwit = 2;
|
||||
}
|
||||
|
||||
message WithdrawRequest {
|
||||
|
|
|
@ -867,14 +867,12 @@ impl From<responses::WaitsendpayResponse> for pb::WaitsendpayResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables,deprecated)]
|
||||
#[allow(unused_variables)]
|
||||
impl From<responses::NewaddrResponse> for pb::NewaddrResponse {
|
||||
fn from(c: responses::NewaddrResponse) -> Self {
|
||||
Self {
|
||||
p2tr: c.p2tr, // Rule #2 for type string?
|
||||
bech32: c.bech32, // Rule #2 for type string?
|
||||
#[allow(deprecated)]
|
||||
p2sh_segwit: c.p2sh_segwit, // Rule #2 for type string?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4129,10 +4129,6 @@ pub mod responses {
|
|||
pub p2tr: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub bech32: Option<String>,
|
||||
#[deprecated]
|
||||
#[serde(rename = "p2sh-segwit")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub p2sh_segwit: Option<String>,
|
||||
}
|
||||
|
||||
impl TryFrom<Response> for NewaddrResponse {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -674,7 +674,6 @@ def newaddr2py(m):
|
|||
return remove_default({
|
||||
"p2tr": m.p2tr, # PrimitiveField in generate_composite
|
||||
"bech32": m.bech32, # PrimitiveField in generate_composite
|
||||
"p2sh_segwit": m.p2sh_segwit, # PrimitiveField in generate_composite
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ On success, an object is returned, containing:
|
|||
|
||||
- **p2tr** (string, optional): The taproot address *(added v23.08)*
|
||||
- **bech32** (string, optional): The bech32 (native segwit) address
|
||||
- **p2sh-segwit** (string, optional): The p2sh-wrapped address **deprecated, removal in v23.11**
|
||||
|
||||
[comment]: # (GENERATE-FROM-SCHEMA-END)
|
||||
|
||||
|
@ -57,4 +56,4 @@ RESOURCES
|
|||
|
||||
Main web site: <https://github.com/ElementsProject/lightning>
|
||||
|
||||
[comment]: # ( SHA256STAMP:f93771e450afe0fc20b2ff9763ba7654d4caf17c35cf45186f2cb9146a67503f)
|
||||
[comment]: # ( SHA256STAMP:3bfa85acd8c4a2a035e8c13926ae324e3b283a4ee813942fb028d744a5454386)
|
||||
|
|
|
@ -12,11 +12,6 @@
|
|||
"bech32": {
|
||||
"type": "string",
|
||||
"description": "The bech32 (native segwit) address"
|
||||
},
|
||||
"p2sh-segwit": {
|
||||
"deprecated": "v23.02",
|
||||
"type": "string",
|
||||
"description": "The p2sh-wrapped address"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,21 +39,12 @@ encode_pubkey_to_addr(const tal_t *ctx,
|
|||
{
|
||||
char *out;
|
||||
const char *hrp;
|
||||
struct sha256 h;
|
||||
struct ripemd160 h160;
|
||||
u8 *redeemscript;
|
||||
bool ok;
|
||||
|
||||
assert(addrtype != ADDR_ALL);
|
||||
|
||||
if (addrtype == ADDR_P2SH_SEGWIT) {
|
||||
redeemscript = bitcoin_redeem_p2sh_p2wpkh(ctx, pubkey);
|
||||
sha256(&h, redeemscript, tal_count(redeemscript));
|
||||
ripemd160(&h160, h.u.u8, sizeof(h));
|
||||
out = p2sh_to_base58(ctx,
|
||||
chainparams,
|
||||
&h160);
|
||||
} else if (addrtype == ADDR_BECH32) {
|
||||
switch (addrtype) {
|
||||
case ADDR_BECH32:
|
||||
hrp = chainparams->onchain_hrp;
|
||||
|
||||
/* out buffer is 73 + strlen(human readable part),
|
||||
|
@ -68,10 +59,9 @@ encode_pubkey_to_addr(const tal_t *ctx,
|
|||
0);
|
||||
|
||||
ok = segwit_addr_encode(out, hrp, 0, h160.u.u8, sizeof(h160));
|
||||
if (!ok)
|
||||
out = tal_free(out);
|
||||
} else {
|
||||
assert(addrtype == ADDR_P2TR);
|
||||
goto done;
|
||||
|
||||
case ADDR_P2TR: {
|
||||
u8 *p2tr_spk = scriptpubkey_p2tr(ctx, pubkey);
|
||||
u8 *x_key = p2tr_spk + 2;
|
||||
hrp = chainparams->onchain_hrp;
|
||||
|
@ -83,10 +73,19 @@ encode_pubkey_to_addr(const tal_t *ctx,
|
|||
out = tal_arr(ctx, char, 73 + strlen(hrp));
|
||||
|
||||
ok = segwit_addr_encode(out, hrp, /* witver */ 1, x_key, 32);
|
||||
if (!ok)
|
||||
out = tal_free(out);
|
||||
goto done;
|
||||
}
|
||||
|
||||
case ADDR_ALL:
|
||||
abort();
|
||||
}
|
||||
abort();
|
||||
|
||||
|
||||
done:
|
||||
if (!ok)
|
||||
out = tal_free(out);
|
||||
|
||||
if (out_redeemscript)
|
||||
*out_redeemscript = redeemscript;
|
||||
else
|
||||
|
@ -102,10 +101,7 @@ static struct command_result *param_newaddr(struct command *cmd,
|
|||
enum addrtype **addrtype)
|
||||
{
|
||||
*addrtype = tal(cmd, enum addrtype);
|
||||
if (cmd->ld->deprecated_apis
|
||||
&& json_tok_streq(buffer, tok, "p2sh-segwit"))
|
||||
**addrtype = ADDR_P2SH_SEGWIT;
|
||||
else if (json_tok_streq(buffer, tok, "bech32"))
|
||||
if (json_tok_streq(buffer, tok, "bech32"))
|
||||
**addrtype = ADDR_BECH32;
|
||||
else if (!chainparams->is_elements && json_tok_streq(buffer, tok, "p2tr"))
|
||||
**addrtype = ADDR_P2TR;
|
||||
|
@ -138,9 +134,6 @@ bool WARN_UNUSED_RESULT newaddr_inner(struct command *cmd, struct pubkey *pubkey
|
|||
txfilter_add_scriptpubkey(cmd->ld->owned_txfilter, b32script);
|
||||
if (addrtype & ADDR_P2TR)
|
||||
txfilter_add_scriptpubkey(cmd->ld->owned_txfilter, p2tr_script);
|
||||
if (cmd->ld->deprecated_apis && (addrtype & ADDR_P2SH_SEGWIT))
|
||||
txfilter_add_scriptpubkey(cmd->ld->owned_txfilter,
|
||||
scriptpubkey_p2sh(tmpctx, b32script));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -153,7 +146,7 @@ static struct command_result *json_newaddr(struct command *cmd,
|
|||
struct json_stream *response;
|
||||
struct pubkey pubkey;
|
||||
enum addrtype *addrtype;
|
||||
char *p2sh, *bech32, *p2tr;
|
||||
char *bech32, *p2tr;
|
||||
|
||||
if (!param(cmd, buffer, params,
|
||||
p_opt_def("addresstype", param_newaddr, &addrtype, ADDR_BECH32),
|
||||
|
@ -164,10 +157,9 @@ static struct command_result *json_newaddr(struct command *cmd,
|
|||
return command_fail(cmd, LIGHTNINGD, "Keys exhausted ");
|
||||
};
|
||||
|
||||
p2sh = encode_pubkey_to_addr(cmd, &pubkey, ADDR_P2SH_SEGWIT, NULL);
|
||||
bech32 = encode_pubkey_to_addr(cmd, &pubkey, ADDR_BECH32, NULL);
|
||||
p2tr = encode_pubkey_to_addr(cmd, &pubkey, ADDR_P2TR, NULL);
|
||||
if (!p2sh || !bech32 || !p2tr) {
|
||||
if (!bech32 || !p2tr) {
|
||||
return command_fail(cmd, LIGHTNINGD,
|
||||
"p2wpkh address encoding failure.");
|
||||
}
|
||||
|
@ -177,8 +169,6 @@ static struct command_result *json_newaddr(struct command *cmd,
|
|||
json_add_string(response, "bech32", bech32);
|
||||
if (*addrtype & ADDR_P2TR)
|
||||
json_add_string(response, "p2tr", p2tr);
|
||||
if (cmd->ld->deprecated_apis && (*addrtype & ADDR_P2SH_SEGWIT))
|
||||
json_add_string(response, "p2sh-segwit", p2sh);
|
||||
return command_success(cmd, response);
|
||||
}
|
||||
|
||||
|
@ -221,13 +211,6 @@ static struct command_result *json_listaddrs(struct command *cmd,
|
|||
|
||||
bip32_pubkey(cmd->ld, &pubkey, keyidx);
|
||||
|
||||
// p2sh
|
||||
u8 *redeemscript_p2sh;
|
||||
char *out_p2sh = encode_pubkey_to_addr(cmd,
|
||||
&pubkey,
|
||||
ADDR_P2SH_SEGWIT,
|
||||
&redeemscript_p2sh);
|
||||
|
||||
// bech32 : p2wpkh
|
||||
u8 *redeemscript_p2wpkh;
|
||||
char *out_p2wpkh = encode_pubkey_to_addr(cmd,
|
||||
|
@ -251,9 +234,6 @@ static struct command_result *json_listaddrs(struct command *cmd,
|
|||
json_object_start(response, NULL);
|
||||
json_add_u64(response, "keyidx", keyidx);
|
||||
json_add_pubkey(response, "pubkey", &pubkey);
|
||||
json_add_string(response, "p2sh", out_p2sh);
|
||||
json_add_hex_talarr(response, "p2sh_redeemscript",
|
||||
redeemscript_p2sh);
|
||||
json_add_string(response, "bech32", out_p2wpkh);
|
||||
json_add_hex_talarr(response, "bech32_redeemscript",
|
||||
redeemscript_p2wpkh);
|
||||
|
|
|
@ -3,11 +3,9 @@
|
|||
#include "config.h"
|
||||
|
||||
enum addrtype {
|
||||
/* Deprecated! */
|
||||
ADDR_P2SH_SEGWIT = 1,
|
||||
ADDR_BECH32 = 2,
|
||||
ADDR_P2TR = 4,
|
||||
ADDR_ALL = (ADDR_P2SH_SEGWIT + ADDR_BECH32 + ADDR_P2TR)
|
||||
ADDR_ALL = (ADDR_BECH32 + ADDR_P2TR)
|
||||
};
|
||||
|
||||
struct utxo;
|
||||
|
|
Loading…
Reference in New Issue