@@ -42,7 +42,7 @@ use lightning::util::sweep::OutputSweeper;
4242use lightning_persister:: fs_store:: v1:: FilesystemStore ;
4343use vss_client:: headers:: VssHeaderProvider ;
4444
45- use crate :: chain:: ChainSource ;
45+ use crate :: chain:: { ChainSource , FeeSourceConfig } ;
4646use crate :: config:: {
4747 default_user_config, may_announce_channel, AnnounceError , AsyncPaymentsRole ,
4848 BitcoindRestClientConfig , Config , ElectrumSyncConfig , EsploraSyncConfig ,
@@ -105,6 +105,9 @@ enum ChainDataSourceConfig {
105105 rpc_password : String ,
106106 rest_client_config : Option < BitcoindRestClientConfig > ,
107107 } ,
108+ CompactBlockFilter {
109+ peers : Vec < std:: net:: SocketAddr > ,
110+ } ,
108111}
109112
110113#[ derive( Debug , Clone ) ]
@@ -240,6 +243,7 @@ impl std::error::Error for BuildError {}
240243pub struct NodeBuilder {
241244 config : Config ,
242245 chain_data_source_config : Option < ChainDataSourceConfig > ,
246+ fee_source_config : Option < FeeSourceConfig > ,
243247 gossip_source_config : Option < GossipSourceConfig > ,
244248 liquidity_source_config : Option < LiquiditySourceConfig > ,
245249 log_writer_config : Option < LogWriterConfig > ,
@@ -259,6 +263,7 @@ impl NodeBuilder {
259263 /// Creates a new builder instance from an [`Config`].
260264 pub fn from_config ( config : Config ) -> Self {
261265 let chain_data_source_config = None ;
266+ let fee_source_config = None ;
262267 let gossip_source_config = None ;
263268 let liquidity_source_config = None ;
264269 let log_writer_config = None ;
@@ -268,6 +273,7 @@ impl NodeBuilder {
268273 Self {
269274 config,
270275 chain_data_source_config,
276+ fee_source_config,
271277 gossip_source_config,
272278 liquidity_source_config,
273279 log_writer_config,
@@ -352,6 +358,40 @@ impl NodeBuilder {
352358 self
353359 }
354360
361+ /// Configures the [`Node`] instance to source its chain data via BIP157 compact block filters.
362+ ///
363+ /// The given `peers` will be used as seed peers for the compact block filter node. An empty
364+ /// list is valid for standard networks (mainnet, testnet, signet) where DNS seeds are used
365+ /// for peer discovery. For custom networks (e.g. custom signets), at least one peer must be
366+ /// provided.
367+ pub fn set_chain_source_bip157 ( & mut self , peers : Vec < std:: net:: SocketAddr > ) -> & mut Self {
368+ self . chain_data_source_config =
369+ Some ( ChainDataSourceConfig :: CompactBlockFilter { peers } ) ;
370+ self
371+ }
372+
373+ /// Configures the BIP-157 chain source to use an Esplora server for fee rate estimation.
374+ ///
375+ /// By default the BIP-157 backend derives fee rates from the latest block's coinbase output.
376+ /// Setting this provides more accurate, per-target fee estimates from a mempool-aware server.
377+ ///
378+ /// Only takes effect when the chain source is set to BIP-157 via [`Self::set_chain_source_bip157`].
379+ pub fn set_fee_source_esplora ( & mut self , server_url : String ) -> & mut Self {
380+ self . fee_source_config = Some ( FeeSourceConfig :: Esplora ( server_url) ) ;
381+ self
382+ }
383+
384+ /// Configures the BIP-157 chain source to use an Electrum server for fee rate estimation.
385+ ///
386+ /// By default the BIP-157 backend derives fee rates from the latest block's coinbase output.
387+ /// Setting this provides more accurate, per-target fee estimates from a mempool-aware server.
388+ ///
389+ /// Only takes effect when the chain source is set to BIP-157 via [`Self::set_chain_source_bip157`].
390+ pub fn set_fee_source_electrum ( & mut self , server_url : String ) -> & mut Self {
391+ self . fee_source_config = Some ( FeeSourceConfig :: Electrum ( server_url) ) ;
392+ self
393+ }
394+
355395 /// Configures the [`Node`] instance to synchronize chain data from a Bitcoin Core REST endpoint.
356396 ///
357397 /// This method enables chain data synchronization via Bitcoin Core's REST interface. We pass
@@ -727,6 +767,7 @@ impl NodeBuilder {
727767 build_with_store_internal (
728768 config,
729769 self . chain_data_source_config . as_ref ( ) ,
770+ self . fee_source_config . clone ( ) ,
730771 self . gossip_source_config . as_ref ( ) ,
731772 self . liquidity_source_config . as_ref ( ) ,
732773 self . pathfinding_scores_sync_config . as_ref ( ) ,
@@ -847,6 +888,21 @@ impl ArcedNodeBuilder {
847888 ) ;
848889 }
849890
891+ /// Configures the [`Node`] instance to synchronize chain data via BIP-157 compact block filters.
892+ pub fn set_chain_source_bip157 ( & self , peers : Vec < std:: net:: SocketAddr > ) {
893+ self . inner . write ( ) . unwrap ( ) . set_chain_source_bip157 ( peers) ;
894+ }
895+
896+ /// Configures the BIP-157 chain source to use an Esplora server for fee rate estimation.
897+ pub fn set_fee_source_esplora ( & self , server_url : String ) {
898+ self . inner . write ( ) . unwrap ( ) . set_fee_source_esplora ( server_url) ;
899+ }
900+
901+ /// Configures the BIP-157 chain source to use an Electrum server for fee rate estimation.
902+ pub fn set_fee_source_electrum ( & self , server_url : String ) {
903+ self . inner . write ( ) . unwrap ( ) . set_fee_source_electrum ( server_url) ;
904+ }
905+
850906 /// Configures the [`Node`] instance to source its gossip data from the Lightning peer-to-peer
851907 /// network.
852908 pub fn set_gossip_source_p2p ( & self ) {
@@ -1121,7 +1177,7 @@ impl ArcedNodeBuilder {
11211177/// Builds a [`Node`] instance according to the options previously configured.
11221178fn build_with_store_internal (
11231179 config : Arc < Config > , chain_data_source_config : Option < & ChainDataSourceConfig > ,
1124- gossip_source_config : Option < & GossipSourceConfig > ,
1180+ fee_source_config : Option < FeeSourceConfig > , gossip_source_config : Option < & GossipSourceConfig > ,
11251181 liquidity_source_config : Option < & LiquiditySourceConfig > ,
11261182 pathfinding_scores_sync_config : Option < & PathfindingScoresSyncConfig > ,
11271183 async_payments_role : Option < AsyncPaymentsRole > , recovery_mode : bool , seed_bytes : [ u8 ; 64 ] ,
@@ -1254,6 +1310,16 @@ fn build_with_store_internal(
12541310 . await
12551311 } ) ,
12561312 } ,
1313+ Some ( ChainDataSourceConfig :: CompactBlockFilter { peers } ) => ChainSource :: new_kyoto (
1314+ peers. clone ( ) ,
1315+ fee_source_config,
1316+ Arc :: clone ( & fee_estimator) ,
1317+ Arc :: clone ( & tx_broadcaster) ,
1318+ Arc :: clone ( & kv_store) ,
1319+ Arc :: clone ( & config) ,
1320+ Arc :: clone ( & logger) ,
1321+ Arc :: clone ( & node_metrics) ,
1322+ ) ,
12571323
12581324 None => {
12591325 // Default to Esplora client.
0 commit comments