Skip to content

Commit 606aad0

Browse files
committed
lightningd: expose funding PSBT (if we have it) in JSON API.
Changelog-Added: JSON-RPC: `psbt` field in `funding` in listpeerchannels, and `funding_psbt` in listclosedchannels. Signed-off-by: Rusty Russell <[email protected]>
1 parent 409beb6 commit 606aad0

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

contrib/msggen/msggen/schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18584,6 +18584,13 @@
1858418584
"The 0-based output number of the funding transaction which opens the channel."
1858518585
]
1858618586
},
18587+
"funding_psbt": {
18588+
"type": "string",
18589+
"added": "v25.12",
18590+
"description": [
18591+
"The PSBT (may be non-final or unsigned) we should use to open the channel, if any"
18592+
]
18593+
},
1858718594
"leased": {
1858818595
"type": "boolean",
1858918596
"description": [
@@ -24327,6 +24334,13 @@
2432724334
"description": [
2432824335
"Amount we were paid by peer at open."
2432924336
]
24337+
},
24338+
"psbt": {
24339+
"type": "string",
24340+
"added": "v25.12",
24341+
"description": [
24342+
"The PSBT (may be non-final or unsigned) we should use to open the channel, if any. This is initially from `fundchannel_complete`, but will be updated with if `sendpsbt` is called with an updated PSBT."
24343+
]
2433024344
}
2433124345
}
2433224346
},

doc/schemas/listclosedchannels.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@
188188
"The 0-based output number of the funding transaction which opens the channel."
189189
]
190190
},
191+
"funding_psbt": {
192+
"type": "string",
193+
"added": "v25.12",
194+
"description": [
195+
"The PSBT (may be non-final or unsigned) we should use to open the channel, if any"
196+
]
197+
},
191198
"leased": {
192199
"type": "boolean",
193200
"description": [

doc/schemas/listpeerchannels.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,13 @@
502502
"description": [
503503
"Amount we were paid by peer at open."
504504
]
505+
},
506+
"psbt": {
507+
"type": "string",
508+
"added": "v25.12",
509+
"description": [
510+
"The PSBT (may be non-final or unsigned) we should use to open the channel, if any. This is initially from `fundchannel_complete`, but will be updated with if `sendpsbt` is called with an updated PSBT."
511+
]
505512
}
506513
}
507514
},

lightningd/closed_channel.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ static void json_add_closed_channel(struct json_stream *response,
5959
} else if (!amount_msat_is_zero(channel->push))
6060
json_add_amount_msat(response, "funding_pushed_msat",
6161
channel->push);
62+
if (channel->funding_psbt)
63+
json_add_psbt(response, "funding_psbt", channel->funding_psbt);
6264

6365
json_add_amount_sat_msat(response, "total_msat", channel->funding_sats);
6466
json_add_amount_msat(response, "final_to_us_msat", channel->our_msat);

lightningd/peer_control.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,8 @@ static void NON_NULL_ARGS(1, 2, 4, 5) json_add_channel(struct command *cmd,
11551155
channel->push);
11561156
}
11571157

1158+
if (channel->funding_psbt)
1159+
json_add_psbt(response, "psbt", channel->funding_psbt);
11581160
json_object_end(response);
11591161

11601162
if (!amount_sat_to_msat(&funding_msat, channel->funding_sats)) {

tests/test_plugin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3295,6 +3295,8 @@ def test_sql(node_factory, bitcoind):
32953295
'type': 'txid'},
32963296
{'name': 'funding_outnum',
32973297
'type': 'u32'},
3298+
{'name': 'funding_psbt',
3299+
'type': 'string'},
32983300
{'name': 'leased',
32993301
'type': 'boolean'},
33003302
{'name': 'funding_fee_paid_msat',
@@ -3606,6 +3608,8 @@ def test_sql(node_factory, bitcoind):
36063608
'type': 'msat'},
36073609
{'name': 'funding_fee_rcvd_msat',
36083610
'type': 'msat'},
3611+
{'name': 'funding_psbt',
3612+
'type': 'string'},
36093613
{'name': 'to_us_msat',
36103614
'type': 'msat'},
36113615
{'name': 'min_to_us_msat',

0 commit comments

Comments
 (0)