Skip to content

Commit 55a8d29

Browse files
committed
Expose set_paths_to_static_invoice_server
1 parent 958fe1c commit 55a8d29

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/builder.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use crate::wallet::persist::KVStoreWalletPersister;
3838
use crate::wallet::Wallet;
3939
use crate::{Node, NodeMetrics};
4040

41+
use lightning::blinded_path::message::BlindedMessagePath;
4142
use lightning::chain::{chainmonitor, BestBlock, Watch};
4243
use lightning::io::Cursor;
4344
use 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();

src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
1010
use crate::logger::LogLevel;
1111

12+
use lightning::blinded_path::message::BlindedMessagePath;
1213
use lightning::ln::msgs::SocketAddress;
1314
use lightning::routing::gossip::NodeAlias;
1415
use lightning::routing::router::RouteParametersConfig;
@@ -179,6 +180,10 @@ pub struct Config {
179180
/// **Note:** If unset, default parameters will be used, and you will be able to override the
180181
/// parameters on a per-payment basis in the corresponding method calls.
181182
pub route_parameters: Option<RouteParametersConfig>,
183+
184+
/// The [`BlindedMessagePath`]s that we will use as an async recipient to interactively build [`Offer`]s with a
185+
/// static invoice server, so the server can serve [`StaticInvoice`]s to payers on our behalf when we're offline.
186+
pub static_invoice_server_paths: Option<Vec<BlindedMessagePath>>,
182187
}
183188

184189
impl Default for Config {
@@ -193,6 +198,7 @@ impl Default for Config {
193198
anchor_channels_config: Some(AnchorChannelsConfig::default()),
194199
route_parameters: None,
195200
node_alias: None,
201+
static_invoice_server_paths: None,
196202
}
197203
}
198204
}

0 commit comments

Comments
 (0)