From c9fdf60ac1b896c4069743cd8219dc8d686dd2b6 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 3 Nov 2025 20:31:03 +1030 Subject: [PATCH] wallet: make `p2tr` the default address for newaddr. Of course we still have to return a `bech32` for the deprecation period. Changelog-Added: JSON-RPC: `newaddr` will now return a `p2tr` field by default. Changelog-Deprecated: JSON-RPC: `newaddr` returning a `bech32` field if `addresstype` is not specified (use `p2tr`). Signed-off-by: Rusty Russell --- contrib/msggen/msggen/schema.json | 2 +- doc/developers-guide/deprecated-features.md | 3 ++- doc/schemas/newaddr.json | 2 +- wallet/walletrpc.c | 11 ++++++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/contrib/msggen/msggen/schema.json b/contrib/msggen/msggen/schema.json index 9a0c0266d..26b41277d 100644 --- a/contrib/msggen/msggen/schema.json +++ b/contrib/msggen/msggen/schema.json @@ -27137,7 +27137,7 @@ "description": [ "It specifies the type of address wanted; currently *bech32* (e.g. `tb1qu9j4lg5f9rgjyfhvfd905vw46eg39czmktxqgg` on bitcoin testnet or `bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej` on bitcoin mainnet), or *p2tr* taproot addresses. The special value *all* generates all known address types for the same underlying key." ], - "default": "*bech32* address", + "default": "*p2tr* address", "enum": [ "bech32", "p2tr", diff --git a/doc/developers-guide/deprecated-features.md b/doc/developers-guide/deprecated-features.md index 086738795..4acd298f8 100644 --- a/doc/developers-guide/deprecated-features.md +++ b/doc/developers-guide/deprecated-features.md @@ -21,7 +21,8 @@ hidden: false | channel_state_changed.null_scid | Notification Field | v25.09 | v26.09 | In channel_state_changed notification, `short_channel_id` will be missing instead of `null` | | notification.payload | Notification Field | v25.09 | v26.09 | Notifications from plugins used to have fields in `payload` sub-object, now they are not (just like normal notifications) | | pay_notifications.raw_fields | Field | v25.09 | v26.09 | `channel_hint_update`, `pay_failure` and `pay_success` notifications now wrap members in an object of the same name | -| encrypted_hsm | Config | v25.12 | v26.12 | `hsm-passphrase` is a name which also makes sense for modern hsm_secrets which use BIP 39 | +| encrypted_hsm | Config | v25.12 | v26.12 | `hsm-passphrase` is a name which also makes sense for modern hsm_secrets which use BIP 39 | +| newaddr.addresstype.defaultbech32 | Parameter | v25.12 | v26.12 | Use `p2tr` in the response (present since v23.08 if `addresstype` is `p2tr`, and always present since v24.12). | Inevitably there are features which need to change: either to be generalized, or removed when they can no longer be supported. diff --git a/doc/schemas/newaddr.json b/doc/schemas/newaddr.json index 098a338c4..dc9c94c29 100644 --- a/doc/schemas/newaddr.json +++ b/doc/schemas/newaddr.json @@ -19,7 +19,7 @@ "description": [ "It specifies the type of address wanted; currently *bech32* (e.g. `tb1qu9j4lg5f9rgjyfhvfd905vw46eg39czmktxqgg` on bitcoin testnet or `bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej` on bitcoin mainnet), or *p2tr* taproot addresses. The special value *all* generates all known address types for the same underlying key." ], - "default": "*bech32* address", + "default": "*p2tr* address", "enum": [ "bech32", "p2tr", diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c index a91b2aa0d..41832096e 100644 --- a/wallet/walletrpc.c +++ b/wallet/walletrpc.c @@ -149,10 +149,19 @@ static struct command_result *json_newaddr(struct command *cmd, char *bech32, *p2tr; if (!param(cmd, buffer, params, - p_opt_def("addresstype", param_newaddr, &addrtype, ADDR_BECH32), + p_opt("addresstype", param_newaddr, &addrtype), NULL)) return command_param_failed(); + if (!addrtype) { + addrtype = tal(cmd, enum addrtype); + if (command_deprecated_in_ok(cmd, "addresstype.defaultbech32", + "v25.12", "v26.12")) + *addrtype = ADDR_ALL; + else + *addrtype = ADDR_P2TR; + } + if (!newaddr_inner(cmd, &pubkey, *addrtype)) { return command_fail(cmd, LIGHTNINGD, "Keys exhausted "); };