Skip to content

Commit 809f3b0

Browse files
ddustinrustyrussell
authored andcommitted
close: Print multiple txs; Fixes #6467
Changelog-Changed: `close` now outputs txs & txids of all closing transactions (splice candidates can cause there to be multiple).
1 parent 4500661 commit 809f3b0

File tree

13 files changed

+994
-883
lines changed

13 files changed

+994
-883
lines changed

.msggen.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,8 @@
785785
"CloseResponse": {
786786
"Close.tx": 2,
787787
"Close.txid": 3,
788+
"Close.txids[]": 5,
789+
"Close.txs[]": 4,
788790
"Close.type": 1
789791
},
790792
"ConnectAddress": {
@@ -4093,10 +4095,18 @@
40934095
},
40944096
"Close.tx": {
40954097
"added": "pre-v0.10.1",
4096-
"deprecated": null
4098+
"deprecated": "v24.11"
40974099
},
40984100
"Close.txid": {
40994101
"added": "pre-v0.10.1",
4102+
"deprecated": "v24.11"
4103+
},
4104+
"Close.txids[]": {
4105+
"added": "v24.11",
4106+
"deprecated": null
4107+
},
4108+
"Close.txs[]": {
4109+
"added": "v24.11",
41004110
"deprecated": null
41014111
},
41024112
"Close.type": {

cln-grpc/proto/node.proto

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-grpc/src/convert.rs

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-rpc/src/model.rs

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/msggen/msggen/schema.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5600,21 +5600,51 @@
56005600
"additionalProperties": false,
56015601
"required": [
56025602
"tx",
5603-
"txid"
5603+
"txid",
5604+
"txs",
5605+
"txids"
56045606
],
56055607
"properties": {
56065608
"type": {},
56075609
"tx": {
56085610
"type": "hex",
5611+
"deprecated": [
5612+
"v24.11",
5613+
"v25.11"
5614+
],
56095615
"description": [
56105616
"The raw bitcoin transaction used to close the channel (if it was open)."
56115617
]
56125618
},
56135619
"txid": {
56145620
"type": "txid",
5621+
"deprecated": [
5622+
"v24.11",
5623+
"v25.11"
5624+
],
56155625
"description": [
56165626
"The transaction id of the *tx* field."
56175627
]
5628+
},
5629+
"txs": {
5630+
"added": "v24.11",
5631+
"type": "array",
5632+
"items": {
5633+
"type": "hex"
5634+
},
5635+
"description": [
5636+
"The raw bitcoin transactions used to close the channel (if it was open)."
5637+
]
5638+
},
5639+
"txids": {
5640+
"added": "v24.11",
5641+
"type": "array",
5642+
"items": {
5643+
"type": "txid"
5644+
},
5645+
"description": [
5646+
"The transaction ids of the *tx* field(s)."
5647+
]
56185648
}
56195649
}
56205650
},

contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

Lines changed: 866 additions & 866 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/pyln-testing/pyln/testing/grpc2py.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ def checkmessage2py(m):
317317

318318
def close2py(m):
319319
return remove_default({
320+
"txids": [hexlify(m.txids) for i in hexlify(m.txids)], # ArrayField[primitive] in generate_composite
321+
"txs": [hexlify(m.txs) for i in hexlify(m.txs)], # ArrayField[primitive] in generate_composite
320322
"type": str(m.item_type), # EnumField in generate_composite
321323
"tx": hexlify(m.tx), # PrimitiveField in generate_composite
322324
"txid": hexlify(m.txid), # PrimitiveField in generate_composite

doc/schemas/lightning-close.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,51 @@
107107
"additionalProperties": false,
108108
"required": [
109109
"tx",
110-
"txid"
110+
"txid",
111+
"txs",
112+
"txids"
111113
],
112114
"properties": {
113115
"type": {},
114116
"tx": {
115117
"type": "hex",
118+
"deprecated": [
119+
"v24.11",
120+
"v25.11"
121+
],
116122
"description": [
117123
"The raw bitcoin transaction used to close the channel (if it was open)."
118124
]
119125
},
120126
"txid": {
121127
"type": "txid",
128+
"deprecated": [
129+
"v24.11",
130+
"v25.11"
131+
],
122132
"description": [
123133
"The transaction id of the *tx* field."
124134
]
135+
},
136+
"txs": {
137+
"added": "v24.11",
138+
"type": "array",
139+
"items": {
140+
"type": "hex"
141+
},
142+
"description": [
143+
"The raw bitcoin transactions used to close the channel (if it was open)."
144+
]
145+
},
146+
"txids": {
147+
"added": "v24.11",
148+
"type": "array",
149+
"items": {
150+
"type": "txid"
151+
},
152+
"description": [
153+
"The transaction ids of the *tx* field(s)."
154+
]
125155
}
126156
}
127157
},

lightningd/closing_control.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,36 @@ struct close_command {
5252
/* Resolve a single close command. */
5353
static void
5454
resolve_one_close_command(struct close_command *cc, bool cooperative,
55-
const struct bitcoin_tx *close_tx)
55+
struct bitcoin_tx **close_txs)
5656
{
57+
assert(tal_count(close_txs));
5758
struct json_stream *result = json_stream_success(cc->cmd);
59+
const struct bitcoin_tx *close_tx = close_txs[tal_count(close_txs) - 1];
5860

5961
json_add_tx(result, "tx", close_tx);
6062
if (!invalid_last_tx(close_tx)) {
6163
struct bitcoin_txid txid;
6264
bitcoin_txid(close_tx, &txid);
6365
json_add_txid(result, "txid", &txid);
6466
}
67+
68+
json_array_start(result, "txs");
69+
for (int i = 0; i < tal_count(close_txs); i++)
70+
json_add_tx(result, NULL, close_txs[i]);
71+
json_array_end(result);
72+
73+
json_array_start(result, "txids");
74+
for (int i = 0; i < tal_count(close_txs); i++) {
75+
if (invalid_last_tx(close_txs[i])) {
76+
json_add_string(result, NULL, "INVALID_TXID");
77+
} else {
78+
struct bitcoin_txid txid;
79+
bitcoin_txid(close_txs[i], &txid);
80+
json_add_txid(result, NULL, &txid);
81+
}
82+
}
83+
json_array_end(result);
84+
6585
if (cooperative)
6686
json_add_string(result, "type", "mutual");
6787
else
@@ -85,15 +105,15 @@ const char *cmd_id_from_close_command(const tal_t *ctx,
85105

86106
/* Resolve a close command for a channel that will be closed soon. */
87107
void resolve_close_command(struct lightningd *ld, struct channel *channel,
88-
bool cooperative, const struct bitcoin_tx *close_tx)
108+
bool cooperative, struct bitcoin_tx **close_txs)
89109
{
90110
struct close_command *cc;
91111
struct close_command *n;
92112

93113
list_for_each_safe(&ld->close_commands, cc, n, list) {
94114
if (cc->channel != channel)
95115
continue;
96-
resolve_one_close_command(cc, cooperative, close_tx);
116+
resolve_one_close_command(cc, cooperative, close_txs);
97117
}
98118
}
99119

lightningd/closing_control.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const char *cmd_id_from_close_command(const tal_t *ctx,
1414

1515
/* Resolve a close command for a channel that will be closed soon. */
1616
void resolve_close_command(struct lightningd *ld, struct channel *channel,
17-
bool cooperative, const struct bitcoin_tx *close_tx);
17+
bool cooperative, struct bitcoin_tx **close_txs);
1818

1919
void peer_start_closingd(struct channel *channel,
2020
struct peer_fd *peer_fd);

0 commit comments

Comments
 (0)