Skip to content

Commit b52d545

Browse files
nGolinemadelinevibes
authored andcommitted
wire/splice: rename messages and TLV fields per updated BOLTs
Rename splice→splice_init, relative_satoshis→funding_contribution_satoshis, txsigs_tlvs→tx_signatures_tlvs, and splice_info/batch_info→funding_txid/message_type. Consolidate three CLN-specific shim patches into extracted_peer_cln_batch_element.patch. Changelog-None
1 parent cad409e commit b52d545

20 files changed

Lines changed: 143 additions & 191 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ CCANDIR := ccan
3333

3434
# Where we keep the BOLT RFCs
3535
BOLTDIR := ../bolts/
36-
DEFAULT_BOLTVERSION := 311119388a46dfa859da3d2eda0ca836cfc5f078
36+
DEFAULT_BOLTVERSION := 4b539711d4726f274482051150bc6612e370b4e2
3737
# Can be overridden on cmdline.
3838
BOLTVERSION := $(DEFAULT_BOLTVERSION)
3939

channeld/channeld.c

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#define HSM_FD 4
5252

5353
#define VALID_STFU_MESSAGE(msg) \
54-
((msg) == WIRE_SPLICE || \
54+
((msg) == WIRE_SPLICE_INIT || \
5555
(msg) == WIRE_SPLICE_ACK || \
5656
(msg) == WIRE_TX_INIT_RBF || \
5757
(msg) == WIRE_TX_ACK_RBF || \
@@ -1220,7 +1220,7 @@ static u8 *send_commit_part(const tal_t *ctx,
12201220
(int)splice_amnt, (int)remote_splice_amnt,
12211221
remote_index);
12221222

1223-
cs_tlv->splice_info = tal_dup(cs_tlv, struct bitcoin_txid, &funding->txid);
1223+
cs_tlv->funding_txid = tal_dup(cs_tlv, struct bitcoin_txid, &funding->txid);
12241224
}
12251225

12261226
txs = channel_txs(tmpctx, funding, funding_sats, &htlc_map,
@@ -1319,8 +1319,8 @@ static void send_message_batch(struct peer *peer, u8 **msgs)
13191319

13201320
/* Build the `start_batch` msg now so know it's size */
13211321
tlvs = tlv_start_batch_tlvs_new(tmpctx);
1322-
tlvs->batch_info = tal(tlvs, u16);
1323-
*tlvs->batch_info = WIRE_COMMITMENT_SIGNED;
1322+
tlvs->message_type = tal(tlvs, u16);
1323+
*tlvs->message_type = WIRE_COMMITMENT_SIGNED;
13241324
batch_msg = towire_start_batch(tmpctx, &peer->channel_id,
13251325
tal_count(msgs), tlvs);
13261326
size += tal_bytelen(batch_msg) + hdr_size;
@@ -2053,7 +2053,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
20532053
* - If `funding_txid` is missing in one of the `commitment_signed` messages:
20542054
* - MUST send an `error` and fail the channel.
20552055
*/
2056-
if (!cs_tlv->splice_info)
2056+
if (!cs_tlv->funding_txid)
20572057
peer_failed_err(peer->pps, &peer->channel_id,
20582058
"Must send funding_txid when sending"
20592059
" a commitment batch.");
@@ -2065,7 +2065,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
20652065
* - MUST send an `error` and fail the channel.
20662066
*/
20672067
if (!tal_count(peer->splice_state->inflights)
2068-
&& !bitcoin_txid_eq(cs_tlv->splice_info,
2068+
&& !bitcoin_txid_eq(cs_tlv->funding_txid,
20692069
&peer->channel->funding.txid))
20702070
peer_failed_err(peer->pps, &peer->channel_id,
20712071
"Commitment batch is is missing our"
@@ -2077,7 +2077,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
20772077
* - If `funding_txid` is missing in one of the `commitment_signed` messages:
20782078
* - MUST send an `error` and fail the channel.
20792079
*/
2080-
if (commit_index && !cs_tlv->splice_info)
2080+
if (commit_index && !cs_tlv->funding_txid)
20812081
peer_failed_err(peer->pps, &peer->channel_id,
20822082
"Must send funding_txid when sending"
20832083
" a commitment batch");
@@ -2123,14 +2123,14 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
21232123
status_debug("handle_peer_commit_sig for inflight outpoint %s",
21242124
fmt_bitcoin_txid(tmpctx, &outpoint.txid));
21252125

2126-
if (cs_tlv->splice_info
2126+
if (cs_tlv->funding_txid
21272127
&& !bitcoin_txid_eq(&outpoint.txid,
2128-
cs_tlv->splice_info))
2128+
cs_tlv->funding_txid))
21292129
peer_failed_err(peer->pps, &peer->channel_id,
21302130
"Expected commit sig message for %s but"
21312131
" got %s",
21322132
fmt_bitcoin_txid(tmpctx, &outpoint.txid),
2133-
fmt_bitcoin_txid(tmpctx, cs_tlv->splice_info));
2133+
fmt_bitcoin_txid(tmpctx, cs_tlv->funding_txid));
21342134
}
21352135
else {
21362136
outpoint = peer->channel->funding;
@@ -2174,7 +2174,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
21742174
peer_failed_warn(peer->pps, &peer->channel_id,
21752175
"Bad commit_sig signature %"PRIu64" %s for tx"
21762176
" %s wscript %s key %s feerate %u. Outpoint"
2177-
" %s, funding_sats: %s, splice_info: %s,"
2177+
" %s, funding_sats: %s, funding_txid: %s,"
21782178
" inflight splice count: %zu",
21792179
local_index,
21802180
fmt_bitcoin_signature(msg, &commit_sig),
@@ -2184,9 +2184,9 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
21842184
channel_feerate(peer->channel, LOCAL),
21852185
fmt_bitcoin_outpoint(tmpctx, &outpoint),
21862186
fmt_amount_sat(tmpctx, funding_sats),
2187-
cs_tlv && cs_tlv->splice_info
2187+
cs_tlv && cs_tlv->funding_txid
21882188
? fmt_bitcoin_txid(tmpctx,
2189-
cs_tlv->splice_info)
2189+
cs_tlv->funding_txid)
21902190
: "N/A",
21912191
tal_count(peer->splice_state->inflights));
21922192
}
@@ -2350,10 +2350,10 @@ static int commit_index_from_msg(const u8 *msg, struct peer *peer)
23502350
fromwire_commitment_signed(tmpctx, msg, &channel_id, &commit_sig.s,
23512351
&raw_sigs, &cs_tlv);
23522352

