Skip to content

Commit 93d04d0

Browse files
rustyrussellcdecker
authored andcommitted
wire: update to latest version of the spec.
The main change here is that the previously-optional open/accept fields and reestablish fields are now compulsory (everyone was including them anyway). In fact, the open/accept is a TLV because it was actually the same format. For more details, see lightning-rfc/f068dd0d8dfa5ae75feedd99f269e23be4777381 Changelog-Removed: protocol: support for optioned form of reestablish messages now compulsory. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent a66415a commit 93d04d0

File tree

18 files changed

+123
-164
lines changed

18 files changed

+123
-164
lines changed

Makefile

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

2525
# Where we keep the BOLT RFCs
2626
BOLTDIR := ../lightning-rfc/
27-
BOLTVERSION := 4107c69e315b4f33d5b00459bef919bcfaa64bf2
27+
BOLTVERSION := 9e8e29af9b9a922eb114b2c716205d0772946e56
2828

2929
-include config.vars
3030

bitcoin/script.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ u8 *bitcoin_wscript_htlc_receive(const tal_t *ctx,
662662
* ## HTLC-Timeout and HTLC-Success Transactions
663663
*
664664
*...
665-
* * `txin[0]` witness stack: `0 <remotehtlcsig> <localhtlcsig> <payment_preimage>` for HTLC-success, `0 <remotehtlcsig> <localhtlcsig> 0` for HTLC-timeout
665+
* * `txin[0]` witness stack: `0 <remotehtlcsig> <localhtlcsig> <payment_preimage>` for HTLC-success, `0 <remotehtlcsig> <localhtlcsig> <>` for HTLC-timeout
666666
*/
667667
u8 **bitcoin_witness_htlc_timeout_tx(const tal_t *ctx,
668668
const struct bitcoin_signature *localhtlcsig,

channeld/channeld.c

Lines changed: 17 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,8 +2204,7 @@ static void resend_commitment(struct peer *peer, const struct changed_htlc *last
22042204
* `your_last_per_commitment_secret` is correct for that
22052205
* `next_revocation_number` minus 1:
22062206
*...
2207-
* - otherwise, if it supports `option_data_loss_protect`, AND the
2208-
* `option_data_loss_protect` fields are present:
2207+
* - otherwise, if it supports `option_data_loss_protect`:
22092208
* - if `next_revocation_number` is greater than expected above,
22102209
* AND `your_last_per_commitment_secret` is correct for that
22112210
* `next_revocation_number` minus 1:
@@ -2266,8 +2265,7 @@ static void check_future_dataloss_fields(struct peer *peer,
22662265
* ...
22672266
* - if `your_last_per_commitment_secret` does not match the expected values:
22682267
* - SHOULD fail the channel.
2269-
* - otherwise, if it supports `option_data_loss_protect`, AND the
2270-
* `option_data_loss_protect` fields are present:
2268+
* - otherwise, if it supports `option_data_loss_protect`:
22712269
*...
22722270
* - otherwise (`your_last_per_commitment_secret` or
22732271
* `my_current_per_commitment_point` do not match the expected values):
@@ -2440,41 +2438,33 @@ static void peer_reconnect(struct peer *peer,
24402438
* of the next `revoke_and_ack` message it expects to receive.
24412439
* - if `option_static_remotekey` applies to the commitment transaction:
24422440
* - MUST set `my_current_per_commitment_point` to a valid point.
2443-
* - otherwise, if it supports `option_data_loss_protect`:
2441+
* - otherwise:
24442442
* - MUST set `my_current_per_commitment_point` to its commitment
24452443
* point for the last signed commitment it received from its
24462444
* channel peer (i.e. the commitment_point corresponding to the
24472445
* commitment transaction the sender would use to unilaterally
24482446
* close).
2449-
* - if `option_static_remotekey` applies to the commitment
2450-
* transaction, or the sending node supports
2451-
* `option_data_loss_protect`:
2452-
* - if `next_revocation_number` equals 0:
2453-
* - MUST set `your_last_per_commitment_secret` to all zeroes
2454-
* - otherwise:
2455-
* - MUST set `your_last_per_commitment_secret` to the last
2456-
* `per_commitment_secret` it received
2447+
* - if `next_revocation_number` equals 0:
2448+
* - MUST set `your_last_per_commitment_secret` to all zeroes
2449+
* - otherwise:
2450+
* - MUST set `your_last_per_commitment_secret` to the last
2451+
* `per_commitment_secret` it received
24572452
*/
24582453
if (peer->channel->option_static_remotekey) {
2459-
msg = towire_channel_reestablish_option_static_remotekey
2454+
msg = towire_channel_reestablish
24602455
(NULL, &peer->channel_id,
24612456
peer->next_index[LOCAL],
24622457
peer->revocations_received,
24632458
last_remote_per_commit_secret,
24642459
/* Can send any (valid) point here */
24652460
&peer->remote_per_commit);
2466-
} else if (dataloss_protect) {
2467-
msg = towire_channel_reestablish_option_data_loss_protect
2461+
} else {
2462+
msg = towire_channel_reestablish
24682463
(NULL, &peer->channel_id,
24692464
peer->next_index[LOCAL],
24702465
peer->revocations_received,
24712466
last_remote_per_commit_secret,
24722467
&my_current_per_commitment_point);
2473-
} else {
2474-
msg = towire_channel_reestablish
2475-
(NULL, &peer->channel_id,
2476-
peer->next_index[LOCAL],
2477-
peer->revocations_received);
24782468
}
24792469

24802470
sync_crypto_write(peer->pps, take(msg));
@@ -2494,43 +2484,17 @@ static void peer_reconnect(struct peer *peer,
24942484
msg) ||
24952485
capture_premature_msg(&premature_msgs, msg));
24962486

2497-
if (peer->channel->option_static_remotekey) {
2498-
struct pubkey ignore;
2499-
if (!fromwire_channel_reestablish_option_static_remotekey(msg,
2500-
&channel_id,
2501-
&next_commitment_number,
2502-
&next_revocation_number,
2503-
&last_local_per_commitment_secret,
2504-
&ignore)) {
2505-
peer_failed(peer->pps,
2506-
&peer->channel_id,
2507-
"bad reestablish static_remotekey msg: %s %s",
2508-
wire_type_name(fromwire_peektype(msg)),
2509-
tal_hex(msg, msg));
2510-
}
2511-
} else if (dataloss_protect) {
2512-
if (!fromwire_channel_reestablish_option_data_loss_protect(msg,
2487+
if (!fromwire_channel_reestablish(msg,
25132488
&channel_id,
25142489
&next_commitment_number,
25152490
&next_revocation_number,
25162491
&last_local_per_commitment_secret,
25172492
&remote_current_per_commitment_point)) {
2518-
peer_failed(peer->pps,
2519-
&peer->channel_id,
2520-
"bad reestablish dataloss msg: %s %s",
2521-
wire_type_name(fromwire_peektype(msg)),
2522-
tal_hex(msg, msg));
2523-
}
2524-
} else {
2525-
if (!fromwire_channel_reestablish(msg, &channel_id,
2526-
&next_commitment_number,
2527-
&next_revocation_number)) {
2528-
peer_failed(peer->pps,
2529-
&peer->channel_id,
2530-
"bad reestablish msg: %s %s",
2531-
wire_type_name(fromwire_peektype(msg)),
2532-
tal_hex(msg, msg));
2533-
}
2493+
peer_failed(peer->pps,
2494+
&peer->channel_id,
2495+
"bad reestablish msg: %s %s",
2496+
wire_type_name(fromwire_peektype(msg)),
2497+
tal_hex(msg, msg));
25342498
}
25352499

25362500
status_debug("Got reestablish commit=%"PRIu64" revoke=%"PRIu64,

closingd/closingd.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ static void do_reconnect(struct per_peer_state *pps,
154154
struct channel_id their_channel_id;
155155
u64 next_local_commitment_number, next_remote_revocation_number;
156156
struct pubkey my_current_per_commitment_point, next_commitment_point;
157+
struct secret their_secret;
157158

158159
my_current_per_commitment_point = get_per_commitment_point(next_index[LOCAL]-1);
159160

@@ -175,9 +176,7 @@ static void do_reconnect(struct per_peer_state *pps,
175176
* of the next `revoke_and_ack` message it expects to receive.
176177
*/
177178

178-
/* We're always allowed to send extra fields, so we send dataloss_protect
179-
* even if we didn't negotiate it */
180-
msg = towire_channel_reestablish_option_data_loss_protect(NULL, channel_id,
179+
msg = towire_channel_reestablish(NULL, channel_id,
181180
next_index[LOCAL],
182181
revocations_received,
183182
last_remote_per_commit_secret,
@@ -199,7 +198,9 @@ static void do_reconnect(struct per_peer_state *pps,
199198

200199
if (!fromwire_channel_reestablish(channel_reestablish, &their_channel_id,
201200
&next_local_commitment_number,
202-
&next_remote_revocation_number)) {
201+
&next_remote_revocation_number,
202+
&their_secret,
203+
&next_commitment_point)) {
203204
peer_failed(pps, channel_id,
204205
"bad reestablish msg: %s %s",
205206
wire_type_name(fromwire_peektype(channel_reestablish)),

common/bigsize.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ size_t bigsize_get(const u8 *p, size_t max, bigsize_t *val)
6464
}
6565
*val = ((u64)p[1] << 8) + p[2];
6666
if (*val < 0xfd) {
67-
SUPERVERBOSE("decoded varint is not canonical");
67+
SUPERVERBOSE("decoded bigsize is not canonical");
6868
return 0;
6969
}
7070
return 3;
@@ -76,7 +76,7 @@ size_t bigsize_get(const u8 *p, size_t max, bigsize_t *val)
7676
*val = ((u64)p[1] << 24) + ((u64)p[2] << 16)
7777
+ ((u64)p[3] << 8) + p[4];
7878
if ((*val >> 16) == 0) {
79-
SUPERVERBOSE("decoded varint is not canonical");
79+
SUPERVERBOSE("decoded bigsize is not canonical");
8080
return 0;
8181
}
8282
return 5;
@@ -90,7 +90,7 @@ size_t bigsize_get(const u8 *p, size_t max, bigsize_t *val)
9090
+ ((u64)p[5] << 24) + ((u64)p[6] << 16)
9191
+ ((u64)p[7] << 8) + p[8];
9292
if ((*val >> 32) == 0) {
93-
SUPERVERBOSE("decoded varint is not canonical");
93+
SUPERVERBOSE("decoded bigsize is not canonical");
9494
return 0;
9595
}
9696
return 9;

common/decode_array.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct short_channel_id *decode_short_ids(const tal_t *ctx, const u8 *encoded);
2323

2424
/* BOLT #7:
2525
*
26-
* `encoded_query_flags` is an array of bitfields, one varint per bitfield,
26+
* `encoded_query_flags` is an array of bitfields, one bigsize per bitfield,
2727
* one bitfield for each `short_channel_id`. Bits have the following meaning:
2828
*
2929
* | Bit Position | Meaning |

common/features.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ static const struct feature_style feature_styles[] = {
6161
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
6262
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
6363
[BOLT11_FEATURE] = FEATURE_REPRESENT } },
64-
/* FIXME: Spec is wrong, and Eclair doesn't include in channel_announce! */
6564
/* BOLT #9:
66-
* | 18/19 | `option_support_large_channel` |... INC+ ...
65+
* | 18/19 | `option_support_large_channel` |... IN ...
6766
*/
6867
{ OPT_LARGE_CHANNELS,
6968
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,

common/features.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ u8 *featurebits_or(const tal_t *ctx, const u8 *f1 TAKES, const u8 *f2 TAKES);
9595
*
9696
* | 14/15 | `payment_secret` |... IN9 ...
9797
* | 16/17 | `basic_mpp` |... IN9 ...
98-
* | 18/19 | `option_support_large_channel` |... INC+ ...
98+
* | 18/19 | `option_support_large_channel` |... IN ...
9999
*/
100100
#define OPT_PAYMENT_SECRET 14
101101
#define OPT_BASIC_MPP 16

common/test/run-bigsize.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,19 @@ void towire_u8_array(u8 **pptr UNNEEDED, const u8 *arr UNNEEDED, size_t num UNNE
171171
* "name": "two byte not canonical",
172172
* "value": 0,
173173
* "bytes": "fd00fc",
174-
* "exp_error": "decoded varint is not canonical"
174+
* "exp_error": "decoded bigsize is not canonical"
175175
* },
176176
* {
177177
* "name": "four byte not canonical",
178178
* "value": 0,
179179
* "bytes": "fe0000ffff",
180-
* "exp_error": "decoded varint is not canonical"
180+
* "exp_error": "decoded bigsize is not canonical"
181181
* },
182182
* {
183183
* "name": "eight byte not canonical",
184184
* "value": 0,
185185
* "bytes": "ff00000000ffffffff",
186-
* "exp_error": "decoded varint is not canonical"
186+
* "exp_error": "decoded bigsize is not canonical"
187187
* },
188188
* {
189189
* "name": "two byte short read",

gossipd/queries.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ bool query_short_channel_ids(struct daemon *daemon,
167167
/* BOLT #7:
168168
* - MAY include an optional `query_flags`. If so:
169169
* - MUST set `encoding_type`, as for `encoded_short_ids`.
170-
* - Each query flag is a minimally-encoded varint.
170+
* - Each query flag is a minimally-encoded bigsize.
171171
* - MUST encode one query flag per `short_channel_id`.
172172
*/
173173
if (query_flags)
@@ -353,18 +353,15 @@ static void reply_channel_range(struct peer *peer,
353353
{
354354
/* BOLT #7:
355355
*
356-
* - For each `reply_channel_range`:
356+
* - MUST respond with one or more `reply_channel_range`:
357357
* - MUST set with `chain_hash` equal to that of `query_channel_range`,
358-
* - MUST encode a `short_channel_id` for every open channel it
359-
* knows in blocks `first_blocknum` to `first_blocknum` plus
360-
* `number_of_blocks` minus one.
361358
* - MUST limit `number_of_blocks` to the maximum number of blocks
362359
* whose results could fit in `encoded_short_ids`
363360
* - if does not maintain up-to-date channel information for
364361
* `chain_hash`:
365-
* - MUST set `complete` to 0.
362+
* - MUST set `full_information` to 0.
366363
* - otherwise:
367-
* - SHOULD set `complete` to 1.
364+
* - SHOULD set `full_information` to 1.
368365
*/
369366
struct tlv_reply_channel_range_tlvs *tlvs
370367
= tlv_reply_channel_range_tlvs_new(tmpctx);
@@ -449,7 +446,7 @@ static bool queue_channel_ranges(struct peer *peer,
449446
* * [`chain_hash`:`chain_hash`]
450447
* * [`u32`:`first_blocknum`]
451448
* * [`u32`:`number_of_blocks`]
452-
* * [`byte`:`complete`]
449+
* * [`byte`:`full_information`]
453450
* * [`u16`:`len`]
454451
* * [`len*byte`:`encoded_short_ids`]
455452
*/
@@ -696,9 +693,18 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg)
696693
*
697694
* The receiver of `query_channel_range`:
698695
*...
699-
* - MUST respond with one or more `reply_channel_range` whose
700-
* combined range cover the requested `first_blocknum` to
701-
* `first_blocknum` plus `number_of_blocks` minus one.
696+
* - the first `reply_channel_range` message:
697+
* - MUST set `first_blocknum` less than or equal to the
698+
* `first_blocknum` in `query_channel_range`
699+
* - MUST set `first_blocknum` plus `number_of_blocks` greater than
700+
* `first_blocknum` in `query_channel_range`.
701+
* - successive `reply_channel_range` message:
702+
* - MUST set `first_blocknum` to the previous `first_blocknum`
703+
* plus `number_of_blocks`.
704+
* - the final `reply_channel_range` message:
705+
* - MUST have `first_blocknum` plus `number_of_blocks` equal or
706+
* greater than the `query_channel_range` `first_blocknum` plus
707+
* `number_of_blocks`.
702708
*/
703709
/* ie. They can be outside range we asked, but they must overlap! */
704710
if (first_blocknum + number_of_blocks <= peer->range_first_blocknum
@@ -988,9 +994,9 @@ void maybe_send_query_responses(struct peer *peer)
988994
* `reply_short_channel_ids_end`.
989995
* - if does not maintain up-to-date channel information for
990996
* `chain_hash`:
991-
* - MUST set `complete` to 0.
997+
* - MUST set `full_information` to 0.
992998
* - otherwise:
993-
* - SHOULD set `complete` to 1.
999+
* - SHOULD set `full_information` to 1.
9941000
*/
9951001
/* FIXME: We consider ourselves to have complete knowledge. */
9961002
u8 *end = towire_reply_short_channel_ids_end(peer,

gossipd/queries.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void maybe_send_query_responses(struct peer *peer);
2121

2222
/* BOLT #7:
2323
*
24-
* `query_option_flags` is a bitfield represented as a minimally-encoded varint.
24+
* `query_option_flags` is a bitfield represented as a minimally-encoded bigsize.
2525
* Bits have the following meaning:
2626
*
2727
* | Bit Position | Meaning |

onchaind/onchaind.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2270,7 +2270,7 @@ static void handle_our_unilateral(const struct tx_parts *tx,
22702270
* only be valid after that duration has passed) and
22712271
* witness:
22722272
*
2273-
* <local_delayedsig> 0
2273+
* <local_delayedsig> <>
22742274
*/
22752275
to_us = tx_to_us(out, delayed_payment_to_us, out,
22762276
to_self_delay[LOCAL], 0, NULL, 0,

0 commit comments

Comments
 (0)