@@ -828,6 +828,19 @@ impl ArcedNodeBuilder {
828828 self . inner . write ( ) . unwrap ( ) . set_chain_source_electrum ( server_url, sync_config) ;
829829 }
830830
831+ /// Configures the [`Node`] instance to source its chain data via BIP 157 compact block
832+ /// filters.
833+ ///
834+ /// `peers` is an optional list of peer addresses to connect to for sourcing compact block
835+ /// filters. If empty, the node will discover peers via DNS seeds.
836+ ///
837+ /// If no `sync_config` is given, default values are used. See [`CbfSyncConfig`] for more
838+ /// information.
839+ #[ cfg( feature = "cbf" ) ]
840+ pub fn set_chain_source_cbf ( & self , peers : Vec < String > , sync_config : Option < CbfSyncConfig > ) {
841+ self . inner . write ( ) . unwrap ( ) . set_chain_source_cbf ( peers, sync_config) ;
842+ }
843+
831844 /// Configures the [`Node`] instance to connect to a Bitcoin Core node via RPC.
832845 ///
833846 /// This method establishes an RPC connection that enables all essential chain operations including
@@ -2010,6 +2023,9 @@ pub(crate) fn sanitize_alias(alias_str: &str) -> Result<NodeAlias, BuildError> {
20102023
20112024#[ cfg( test) ]
20122025mod tests {
2026+ #[ cfg( all( feature = "cbf" , feature = "uniffi" ) ) ]
2027+ use crate :: config:: CbfSyncConfig ;
2028+
20132029 use super :: { sanitize_alias, BuildError , NodeAlias } ;
20142030
20152031 #[ test]
@@ -2047,4 +2063,23 @@ mod tests {
20472063 let node = sanitize_alias ( alias) ;
20482064 assert_eq ! ( node. err( ) . unwrap( ) , BuildError :: InvalidNodeAlias ) ;
20492065 }
2066+
2067+ #[ cfg( all( feature = "cbf" , feature = "uniffi" ) ) ]
2068+ #[ test]
2069+ fn arced_builder_can_set_cbf_chain_source ( ) {
2070+ let builder = super :: ArcedNodeBuilder :: new ( ) ;
2071+ let sync_config = CbfSyncConfig :: default ( ) ;
2072+
2073+ let peers = vec ! [ "127.0.0.1:8333" . to_string( ) ] ;
2074+ builder. set_chain_source_cbf ( peers. clone ( ) , Some ( sync_config. clone ( ) ) ) ;
2075+
2076+ let guard = builder. inner . read ( ) . unwrap ( ) ;
2077+ assert ! ( matches!(
2078+ guard. chain_data_source_config. as_ref( ) ,
2079+ Some ( super :: ChainDataSourceConfig :: Cbf {
2080+ peers: p,
2081+ sync_config: Some ( config) ,
2082+ } ) if config == & sync_config && p == & peers
2083+ ) ) ;
2084+ }
20502085}
0 commit comments