2353-
if (!cs_tlv || !cs_tlv->splice_info)
2353+
if (!cs_tlv || !cs_tlv->funding_txid)
23542354
return -1;
23552355

2356-
funding_txid = *cs_tlv->splice_info;
2356+
funding_txid = *cs_tlv->funding_txid;
23572357

23582358
if (bitcoin_txid_eq(&funding_txid, &peer->channel->funding.txid))
23592359
return 0;
@@ -2451,11 +2451,11 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
24512451
" [%"PRIu16"/%"PRIu16"]",
24522452
tal_hex(sub_msg, sub_msg), i, batch_size);
24532453

2454-
if (!sub_cs_tlv->splice_info)
2454+
if (!sub_cs_tlv->funding_txid)
24552455
peer_failed_warn(peer->pps, &peer->channel_id,
24562456
"commit_sig %s in commit_sig batch:"
24572457
" [%"PRIu16"/%"PRIu16"] missing"
2458-
" splice_info",
2458+
" funding_txid",
24592459
tal_hex(sub_msg, sub_msg), i, batch_size);
24602460

24612461
msg_batch[i] = sub_msg;
@@ -2486,12 +2486,12 @@ static void handle_peer_start_batch(struct peer *peer, const u8 *msg)
24862486
peer_failed_warn(peer->pps, &peer->channel_id,
24872487
"Bad start_batch %s", tal_hex(msg, msg));
24882488

