diff --git a/sim-lib/src/lib.rs b/sim-lib/src/lib.rs index f7b3df10..1eece823 100644 --- a/sim-lib/src/lib.rs +++ b/sim-lib/src/lib.rs @@ -819,32 +819,37 @@ async fn produce_random_events { - let destination = network_generator.lock().await.sample_node_by_capacity(source.pubkey); + let (destination, capacity) = network_generator.lock().await.sample_node_by_capacity(source.pubkey); + + if !destination.features.supports_keysend() { + log::debug!("Destination does not support keysend, skipping payment: {source} -> {destination}"); + continue; + }; // Only proceed with a payment if the amount is non-zero, otherwise skip this round. If we can't get // a payment amount something has gone wrong (because we should have validated that we can always // generate amounts), so we exit. - let amount = match node_generator.payment_amount(destination.1) { + let amount = match node_generator.payment_amount(capacity) { Ok(amt) => { if amt == 0 { - log::debug!("Skipping zero amount payment for {source} -> {}.", destination.0); + log::debug!("Skipping zero amount payment for {source} -> {destination}."); continue; } amt }, Err(e) => { - log::error!("Could not get amount for {source} -> {}: {e}. Please report a bug!", destination.0); + log::error!("Could not get amount for {source} -> {destination}: {e}. Please report a bug!"); break; }, }; - log::debug!("Generated random payment: {source} -> {}: {amount} msat.", destination.0); + log::debug!("Generated random payment: {source} -> {}: {amount} msat.", destination); // Send the payment, exiting if we can no longer send to the consumer. - let event = SimulationEvent::SendPayment(destination.0.clone(), amount); + let event = SimulationEvent::SendPayment(destination.clone(), amount); if let Err(e) = sender.send(event).await { log::debug!( - "Stopped random producer for {amount}: {source} -> {}. Consumer error: {e}.", destination.0, + "Stopped random producer for {amount}: {source} -> {destination}. Consumer error: {e}.", ); break; }