From: Valentine Wallace Date: Thu, 18 Mar 2021 22:30:20 +0000 (-0400) Subject: Forward HTLCs after a timeout and a few other cleanups X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=80916829ec20eb8a510462e765a03c3ed051f2e0;p=ldk-sample Forward HTLCs after a timeout and a few other cleanups --- diff --git a/README.md b/README.md index 740aa25..4b9e99a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Sample node implementation using LDK. ## Installation ``` -git clone git@github.com:valentinewallace/ldk-sample.git +git clone git@github.com:lightningdevkit/ldk-sample.git ``` ## Usage diff --git a/src/main.rs b/src/main.rs index 421db95..37d464a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -130,6 +130,7 @@ fn handle_ldk_events(peer_manager: Arc, channel_manager: Arc, channel_manager: Arc { + Event::PaymentFailed { payment_hash, rejected_by_dest } => { print!("\nNEW EVENT: Failed to send payment to payment hash {:?}: ", hex_utils::hex_str(&payment_hash.0)); if rejected_by_dest { @@ -189,8 +190,14 @@ fn handle_ldk_events(peer_manager: Arc, channel_manager: Arc { - loop_channel_manager.process_pending_htlc_forwards(); + Event::PendingHTLCsForwardable { time_forwardable } => { + let forwarding_channel_manager = loop_channel_manager.clone(); + thread::spawn(move || { + let min = time_forwardable.as_secs(); + let seconds_to_sleep = thread_rng().gen_range(min, min * 5); + thread::sleep(Duration::new(seconds_to_sleep, 0)); + forwarding_channel_manager.process_pending_htlc_forwards(); + }); }, Event::SpendableOutputs { outputs } => { let destination_address = bitcoind_client.get_new_address();