76
76
//! (see [BOLT PR #1110](https://github.com/lightning/bolts/pull/1110) for more info).
77
77
//! - `Quiescence` - protocol to quiesce a channel by indicating that "SomeThing Fundamental is Underway"
78
78
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#channel-quiescence) for more information).
79
+ //! - `ZeroFeeCommitments` - A channel type which always uses zero transaction fee on commitment transactions.
80
+ //! (see [BOLT PR #1228](https://github.com/lightning/bolts/pull/1228) for more info).
79
81
//!
80
82
//! LDK knows about the following features, but does not support them:
81
83
//! - `AnchorsNonzeroFeeHtlcTx` - the initial version of anchor outputs, which was later found to be
@@ -156,7 +158,7 @@ mod sealed {
156
158
// Byte 4
157
159
Quiescence | OnionMessages ,
158
160
// Byte 5
159
- ProvideStorage | ChannelType | SCIDPrivacy ,
161
+ ProvideStorage | ChannelType | SCIDPrivacy | AnchorZeroFeeCommitments ,
160
162
// Byte 6
161
163
ZeroConf ,
162
164
// Byte 7
@@ -177,7 +179,7 @@ mod sealed {
177
179
// Byte 4
178
180
Quiescence | OnionMessages ,
179
181
// Byte 5
180
- ProvideStorage | ChannelType | SCIDPrivacy ,
182
+ ProvideStorage | ChannelType | SCIDPrivacy | AnchorZeroFeeCommitments ,
181
183
// Byte 6
182
184
ZeroConf | Keysend ,
183
185
// Byte 7
@@ -242,7 +244,7 @@ mod sealed {
242
244
// Byte 4
243
245
,
244
246
// Byte 5
245
- SCIDPrivacy ,
247
+ SCIDPrivacy | AnchorZeroFeeCommitments ,
246
248
// Byte 6
247
249
ZeroConf ,
248
250
] ) ;
@@ -251,7 +253,7 @@ mod sealed {
251
253
/// useful for manipulating feature flags.
252
254
macro_rules! define_feature {
253
255
( $odd_bit: expr, $feature: ident, [ $( $context: ty) ,+] , $doc: expr, $optional_setter: ident,
254
- $required_setter: ident, $supported_getter: ident) => {
256
+ $required_setter: ident, $clear : ident , $ supported_getter: ident) => {
255
257
#[ doc = $doc]
256
258
///
257
259
/// See [BOLT #9] for details.
@@ -354,6 +356,11 @@ mod sealed {
354
356
<T as $feature>:: set_required_bit( & mut self . flags) ;
355
357
}
356
358
359
+ /// Unsets this feature.
360
+ pub fn $clear( & mut self ) {
361
+ <T as $feature>:: clear_bits( & mut self . flags) ;
362
+ }
363
+
357
364
/// Checks if this feature is supported.
358
365
pub fn $supported_getter( & self ) -> bool {
359
366
<T as $feature>:: supports_feature( & self . flags)
@@ -377,8 +384,8 @@ mod sealed {
377
384
) *
378
385
} ;
379
386
( $odd_bit: expr, $feature: ident, [ $( $context: ty) ,+] , $doc: expr, $optional_setter: ident,
380
- $required_setter: ident, $supported_getter: ident, $required_getter: ident) => {
381
- define_feature!( $odd_bit, $feature, [ $( $context) ,+] , $doc, $optional_setter, $required_setter, $supported_getter) ;
387
+ $required_setter: ident, $clear : ident , $ supported_getter: ident, $required_getter: ident) => {
388
+ define_feature!( $odd_bit, $feature, [ $( $context) ,+] , $doc, $optional_setter, $required_setter, $clear , $ supported_getter) ;
382
389
impl <T : $feature> Features <T > {
383
390
/// Checks if this feature is required.
384
391
pub fn $required_getter( & self ) -> bool {
@@ -395,6 +402,7 @@ mod sealed {
395
402
"Feature flags for `option_data_loss_protect`." ,
396
403
set_data_loss_protect_optional,
397
404
set_data_loss_protect_required,
405
+ clear_data_loss_protect,
398
406
supports_data_loss_protect,
399
407
requires_data_loss_protect
400
408
) ;
@@ -406,6 +414,7 @@ mod sealed {
406
414
"Feature flags for `initial_routing_sync`." ,
407
415
set_initial_routing_sync_optional,
408
416
set_initial_routing_sync_required,
417
+ clear_initial_routing_sync,
409
418
initial_routing_sync
410
419
) ;
411
420
define_feature ! (
@@ -415,6 +424,7 @@ mod sealed {
415
424
"Feature flags for `option_upfront_shutdown_script`." ,
416
425
set_upfront_shutdown_script_optional,
417
426
set_upfront_shutdown_script_required,
427
+ clear_upfront_shutdown_script,
418
428
supports_upfront_shutdown_script,
419
429
requires_upfront_shutdown_script
420
430
) ;
@@ -425,6 +435,7 @@ mod sealed {
425
435
"Feature flags for `gossip_queries`." ,
426
436
set_gossip_queries_optional,
427
437
set_gossip_queries_required,
438
+ clear_gossip_queries,
428
439
supports_gossip_queries,
429
440
requires_gossip_queries
430
441
) ;
@@ -435,6 +446,7 @@ mod sealed {
435
446
"Feature flags for `var_onion_optin`." ,
436
447
set_variable_length_onion_optional,
437
448
set_variable_length_onion_required,
449
+ clear_variable_length_onion,
438
450
supports_variable_length_onion,
439
451
requires_variable_length_onion
440
452
) ;
@@ -445,6 +457,7 @@ mod sealed {
445
457
"Feature flags for `option_static_remotekey`." ,
446
458
set_static_remote_key_optional,
447
459
set_static_remote_key_required,
460
+ clear_static_remote_key,
448
461
supports_static_remote_key,
449
462
requires_static_remote_key
450
463
) ;
@@ -455,6 +468,7 @@ mod sealed {
455
468
"Feature flags for `payment_secret`." ,
456
469
set_payment_secret_optional,
457
470
set_payment_secret_required,
471
+ clear_payment_secret,
458
472
supports_payment_secret,
459
473
requires_payment_secret
460
474
) ;
@@ -465,6 +479,7 @@ mod sealed {
465
479
"Feature flags for `basic_mpp`." ,
466
480
set_basic_mpp_optional,
467
481
set_basic_mpp_required,
482
+ clear_basic_mpp,
468
483
supports_basic_mpp,
469
484
requires_basic_mpp
470
485
) ;
@@ -475,6 +490,7 @@ mod sealed {
475
490
"Feature flags for `option_support_large_channel` (aka wumbo channels)." ,
476
491
set_wumbo_optional,
477
492
set_wumbo_required,
493
+ clear_wumbo,
478
494
supports_wumbo,
479
495
requires_wumbo
480
496
) ;
@@ -485,6 +501,7 @@ mod sealed {
485
501
"Feature flags for `option_anchors_nonzero_fee_htlc_tx`." ,
486
502
set_anchors_nonzero_fee_htlc_tx_optional,
487
503
set_anchors_nonzero_fee_htlc_tx_required,
504
+ clear_anchors_nonzero_fee_htlc_tx,
488
505
supports_anchors_nonzero_fee_htlc_tx,
489
506
requires_anchors_nonzero_fee_htlc_tx
490
507
) ;
@@ -495,6 +512,7 @@ mod sealed {
495
512
"Feature flags for `option_anchors_zero_fee_htlc_tx`." ,
496
513
set_anchors_zero_fee_htlc_tx_optional,
497
514
set_anchors_zero_fee_htlc_tx_required,
515
+ clear_anchors_zero_fee_htlc_tx,
498
516
supports_anchors_zero_fee_htlc_tx,
499
517
requires_anchors_zero_fee_htlc_tx
500
518
) ;
@@ -505,6 +523,7 @@ mod sealed {
505
523
"Feature flags for `option_route_blinding`." ,
506
524
set_route_blinding_optional,
507
525
set_route_blinding_required,
526
+ clear_route_blinding,
508
527
supports_route_blinding,
509
528
requires_route_blinding
510
529
) ;
@@ -515,6 +534,7 @@ mod sealed {
515
534
"Feature flags for `opt_shutdown_anysegwit`." ,
516
535
set_shutdown_any_segwit_optional,
517
536
set_shutdown_any_segwit_required,
537
+ clear_shutdown_anysegwit,
518
538
supports_shutdown_anysegwit,
519
539
requires_shutdown_anysegwit
520
540
) ;
@@ -525,6 +545,7 @@ mod sealed {
525
545
"Feature flags for `option_dual_fund`." ,
526
546
set_dual_fund_optional,
527
547
set_dual_fund_required,
548
+ clear_dual_fund,
528
549
supports_dual_fund,
529
550
requires_dual_fund
530
551
) ;
@@ -535,6 +556,7 @@ mod sealed {
535
556
"Feature flags for `option_taproot`." ,
536
557
set_taproot_optional,
537
558
set_taproot_required,
559
+ clear_taproot,
538
560
supports_taproot,
539
561
requires_taproot
540
562
) ;
@@ -545,6 +567,7 @@ mod sealed {
545
567
"Feature flags for `option_quiesce`." ,
546
568
set_quiescence_optional,
547
569
set_quiescence_required,
570
+ clear_quiescence,
548
571
supports_quiescence,
549
572
requires_quiescence
550
573
) ;
@@ -555,16 +578,29 @@ mod sealed {
555
578
"Feature flags for `option_onion_messages`." ,
556
579
set_onion_messages_optional,
557
580
set_onion_messages_required,
581
+ clear_onion_messages,
558
582
supports_onion_messages,
559
583
requires_onion_messages
560
584
) ;
585
+ define_feature ! (
586
+ 41 ,
587
+ AnchorZeroFeeCommitments ,
588
+ [ InitContext , NodeContext , ChannelTypeContext ] ,
589
+ "Feature flags for `option_zero_fee_commitments`." ,
590
+ set_anchor_zero_fee_commitments_optional,
591
+ set_anchor_zero_fee_commitments_required,
592
+ clear_anchor_zero_fee_commitments,
593
+ supports_anchor_zero_fee_commitments,
594
+ requires_anchor_zero_fee_commitments
595
+ ) ;
561
596
define_feature ! (
562
597
43 ,
563
598
ProvideStorage ,
564
599
[ InitContext , NodeContext ] ,
565
600
"Feature flags for `option_provide_storage`." ,
566
601
set_provide_storage_optional,
567
602
set_provide_storage_required,
603
+ clear_provide_storage,
568
604
supports_provide_storage,
569
605
requires_provide_storage
570
606
) ;
@@ -575,19 +611,28 @@ mod sealed {
575
611
"Feature flags for `option_channel_type`." ,
576
612
set_channel_type_optional,
577
613
set_channel_type_required,
614
+ clear_channel_type,
578
615
supports_channel_type,
579
616
requires_channel_type
580
617
) ;
581
- define_feature ! ( 47 , SCIDPrivacy , [ InitContext , NodeContext , ChannelTypeContext ] ,
618
+ define_feature ! ( 47 ,
619
+ SCIDPrivacy ,
620
+ [ InitContext , NodeContext , ChannelTypeContext ] ,
582
621
"Feature flags for only forwarding with SCID aliasing. Called `option_scid_alias` in the BOLTs" ,
583
- set_scid_privacy_optional, set_scid_privacy_required, supports_scid_privacy, requires_scid_privacy) ;
622
+ set_scid_privacy_optional,
623
+ set_scid_privacy_required,
624
+ clear_scid_privacy,
625
+ supports_scid_privacy,
626
+ requires_scid_privacy
627
+ ) ;
584
628
define_feature ! (
585
629
49 ,
586
630
PaymentMetadata ,
587
631
[ Bolt11InvoiceContext ] ,
588
632
"Feature flags for payment metadata in invoices." ,
589
633
set_payment_metadata_optional,
590
634
set_payment_metadata_required,
635
+ clear_payment_metadata,
591
636
supports_payment_metadata,
592
637
requires_payment_metadata
593
638
) ;
@@ -601,6 +646,7 @@ mod sealed {
601
646
"Feature flags for keysend payments." ,
602
647
set_keysend_optional,
603
648
set_keysend_required,
649
+ clear_keysend,
604
650
supports_keysend,
605
651
requires_keysend
606
652
) ;
@@ -611,6 +657,7 @@ mod sealed {
611
657
"Feature flags for Trampoline routing." ,
612
658
set_trampoline_routing_optional,
613
659
set_trampoline_routing_required,
660
+ clear_trampoline_routing,
614
661
supports_trampoline_routing,
615
662
requires_trampoline_routing
616
663
) ;
@@ -621,6 +668,7 @@ mod sealed {
621
668
"Feature flags for DNS resolving." ,
622
669
set_dns_resolution_optional,
623
670
set_dns_resolution_required,
671
+ clear_dns_resolution,
624
672
supports_dns_resolution,
625
673
requires_dns_resolution
626
674
) ;
@@ -643,6 +691,7 @@ mod sealed {
643
691
"Feature flags for an unknown feature used in testing." ,
644
692
set_unknown_feature_optional,
645
693
set_unknown_feature_required,
694
+ clear_unknown_feature,
646
695
supports_unknown_test_feature,
647
696
requires_unknown_test_feature
648
697
) ;
@@ -1038,51 +1087,6 @@ impl<T: sealed::Context> Features<T> {
1038
1087
}
1039
1088
}
1040
1089
1041
- impl < T : sealed:: UpfrontShutdownScript > Features < T > {
1042
- /// Unsets the `upfront_shutdown_script` feature
1043
- pub fn clear_upfront_shutdown_script ( mut self ) -> Self {
1044
- <T as sealed:: UpfrontShutdownScript >:: clear_bits ( & mut self . flags ) ;
1045
- self
1046
- }
1047
- }
1048
-
1049
- impl < T : sealed:: ShutdownAnySegwit > Features < T > {
1050
- /// Unsets the `shutdown_anysegwit` feature
1051
- pub fn clear_shutdown_anysegwit ( mut self ) -> Self {
1052
- <T as sealed:: ShutdownAnySegwit >:: clear_bits ( & mut self . flags ) ;
1053
- self
1054
- }
1055
- }
1056
-
1057
- impl < T : sealed:: Wumbo > Features < T > {
1058
- /// Unsets the `wumbo` feature
1059
- pub fn clear_wumbo ( mut self ) -> Self {
1060
- <T as sealed:: Wumbo >:: clear_bits ( & mut self . flags ) ;
1061
- self
1062
- }
1063
- }
1064
-
1065
- impl < T : sealed:: SCIDPrivacy > Features < T > {
1066
- /// Unsets the `scid_privacy` feature
1067
- pub fn clear_scid_privacy ( & mut self ) {
1068
- <T as sealed:: SCIDPrivacy >:: clear_bits ( & mut self . flags ) ;
1069
- }
1070
- }
1071
-
1072
- impl < T : sealed:: AnchorsZeroFeeHtlcTx > Features < T > {
1073
- /// Unsets the `anchors_zero_fee_htlc_tx` feature
1074
- pub fn clear_anchors_zero_fee_htlc_tx ( & mut self ) {
1075
- <T as sealed:: AnchorsZeroFeeHtlcTx >:: clear_bits ( & mut self . flags ) ;
1076
- }
1077
- }
1078
-
1079
- impl < T : sealed:: RouteBlinding > Features < T > {
1080
- /// Unsets the `route_blinding` feature
1081
- pub fn clear_route_blinding ( & mut self ) {
1082
- <T as sealed:: RouteBlinding >:: clear_bits ( & mut self . flags ) ;
1083
- }
1084
- }
1085
-
1086
1090
#[ cfg( any( test, feature = "_test_utils" ) ) ]
1087
1091
impl < T : sealed:: UnknownFeature > Features < T > {
1088
1092
/// Sets an unknown feature for testing
0 commit comments