@@ -87,6 +87,7 @@ const LSPS_HARDENED_CHILD_INDEX: u32 = 577;
8787enum ChainDataSourceConfig {
8888 Esplora {
8989 server_url : String ,
90+ headers : HashMap < String , String > ,
9091 sync_config : Option < EsploraSyncConfig > ,
9192 } ,
9293 Electrum {
@@ -294,9 +295,27 @@ impl NodeBuilder {
294295 /// information.
295296 pub fn set_chain_source_esplora (
296297 & mut self , server_url : String , sync_config : Option < EsploraSyncConfig > ,
298+ ) -> & mut Self {
299+ self . chain_data_source_config = Some ( ChainDataSourceConfig :: Esplora {
300+ server_url,
301+ headers : Default :: default ( ) ,
302+ sync_config,
303+ } ) ;
304+ self
305+ }
306+
307+ /// Configures the [`Node`] instance to source its chain data from the given Esplora server.
308+ /// The given `headers` will be included in all requests to the Esplora server, typically used for
309+ /// authentication purposes.
310+ ///
311+ /// If no `sync_config` is given, default values are used. See [`EsploraSyncConfig`] for more
312+ /// information.
313+ pub fn set_chain_source_esplora_with_headers (
314+ & mut self , server_url : String , headers : HashMap < String , String > ,
315+ sync_config : Option < EsploraSyncConfig > ,
297316 ) -> & mut Self {
298317 self . chain_data_source_config =
299- Some ( ChainDataSourceConfig :: Esplora { server_url, sync_config } ) ;
318+ Some ( ChainDataSourceConfig :: Esplora { server_url, headers , sync_config } ) ;
300319 self
301320 }
302321
@@ -1117,10 +1136,11 @@ fn build_with_store_internal(
11171136 ) ) ;
11181137
11191138 let chain_source = match chain_data_source_config {
1120- Some ( ChainDataSourceConfig :: Esplora { server_url, sync_config } ) => {
1139+ Some ( ChainDataSourceConfig :: Esplora { server_url, headers , sync_config } ) => {
11211140 let sync_config = sync_config. unwrap_or ( EsploraSyncConfig :: default ( ) ) ;
11221141 Arc :: new ( ChainSource :: new_esplora (
11231142 server_url. clone ( ) ,
1143+ headers. clone ( ) ,
11241144 sync_config,
11251145 Arc :: clone ( & wallet) ,
11261146 Arc :: clone ( & fee_estimator) ,
@@ -1187,6 +1207,7 @@ fn build_with_store_internal(
11871207 let sync_config = EsploraSyncConfig :: default ( ) ;
11881208 Arc :: new ( ChainSource :: new_esplora (
11891209 server_url. clone ( ) ,
1210+ HashMap :: new ( ) ,
11901211 sync_config,
11911212 Arc :: clone ( & wallet) ,
11921213 Arc :: clone ( & fee_estimator) ,
0 commit comments