# Handling Events

LDK requires that you handle many different events throughout your app's life cycle. You can learn more by reading about our event-driven architecture.

To start handling events in your application, run:

  • Rust
  • Kotlin
  • Swift
use lightning::util::events::{Event};

// In the event handler passed to BackgroundProcessor::start
match event {
  Event::PaymentSent { payment_preimage } => {
    // Handle successful payment
  }
  Event::PaymentFailed { payment_hash, rejected_by_dest } => {
    // Handle failed payment
  }
  Event::FundingGenerationReady { .. } => {
    // Generate the funding transaction for the channel
  }
}

References: Rust Event docs (opens new window), Java/Kotlin Event bindings (opens new window)

Last Updated: 11/18/2024, 6:18:24 PM