5
5
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
6
6
// accordance with one or both of these licenses.
7
7
8
+ mod bitcoind_rpc;
9
+
8
10
use crate :: config:: {
9
11
Config , EsploraSyncConfig , BDK_CLIENT_CONCURRENCY , BDK_CLIENT_STOP_GAP ,
10
12
BDK_WALLET_SYNC_TIMEOUT_SECS , FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS , LDK_WALLET_SYNC_TIMEOUT_SECS ,
@@ -35,6 +37,8 @@ use std::collections::HashMap;
35
37
use std:: sync:: { Arc , Mutex , RwLock } ;
36
38
use std:: time:: { Duration , Instant , SystemTime , UNIX_EPOCH } ;
37
39
40
+ use self :: bitcoind_rpc:: BitcoindRpcClient ;
41
+
38
42
// The default Esplora server we're using.
39
43
pub ( crate ) const DEFAULT_ESPLORA_SERVER_URL : & str = "https://blockstream.info/api" ;
40
44
@@ -109,6 +113,18 @@ pub(crate) enum ChainSource {
109
113
logger : Arc < FilesystemLogger > ,
110
114
node_metrics : Arc < RwLock < NodeMetrics > > ,
111
115
} ,
116
+ BitcoindRpc {
117
+ bitcoind_rpc_client : Arc < BitcoindRpcClient > ,
118
+ onchain_wallet : Arc < Wallet > ,
119
+ onchain_wallet_sync_status : Mutex < WalletSyncStatus > ,
120
+ lightning_wallet_sync_status : Mutex < WalletSyncStatus > ,
121
+ fee_estimator : Arc < OnchainFeeEstimator > ,
122
+ tx_broadcaster : Arc < Broadcaster > ,
123
+ kv_store : Arc < DynStore > ,
124
+ config : Arc < Config > ,
125
+ logger : Arc < FilesystemLogger > ,
126
+ node_metrics : Arc < RwLock < NodeMetrics > > ,
127
+ } ,
112
128
}
113
129
114
130
impl ChainSource {
@@ -141,6 +157,30 @@ impl ChainSource {
141
157
}
142
158
}
143
159
160
+ pub ( crate ) fn new_bitcoind_rpc (
161
+ host : String , port : u16 , rpc_user : String , rpc_password : String ,
162
+ onchain_wallet : Arc < Wallet > , fee_estimator : Arc < OnchainFeeEstimator > ,
163
+ tx_broadcaster : Arc < Broadcaster > , kv_store : Arc < DynStore > , config : Arc < Config > ,
164
+ logger : Arc < FilesystemLogger > , node_metrics : Arc < RwLock < NodeMetrics > > ,
165
+ ) -> Self {
166
+ let bitcoind_rpc_client =
167
+ Arc :: new ( BitcoindRpcClient :: new ( host, port, rpc_user, rpc_password) ) ;
168
+ let onchain_wallet_sync_status = Mutex :: new ( WalletSyncStatus :: Completed ) ;
169
+ let lightning_wallet_sync_status = Mutex :: new ( WalletSyncStatus :: Completed ) ;
170
+ Self :: BitcoindRpc {
171
+ bitcoind_rpc_client,
172
+ onchain_wallet,
173
+ onchain_wallet_sync_status,
174
+ lightning_wallet_sync_status,
175
+ fee_estimator,
176
+ tx_broadcaster,
177
+ kv_store,
178
+ config,
179
+ logger,
180
+ node_metrics,
181
+ }
182
+ }
183
+
144
184
pub ( crate ) async fn continuously_sync_wallets (
145
185
& self , mut stop_sync_receiver : tokio:: sync:: watch:: Receiver < ( ) > ,
146
186
channel_manager : Arc < ChannelManager > , chain_monitor : Arc < ChainMonitor > ,
@@ -201,6 +241,7 @@ impl ChainSource {
201
241
}
202
242
}
203
243
} ,
244
+ Self :: BitcoindRpc { .. } => todo ! ( ) ,
204
245
}
205
246
}
206
247
@@ -319,6 +360,7 @@ impl ChainSource {
319
360
320
361
res
321
362
} ,
363
+ Self :: BitcoindRpc { .. } => todo ! ( ) ,
322
364
}
323
365
}
324
366
@@ -411,6 +453,7 @@ impl ChainSource {
411
453
412
454
res
413
455
} ,
456
+ Self :: BitcoindRpc { .. } => todo ! ( ) ,
414
457
}
415
458
}
416
459
@@ -506,6 +549,7 @@ impl ChainSource {
506
549
507
550
Ok ( ( ) )
508
551
} ,
552
+ Self :: BitcoindRpc { .. } => todo ! ( ) ,
509
553
}
510
554
}
511
555
@@ -582,6 +626,7 @@ impl ChainSource {
582
626
}
583
627
}
584
628
} ,
629
+ Self :: BitcoindRpc { .. } => todo ! ( ) ,
585
630
}
586
631
}
587
632
}
@@ -590,11 +635,13 @@ impl Filter for ChainSource {
590
635
fn register_tx ( & self , txid : & bitcoin:: Txid , script_pubkey : & bitcoin:: Script ) {
591
636
match self {
592
637
Self :: Esplora { tx_sync, .. } => tx_sync. register_tx ( txid, script_pubkey) ,
638
+ Self :: BitcoindRpc { .. } => ( ) ,
593
639
}
594
640
}
595
641
fn register_output ( & self , output : lightning:: chain:: WatchedOutput ) {
596
642
match self {
597
643
Self :: Esplora { tx_sync, .. } => tx_sync. register_output ( output) ,
644
+ Self :: BitcoindRpc { .. } => ( ) ,
598
645
}
599
646
}
600
647
}
0 commit comments