@@ -243,6 +243,10 @@ mod sealed {
243
243
BasicMPP ,
244
244
] ,
245
245
} ) ;
246
+ define_context ! ( OfferContext {
247
+ required_features: [ ] ,
248
+ optional_features: [ ] ,
249
+ } ) ;
246
250
// This isn't a "real" feature context, and is only used in the channel_type field in an
247
251
// `OpenChannel` message.
248
252
define_context ! ( ChannelTypeContext {
@@ -458,7 +462,7 @@ mod sealed {
458
462
supports_keysend, requires_keysend) ;
459
463
460
464
#[ cfg( test) ]
461
- define_feature ! ( 123456789 , UnknownFeature , [ NodeContext , ChannelContext , InvoiceContext ] ,
465
+ define_feature ! ( 123456789 , UnknownFeature , [ NodeContext , ChannelContext , InvoiceContext , OfferContext ] ,
462
466
"Feature flags for an unknown feature used in testing." , set_unknown_feature_optional,
463
467
set_unknown_feature_required, supports_unknown_test_feature, requires_unknown_test_feature) ;
464
468
}
@@ -517,6 +521,8 @@ pub type NodeFeatures = Features<sealed::NodeContext>;
517
521
pub type ChannelFeatures = Features < sealed:: ChannelContext > ;
518
522
/// Features used within an invoice.
519
523
pub type InvoiceFeatures = Features < sealed:: InvoiceContext > ;
524
+ /// Features used within an offer.
525
+ pub type OfferFeatures = Features < sealed:: OfferContext > ;
520
526
521
527
/// Features used within the channel_type field in an OpenChannel message.
522
528
///
@@ -845,24 +851,29 @@ impl_feature_len_prefixed_write!(ChannelFeatures);
845
851
impl_feature_len_prefixed_write ! ( NodeFeatures ) ;
846
852
impl_feature_len_prefixed_write ! ( InvoiceFeatures ) ;
847
853
848
- // Because ChannelTypeFeatures only appears inside of TLVs, it doesn't have a length prefix when
849
- // serialized. Thus, we can't use `impl_feature_len_prefixed_write`, above, and have to write our
850
- // own serialization.
851
- impl Writeable for ChannelTypeFeatures {
852
- fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
853
- self . write_be ( w)
854
- }
855
- }
856
- impl Readable for ChannelTypeFeatures {
857
- fn read < R : io:: Read > ( r : & mut R ) -> Result < Self , DecodeError > {
858
- let v = io_extras:: read_to_end ( r) ?;
859
- Ok ( Self :: from_be_bytes ( v) )
854
+ // Some features only appear inside of TLVs, so they don't have a length prefix when serialized.
855
+ macro_rules! impl_feature_tlv_write {
856
+ ( $features: ident) => {
857
+ impl Writeable for $features {
858
+ fn write<W : Writer >( & self , w: & mut W ) -> Result <( ) , io:: Error > {
859
+ self . write_be( w)
860
+ }
861
+ }
862
+ impl Readable for $features {
863
+ fn read<R : io:: Read >( r: & mut R ) -> Result <Self , DecodeError > {
864
+ let v = io_extras:: read_to_end( r) ?;
865
+ Ok ( Self :: from_be_bytes( v) )
866
+ }
867
+ }
860
868
}
861
869
}
862
870
871
+ impl_feature_tlv_write ! ( ChannelTypeFeatures ) ;
872
+ impl_feature_tlv_write ! ( OfferFeatures ) ;
873
+
863
874
#[ cfg( test) ]
864
875
mod tests {
865
- use super :: { ChannelFeatures , ChannelTypeFeatures , InitFeatures , InvoiceFeatures , NodeFeatures } ;
876
+ use super :: { ChannelFeatures , ChannelTypeFeatures , InitFeatures , InvoiceFeatures , NodeFeatures , OfferFeatures } ;
866
877
use bitcoin:: bech32:: { Base32Len , FromBase32 , ToBase32 , u5} ;
867
878
868
879
#[ test]
@@ -873,6 +884,9 @@ mod tests {
873
884
assert ! ( !InitFeatures :: known( ) . supports_unknown_bits( ) ) ;
874
885
assert ! ( !NodeFeatures :: known( ) . requires_unknown_bits( ) ) ;
875
886
assert ! ( !NodeFeatures :: known( ) . supports_unknown_bits( ) ) ;
887
+ assert ! ( !InvoiceFeatures :: known( ) . supports_unknown_bits( ) ) ;
888
+ assert ! ( !OfferFeatures :: known( ) . supports_unknown_bits( ) ) ;
889
+ assert_eq ! ( OfferFeatures :: known( ) , OfferFeatures :: empty( ) ) ;
876
890
877
891
assert ! ( InitFeatures :: known( ) . supports_upfront_shutdown_script( ) ) ;
878
892
assert ! ( NodeFeatures :: known( ) . supports_upfront_shutdown_script( ) ) ;
0 commit comments