f2de6d289e4cc413304506e253edd19a8088602f
[ldk-sample] / src / main.rs
1 pub mod bitcoind_client;
2 mod cli;
3 mod convert;
4 mod disk;
5 mod hex_utils;
6
7 use crate::bitcoind_client::BitcoindClient;
8 use crate::disk::FilesystemLogger;
9 use bitcoin::blockdata::constants::genesis_block;
10 use bitcoin::blockdata::transaction::Transaction;
11 use bitcoin::consensus::encode;
12 use bitcoin::hashes::sha256::Hash as Sha256;
13 use bitcoin::hashes::Hash;
14 use bitcoin::network::constants::Network;
15 use bitcoin::secp256k1::Secp256k1;
16 use bitcoin::BlockHash;
17 use bitcoin_bech32::WitnessProgram;
18 use lightning::chain;
19 use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator};
20 use lightning::chain::chainmonitor;
21 use lightning::chain::keysinterface::{InMemorySigner, KeysInterface, KeysManager};
22 use lightning::chain::{BestBlock, Filter, Watch};
23 use lightning::ln::channelmanager;
24 use lightning::ln::channelmanager::{
25         ChainParameters, ChannelManagerReadArgs, SimpleArcChannelManager,
26 };
27 use lightning::ln::peer_handler::{MessageHandler, SimpleArcPeerManager};
28 use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
29 use lightning::routing::network_graph::NetGraphMsgHandler;
30 use lightning::util::config::UserConfig;
31 use lightning::util::events::Event;
32 use lightning::util::ser::ReadableArgs;
33 use lightning_background_processor::BackgroundProcessor;
34 use lightning_block_sync::init;
35 use lightning_block_sync::poll;
36 use lightning_block_sync::SpvClient;
37 use lightning_block_sync::UnboundedCache;
38 use lightning_net_tokio::SocketDescriptor;
39 use lightning_persister::FilesystemPersister;
40 use rand::{thread_rng, Rng};
41 use std::collections::hash_map::Entry;
42 use std::collections::HashMap;
43 use std::fmt;
44 use std::fs;
45 use std::fs::File;
46 use std::io;
47 use std::io::Write;
48 use std::ops::Deref;
49 use std::path::Path;
50 use std::sync::{Arc, Mutex};
51 use std::time::{Duration, SystemTime};
52
53 pub(crate) enum HTLCStatus {
54         Pending,
55         Succeeded,
56         Failed,
57 }
58
59 pub(crate) struct MillisatAmount(Option<u64>);
60
61 impl fmt::Display for MillisatAmount {
62         fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
63                 match self.0 {
64                         Some(amt) => write!(f, "{}", amt),
65                         None => write!(f, "unknown"),
66                 }
67         }
68 }
69
70 pub(crate) struct PaymentInfo {
71         preimage: Option<PaymentPreimage>,
72         secret: Option<PaymentSecret>,
73         status: HTLCStatus,
74         amt_msat: MillisatAmount,
75 }
76
77 pub(crate) type PaymentInfoStorage = Arc<Mutex<HashMap<PaymentHash, PaymentInfo>>>;
78
79 type ChainMonitor = chainmonitor::ChainMonitor<
80         InMemorySigner,
81         Arc<dyn Filter + Send + Sync>,
82         Arc<BitcoindClient>,
83         Arc<BitcoindClient>,
84         Arc<FilesystemLogger>,
85         Arc<FilesystemPersister>,
86 >;
87
88 pub(crate) type PeerManager = SimpleArcPeerManager<
89         SocketDescriptor,
90         ChainMonitor,
91         BitcoindClient,
92         BitcoindClient,
93         dyn chain::Access + Send + Sync,
94         FilesystemLogger,
95 >;
96
97 pub(crate) type ChannelManager =
98         SimpleArcChannelManager<ChainMonitor, BitcoindClient, BitcoindClient, FilesystemLogger>;
99
100 async fn handle_ldk_events(
101         channel_manager: Arc<ChannelManager>, bitcoind_client: Arc<BitcoindClient>,
102         keys_manager: Arc<KeysManager>, inbound_payments: PaymentInfoStorage,
103         outbound_payments: PaymentInfoStorage, network: Network, event: Event,
104 ) {
105         match event {
106                 Event::FundingGenerationReady {
107                         temporary_channel_id,
108                         channel_value_satoshis,
109                         output_script,
110                         ..
111                 } => {
112                         // Construct the raw transaction with one output, that is paid the amount of the
113                         // channel.
114                         let addr = WitnessProgram::from_scriptpubkey(
115                                 &output_script[..],
116                                 match network {
117                                         Network::Bitcoin => bitcoin_bech32::constants::Network::Bitcoin,
118                                         Network::Testnet => bitcoin_bech32::constants::Network::Testnet,
119                                         Network::Regtest => bitcoin_bech32::constants::Network::Regtest,
120                                         Network::Signet => panic!("Signet unsupported"),
121                                 },
122                         )
123                         .expect("Lightning funding tx should always be to a SegWit output")
124                         .to_address();
125                         let mut outputs = vec![HashMap::with_capacity(1)];
126                         outputs[0].insert(addr, channel_value_satoshis as f64 / 100_000_000.0);
127                         let raw_tx = bitcoind_client.create_raw_transaction(outputs).await;
128
129                         // Have your wallet put the inputs into the transaction such that the output is
130                         // satisfied.
131                         let funded_tx = bitcoind_client.fund_raw_transaction(raw_tx).await;
132                         let change_output_position = funded_tx.changepos;
133                         assert!(change_output_position == 0 || change_output_position == 1);
134
135                         // Sign the final funding transaction and broadcast it.
136                         let signed_tx = bitcoind_client.sign_raw_transaction_with_wallet(funded_tx.hex).await;
137                         assert_eq!(signed_tx.complete, true);
138                         let final_tx: Transaction =
139                                 encode::deserialize(&hex_utils::to_vec(&signed_tx.hex).unwrap()).unwrap();
140                         // Give the funding transaction back to LDK for opening the channel.
141                         if channel_manager
142                                 .funding_transaction_generated(&temporary_channel_id, final_tx)
143                                 .is_err()
144                         {
145                                 println!(
146                                         "\nERROR: Channel went away before we could fund it. The peer disconnected or refused the channel.");
147                                 print!("> ");
148                                 io::stdout().flush().unwrap();
149                         }
150                 }
151                 Event::PaymentReceived { payment_hash, payment_preimage, payment_secret, amt, .. } => {
152                         let mut payments = inbound_payments.lock().unwrap();
153                         let status = match channel_manager.claim_funds(payment_preimage.unwrap()) {
154                                 true => {
155                                         println!(
156                                                 "\nEVENT: received payment from payment hash {} of {} millisatoshis",
157                                                 hex_utils::hex_str(&payment_hash.0),
158                                                 amt
159                                         );
160                                         print!("> ");
161                                         io::stdout().flush().unwrap();
162                                         HTLCStatus::Succeeded
163                                 }
164                                 _ => HTLCStatus::Failed,
165                         };
166                         match payments.entry(payment_hash) {
167                                 Entry::Occupied(mut e) => {
168                                         let payment = e.get_mut();
169                                         payment.status = status;
170                                         payment.preimage = Some(payment_preimage.unwrap());
171                                         payment.secret = Some(payment_secret);
172                                 }
173                                 Entry::Vacant(e) => {
174                                         e.insert(PaymentInfo {
175                                                 preimage: Some(payment_preimage.unwrap()),
176                                                 secret: Some(payment_secret),
177                                                 status,
178                                                 amt_msat: MillisatAmount(Some(amt)),
179                                         });
180                                 }
181                         }
182                 }
183                 Event::PaymentSent { payment_preimage } => {
184                         let hashed = PaymentHash(Sha256::hash(&payment_preimage.0).into_inner());
185                         let mut payments = outbound_payments.lock().unwrap();
186                         for (payment_hash, payment) in payments.iter_mut() {
187                                 if *payment_hash == hashed {
188                                         payment.preimage = Some(payment_preimage);
189                                         payment.status = HTLCStatus::Succeeded;
190                                         println!(
191                                                 "\nEVENT: successfully sent payment of {} millisatoshis from \
192                                                                  payment hash {:?} with preimage {:?}",
193                                                 payment.amt_msat,
194                                                 hex_utils::hex_str(&payment_hash.0),
195                                                 hex_utils::hex_str(&payment_preimage.0)
196                                         );
197                                         print!("> ");
198                                         io::stdout().flush().unwrap();
199                                 }
200                         }
201                 }
202                 Event::PaymentFailed { payment_hash, rejected_by_dest } => {
203                         print!(
204                                 "\nEVENT: Failed to send payment to payment hash {:?}: ",
205                                 hex_utils::hex_str(&payment_hash.0)
206                         );
207                         if rejected_by_dest {
208                                 println!("re-attempting the payment will not succeed");
209                         } else {
210                                 println!("payment may be retried");
211                         }
212                         print!("> ");
213                         io::stdout().flush().unwrap();
214
215                         let mut payments = outbound_payments.lock().unwrap();
216                         if payments.contains_key(&payment_hash) {
217                                 let payment = payments.get_mut(&payment_hash).unwrap();
218                                 payment.status = HTLCStatus::Failed;
219                         }
220                 }
221                 Event::PendingHTLCsForwardable { time_forwardable } => {
222                         let forwarding_channel_manager = channel_manager.clone();
223                         tokio::spawn(async move {
224                                 let min = time_forwardable.as_millis() as u64;
225                                 let millis_to_sleep = thread_rng().gen_range(min, min * 5) as u64;
226                                 tokio::time::sleep(Duration::from_millis(millis_to_sleep)).await;
227                                 forwarding_channel_manager.process_pending_htlc_forwards();
228                         });
229                 }
230                 Event::SpendableOutputs { outputs } => {
231                         let destination_address = bitcoind_client.get_new_address().await;
232                         let output_descriptors = &outputs.iter().map(|a| a).collect::<Vec<_>>();
233                         let tx_feerate =
234                                 bitcoind_client.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
235                         let spending_tx = keys_manager
236                                 .spend_spendable_outputs(
237                                         output_descriptors,
238                                         Vec::new(),
239                                         destination_address.script_pubkey(),
240                                         tx_feerate,
241                                         &Secp256k1::new(),
242                                 )
243                                 .unwrap();
244                         bitcoind_client.broadcast_transaction(&spending_tx);
245                 }
246         }
247 }
248
249 async fn start_ldk() {
250         let args = match cli::parse_startup_args() {
251                 Ok(user_args) => user_args,
252                 Err(()) => return,
253         };
254
255         // Initialize the LDK data directory if necessary.
256         let ldk_data_dir = format!("{}/.ldk", args.ldk_storage_dir_path);
257         fs::create_dir_all(ldk_data_dir.clone()).unwrap();
258
259         // Initialize our bitcoind client.
260         let bitcoind_client = match BitcoindClient::new(
261                 args.bitcoind_rpc_host.clone(),
262                 args.bitcoind_rpc_port,
263                 args.bitcoind_rpc_username.clone(),
264                 args.bitcoind_rpc_password.clone(),
265         )
266         .await
267         {
268                 Ok(client) => Arc::new(client),
269                 Err(e) => {
270                         println!("Failed to connect to bitcoind client: {}", e);
271                         return;
272                 }
273         };
274
275         // Check that the bitcoind we've connected to is running the network we expect
276         let bitcoind_chain = bitcoind_client.get_blockchain_info().await.chain;
277         if bitcoind_chain
278                 != match args.network {
279                         bitcoin::Network::Bitcoin => "main",
280                         bitcoin::Network::Testnet => "test",
281                         bitcoin::Network::Regtest => "regtest",
282                         bitcoin::Network::Signet => "signet",
283                 } {
284                 println!(
285                         "Chain argument ({}) didn't match bitcoind chain ({})",
286                         args.network, bitcoind_chain
287                 );
288                 return;
289         }
290
291         // ## Setup
292         // Step 1: Initialize the FeeEstimator
293
294         // BitcoindClient implements the FeeEstimator trait, so it'll act as our fee estimator.
295         let fee_estimator = bitcoind_client.clone();
296
297         // Step 2: Initialize the Logger
298         let logger = Arc::new(FilesystemLogger::new(ldk_data_dir.clone()));
299
300         // Step 3: Initialize the BroadcasterInterface
301
302         // BitcoindClient implements the BroadcasterInterface trait, so it'll act as our transaction
303         // broadcaster.
304         let broadcaster = bitcoind_client.clone();
305
306         // Step 4: Initialize Persist
307         let persister = Arc::new(FilesystemPersister::new(ldk_data_dir.clone()));
308
309         // Step 5: Initialize the ChainMonitor
310         let chain_monitor: Arc<ChainMonitor> = Arc::new(chainmonitor::ChainMonitor::new(
311                 None,
312                 broadcaster.clone(),
313                 logger.clone(),
314                 fee_estimator.clone(),
315                 persister.clone(),
316         ));
317
318         // Step 6: Initialize the KeysManager
319
320         // The key seed that we use to derive the node privkey (that corresponds to the node pubkey) and
321         // other secret key material.
322         let keys_seed_path = format!("{}/keys_seed", ldk_data_dir.clone());
323         let keys_seed = if let Ok(seed) = fs::read(keys_seed_path.clone()) {
324                 assert_eq!(seed.len(), 32);
325                 let mut key = [0; 32];
326                 key.copy_from_slice(&seed);
327                 key
328         } else {
329                 let mut key = [0; 32];
330                 thread_rng().fill_bytes(&mut key);
331                 match File::create(keys_seed_path.clone()) {
332                         Ok(mut f) => {
333                                 f.write_all(&key).expect("Failed to write node keys seed to disk");
334                                 f.sync_all().expect("Failed to sync node keys seed to disk");
335                         }
336                         Err(e) => {
337                                 println!("ERROR: Unable to create keys seed file {}: {}", keys_seed_path, e);
338                                 return;
339                         }
340                 }
341                 key
342         };
343         let cur = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap();
344         let keys_manager = Arc::new(KeysManager::new(&keys_seed, cur.as_secs(), cur.subsec_nanos()));
345
346         // Step 7: Read ChannelMonitor state from disk
347         let mut channelmonitors = persister.read_channelmonitors(keys_manager.clone()).unwrap();
348
349         // Step 8: Initialize the ChannelManager
350         let mut user_config = UserConfig::default();
351         user_config.peer_channel_config_limits.force_announced_channel_preference = false;
352         let mut restarting_node = true;
353         let (channel_manager_blockhash, mut channel_manager) = {
354                 if let Ok(mut f) = fs::File::open(format!("{}/manager", ldk_data_dir.clone())) {
355                         let mut channel_monitor_mut_references = Vec::new();
356                         for (_, channel_monitor) in channelmonitors.iter_mut() {
357                                 channel_monitor_mut_references.push(channel_monitor);
358                         }
359                         let read_args = ChannelManagerReadArgs::new(
360                                 keys_manager.clone(),
361                                 fee_estimator.clone(),
362                                 chain_monitor.clone(),
363                                 broadcaster.clone(),
364                                 logger.clone(),
365                                 user_config,
366                                 channel_monitor_mut_references,
367                         );
368                         <(BlockHash, ChannelManager)>::read(&mut f, read_args).unwrap()
369                 } else {
370                         // We're starting a fresh node.
371                         restarting_node = false;
372                         let getinfo_resp = bitcoind_client.get_blockchain_info().await;
373
374                         let chain_params = ChainParameters {
375                                 network: args.network,
376                                 best_block: BestBlock::new(
377                                         getinfo_resp.latest_blockhash,
378                                         getinfo_resp.latest_height as u32,
379                                 ),
380                         };
381                         let fresh_channel_manager = channelmanager::ChannelManager::new(
382                                 fee_estimator.clone(),
383                                 chain_monitor.clone(),
384                                 broadcaster.clone(),
385                                 logger.clone(),
386                                 keys_manager.clone(),
387                                 user_config,
388                                 chain_params,
389                         );
390                         (getinfo_resp.latest_blockhash, fresh_channel_manager)
391                 }
392         };
393
394         // Step 9: Sync ChannelMonitors and ChannelManager to chain tip
395         let mut chain_listener_channel_monitors = Vec::new();
396         let mut cache = UnboundedCache::new();
397         let mut chain_tip: Option<poll::ValidatedBlockHeader> = None;
398         if restarting_node {
399                 let mut chain_listeners =
400                         vec![(channel_manager_blockhash, &mut channel_manager as &mut dyn chain::Listen)];
401
402                 for (blockhash, channel_monitor) in channelmonitors.drain(..) {
403                         let outpoint = channel_monitor.get_funding_txo().0;
404                         chain_listener_channel_monitors.push((
405                                 blockhash,
406                                 (channel_monitor, broadcaster.clone(), fee_estimator.clone(), logger.clone()),
407                                 outpoint,
408                         ));
409                 }
410
411                 for monitor_listener_info in chain_listener_channel_monitors.iter_mut() {
412                         chain_listeners.push((
413                                 monitor_listener_info.0,
414                                 &mut monitor_listener_info.1 as &mut dyn chain::Listen,
415                         ));
416                 }
417                 chain_tip = Some(
418                         init::synchronize_listeners(
419                                 &mut bitcoind_client.deref(),
420                                 args.network,
421                                 &mut cache,
422                                 chain_listeners,
423                         )
424                         .await
425                         .unwrap(),
426                 );
427         }
428
429         // Step 10: Give ChannelMonitors to ChainMonitor
430         for item in chain_listener_channel_monitors.drain(..) {
431                 let channel_monitor = item.1 .0;
432                 let funding_outpoint = item.2;
433                 chain_monitor.watch_channel(funding_outpoint, channel_monitor).unwrap();
434         }
435
436         // Step 11: Optional: Initialize the NetGraphMsgHandler
437         let genesis = genesis_block(args.network).header.block_hash();
438         let network_graph_path = format!("{}/network_graph", ldk_data_dir.clone());
439         let network_graph = disk::read_network(Path::new(&network_graph_path), genesis);
440         let router = Arc::new(NetGraphMsgHandler::from_net_graph(
441                 None::<Arc<dyn chain::Access + Send + Sync>>,
442                 logger.clone(),
443                 network_graph,
444         ));
445         let router_persist = Arc::clone(&router);
446         tokio::spawn(async move {
447                 let mut interval = tokio::time::interval(Duration::from_secs(600));
448                 loop {
449                         interval.tick().await;
450                         if disk::persist_network(
451                                 Path::new(&network_graph_path),
452                                 &*router_persist.network_graph.read().unwrap(),
453                         )
454                         .is_err()
455                         {
456                                 // Persistence errors here are non-fatal as we can just fetch the routing graph
457                                 // again later, but they may indicate a disk error which could be fatal elsewhere.
458                                 eprintln!(
459                                         "Warning: Failed to persist network graph, check your disk and permissions"
460                                 );
461                         }
462                 }
463         });
464
465         // Step 12: Initialize the PeerManager
466         let channel_manager: Arc<ChannelManager> = Arc::new(channel_manager);
467         let mut ephemeral_bytes = [0; 32];
468         rand::thread_rng().fill_bytes(&mut ephemeral_bytes);
469         let lightning_msg_handler =
470                 MessageHandler { chan_handler: channel_manager.clone(), route_handler: router.clone() };
471         let peer_manager: Arc<PeerManager> = Arc::new(PeerManager::new(
472                 lightning_msg_handler,
473                 keys_manager.get_node_secret(),
474                 &ephemeral_bytes,
475                 logger.clone(),
476         ));
477
478         // ## Running LDK
479         // Step 13: Initialize networking
480
481         let peer_manager_connection_handler = peer_manager.clone();
482         let listening_port = args.ldk_peer_listening_port;
483         tokio::spawn(async move {
484                 let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{}", listening_port))
485                         .await
486                         .expect("Failed to bind to listen port - is something else already listening on it?");
487                 loop {
488                         let peer_mgr = peer_manager_connection_handler.clone();
489                         let tcp_stream = listener.accept().await.unwrap().0;
490                         tokio::spawn(async move {
491                                 lightning_net_tokio::setup_inbound(
492                                         peer_mgr.clone(),
493                                         tcp_stream.into_std().unwrap(),
494                                 )
495                                 .await;
496                         });
497                 }
498         });
499
500         // Step 14: Connect and Disconnect Blocks
501         if chain_tip.is_none() {
502                 chain_tip =
503                         Some(init::validate_best_block_header(&mut bitcoind_client.deref()).await.unwrap());
504         }
505         let channel_manager_listener = channel_manager.clone();
506         let chain_monitor_listener = chain_monitor.clone();
507         let bitcoind_block_source = bitcoind_client.clone();
508         let network = args.network;
509         tokio::spawn(async move {
510                 let mut derefed = bitcoind_block_source.deref();
511                 let chain_poller = poll::ChainPoller::new(&mut derefed, network);
512                 let chain_listener = (chain_monitor_listener, channel_manager_listener);
513                 let mut spv_client =
514                         SpvClient::new(chain_tip.unwrap(), chain_poller, &mut cache, &chain_listener);
515                 loop {
516                         spv_client.poll_best_tip().await.unwrap();
517                         tokio::time::sleep(Duration::from_secs(1)).await;
518                 }
519         });
520
521         // Step 15: Handle LDK Events
522         let channel_manager_event_listener = channel_manager.clone();
523         let keys_manager_listener = keys_manager.clone();
524         // TODO: persist payment info to disk
525         let inbound_payments: PaymentInfoStorage = Arc::new(Mutex::new(HashMap::new()));
526         let outbound_payments: PaymentInfoStorage = Arc::new(Mutex::new(HashMap::new()));
527         let inbound_pmts_for_events = inbound_payments.clone();
528         let outbound_pmts_for_events = outbound_payments.clone();
529         let network = args.network;
530         let bitcoind_rpc = bitcoind_client.clone();
531         let handle = tokio::runtime::Handle::current();
532         let event_handler = move |event| {
533                 handle.block_on(handle_ldk_events(
534                         channel_manager_event_listener.clone(),
535                         bitcoind_rpc.clone(),
536                         keys_manager_listener.clone(),
537                         inbound_pmts_for_events.clone(),
538                         outbound_pmts_for_events.clone(),
539                         network,
540                         event,
541                 ))
542         };
543         // Step 16: Persist ChannelManager
544         let data_dir = ldk_data_dir.clone();
545         let persist_channel_manager_callback =
546                 move |node: &ChannelManager| FilesystemPersister::persist_manager(data_dir.clone(), &*node);
547         // Step 17: Background Processing
548         BackgroundProcessor::start(
549                 persist_channel_manager_callback,
550                 event_handler,
551                 chain_monitor.clone(),
552                 channel_manager.clone(),
553                 peer_manager.clone(),
554                 logger.clone(),
555         );
556
557         // Reconnect to channel peers if possible.
558         let peer_data_path = format!("{}/channel_peer_data", ldk_data_dir.clone());
559         match disk::read_channel_peer_data(Path::new(&peer_data_path)) {
560                 Ok(mut info) => {
561                         for (pubkey, peer_addr) in info.drain() {
562                                 for chan_info in channel_manager.list_channels() {
563                                         if pubkey == chan_info.counterparty.node_id {
564                                                 let _ =
565                                                         cli::connect_peer_if_necessary(pubkey, peer_addr, peer_manager.clone())
566                                                                 .await;
567                                         }
568                                 }
569                         }
570                 }
571                 Err(e) => println!("ERROR: errored reading channel peer info from disk: {:?}", e),
572         }
573
574         // Regularly broadcast our node_announcement. This is only required (or possible) if we have
575         // some public channels, and is only useful if we have public listen address(es) to announce.
576         // In a production environment, this should occur only after the announcement of new channels
577         // to avoid churn in the global network graph.
578         let chan_manager = Arc::clone(&channel_manager);
579         let network = args.network;
580         if !args.ldk_announced_listen_addr.is_empty() {
581                 tokio::spawn(async move {
582                         let mut interval = tokio::time::interval(Duration::from_secs(60));
583                         loop {
584                                 interval.tick().await;
585                                 chan_manager.broadcast_node_announcement(
586                                         [0; 3],
587                                         args.ldk_announced_node_name,
588                                         args.ldk_announced_listen_addr.clone(),
589                                 );
590                         }
591                 });
592         }
593
594         // Start the CLI.
595         cli::poll_for_user_input(
596                 peer_manager.clone(),
597                 channel_manager.clone(),
598                 keys_manager.clone(),
599                 router.clone(),
600                 inbound_payments,
601                 outbound_payments,
602                 ldk_data_dir.clone(),
603                 logger.clone(),
604                 network,
605         )
606         .await;
607 }
608
609 #[tokio::main]
610 pub async fn main() {
611         start_ldk().await;
612 }