@@ -147,7 +147,8 @@ use lightning::impl_writeable_tlv_based;
147147use lightning:: ln:: chan_utils:: FUNDING_TRANSACTION_WITNESS_WEIGHT ;
148148use lightning:: ln:: channel_state:: { ChannelDetails as LdkChannelDetails , ChannelShutdownState } ;
149149use lightning:: ln:: channelmanager:: PaymentId ;
150- use lightning:: ln:: msgs:: SocketAddress ;
150+ use lightning:: ln:: msgs:: { BaseMessageHandler , SocketAddress } ;
151+ use lightning:: ln:: peer_handler:: CustomMessageHandler ;
151152use lightning:: routing:: gossip:: NodeAlias ;
152153use lightning:: sign:: EntropySource ;
153154use lightning:: util:: persist:: KVStoreSync ;
@@ -156,6 +157,9 @@ use lightning_background_processor::process_events_async;
156157pub use lightning_invoice;
157158pub use lightning_liquidity;
158159pub use lightning_types;
160+ use lightning_types:: features:: {
161+ Bolt11InvoiceFeatures , ChannelFeatures , InitFeatures , NodeFeatures ,
162+ } ;
159163use liquidity:: { LSPS1Liquidity , LiquiditySource } ;
160164use lnurl_auth:: LnurlAuth ;
161165use logger:: { log_debug, log_error, log_info, log_trace, LdkLogger , Logger } ;
@@ -1931,6 +1935,63 @@ impl Node {
19311935 Error :: PersistenceFailed
19321936 } )
19331937 }
1938+
1939+ /// Return the features used in node announcement.
1940+ pub fn node_features ( & self ) -> NodeFeatures {
1941+ let gossip_features = match self . gossip_source . as_gossip_sync ( ) {
1942+ lightning_background_processor:: GossipSync :: P2P ( p2p_gossip_sync) => {
1943+ p2p_gossip_sync. provided_node_features ( )
1944+ } ,
1945+ lightning_background_processor:: GossipSync :: Rapid ( _) => NodeFeatures :: empty ( ) ,
1946+ lightning_background_processor:: GossipSync :: None => {
1947+ unreachable ! ( "We must always have a gossip sync!" )
1948+ } ,
1949+ } ;
1950+ self . channel_manager . node_features ( )
1951+ | self . chain_monitor . provided_node_features ( )
1952+ | self . onion_messenger . provided_node_features ( )
1953+ | gossip_features
1954+ | self
1955+ . liquidity_source
1956+ . as_ref ( )
1957+ . map ( |ls| ls. liquidity_manager ( ) . provided_node_features ( ) )
1958+ . unwrap_or_else ( NodeFeatures :: empty)
1959+ }
1960+
1961+ /// Return the node's init features.
1962+ pub fn init_features ( & self ) -> InitFeatures {
1963+ let gossip_init_features = match self . gossip_source . as_gossip_sync ( ) {
1964+ lightning_background_processor:: GossipSync :: P2P ( p2p_gossip_sync) => {
1965+ p2p_gossip_sync. provided_init_features ( self . node_id ( ) )
1966+ } ,
1967+ lightning_background_processor:: GossipSync :: Rapid ( _) => InitFeatures :: empty ( ) ,
1968+ lightning_background_processor:: GossipSync :: None => {
1969+ unreachable ! ( "We must always have a gossip sync!" )
1970+ } ,
1971+ } ;
1972+ self . channel_manager . init_features ( )
1973+ | self . chain_monitor . provided_init_features ( self . node_id ( ) )
1974+ | self . onion_messenger . provided_init_features ( self . node_id ( ) )
1975+ | gossip_init_features
1976+ | self
1977+ . liquidity_source
1978+ . as_ref ( )
1979+ . map ( |ls| ls. liquidity_manager ( ) . provided_init_features ( self . node_id ( ) ) )
1980+ . unwrap_or_else ( InitFeatures :: empty)
1981+ }
1982+
1983+ /// Return the node's channel features.
1984+ pub fn channel_features ( & self ) -> ChannelFeatures {
1985+ self . channel_manager . channel_features ( )
1986+ }
1987+
1988+ /// Return the node's BOLT 11 invoice features.
1989+ pub fn bolt11_invoice_features ( & self ) -> Bolt11InvoiceFeatures {
1990+ // bolt11_invoice_features() is not public because feature
1991+ // flags can vary due to invoice type, so we convert from
1992+ // context.
1993+ self . channel_manager . init_features ( ) . to_context ( )
1994+ }
19341995}
19351996
19361997impl Drop for Node {
0 commit comments