@@ -38,6 +38,7 @@ use crate::wallet::persist::KVStoreWalletPersister;
3838use crate :: wallet:: Wallet ;
3939use crate :: { Node , NodeMetrics } ;
4040
41+ use lightning:: blinded_path:: message:: BlindedMessagePath ;
4142use lightning:: chain:: { chainmonitor, BestBlock , Watch } ;
4243use lightning:: io:: Cursor ;
4344use lightning:: ln:: channelmanager:: { self , ChainParameters , ChannelManagerReadArgs } ;
@@ -169,6 +170,8 @@ pub enum BuildError {
169170 InvalidAnnouncementAddresses ,
170171 /// The provided alias is invalid.
171172 InvalidNodeAlias ,
173+ /// The provided static invoice server paths are invalid.
174+ InvalidStaticInvoiceServerPaths ,
172175 /// An attempt to setup a runtime has failed.
173176 RuntimeSetupFailed ,
174177 /// We failed to read data from the [`KVStore`].
@@ -219,6 +222,9 @@ impl fmt::Display for BuildError {
219222 Self :: NetworkMismatch => {
220223 write ! ( f, "Given network does not match the node's previously configured network." )
221224 } ,
225+ Self :: InvalidStaticInvoiceServerPaths => {
226+ write ! ( f, "Given static invoice server paths are invalid." )
227+ } ,
222228 }
223229 }
224230}
@@ -544,6 +550,15 @@ impl NodeBuilder {
544550 Ok ( self )
545551 }
546552
553+ /// Sets the [`BlindedMessagePath`]s that we will use as an async recipient to interactively build [`Offer`]s with a
554+ /// static invoice server, so the server can serve [`StaticInvoice`]s to payers on our behalf when we're offline.
555+ pub fn set_paths_to_static_invoice_server (
556+ & mut self , paths : Vec < BlindedMessagePath > ,
557+ ) -> Result < & mut Self , BuildError > {
558+ self . config . static_invoice_server_paths = Some ( paths) ;
559+ Ok ( self )
560+ }
561+
547562 /// Builds a [`Node`] instance with a [`SqliteStore`] backend and according to the options
548563 /// previously configured.
549564 pub fn build ( & self ) -> Result < Node , BuildError > {
@@ -1441,6 +1456,13 @@ fn build_with_store_internal(
14411456
14421457 let channel_manager = Arc :: new ( channel_manager) ;
14431458
1459+ // Configure static invoice server.
1460+ if let Some ( paths) = config. static_invoice_server_paths . as_ref ( ) {
1461+ channel_manager
1462+ . set_paths_to_static_invoice_server ( paths. clone ( ) )
1463+ . map_err ( |_| BuildError :: InvalidStaticInvoiceServerPaths ) ?;
1464+ }
1465+
14441466 // Give ChannelMonitors to ChainMonitor
14451467 for ( _blockhash, channel_monitor) in channel_monitors. into_iter ( ) {
14461468 let channel_id = channel_monitor. channel_id ( ) ;
0 commit comments