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
BOLT 2: define channel_type, make negotiation explicit.
This is extracted from channel_upgrade (#868), but used for opening
negotiation as suggested by @Roasbeef on the last spec meeting.
It's a trivial change, fully backwards compatible, but now each channel
has a channel_type, which defines its behavior, rather than an ad-hoc
set of "sticky" feature bits. It also means both peers can *support* a
feature without endorsing it.
Signed-off-by: Rusty Russell <[email protected]>
Copy file name to clipboardExpand all lines: 02-peer-protocol.md
+45-11Lines changed: 45 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -130,6 +130,9 @@ the funding transaction and both versions of the commitment transaction.
130
130
1. type: 0 (`upfront_shutdown_script`)
131
131
2. data:
132
132
*[`...*byte`:`shutdown_scriptpubkey`]
133
+
1. type: 1 (`channel_type`)
134
+
2. data:
135
+
*[`...*byte`:`type`]
133
136
134
137
The `chain_hash` value denotes the exact blockchain that the opened channel will
135
138
reside within. This is usually the genesis hash of the respective blockchain.
@@ -197,6 +200,19 @@ know this node will accept `funding_satoshis` greater than or equal to 2^24.
197
200
Since it's broadcast in the `node_announcement` message other nodes can use it to identify peers
198
201
willing to accept large channel even before exchanging the `init` message with them.
199
202
203
+
#### Defined Channel Types
204
+
205
+
Channel types are an explicit enumeration: for convenience of future
206
+
definitions they reuse even feature bits, but they are not an
207
+
arbitrary combination (they represent the persistent features which
208
+
affect the channel operation).
209
+
210
+
The currently defined types are:
211
+
- no features (no bits set)
212
+
-`option_static_remotekey` (bit 12)
213
+
-`option_anchor_outputs` and `option_static_remotekey` (bits 20 and 12)
214
+
-`option_anchors_zero_fee_htlc_tx` and `option_static_remotekey` (bits 22 and 12)
215
+
200
216
#### Requirements
201
217
202
218
The sending node:
@@ -217,6 +233,10 @@ The sending node:
217
233
- MAY include `upfront_shutdown_script`.
218
234
- if it includes `open_channel_tlvs`:
219
235
- MUST include `upfront_shutdown_script`.
236
+
- if it includes `channel_type`:
237
+
- MUST set it to a defined type representing the type it wants.
238
+
- MUST use the smallest bitmap possible to represent the channel type.
239
+
- SHOULD NOT set it to a type containing a feature which was not negotiated.
220
240
221
241
The sending node SHOULD:
222
242
- set `to_self_delay` sufficient to ensure the sender can irreversibly spend a commitment transaction output, in case of misbehavior by the receiver.
@@ -252,6 +272,7 @@ are not valid secp256k1 pubkeys in compressed format.
252
272
- the funder's amount for the initial commitment transaction is not sufficient for full [fee payment](03-transactions.md#fee-payment).
253
273
- both `to_local` and `to_remote` amounts for the initial commitment transaction are less than or equal to `channel_reserve_satoshis` (see [BOLT 3](03-transactions.md#commitment-transaction-outputs)).
254
274
-`funding_satoshis` is greater than or equal to 2^24 and the receiver does not support `option_support_large_channel`.
275
+
- It supports `channel_type`, `channel_type` was set, and the `type` is not suitable.
255
276
256
277
The receiving node MUST NOT:
257
278
- consider funds received, using `push_msat`, to be received until the funding transaction has reached sufficient depth.
@@ -305,6 +326,9 @@ funding transaction and both versions of the commitment transaction.
305
326
1. type: 0 (`upfront_shutdown_script`)
306
327
2. data:
307
328
*[`...*byte`:`shutdown_scriptpubkey`]
329
+
1. type: 1 (`channel_type`)
330
+
2. data:
331
+
*[`...*byte`:`type`]
308
332
309
333
#### Requirements
310
334
@@ -316,14 +340,20 @@ The sender:
316
340
avoid double-spending of the funding transaction.
317
341
- MUST set `channel_reserve_satoshis` greater than or equal to `dust_limit_satoshis` from the `open_channel` message.
318
342
- MUST set `dust_limit_satoshis` less than or equal to `channel_reserve_satoshis` from the `open_channel` message.
343
+
- if it sets `channel_type`:
344
+
- MUST set it to the `channel_type` from `open_channel`
319
345
320
346
The receiver:
321
347
- if `minimum_depth` is unreasonably large:
322
348
- MAY reject the channel.
323
349
- if `channel_reserve_satoshis` is less than `dust_limit_satoshis` within the `open_channel` message:
324
-
- MUST reject the channel.
350
+
- MUST reject the channel.
325
351
- if `channel_reserve_satoshis` from the `open_channel` message is less than `dust_limit_satoshis`:
326
-
- MUST reject the channel.
352
+
- MUST reject the channel.
353
+
- if `channel_type` is set, and `channel_type` was set in `open_channel`, and they are not equal types:
354
+
- MUST reject the channel.
355
+
356
+
327
357
Other fields have the same requirements as their counterparts in `open_channel`.
328
358
329
359
### The `funding_created` Message
@@ -382,14 +412,18 @@ This message introduces the `channel_id` to identify the channel. It's derived f
382
412
#### Requirements
383
413
384
414
Both peers:
385
-
- if `option_static_remotekey`, `option_anchor_outputs` or
386
-
`option_anchors_zero_fee_htlc_tx` was negotiated:
387
-
-`option_static_remotekey`, `option_anchor_outputs` or
388
-
`option_anchors_zero_fee_htlc_tx` applies to all commitment transactions
415
+
- if `channel_type` was present in both `open_channel` and `accept_channel`:
416
+
- This is the `channel_type` (they must be equal, required above)
389
417
- otherwise:
390
-
-`option_static_remotekey`, `option_anchor_outputs` or
391
-
`option_anchors_zero_fee_htlc_tx` does not apply to any commitment
392
-
transactions
418
+
- if `option_anchors_zero_fee_htlc_tx` was negotiated:
419
+
- the `channel_type` is `option_anchors_zero_fee_htlc_tx` and `option_static_remotekey` (bits 22 and 12)
420
+
- otherwise, if `option_anchor_outputs` was negotiated:
421
+
- the `channel_type` is `option_anchor_outputs` and `option_static_remotekey` (bits 20 and 12)
422
+
- otherwise, if `option_static_remotekey` was negotiated:
423
+
- the `channel_type` is `option_static_remotekey` (bit 12)
424
+
- otherwise:
425
+
- the `channel_type` is empty
426
+
- MUST use that `channel_type` for all commitment transactions.
393
427
394
428
The sender MUST set:
395
429
-`channel_id` by exclusive-OR of the `funding_txid` and the `funding_output_index` from the `funding_created` message.
@@ -503,7 +537,7 @@ A sending node:
503
537
- MUST NOT send a `shutdown`.
504
538
- MUST NOT send an `update_add_htlc` after a `shutdown`.
505
539
- if no HTLCs remain in either commitment transaction:
506
-
- MUST NOT send any `update` message after a `shutdown`.
540
+
- MUST NOT send any `update` message after a `shutdown`.
507
541
- SHOULD fail to route any HTLC added after it has sent `shutdown`.
508
542
- if it sent a non-zero-length `shutdown_scriptpubkey` in `open_channel` or `accept_channel`:
509
543
- MUST send the same value in `scriptpubkey`.
@@ -516,7 +550,7 @@ A sending node:
516
550
4.`OP_0``32` 32-bytes (version 0 pay to witness script hash), OR
517
551
5. if (and only if) `option_shutdown_anysegwit` is negotiated:
518
552
*`OP_1` through `OP_16` inclusive, followed by a single push of 2 to 40 bytes
519
-
(witness program versions 1 through 16)
553
+
(witness program versions 1 through 16)
520
554
521
555
A receiving node:
522
556
- if it hasn't received a `funding_signed` (if it is a funder) or a `funding_created` (if it is a fundee):
0 commit comments