66// accordance with one or both of these licenses.
77
88mod bitcoind_rpc;
9+ #[ cfg( feature = "electrum" ) ]
910mod electrum;
1011
1112use crate :: chain:: bitcoind_rpc:: {
1213 BitcoindRpcClient , BoundedHeaderCache , ChainListener , FeeRateEstimationMode ,
1314} ;
15+ #[ cfg( feature = "electrum" ) ]
1416use crate :: chain:: electrum:: ElectrumRuntimeClient ;
1517use crate :: config:: {
16- BackgroundSyncConfig , Config , ElectrumSyncConfig , EsploraSyncConfig , BDK_CLIENT_CONCURRENCY ,
18+ BackgroundSyncConfig , Config , EsploraSyncConfig , BDK_CLIENT_CONCURRENCY ,
1719 BDK_CLIENT_STOP_GAP , BDK_WALLET_SYNC_TIMEOUT_SECS , FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS ,
1820 LDK_WALLET_SYNC_TIMEOUT_SECS , RESOLVED_CHANNEL_MONITOR_ARCHIVAL_INTERVAL ,
1921 TX_BROADCAST_TIMEOUT_SECS , WALLET_SYNC_INTERVAL_MINIMUM_SECS ,
2022} ;
23+
24+ #[ cfg( feature = "electrum" ) ]
25+ use crate :: config:: ElectrumSyncConfig ;
26+
2127use crate :: fee_estimator:: {
2228 apply_post_estimation_adjustments, get_all_conf_targets, get_num_block_defaults_for_target,
2329 ConfirmationTarget , OnchainFeeEstimator ,
@@ -110,6 +116,7 @@ impl WalletSyncStatus {
110116 }
111117}
112118
119+ #[ cfg( feature = "electrum" ) ]
113120pub ( crate ) enum ElectrumRuntimeStatus {
114121 Started ( Arc < ElectrumRuntimeClient > ) ,
115122 Stopped {
@@ -118,6 +125,7 @@ pub(crate) enum ElectrumRuntimeStatus {
118125 } ,
119126}
120127
128+ #[ cfg( feature = "electrum" ) ]
121129impl ElectrumRuntimeStatus {
122130 pub ( crate ) fn new ( ) -> Self {
123131 let pending_registered_txs = Vec :: new ( ) ;
@@ -201,6 +209,7 @@ pub(crate) enum ChainSource {
201209 logger : Arc < Logger > ,
202210 node_metrics : Arc < RwLock < NodeMetrics > > ,
203211 } ,
212+ #[ cfg( feature = "electrum" ) ]
204213 Electrum {
205214 server_url : String ,
206215 sync_config : ElectrumSyncConfig ,
@@ -260,6 +269,7 @@ impl ChainSource {
260269 }
261270 }
262271
272+ #[ cfg( feature = "electrum" ) ]
263273 pub ( crate ) fn new_electrum (
264274 server_url : String , sync_config : ElectrumSyncConfig , onchain_wallet : Arc < Wallet > ,
265275 fee_estimator : Arc < OnchainFeeEstimator > , tx_broadcaster : Arc < Broadcaster > ,
@@ -313,6 +323,7 @@ impl ChainSource {
313323
314324 pub ( crate ) fn start ( & self , runtime : Arc < tokio:: runtime:: Runtime > ) -> Result < ( ) , Error > {
315325 match self {
326+ #[ cfg( feature = "electrum" ) ]
316327 Self :: Electrum { server_url, electrum_runtime_status, config, logger, .. } => {
317328 electrum_runtime_status. write ( ) . unwrap ( ) . start (
318329 server_url. clone ( ) ,
@@ -330,6 +341,7 @@ impl ChainSource {
330341
331342 pub ( crate ) fn stop ( & self ) {
332343 match self {
344+ #[ cfg( feature = "electrum" ) ]
333345 Self :: Electrum { electrum_runtime_status, .. } => {
334346 electrum_runtime_status. write ( ) . unwrap ( ) . stop ( ) ;
335347 } ,
@@ -372,6 +384,7 @@ impl ChainSource {
372384 return ;
373385 }
374386 } ,
387+ #[ cfg( feature = "electrum" ) ]
375388 Self :: Electrum { sync_config, logger, .. } => {
376389 if let Some ( background_sync_config) = sync_config. background_sync_config . as_ref ( ) {
377390 self . start_tx_based_sync_loop (
@@ -718,6 +731,7 @@ impl ChainSource {
718731
719732 res
720733 } ,
734+ #[ cfg( feature = "electrum" ) ]
721735 Self :: Electrum {
722736 electrum_runtime_status,
723737 onchain_wallet,
@@ -909,6 +923,7 @@ impl ChainSource {
909923
910924 res
911925 } ,
926+ #[ cfg( feature = "electrum" ) ]
912927 Self :: Electrum {
913928 electrum_runtime_status,
914929 lightning_wallet_sync_status,
@@ -998,6 +1013,7 @@ impl ChainSource {
9981013 // `sync_onchain_wallet` and `sync_lightning_wallet`. So nothing to do here.
9991014 unreachable ! ( "Listeners will be synced via transction-based syncing" )
10001015 } ,
1016+ #[ cfg( feature = "electrum" ) ]
10011017 Self :: Electrum { .. } => {
10021018 // In Electrum mode we sync lightning and onchain wallets via
10031019 // `sync_onchain_wallet` and `sync_lightning_wallet`. So nothing to do here.
@@ -1223,6 +1239,7 @@ impl ChainSource {
12231239
12241240 Ok ( ( ) )
12251241 } ,
1242+ #[ cfg( feature = "electrum" ) ]
12261243 Self :: Electrum {
12271244 electrum_runtime_status,
12281245 fee_estimator,
@@ -1478,6 +1495,7 @@ impl ChainSource {
14781495 }
14791496 }
14801497 } ,
1498+ #[ cfg( feature = "electrum" ) ]
14811499 Self :: Electrum { electrum_runtime_status, tx_broadcaster, .. } => {
14821500 let electrum_client: Arc < ElectrumRuntimeClient > = if let Some ( client) =
14831501 electrum_runtime_status. read ( ) . unwrap ( ) . client ( ) . as_ref ( )
@@ -1560,6 +1578,7 @@ impl Filter for ChainSource {
15601578 fn register_tx ( & self , txid : & Txid , script_pubkey : & Script ) {
15611579 match self {
15621580 Self :: Esplora { tx_sync, .. } => tx_sync. register_tx ( txid, script_pubkey) ,
1581+ #[ cfg( feature = "electrum" ) ]
15631582 Self :: Electrum { electrum_runtime_status, .. } => {
15641583 electrum_runtime_status. write ( ) . unwrap ( ) . register_tx ( txid, script_pubkey)
15651584 } ,
@@ -1569,6 +1588,7 @@ impl Filter for ChainSource {
15691588 fn register_output ( & self , output : lightning:: chain:: WatchedOutput ) {
15701589 match self {
15711590 Self :: Esplora { tx_sync, .. } => tx_sync. register_output ( output) ,
1591+ #[ cfg( feature = "electrum" ) ]
15721592 Self :: Electrum { electrum_runtime_status, .. } => {
15731593 electrum_runtime_status. write ( ) . unwrap ( ) . register_output ( output)
15741594 } ,
0 commit comments