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,16 @@ 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
+ fee_estimator : Arc < OnchainFeeEstimator > ,
120
+ tx_broadcaster : Arc < Broadcaster > ,
121
+ kv_store : Arc < DynStore > ,
122
+ config : Arc < Config > ,
123
+ logger : Arc < FilesystemLogger > ,
124
+ node_metrics : Arc < RwLock < NodeMetrics > > ,
125
+ } ,
112
126
}
113
127
114
128
impl ChainSource {
@@ -141,6 +155,26 @@ impl ChainSource {
141
155
}
142
156
}
143
157
158
+ pub ( crate ) fn new_bitcoind_rpc (
159
+ host : String , port : u16 , rpc_user : String , rpc_password : String ,
160
+ onchain_wallet : Arc < Wallet > , fee_estimator : Arc < OnchainFeeEstimator > ,
161
+ tx_broadcaster : Arc < Broadcaster > , kv_store : Arc < DynStore > , config : Arc < Config > ,
162
+ logger : Arc < FilesystemLogger > , node_metrics : Arc < RwLock < NodeMetrics > > ,
163
+ ) -> Self {
164
+ let bitcoind_rpc_client =
165
+ Arc :: new ( BitcoindRpcClient :: new ( host, port, rpc_user, rpc_password) ) ;
166
+ Self :: BitcoindRpc {
167
+ bitcoind_rpc_client,
168
+ onchain_wallet,
169
+ fee_estimator,
170
+ tx_broadcaster,
171
+ kv_store,
172
+ config,
173
+ logger,
174
+ node_metrics,
175
+ }
176
+ }
177
+
144
178
pub ( crate ) async fn continuously_sync_wallets (
145
179
& self , mut stop_sync_receiver : tokio:: sync:: watch:: Receiver < ( ) > ,
146
180
channel_manager : Arc < ChannelManager > , chain_monitor : Arc < ChainMonitor > ,
@@ -201,6 +235,7 @@ impl ChainSource {
201
235
}
202
236
}
203
237
} ,
238
+ Self :: BitcoindRpc { .. } => todo ! ( ) ,
204
239
}
205
240
}
206
241
@@ -319,6 +354,7 @@ impl ChainSource {
319
354
320
355
res
321
356
} ,
357
+ Self :: BitcoindRpc { .. } => todo ! ( ) ,
322
358
}
323
359
}
324
360
@@ -411,6 +447,7 @@ impl ChainSource {
411
447
412
448
res
413
449
} ,
450
+ Self :: BitcoindRpc { .. } => todo ! ( ) ,
414
451
}
415
452
}
416
453
@@ -506,6 +543,7 @@ impl ChainSource {
506
543
507
544
Ok ( ( ) )
508
545
} ,
546
+ Self :: BitcoindRpc { .. } => todo ! ( ) ,
509
547
}
510
548
}
511
549
@@ -582,6 +620,7 @@ impl ChainSource {
582
620
}
583
621
}
584
622
} ,
623
+ Self :: BitcoindRpc { .. } => todo ! ( ) ,
585
624
}
586
625
}
587
626
}
@@ -590,11 +629,13 @@ impl Filter for ChainSource {
590
629
fn register_tx ( & self , txid : & bitcoin:: Txid , script_pubkey : & bitcoin:: Script ) {
591
630
match self {
592
631
Self :: Esplora { tx_sync, .. } => tx_sync. register_tx ( txid, script_pubkey) ,
632
+ Self :: BitcoindRpc { .. } => ( ) ,
593
633
}
594
634
}
595
635
fn register_output ( & self , output : lightning:: chain:: WatchedOutput ) {
596
636
match self {
597
637
Self :: Esplora { tx_sync, .. } => tx_sync. register_output ( output) ,
638
+ Self :: BitcoindRpc { .. } => ( ) ,
598
639
}
599
640
}
600
641
}
0 commit comments