+ Event::HTLCHandlingFailed { .. } => {}
+ Event::PendingHTLCsForwardable { time_forwardable } => {
+ let forwarding_channel_manager = channel_manager.clone();
+ let min = time_forwardable.as_millis() as u64;
+ tokio::spawn(async move {
+ let millis_to_sleep = thread_rng().gen_range(min, min * 5) as u64;
+ tokio::time::sleep(Duration::from_millis(millis_to_sleep)).await;
+ forwarding_channel_manager.process_pending_htlc_forwards();
+ });
+ }
+ Event::SpendableOutputs { outputs, channel_id: _ } => {
+ // SpendableOutputDescriptors, of which outputs is a vec of, are critical to keep track
+ // of! While a `StaticOutput` descriptor is just an output to a static, well-known key,
+ // other descriptors are not currently ever regenerated for you by LDK. Once we return
+ // from this method, the descriptor will be gone, and you may lose track of some funds.
+ //
+ // Here we simply persist them to disk, with a background task running which will try
+ // to spend them regularly (possibly duplicatively/RBF'ing them). These can just be
+ // treated as normal funds where possible - they are only spendable by us and there is
+ // no rush to claim them.
+ for output in outputs {
+ let key = hex_utils::hex_str(&keys_manager.get_secure_random_bytes());
+ // Note that if the type here changes our read code needs to change as well.
+ let output: SpendableOutputDescriptor = output;
+ fs_store.write(PENDING_SPENDABLE_OUTPUT_DIR, "", &key, &output.encode()).unwrap();
+ }
+ }
+ Event::ChannelPending { channel_id, counterparty_node_id, .. } => {
+ println!(
+ "\nEVENT: Channel {} with peer {} is pending awaiting funding lock-in!",
+ channel_id,
+ hex_utils::hex_str(&counterparty_node_id.serialize()),
+ );
+ print!("> ");
+ io::stdout().flush().unwrap();
+ }
+ Event::ChannelReady {
+ ref channel_id,
+ user_channel_id: _,
+ ref counterparty_node_id,
+ channel_type: _,
+ } => {
+ println!(
+ "\nEVENT: Channel {} with peer {} is ready to be used!",
+ channel_id,
+ hex_utils::hex_str(&counterparty_node_id.serialize()),
+ );
+ print!("> ");
+ io::stdout().flush().unwrap();
+ }
+ Event::ChannelClosed {
+ channel_id,
+ reason,
+ user_channel_id: _,
+ counterparty_node_id,
+ channel_capacity_sats: _,
+ channel_funding_txo: _,
+ } => {
+ println!(
+ "\nEVENT: Channel {} with counterparty {} closed due to: {:?}",
+ channel_id,
+ counterparty_node_id.map(|id| format!("{}", id)).unwrap_or("".to_owned()),
+ reason
+ );
+ print!("> ");
+ io::stdout().flush().unwrap();
+ }
+ Event::DiscardFunding { .. } => {
+ // A "real" node should probably "lock" the UTXOs spent in funding transactions until
+ // the funding transaction either confirms, or this event is generated.
+ }
+ Event::HTLCIntercepted { .. } => {}
+ Event::BumpTransaction(event) => bump_tx_event_handler.handle_event(&event),
+ Event::ConnectionNeeded { .. } => {}