2489-
if (!tlvs || !tlvs->batch_info
2490-
|| *tlvs->batch_info != WIRE_COMMITMENT_SIGNED) {
2489+
if (!tlvs || !tlvs->message_type
2490+
|| *tlvs->message_type != WIRE_COMMITMENT_SIGNED) {
24912491
status_unusual("Ignoring Unrecognized start_batch message type"
24922492
" %s, expected WIRE_COMMITMENT_SIGNED.",
2493-
tlvs && tlvs->batch_info
2494-
? peer_wire_name(*tlvs->batch_info)
2493+
tlvs && tlvs->message_type
2494+
? peer_wire_name(*tlvs->message_type)
24952495
: "N/A");
24962496
return;
24972497
}
@@ -2885,7 +2885,7 @@ static void handle_unexpected_tx_sigs(struct peer *peer, const u8 *msg)
28852885
struct channel_id cid;
28862886
struct bitcoin_txid txid;
28872887

2888-
struct tlv_txsigs_tlvs *txsig_tlvs = tlv_txsigs_tlvs_new(tmpctx);
2888+
struct tlv_tx_signatures_tlvs *txsig_tlvs = tlv_tx_signatures_tlvs_new(tmpctx);
28892889

28902890
/* In a rare case, a v2 peer may re-send a tx_sigs message.
28912891
* This happens when they've/we've exchanged channel_ready,
@@ -3793,7 +3793,7 @@ static void resume_splice_negotiation(struct peer *peer,
37933793
struct bitcoin_tx *final_tx;
37943794
struct bitcoin_txid final_txid;
37953795
u8 **wit_stack;
3796-
struct tlv_txsigs_tlvs *txsig_tlvs, *their_txsigs_tlvs;
3796+
struct tlv_tx_signatures_tlvs *txsig_tlvs, *their_txsigs_tlvs;
37973797
const u8 *msg_received;
37983798
struct witness **inws;
37993799
struct bitcoin_signature *their_sig;
@@ -3898,7 +3898,7 @@ static void resume_splice_negotiation(struct peer *peer,
38983898
fmt_bitcoin_signature(tmpctx, &splice_sig),
38993899
fmt_wally_psbt(tmpctx, current_psbt));
39003900

3901-
txsig_tlvs = tlv_txsigs_tlvs_new(tmpctx);
3901+
txsig_tlvs = tlv_tx_signatures_tlvs_new(tmpctx);
39023902
txsig_tlvs->shared_input_signature = &splice_sig.s;
39033903

39043904
/* DTODO: is this finalize call required? */
@@ -3965,7 +3965,7 @@ static void resume_splice_negotiation(struct peer *peer,
39653965
" WIRE_TX_SIGNATURES)",
39663966
peer_wire_name(type));
39673967

3968-
their_txsigs_tlvs = tlv_txsigs_tlvs_new(tmpctx);
3968+
their_txsigs_tlvs = tlv_tx_signatures_tlvs_new(tmpctx);
39693969
if (!fromwire_tx_signatures(tmpctx, msg, &cid,
39703970
&inflight->outpoint.txid,
39713971
cast_const3(struct witness ***,
@@ -4224,15 +4224,17 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
42244224

42254225
type = fromwire_peektype(inmsg);
42264226

4227-
if (type == WIRE_SPLICE) {
4228-
if (!fromwire_splice(inmsg,
4229-
&channel_id,
4230-
&peer->splicing->opener_relative,
4231-
&funding_feerate_perkw,
4232-
&locktime,
4233-
&peer->splicing->remote_funding_pubkey))
4227+
if (type == WIRE_SPLICE_INIT) {
4228+
struct tlv_splice_init_tlvs *splice_init_tlvs;
4229+
if (!fromwire_splice_init(tmpctx, inmsg,
4230+
&channel_id,
4231+
&peer->splicing->opener_relative,
4232+
&funding_feerate_perkw,
4233+
&locktime,
4234+
&peer->splicing->remote_funding_pubkey,
4235+
&splice_init_tlvs))
42344236
peer_failed_warn(peer->pps, &peer->channel_id,
4235-
"Bad wire_splice %s",
4237+
"Bad wire_splice_init %s",
42364238
tal_hex(tmpctx, inmsg));
42374239
if (last_inflight(peer)) {
42384240
peer_failed_warn(peer->pps, &peer->channel_id,
@@ -4282,11 +4284,12 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
42824284
/* TODO: Add plugin hook for user to adjust accepter amount */
42834285
peer->splicing->accepter_relative = 0;
42844286

4285-
if (type == WIRE_SPLICE) {
4287+
if (type == WIRE_SPLICE_INIT) {
42864288
msg = towire_splice_ack(NULL,
42874289
&peer->channel_id,
42884290
peer->splicing->accepter_relative,
4289-
&peer->channel->funding_pubkey[LOCAL]);
4291+
&peer->channel->funding_pubkey[LOCAL],
4292+
NULL);
42904293
} else if (type == WIRE_TX_INIT_RBF) {
42914294
ack_rbf_tlvs = tlv_tx_ack_rbf_tlvs_new(tmpctx);
42924295
ack_rbf_tlvs->funding_output_contribution = tal(ack_rbf_tlvs, s64);
@@ -4415,10 +4418,12 @@ static void splice_initiator(struct peer *peer, const u8 *inmsg)
44154418
type = fromwire_peektype(inmsg);
44164419

44174420
if (type == WIRE_SPLICE_ACK) {
4418-
if (!fromwire_splice_ack(inmsg,
4421+
struct tlv_splice_ack_tlvs *splice_ack_tlvs;
4422+
if (!fromwire_splice_ack(tmpctx, inmsg,
44194423
&channel_id,
44204424
&peer->splicing->accepter_relative,
4421-
&peer->splicing->remote_funding_pubkey))
4425+
&peer->splicing->remote_funding_pubkey,
4426+
&splice_ack_tlvs))
44224427
peer_failed_warn(peer->pps, &peer->channel_id,
44234428
"Bad wire_splice_ack %s",
44244429
tal_hex(tmpctx, inmsg));
@@ -4928,12 +4933,13 @@ static void handle_splice_stfu_success(struct peer *peer)
49284933
u8 *msg;
49294934
struct tlv_tx_init_rbf_tlvs *init_rbf_tlvs;
49304935
if (!last_inflight(peer)) {
4931-
msg = towire_splice(tmpctx,
4932-
&peer->channel_id,
4933-
peer->splicing->opener_relative,
4934-
peer->splicing->feerate_per_kw,
4935-
peer->splicing->current_psbt->fallback_locktime,
4936-
&peer->channel->funding_pubkey[LOCAL]);
4936+
msg = towire_splice_init(tmpctx,
4937+
&peer->channel_id,
4938+
peer->splicing->opener_relative,
4939+
peer->splicing->feerate_per_kw,
4940+
peer->splicing->current_psbt->fallback_locktime,
4941+
&peer->channel->funding_pubkey[LOCAL],
4942+
NULL);
49374943
}
49384944
else { /* RBF attempt */
49394945
init_rbf_tlvs = tlv_tx_init_rbf_tlvs_new(tmpctx);
@@ -5191,7 +5197,7 @@ static void peer_in(struct peer *peer, const u8 *msg)
51915197
case WIRE_STFU:
51925198
handle_stfu(peer, msg);
51935199
return;
5194-
case WIRE_SPLICE:
5200+
case WIRE_SPLICE_INIT:
51955201
case WIRE_TX_INIT_RBF:
51965202
splice_accepter(peer, msg);
51975203
return;
@@ -5954,6 +5960,17 @@ static void peer_reconnect(struct peer *peer,
59545960
"next_funding_txid not recognized.");
59555961
}
59565962

5963+
/* "none of those channel_reestablish messages contain
5964+
* my_current_funding_locked or next_funding for a splice transaction" */
5965+
bool is_splice_active = local_next_funding
5966+
|| peer->splice_state->locked_ready[LOCAL]
5967+
|| remote_next_funding
5968+
|| (recv_tlvs
5969+
&& recv_tlvs->my_current_funding_locked
5970+
&& !bitcoin_txid_eq(
5971+
&recv_tlvs->my_current_funding_locked->my_current_funding_locked_txid,
5972+
&peer->channel->funding.txid));
5973+
59575974
/* BOLT #2:
59585975
*
59595976
* A node:
@@ -5971,7 +5988,8 @@ static void peer_reconnect(struct peer *peer,
59715988

59725989
if (peer->channel_ready[LOCAL]
59735990
&& peer->next_index[LOCAL] == 1
5974-
&& next_commitment_number == 1) {
5991+
&& next_commitment_number == 1
5992+
&& !is_splice_active) {
59755993
struct tlv_channel_ready_tlvs *tlvs = tlv_channel_ready_tlvs_new(tmpctx);
59765994

59775995
tlvs->short_channel_id = &peer->local_alias;

common/gossmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1947,7 +1947,7 @@ const void *gossmap_stream_next(const tal_t *ctx,
19471947
case WIRE_OPEN_CHANNEL2:
19481948
case WIRE_ACCEPT_CHANNEL2:
19491949
case WIRE_STFU:
1950-
case WIRE_SPLICE:
1950+
case WIRE_SPLICE_INIT:
19511951
case WIRE_SPLICE_ACK:
19521952
case WIRE_SPLICE_LOCKED:
19531953
case WIRE_SHUTDOWN:

common/interactivetx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static u8 *read_next_msg(const tal_t *ctx,
182182
case WIRE_STFU:
183183
case WIRE_PEER_STORAGE:
184184
case WIRE_PEER_STORAGE_RETRIEVAL:
185-
case WIRE_SPLICE:
185+
case WIRE_SPLICE_INIT:
186186
case WIRE_SPLICE_ACK:
187187
case WIRE_SPLICE_LOCKED:
188188
*error = tal_fmt(ctx,
@@ -838,7 +838,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
838838
case WIRE_PONG:
839839
case WIRE_PEER_STORAGE:
840840
case WIRE_PEER_STORAGE_RETRIEVAL:
841-
case WIRE_SPLICE:
841+
case WIRE_SPLICE_INIT:
842842
case WIRE_SPLICE_ACK:
843843
case WIRE_STFU:
844844
case WIRE_SPLICE_LOCKED:

connectd/gossip_rcvd_filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static bool is_msg_gossip_broadcast(const u8 *cursor)
9393
case WIRE_OPEN_CHANNEL2:
9494
case WIRE_ACCEPT_CHANNEL2:
9595
case WIRE_STFU:
96-
case WIRE_SPLICE:
96+
case WIRE_SPLICE_INIT:
9797
case WIRE_SPLICE_ACK:
9898
case WIRE_SPLICE_LOCKED:
9999
break;

connectd/gossip_store.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static bool public_msg_type(enum peer_wire type)
101101
case WIRE_PEER_STORAGE:
102102
case WIRE_PEER_STORAGE_RETRIEVAL:
103103
case WIRE_STFU:
104-
case WIRE_SPLICE:
104+
case WIRE_SPLICE_INIT:
105105
case WIRE_SPLICE_ACK:
106106
case WIRE_SPLICE_LOCKED:
107107
return false;

connectd/multiplex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ static bool is_urgent(enum peer_wire type)
355355
case WIRE_PEER_STORAGE:
356356
case WIRE_PEER_STORAGE_RETRIEVAL:
357357
case WIRE_STFU:
358-
case WIRE_SPLICE:
358+
case WIRE_SPLICE_INIT:
359359
case WIRE_SPLICE_ACK:
360360
case WIRE_SPLICE_LOCKED:
361361
case WIRE_PING:

gossipd/gossipd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static void handle_recv_gossip(struct daemon *daemon, const u8 *outermsg)
261261
case WIRE_PEER_STORAGE:
262262
case WIRE_PEER_STORAGE_RETRIEVAL:
263263
case WIRE_STFU:
264-
case WIRE_SPLICE:
264+
case WIRE_SPLICE_INIT:
265265
case WIRE_SPLICE_ACK:
266266
case WIRE_SPLICE_LOCKED:
267267
break;

openingd/dualopend.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ static void handle_tx_sigs(struct state *state, const u8 *msg)
13041304
const struct witness **witnesses;
13051305
struct tx_state *tx_state = state->tx_state;
13061306

1307-
struct tlv_txsigs_tlvs *txsig_tlvs = tlv_txsigs_tlvs_new(tmpctx);
1307+
struct tlv_tx_signatures_tlvs *txsig_tlvs = tlv_tx_signatures_tlvs_new(tmpctx);
13081308
if (!fromwire_tx_signatures(tmpctx, msg, &cid, &txid,
13091309
cast_const3(
13101310
struct witness ***,
@@ -1700,7 +1700,7 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state)
17001700
case WIRE_PEER_STORAGE:
17011701
case WIRE_PEER_STORAGE_RETRIEVAL:
17021702
case WIRE_STFU:
1703-
case WIRE_SPLICE:
1703+
case WIRE_SPLICE_INIT:
17041704
case WIRE_SPLICE_ACK:
17051705
case WIRE_SPLICE_LOCKED:
17061706
break;
@@ -2082,7 +2082,7 @@ static bool run_tx_interactive(struct state *state,
20822082
case WIRE_PEER_STORAGE:
20832083
case WIRE_PEER_STORAGE_RETRIEVAL:
20842084
case WIRE_STFU:
2085-
case WIRE_SPLICE:
2085+
case WIRE_SPLICE_INIT:
20862086
case WIRE_SPLICE_ACK:
20872087
case WIRE_SPLICE_LOCKED:
20882088
open_abort(state, "Unexpected wire message %s",
@@ -4282,7 +4282,7 @@ static u8 *handle_peer_in(struct state *state)
42824282
case WIRE_PEER_STORAGE:
42834283
case WIRE_PEER_STORAGE_RETRIEVAL:
42844284
case WIRE_STFU:
4285-
case WIRE_SPLICE:
4285+
case WIRE_SPLICE_INIT:
42864286
case WIRE_SPLICE_ACK:
42874287
case WIRE_SPLICE_LOCKED:
42884288
case WIRE_PROTOCOL_BATCH_ELEMENT:

0 commit comments

Comments
 (0)