@@ -151,7 +151,8 @@ use lightning::impl_writeable_tlv_based;
151151use lightning:: ln:: chan_utils:: FUNDING_TRANSACTION_WITNESS_WEIGHT ;
152152use lightning:: ln:: channel_state:: { ChannelDetails as LdkChannelDetails , ChannelShutdownState } ;
153153use lightning:: ln:: channelmanager:: PaymentId ;
154- use lightning:: ln:: msgs:: SocketAddress ;
154+ use lightning:: ln:: msgs:: { BaseMessageHandler , SocketAddress } ;
155+ use lightning:: ln:: peer_handler:: CustomMessageHandler ;
155156use lightning:: routing:: gossip:: NodeAlias ;
156157use lightning:: sign:: EntropySource ;
157158use lightning:: util:: persist:: KVStoreSync ;
@@ -160,6 +161,9 @@ use lightning_background_processor::process_events_async;
160161pub use lightning_invoice;
161162pub use lightning_liquidity;
162163pub use lightning_types;
164+ use lightning_types:: features:: {
165+ Bolt11InvoiceFeatures , ChannelFeatures , InitFeatures , NodeFeatures ,
166+ } ;
163167use liquidity:: { LSPS1Liquidity , LiquiditySource } ;
164168use lnurl_auth:: LnurlAuth ;
165169use logger:: { log_debug, log_error, log_info, log_trace, LdkLogger , Logger } ;
@@ -1949,6 +1953,63 @@ impl Node {
19491953 Error :: PersistenceFailed
19501954 } )
19511955 }
1956+
1957+ /// Return the features used in node announcement.
1958+ pub fn node_features ( & self ) -> NodeFeatures {
1959+ let gossip_features = match self . gossip_source . as_gossip_sync ( ) {
1960+ lightning_background_processor:: GossipSync :: P2P ( p2p_gossip_sync) => {
1961+ p2p_gossip_sync. provided_node_features ( )
1962+ } ,
1963+ lightning_background_processor:: GossipSync :: Rapid ( _) => NodeFeatures :: empty ( ) ,
1964+ lightning_background_processor:: GossipSync :: None => {
1965+ unreachable ! ( "We must always have a gossip sync!" )
1966+ } ,
1967+ } ;
1968+ self . channel_manager . node_features ( )
1969+ | self . chain_monitor . provided_node_features ( )
1970+ | self . onion_messenger . provided_node_features ( )
1971+ | gossip_features
1972+ | self
1973+ . liquidity_source
1974+ . as_ref ( )
1975+ . map ( |ls| ls. liquidity_manager ( ) . provided_node_features ( ) )
1976+ . unwrap_or_else ( NodeFeatures :: empty)
1977+ }
1978+
1979+ /// Return the node's init features.
1980+ pub fn init_features ( & self ) -> InitFeatures {
1981+ let gossip_init_features = match self . gossip_source . as_gossip_sync ( ) {
1982+ lightning_background_processor:: GossipSync :: P2P ( p2p_gossip_sync) => {
1983+ p2p_gossip_sync. provided_init_features ( self . node_id ( ) )
1984+ } ,
1985+ lightning_background_processor:: GossipSync :: Rapid ( _) => InitFeatures :: empty ( ) ,
1986+ lightning_background_processor:: GossipSync :: None => {
1987+ unreachable ! ( "We must always have a gossip sync!" )
1988+ } ,
1989+ } ;
1990+ self . channel_manager . init_features ( )
1991+ | self . chain_monitor . provided_init_features ( self . node_id ( ) )
1992+ | self . onion_messenger . provided_init_features ( self . node_id ( ) )
1993+ | gossip_init_features
1994+ | self
1995+ . liquidity_source
1996+ . as_ref ( )
1997+ . map ( |ls| ls. liquidity_manager ( ) . provided_init_features ( self . node_id ( ) ) )
1998+ . unwrap_or_else ( InitFeatures :: empty)
1999+ }
2000+
2001+ /// Return the node's channel features.
2002+ pub fn channel_features ( & self ) -> ChannelFeatures {
2003+ self . channel_manager . channel_features ( )
2004+ }
2005+
2006+ /// Return the node's BOLT 11 invoice features.
2007+ pub fn bolt11_invoice_features ( & self ) -> Bolt11InvoiceFeatures {
2008+ // bolt11_invoice_features() is not public because feature
2009+ // flags can vary due to invoice type, so we convert from
2010+ // context.
2011+ self . channel_manager . init_features ( ) . to_context ( )
2012+ }
19522013}
19532014
19542015impl Drop for Node {
0 commit comments