@@ -141,12 +141,16 @@ use lightning::chain::BestBlock;
141141use lightning:: impl_writeable_tlv_based;
142142use lightning:: ln:: channel_state:: { ChannelDetails as LdkChannelDetails , ChannelShutdownState } ;
143143use lightning:: ln:: channelmanager:: PaymentId ;
144- use lightning:: ln:: msgs:: SocketAddress ;
144+ use lightning:: ln:: msgs:: { BaseMessageHandler , SocketAddress } ;
145+ use lightning:: ln:: peer_handler:: CustomMessageHandler ;
145146use lightning:: routing:: gossip:: NodeAlias ;
146147use lightning:: sign:: EntropySource ;
147148use lightning:: util:: persist:: KVStoreSync ;
148149use lightning:: util:: wallet_utils:: Wallet as LdkWallet ;
149150use lightning_background_processor:: process_events_async;
151+ use lightning_types:: features:: {
152+ Bolt11InvoiceFeatures , ChannelFeatures , InitFeatures , NodeFeatures ,
153+ } ;
150154use liquidity:: { LSPS1Liquidity , LiquiditySource } ;
151155use logger:: { log_debug, log_error, log_info, log_trace, LdkLogger , Logger } ;
152156use payment:: asynchronous:: om_mailbox:: OnionMessageMailbox ;
@@ -1725,6 +1729,63 @@ impl Node {
17251729 Error :: PersistenceFailed
17261730 } )
17271731 }
1732+
1733+ /// Return the features used in node announcement.
1734+ pub fn node_features ( & self ) -> NodeFeatures {
1735+ let gossip_features = match self . gossip_source . as_gossip_sync ( ) {
1736+ lightning_background_processor:: GossipSync :: P2P ( p2p_gossip_sync) => {
1737+ p2p_gossip_sync. provided_node_features ( )
1738+ } ,
1739+ lightning_background_processor:: GossipSync :: Rapid ( _) => NodeFeatures :: empty ( ) ,
1740+ lightning_background_processor:: GossipSync :: None => {
1741+ unreachable ! ( "We must always have a gossip sync!" )
1742+ } ,
1743+ } ;
1744+ self . channel_manager . node_features ( )
1745+ | self . chain_monitor . provided_node_features ( )
1746+ | self . onion_messenger . provided_node_features ( )
1747+ | gossip_features
1748+ | self
1749+ . liquidity_source
1750+ . as_ref ( )
1751+ . map ( |ls| ls. liquidity_manager ( ) . provided_node_features ( ) )
1752+ . unwrap_or_else ( NodeFeatures :: empty)
1753+ }
1754+
1755+ /// Return the node's init features.
1756+ pub fn init_features ( & self ) -> InitFeatures {
1757+ let gossip_init_features = match self . gossip_source . as_gossip_sync ( ) {
1758+ lightning_background_processor:: GossipSync :: P2P ( p2p_gossip_sync) => {
1759+ p2p_gossip_sync. provided_init_features ( self . node_id ( ) )
1760+ } ,
1761+ lightning_background_processor:: GossipSync :: Rapid ( _) => InitFeatures :: empty ( ) ,
1762+ lightning_background_processor:: GossipSync :: None => {
1763+ unreachable ! ( "We must always have a gossip sync!" )
1764+ } ,
1765+ } ;
1766+ self . channel_manager . init_features ( )
1767+ | self . chain_monitor . provided_init_features ( self . node_id ( ) )
1768+ | self . onion_messenger . provided_init_features ( self . node_id ( ) )
1769+ | gossip_init_features
1770+ | self
1771+ . liquidity_source
1772+ . as_ref ( )
1773+ . map ( |ls| ls. liquidity_manager ( ) . provided_init_features ( self . node_id ( ) ) )
1774+ . unwrap_or_else ( InitFeatures :: empty)
1775+ }
1776+
1777+ /// Return the node's channel features.
1778+ pub fn channel_features ( & self ) -> ChannelFeatures {
1779+ self . channel_manager . channel_features ( )
1780+ }
1781+
1782+ /// Return the node's BOLT 11 invoice features.
1783+ pub fn bolt11_invoice_features ( & self ) -> Bolt11InvoiceFeatures {
1784+ // bolt11_invoice_features() is not public because feature
1785+ // flags can vary due to invoice type, so we convert from
1786+ // context.
1787+ self . channel_manager . init_features ( ) . to_context ( )
1788+ }
17281789}
17291790
17301791impl Drop for Node {
0 commit comments