Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,4 @@ autogenerate-examples-status.log
# Ignore nix outputs
result
result-[0-9]*
tests/plugins/channeld_fakenet
128 changes: 128 additions & 0 deletions contrib/msggen/msggen/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17245,6 +17245,134 @@
}
]
},
"lightning-listaddresses.json": {
"$schema": "../rpc-schema-draft.json",
"type": "object",
"added": "v24.11",
"rpc": "listaddresses",
"title": "Command to list all addresses issued by the node to date",
"description": [
"The **listaddresses** RPC command provides a detailed list of all Bitcoin addresses that have been generated and issued by the Core Lightning node up to the current date."
],
"categories": [
"readonly"
],
"request": {
"required": [],
"additionalProperties": false,
"properties": {
"address": {
"type": "string",
"description": [
"A Bitcoin accepted type, including a bech32, address for lookup in the list of addresses issued to date."
]
},
"start": {
"type": "u64",
"description": [
"Starting key index for listing addresses or searching for a particular address."
],
"default": 1
},
"limit": {
"type": "u32",
"description": [
"The maximum number of addresses to return or search for."
],
"default": "Total number of addresses issued"
}
}
},
"response": {
"required": [
"addresses"
],
"additionalProperties": false,
"properties": {
"addresses": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"keyidx"
],
"properties": {
"keyidx": {
"type": "u64",
"description": [
"The key index of the address issued."
]
},
"bech32": {
"type": "string",
"description": [
"The bech32 (native segwit) address."
]
},
"p2tr": {
"type": "string",
"description": [
"The taproot address."
]
}
}
}
}
}
},
"author": [
"Shahana Farooqui <<sfarooqui@blockstream.com>> is mainly responsible."
],
"see_also": [
"lightning-newaddr(7)",
"lightning-withdraw(7)"
],
"resources": [
"Main web site: <https://github.com/ElementsProject/lightning>"
],
"examples": [
{
"request": {
"id": "example:listaddresses#1",
"method": "listaddresses",
"params": [
"bcrt1phtprcvhz842sxe8qw0yryvc0g6n6dw2puweklcpnfye273kjpfhs0d6d2e"
]
},
"response": {
"addresses": [
{
"keyidx": 13,
"p2tr": "bcrt1phtprcvhz842sxe8qw0yryvc0g6n6dw2puweklcpnfye273kjpfhs0d6d2e"
}
]
}
},
{
"request": {
"id": "example:listaddresses#2",
"method": "listaddresses",
"params": {
"start": 6,
"limit": 2
}
},
"response": {
"addresses": [
{
"keyidx": 6,
"bech32": "bcrt1qkpw662yvzdy5ttdg8nw4eh4el0uc7m2ythw0h3"
},
{
"keyidx": 7,
"p2tr": "bcrt1pn45xgkyj54usdu98plm4zgcp4c5jvvfxmyexwcm5kc3gyfsrjmasd6ctsf"
}
]
}
}
]
},
"lightning-listchannels.json": {
"$schema": "../rpc-schema-draft.json",
"type": "object",
Expand Down
1 change: 1 addition & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ GENERATE_MARKDOWN := doc/lightning-addgossip.7 \
doc/lightning-invoice.7 \
doc/lightning-invoicerequest.7 \
doc/lightning-keysend.7 \
doc/lightning-listaddresses.7 \
doc/lightning-listchannels.7 \
doc/lightning-listclosedchannels.7 \
doc/lightning-listconfigs.7 \
Expand Down
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Core Lightning Documentation
lightning-invoice <lightning-invoice.7.md>
lightning-invoicerequest <lightning-invoicerequest.7.md>
lightning-keysend <lightning-keysend.7.md>
lightning-listaddresses <lightning-listaddresses.7.md>
lightning-listchannels <lightning-listchannels.7.md>
lightning-listclosedchannels <lightning-listclosedchannels.7.md>
lightning-listconfigs <lightning-listconfigs.7.md>
Expand Down
128 changes: 128 additions & 0 deletions doc/schemas/lightning-listaddresses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
"$schema": "../rpc-schema-draft.json",
"type": "object",
"added": "v24.11",
"rpc": "listaddresses",
"title": "Command to list all addresses issued by the node to date",
"description": [
"The **listaddresses** RPC command provides a detailed list of all Bitcoin addresses that have been generated and issued by the Core Lightning node up to the current date."
],
"categories": [
"readonly"
],
"request": {
"required": [],
"additionalProperties": false,
"properties": {
"address": {
"type": "string",
"description": [
"A Bitcoin accepted type, including a bech32, address for lookup in the list of addresses issued to date."
]
},
"start": {
"type": "u64",
"description": [
"Starting key index for listing addresses or searching for a particular address."
],
"default": 1
},
"limit": {
"type": "u32",
"description": [
"The maximum number of addresses to return or search for."
],
"default": "Total number of addresses issued"
}
}
},
"response": {
"required": [
"addresses"
],
"additionalProperties": false,
"properties": {
"addresses": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"keyidx"
],
"properties": {
"keyidx": {
"type": "u64",
"description": [
"The key index of the address issued."
]
},
"bech32": {
"type": "string",
"description": [
"The bech32 (native segwit) address."
]
},
"p2tr": {
"type": "string",
"description": [
"The taproot address."
]
}
}
}
}
}
},
"author": [
"Shahana Farooqui <<sfarooqui@blockstream.com>> is mainly responsible."
],
"see_also": [
"lightning-newaddr(7)",
"lightning-withdraw(7)"
],
"resources": [
"Main web site: <https://github.com/ElementsProject/lightning>"
],
"examples": [
{
"request": {
"id": "example:listaddresses#1",
"method": "listaddresses",
"params": [
"bcrt1phtprcvhz842sxe8qw0yryvc0g6n6dw2puweklcpnfye273kjpfhs0d6d2e"
]
},
"response": {
"addresses": [
{
"keyidx": 13,
"p2tr": "bcrt1phtprcvhz842sxe8qw0yryvc0g6n6dw2puweklcpnfye273kjpfhs0d6d2e"
}
]
}
},
{
"request": {
"id": "example:listaddresses#2",
"method": "listaddresses",
"params": {
"start": 6,
"limit": 2
}
},
"response": {
"addresses": [
{
"keyidx": 6,
"bech32": "bcrt1qkpw662yvzdy5ttdg8nw4eh4el0uc7m2ythw0h3"
},
{
"keyidx": 7,
"p2tr": "bcrt1pn45xgkyj54usdu98plm4zgcp4c5jvvfxmyexwcm5kc3gyfsrjmasd6ctsf"
}
]
}
}
]
}
2 changes: 1 addition & 1 deletion lightningd/anchorspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ static struct wally_psbt *anchor_psbt(const tal_t *ctx,

bip32_pubkey(ld, &final_key, channel->final_key_idx);
psbt_append_output(psbt,
scriptpubkey_p2wpkh(tmpctx, &final_key),
scriptpubkey_p2tr(tmpctx, &final_key),
change);
return psbt;
}
Expand Down
6 changes: 3 additions & 3 deletions lightningd/channel_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1212,9 +1212,9 @@ static void peer_got_shutdown(struct channel *channel, const u8 *msg)
u8 *scriptpubkey;
struct lightningd *ld = channel->peer->ld;
struct bitcoin_outpoint *wrong_funding;
bool anysegwit = feature_negotiated(ld->our_features,
channel->peer->their_features,
OPT_SHUTDOWN_ANYSEGWIT);
bool anysegwit = !chainparams->is_elements && feature_negotiated(ld->our_features,
channel->peer->their_features,
OPT_SHUTDOWN_ANYSEGWIT);
bool anchors = feature_negotiated(ld->our_features,
channel->peer->their_features,
OPT_ANCHOR_OUTPUTS_DEPRECATED)
Expand Down
10 changes: 8 additions & 2 deletions lightningd/dual_open_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,9 @@ wallet_commit_channel(struct lightningd *ld,
{
struct amount_msat our_msat, lease_fee_msat;
struct channel_inflight *inflight;
bool anysegwit = !chainparams->is_elements && feature_negotiated(channel->peer->ld->our_features,
channel->peer->their_features,
OPT_SHUTDOWN_ANYSEGWIT);
bool any_active = peer_any_channel(channel->peer, channel_state_wants_peercomms, NULL);

if (!amount_sat_to_msat(&our_msat, our_funding)) {
Expand All @@ -1395,8 +1398,11 @@ wallet_commit_channel(struct lightningd *ld,
return NULL;
}

/* Get a key to use for closing outputs from this tx */
channel->final_key_idx = wallet_get_newindex(ld);
/* Get a key to use for closing outputs from this tx. Prefer
* P2TR, but we'll use BECH32 for older peers (but always P2TR
* for our own onchian spends, if any). */

channel->final_key_idx = wallet_get_newindex(ld, anysegwit ? ADDR_P2TR : (ADDR_BECH32|ADDR_P2TR));
if (channel->final_key_idx == -1) {
log_broken(channel->log, "Can't get final key index");
return NULL;
Expand Down
16 changes: 10 additions & 6 deletions lightningd/onchain_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,10 +882,15 @@ static struct bitcoin_tx *onchaind_tx_unsigned(const tal_t *ctx,
bitcoin_tx_add_input(tx, &info->out, info->to_self_delay,
NULL, info->out_sats, NULL, info->wscript);

/* FIXME should this be p2tr now? */
bitcoin_tx_add_output(
tx, scriptpubkey_p2wpkh(tmpctx, &final_key), NULL, info->out_sats);
psbt_add_keypath_to_last_output(tx, channel->final_key_idx, &final_wallet_ext_key, false /* is_taproot */);
if (chainparams->is_elements) {
bitcoin_tx_add_output(
tx, scriptpubkey_p2wpkh(tmpctx, &final_key), NULL, info->out_sats);
psbt_add_keypath_to_last_output(tx, channel->final_key_idx, &final_wallet_ext_key, false /* is_taproot */);
} else {
bitcoin_tx_add_output(
tx, scriptpubkey_p2tr(tmpctx, &final_key), NULL, info->out_sats);
psbt_add_keypath_to_last_output(tx, channel->final_key_idx, &final_wallet_ext_key, true /* is_taproot */);
}

/* Worst-case sig is 73 bytes */
weight = bitcoin_tx_weight(tx) + 1 + 3 + 73 + 0 + tal_count(info->wscript);
Expand Down Expand Up @@ -1117,7 +1122,7 @@ static bool consider_onchain_htlc_tx_rebroadcast(struct channel *channel,
struct pubkey final_key;
bip32_pubkey(ld, &final_key, channel->final_key_idx);
psbt_append_output(psbt,
scriptpubkey_p2wpkh(tmpctx, &final_key),
scriptpubkey_p2tr(tmpctx, &final_key),
change);
}

Expand Down Expand Up @@ -1798,7 +1803,6 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
&our_last_txid,
channel->shutdown_scriptpubkey[LOCAL],
channel->shutdown_scriptpubkey[REMOTE],
channel->final_key_idx,
channel->opener,
&channel->local_basepoints,
&channel->channel_info.theirbase,
Expand Down
9 changes: 8 additions & 1 deletion lightningd/opening_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ wallet_commit_channel(struct lightningd *ld,
struct timeabs timestamp;
bool any_active = peer_any_channel(uc->peer, channel_state_wants_peercomms, NULL);
struct channel_stats zero_channel_stats;
enum addrtype addrtype;

/* We can't have any payments yet */
memset(&zero_channel_stats, 0, sizeof(zero_channel_stats));
Expand All @@ -119,8 +120,14 @@ wallet_commit_channel(struct lightningd *ld,
*/
assert(!(uc->got_offer && uc->fc));

/* FIXME: P2TR for elements! */
if (chainparams->is_elements)
addrtype = ADDR_BECH32;
else
addrtype = ADDR_P2TR;

/* Get a key to use for closing outputs from this tx */
final_key_idx = wallet_get_newindex(ld);
final_key_idx = wallet_get_newindex(ld, addrtype);
if (final_key_idx == -1) {
log_broken(uc->log, "Can't get final key index");
return NULL;
Expand Down
Loading