You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* This is a forced close of the channel. Very early on (before
137
+
opening), this may not require any action but forgetting the
138
+
existence of the channel. Usually it requires signing and
139
+
broadcasting the latest commitment transaction, although during
140
+
mutual close it can also be performed by signing and broadcasting a
141
+
mutual close transaction. See [BOLT #5](05-onchain.md#failing-a-channel).
142
+
143
+
*#### *Close the connection*:
144
+
* This means closing communication with the peer (such as closing
145
+
the TCP socket). It does not imply closing any channels with the
146
+
peer, but does cause the discarding of uncommitted state for
147
+
connections with channels: see [BOLT #2](02-peer-protocol.md#message-retransmission).
148
+
135
149
*#### *Final node*:
136
150
* The final recipient of a packet that is routing a payment from an *[origin node](#origin-node)* through some number of *[hops](#hop)*. It is also the final *[receiving peer](#receiving-peer)* in a chain.
*[The `ping` and `pong` Messages](#the-ping-and-pong-messages)
23
23
*[Appendix A: BigSize Test Vectors](#appendix-a-bigsize-test-vectors)
@@ -285,11 +285,11 @@ The receiving node:
285
285
- upon receiving unknown _odd_ feature bits that are non-zero:
286
286
- MUST ignore the bit.
287
287
- upon receiving unknown _even_ feature bits that are non-zero:
288
-
- MUST fail the connection.
288
+
- MUST close the connection.
289
289
- upon receiving `networks` containing no common chains
290
-
- MAY fail the connection.
290
+
- MAY close the connection.
291
291
- if the feature vector does not set all known, transitive dependencies:
292
-
- MUST fail the connection.
292
+
- MUST close the connection.
293
293
294
294
#### Rationale
295
295
@@ -306,7 +306,7 @@ support a single network, the `networks` fields avoids nodes
306
306
erroneously believing they will receive updates about their preferred
307
307
network, or that they can open channels.
308
308
309
-
### The `error`Message
309
+
### The `error`and `warning` Messages
310
310
311
311
For simplicity of diagnosis, it's often useful to tell a peer that something is incorrect.
312
312
@@ -316,7 +316,11 @@ For simplicity of diagnosis, it's often useful to tell a peer that something is
316
316
*[`u16`:`len`]
317
317
*[`len*byte`:`data`]
318
318
319
-
The 2-byte `len` field indicates the number of bytes in the immediately following field.
319
+
1. type: 1 (`warning`)
320
+
2. data:
321
+
*[`channel_id`:`channel_id`]
322
+
*[`u16`:`len`]
323
+
*[`len*byte`:`data`]
320
324
321
325
#### Requirements
322
326
@@ -331,24 +335,31 @@ The fundee node:
331
335
- MUST use `temporary_channel_id` in lieu of `channel_id`.
332
336
333
337
A sending node:
334
-
- when sending `error`:
335
-
- MUST fail the channel referred to by the error message.
336
338
- SHOULD send `error` for protocol violations or internal errors that make channels unusable or that make further communication unusable.
337
339
- SHOULD send `error` with the unknown `channel_id` in reply to messages of type `32`-`255` related to unknown channels.
340
+
- when sending `error`:
341
+
- MUST fail the channel(s) referred to by the error message.
342
+
- MAY set `channel_id` to all zero to indicate all channels.
343
+
- when sending `warning`:
344
+
- MAY set `channel_id` to all zero if the warning is not related to a specific channel.
345
+
- MAY close the connection after sending.
338
346
- MAY send an empty `data` field.
339
347
- when failure was caused by an invalid signature check:
340
348
- SHOULD include the raw, hex-encoded transaction in reply to a `funding_created`, `funding_signed`, `closing_signed`, or `commitment_signed` message.
341
-
- when `channel_id` is 0:
342
-
- MUST fail all channels with the receiving node.
343
-
- MUST close the connection.
344
-
- MUST set `len` equal to the length of `data`.
345
349
346
350
The receiving node:
347
351
- upon receiving `error`:
348
-
- MUST fail the channel referred to by the error message, if that channel is with the sending node.
349
-
- if no existing channel is referred to by the message:
352
+
- if `channel_id` is all zero:
353
+
- MUST fail all channels with the sending node.
354
+
- otherwise:
355
+
- MUST fail the channel referred to by `channel_id`, if that channel is with the sending node.
356
+
- upon receiving `warning`:
357
+
- SHOULD log the message for later diagnosis.
358
+
- MAY disconnect.
359
+
- MAY reconnect after some delay to retry.
360
+
- MAY attempt `shutdown` if permitted at this point.
361
+
- if no existing channel is referred to by `channel_id`:
350
362
- MUST ignore the message.
351
-
- MUST truncate `len` to the remainder of the packet (if it's larger).
352
363
- if `data` is not composed solely of printable ASCII characters (For reference: the printable character set includes byte values 32 through 126, inclusive):
353
364
- SHOULD NOT print out `data` verbatim.
354
365
@@ -359,6 +370,11 @@ if the connection is simply dropped, then the peer may retry the
359
370
connection. It's also useful to describe protocol violations for
360
371
diagnosis, as this indicates that one peer has a bug.
361
372
373
+
On the other hand, overuse of error messages has lead to
374
+
implementations ignoring them (to avoid an otherwise expensive channel
375
+
break), so the "warning" message was added to allow some degree of
376
+
retry or recovery for spurious errors.
377
+
362
378
It may be wise not to distinguish errors in production settings, lest
363
379
it leak information — hence, the optional `data` field.
364
380
@@ -394,7 +410,7 @@ A node sending a `ping` message:
394
410
- MUST NOT set `ignored` to sensitive data such as secrets or portions of initialized
395
411
memory.
396
412
- if it doesn't receive a corresponding `pong`:
397
-
- MAY terminate the network connection,
413
+
- MAY close the network connection,
398
414
- and MUST NOT fail the channels in this case.
399
415
400
416
A node sending a `pong` message:
@@ -410,7 +426,7 @@ A node receiving a `ping` message:
410
426
411
427
A node receiving a `pong` message:
412
428
- if `byteslen` does not correspond to any `ping`'s `num_pong_bytes` value it has sent:
Copy file name to clipboardExpand all lines: 02-peer-protocol.md
+51-29Lines changed: 51 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -392,7 +392,8 @@ The sender:
392
392
393
393
The recipient:
394
394
- if `signature` is incorrect OR non-compliant with LOW-S-standard rule<sup>[LOWS](https://github.com/bitcoin/bitcoin/pull/6769)</sup>:
395
-
- MUST fail the channel.
395
+
- MUST send a `warning` and close the connection, or send an
396
+
`error` and fail the channel.
396
397
397
398
#### Rationale
398
399
@@ -438,7 +439,8 @@ The sender MUST set:
438
439
439
440
The recipient:
440
441
- if `signature` is incorrect OR non-compliant with LOW-S-standard rule<sup>[LOWS](https://github.com/bitcoin/bitcoin/pull/6769)</sup>:
441
-
- MUST fail the channel.
442
+
- MUST send a `warning` and close the connection, or send an
443
+
`error` and fail the channel.
442
444
- MUST NOT broadcast the funding transaction before receipt of a valid `funding_signed`.
443
445
- on receipt of a valid `funding_signed`:
444
446
- SHOULD broadcast the funding transaction.
@@ -484,7 +486,7 @@ A non-funding node (fundee):
484
486
transaction after a timeout of 2016 blocks.
485
487
486
488
From the point of waiting for `funding_locked` onward, either node MAY
487
-
fail the channel if it does not receive a required response from the
489
+
send an `error` and fail the channel if it does not receive a required response from the
488
490
other node after a reasonable timeout.
489
491
490
492
#### Rationale
@@ -558,14 +560,15 @@ A sending node:
558
560
559
561
A receiving node:
560
562
- if it hasn't received a `funding_signed` (if it is a funder) or a `funding_created` (if it is a fundee):
561
-
- SHOULD fail the connection
563
+
- SHOULD send an `error` and fail the channel.
562
564
- if the `scriptpubkey` is not in one of the above forms:
563
-
- SHOULD fail the connection.
565
+
- SHOULD send a `warning`.
564
566
- if it hasn't sent a `funding_locked` yet:
565
567
- MAY reply to a `shutdown` message with a `shutdown`
566
568
- once there are no outstanding updates on the peer, UNLESS it has already sent a `shutdown`:
567
569
- MUST reply to a `shutdown` message with a `shutdown`
568
570
- if both nodes advertised the `option_upfront_shutdown_script` feature, and the receiving node received a non-zero-length `shutdown_scriptpubkey` in `open_channel` or `accept_channel`, and that `shutdown_scriptpubkey` is not equal to `scriptpubkey`:
571
+
- MAY send a `warning`.
569
572
- MUST fail the connection.
570
573
571
574
#### Rationale
@@ -647,7 +650,8 @@ The sending node:
647
650
The receiving node:
648
651
- if the `signature` is not valid for either variant of closing transaction
649
652
specified in [BOLT #3](03-transactions.md#closing-transaction) OR non-compliant with LOW-S-standard rule<sup>[LOWS](https://github.com/bitcoin/bitcoin/pull/6769)</sup>:
650
-
- MUST fail the connection.
653
+
- MUST send a `warning` and close the connection, or send an
654
+
`error` and fail the channel.
651
655
- if `fee_satoshis` is equal to its previously sent `fee_satoshis`:
652
656
- SHOULD sign and broadcast the final closing transaction.
653
657
- MAY close the connection.
@@ -673,7 +677,8 @@ The receiving node:
673
677
- MUST propose a `fee_satoshis` in the overlap between received and (about-to-be) sent `fee_range`.
674
678
- otherwise, if `fee_satoshis` is not strictly between its last-sent `fee_satoshis`
675
679
and its previously-received `fee_satoshis`, UNLESS it has since reconnected:
676
-
- SHOULD fail the connection.
680
+
- SHOULD send a `warning` and close the connection, or send an
681
+
`error` and fail the channel.
677
682
- otherwise, if the receiver agrees with the fee:
678
683
- SHOULD reply with a `closing_signed` with the same `fee_satoshis` value.
679
684
- otherwise:
@@ -888,6 +893,7 @@ An offering node:
888
893
- MUST NOT offer an HTLC with a timeout deadline before its `cltv_expiry`.
889
894
- if an HTLC which it offered is in either node's current
890
895
commitment transaction, AND is past this timeout deadline:
896
+
- SHOULD send an `error` to the receiving peer (if connected).
891
897
- MUST fail the channel.
892
898
893
899
A fulfilling node:
@@ -896,6 +902,7 @@ A fulfilling node:
896
902
- MUST fail (and not forward) an HTLC whose fulfillment deadline is already past.
897
903
- if an HTLC it has fulfilled is in either node's current commitment
898
904
transaction, AND is past this fulfillment deadline:
905
+
- SHOULD send an `error` to the offering peer (if connected).
899
906
- MUST fail the channel.
900
907
901
908
### Adding an HTLC: `update_add_htlc`
@@ -959,19 +966,24 @@ been received). It MUST continue incrementing instead.
959
966
960
967
A receiving node:
961
968
- receiving an `amount_msat` equal to 0, OR less than its own `htlc_minimum_msat`:
962
-
- SHOULD fail the channel.
969
+
- SHOULD send a `warning` and close the connection, or send an
970
+
`error` and fail the channel.
963
971
- receiving an `amount_msat` that the sending node cannot afford at the current `feerate_per_kw` (while maintaining its channel reserve and any `to_local_anchor` and `to_remote_anchor` costs):
964
-
- SHOULD fail the channel.
972
+
- SHOULD send a `warning` and close the connection, or send an
973
+
`error` and fail the channel.
965
974
- if a sending node adds more than receiver `max_accepted_htlcs` HTLCs to
966
975
its local commitment transaction, OR adds more than receiver `max_htlc_value_in_flight_msat` worth of offered HTLCs to its local commitment transaction:
967
-
- SHOULD fail the channel.
976
+
- SHOULD send a `warning` and close the connection, or send an
977
+
`error` and fail the channel.
968
978
- if sending node sets `cltv_expiry` to greater or equal to 500000000:
969
-
- SHOULD fail the channel.
979
+
- SHOULD send a `warning` and close the connection, or send an
980
+
`error` and fail the channel.
970
981
- MUST allow multiple HTLCs with the same `payment_hash`.
971
982
- if the sender did not previously acknowledge the commitment of that HTLC:
972
983
- MUST ignore a repeated `id` value after a reconnection.
973
984
- if other `id` violations occur:
974
-
- MAY fail the channel.
985
+
- MAY send a `warning` and close the connection, or send an
986
+
`error` and fail the channel.
975
987
976
988
The `onion_routing_packet` contains an obfuscated list of hops and instructions for each hop along the path.
977
989
It commits to the HTLC by setting the `payment_hash` as associated data, i.e. includes the `payment_hash` in the computation of HMACs.
@@ -1057,13 +1069,16 @@ A node:
1057
1069
1058
1070
A receiving node:
1059
1071
- if the `id` does not correspond to an HTLC in its current commitment transaction:
1060
-
- MUST fail the channel.
1072
+
- MUST send a `warning` and close the connection, or send an
1073
+
`error` and fail the channel.
1061
1074
- if the `payment_preimage` value in `update_fulfill_htlc`
1062
1075
doesn't SHA256 hash to the corresponding HTLC `payment_hash`:
1063
-
- MUST fail the channel.
1076
+
- MUST send a `warning` and close the connection, or send an
1077
+
`error` and fail the channel.
1064
1078
- if the `BADONION` bit in `failure_code` is not set for
1065
1079
`update_fail_malformed_htlc`:
1066
-
- MUST fail the channel.
1080
+
- MUST send a `warning` and close the connection, or send an
1081
+
`error` and fail the channel.
1067
1082
- if the `sha256_of_onion` in `update_fail_malformed_htlc` doesn't match the
1068
1083
onion it sent:
1069
1084
- MAY retry or choose an alternate error response.
@@ -1122,12 +1137,15 @@ fee changes).
1122
1137
A receiving node:
1123
1138
- once all pending updates are applied:
1124
1139
- if `signature` is not valid for its local commitment transaction OR non-compliant with LOW-S-standard rule <sup>[LOWS](https://github.com/bitcoin/bitcoin/pull/6769)</sup>:
1125
-
- MUST fail the channel.
1140
+
- MUST send a `warning` and close the connection, or send an
1141
+
`error` and fail the channel.
1126
1142
- if `num_htlcs` is not equal to the number of HTLC outputs in the local
1127
1143
commitment transaction:
1128
-
- MUST fail the channel.
1144
+
- MUST send a `warning` and close the connection, or send an
1145
+
`error` and fail the channel.
1129
1146
- if any `htlc_signature` is not valid for the corresponding HTLC transaction OR non-compliant with LOW-S-standard rule <sup>[LOWS](https://github.com/bitcoin/bitcoin/pull/6769)</sup>:
1130
-
- MUST fail the channel.
1147
+
- MUST send a `warning` and close the connection, or send an
1148
+
`error` and fail the channel.
1131
1149
- MUST respond with a `revoke_and_ack` message.
1132
1150
1133
1151
#### Rationale
@@ -1181,9 +1199,10 @@ A sending node:
1181
1199
1182
1200
A receiving node:
1183
1201
- if `per_commitment_secret` is not a valid secret key or does not generate the previous `per_commitment_point`:
1184
-
- MUST fail the channel.
1202
+
- MUST send an `error` and fail the channel.
1185
1203
- if the `per_commitment_secret` was not generated by the protocol in [BOLT #3](03-transactions.md#per-commitment-secret-requirements):
1186
-
- MAY fail the channel.
1204
+
- MAY send a `warning` and close the connection, or send an
1205
+
`error` and fail the channel.
1187
1206
1188
1207
A node:
1189
1208
- MUST NOT broadcast old (revoked) commitment transactions,
@@ -1225,12 +1244,15 @@ The node _not responsible_ for paying the Bitcoin fee:
1225
1244
1226
1245
A receiving node:
1227
1246
- if the `update_fee` is too low for timely processing, OR is unreasonably large:
1228
-
- SHOULD fail the channel.
1247
+
- MUST send a `warning` and close the connection, or send an
1248
+
`error` and fail the channel.
1229
1249
- if the sender is not responsible for paying the Bitcoin fee:
1230
-
- MUST fail the channel.
1250
+
- MUST send a `warning` and close the connection, or send an
1251
+
`error` and fail the channel.
1231
1252
- if the sender cannot afford the new fee rate on the receiving node's
1232
1253
current commitment transaction:
1233
-
- SHOULD fail the channel,
1254
+
- SHOULD send a `warning` and close the connection, or send an
1255
+
`error` and fail the channel.
1234
1256
- but MAY delay this check until the `update_fee` is committed.
1235
1257
1236
1258
#### Rationale
@@ -1357,10 +1379,10 @@ A node:
1357
1379
- if `next_commitment_number` is not 1 greater than the
1358
1380
commitment number of the last `commitment_signed` message the receiving
1359
1381
node has sent:
1360
-
- SHOULD fail the channel.
1382
+
- SHOULD send an `error` and fail the channel.
1361
1383
- if it has not sent `commitment_signed`, AND `next_commitment_number`
1362
1384
is not equal to 1:
1363
-
- SHOULD fail the channel.
1385
+
- SHOULD send an `error` and fail the channel.
1364
1386
- if `next_revocation_number` is equal to the commitment number of
1365
1387
the last `revoke_and_ack` the receiving node sent, AND the receiving node
1366
1388
hasn't already received a `closing_signed`:
@@ -1372,10 +1394,10 @@ A node:
1372
1394
- otherwise:
1373
1395
- if `next_revocation_number` is not equal to 1 greater than the
1374
1396
commitment number of the last `revoke_and_ack` the receiving node has sent:
1375
-
- SHOULD fail the channel.
1397
+
- SHOULD send an `error` and fail the channel.
1376
1398
- if it has not sent `revoke_and_ack`, AND `next_revocation_number`
1377
1399
is not equal to 0:
1378
-
- SHOULD fail the channel.
1400
+
- SHOULD send an `error` and fail the channel.
1379
1401
1380
1402
A receiving node:
1381
1403
- if `option_static_remotekey` or `option_anchors` applies to the commitment
@@ -1387,7 +1409,7 @@ A node:
1387
1409
- SHOULD fail the channel.
1388
1410
- otherwise:
1389
1411
- if `your_last_per_commitment_secret` does not match the expected values:
1390
-
- SHOULD fail the channel.
1412
+
- SHOULD send an `error` and fail the channel.
1391
1413
- otherwise, if it supports `option_data_loss_protect`:
1392
1414
- if `next_revocation_number` is greater than expected above, AND
1393
1415
`your_last_per_commitment_secret` is correct for that
@@ -1398,7 +1420,7 @@ A node:
1398
1420
should the sending node broadcast its commitment transaction on-chain.
1399
1421
- otherwise (`your_last_per_commitment_secret` or `my_current_per_commitment_point`
1400
1422
do not match the expected values):
1401
-
- SHOULD fail the channel.
1423
+
- SHOULD send an `error` and fail the channel.
1402
1424
1403
1425
A node:
1404
1426
- MUST NOT assume that previously-transmitted messages were lost,
0 commit comments