From: Matt Corallo Date: Mon, 5 Jul 2021 02:34:33 +0000 (+0000) Subject: Do not panic if we fail to fund a channel X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=5ff97eca45db6c8e3498c88a1f2cca99dec14208;p=ldk-sample Do not panic if we fail to fund a channel I saw this where a bitcoind was hung connecting a block, and while we were waiting the peer refused the channel via an error message. When bitcoind eventually returned, we paniced as the channel was now gone. --- diff --git a/src/main.rs b/src/main.rs index 3932a58..b7d74aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -139,7 +139,15 @@ async fn handle_ldk_events( let final_tx: Transaction = encode::deserialize(&hex_utils::to_vec(&signed_tx.hex).unwrap()).unwrap(); // Give the funding transaction back to LDK for opening the channel. - channel_manager.funding_transaction_generated(&temporary_channel_id, final_tx).unwrap(); + if channel_manager + .funding_transaction_generated(&temporary_channel_id, final_tx) + .is_err() + { + println!( + "\nERROR: Channel went away before we could fund it. The peer disconnected or refused the channel."); + print!("> "); + io::stdout().flush().unwrap(); + } } Event::PaymentReceived { payment_hash, payment_preimage, payment_secret, amt, .. } => { let mut payments = inbound_payments.lock().unwrap();