@@ -235,6 +235,10 @@ mod sealed {
235
235
BasicMPP ,
236
236
] ,
237
237
} ) ;
238
+ define_context ! ( OfferContext {
239
+ required_features: [ ] ,
240
+ optional_features: [ ] ,
241
+ } ) ;
238
242
// This isn't a "real" feature context, and is only used in the channel_type field in an
239
243
// `OpenChannel` message.
240
244
define_context ! ( ChannelTypeContext {
@@ -495,6 +499,8 @@ pub type NodeFeatures = Features<sealed::NodeContext>;
495
499
pub type ChannelFeatures = Features < sealed:: ChannelContext > ;
496
500
/// Features used within an invoice.
497
501
pub type InvoiceFeatures = Features < sealed:: InvoiceContext > ;
502
+ /// Features used within an offer.
503
+ pub type OfferFeatures = Features < sealed:: OfferContext > ;
498
504
499
505
/// Features used within the channel_type field in an OpenChannel message.
500
506
///
@@ -811,21 +817,26 @@ impl_feature_len_prefixed_write!(ChannelFeatures);
811
817
impl_feature_len_prefixed_write ! ( NodeFeatures ) ;
812
818
impl_feature_len_prefixed_write ! ( InvoiceFeatures ) ;
813
819
814
- // Because ChannelTypeFeatures only appears inside of TLVs, it doesn't have a length prefix when
815
- // serialized. Thus, we can't use `impl_feature_len_prefixed_write`, above, and have to write our
816
- // own serialization.
817
- impl Writeable for ChannelTypeFeatures {
818
- fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
819
- self . write_be ( w)
820
- }
821
- }
822
- impl Readable for ChannelTypeFeatures {
823
- fn read < R : io:: Read > ( r : & mut R ) -> Result < Self , DecodeError > {
824
- let v = io_extras:: read_to_end ( r) ?;
825
- Ok ( Self :: from_be_bytes ( v) )
820
+ // Some features only appears inside of TLVs, so they don't have a length prefix when serialized.
821
+ macro_rules! impl_feature_tlv_value_write {
822
+ ( $features: ident) => {
823
+ impl Writeable for $features {
824
+ fn write<W : Writer >( & self , w: & mut W ) -> Result <( ) , io:: Error > {
825
+ self . write_be( w)
826
+ }
827
+ }
828
+ impl Readable for $features {
829
+ fn read<R : io:: Read >( r: & mut R ) -> Result <Self , DecodeError > {
830
+ let v = io_extras:: read_to_end( r) ?;
831
+ Ok ( Self :: from_be_bytes( v) )
832
+ }
833
+ }
826
834
}
827
835
}
828
836
837
+ impl_feature_tlv_value_write ! ( ChannelTypeFeatures ) ;
838
+ impl_feature_tlv_value_write ! ( OfferFeatures ) ;
839
+
829
840
#[ cfg( test) ]
830
841
mod tests {
831
842
use super :: { ChannelFeatures , ChannelTypeFeatures , InitFeatures , InvoiceFeatures , NodeFeatures } ;
0 commit comments