Do not panic if we fail to fund a channel
[ldk-sample] / src / main.rs
index 3932a58192432302f4f426cf690666e672157731..b7d74aa0ffb57c0ed427ead353f162b3acd20dbd 100644 (file)
@@ -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();