Skip to content

Document when event fields are Some #2269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lightning/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ pub enum Event {
payment_id: PaymentId,
/// The hash that was given to [`ChannelManager::send_payment`].
///
/// This will be `Some` for all payments which completed on LDK 0.0.104 or later.
///
/// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
payment_hash: Option<PaymentHash>,
/// The payment path that was successful.
Expand All @@ -518,6 +520,8 @@ pub enum Event {
PaymentPathFailed {
/// The `payment_id` passed to [`ChannelManager::send_payment`].
///
/// This will be `Some` for all payment paths which failed on LDK 0.0.103 or later.
///
/// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
/// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
payment_id: Option<PaymentId>,
Expand Down
5 changes: 4 additions & 1 deletion lightning/src/ln/outbound_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub(crate) enum PendingOutboundPayment {
/// and add a pending payment that was already fulfilled.
Fulfilled {
session_privs: HashSet<[u8; 32]>,
/// Filled in for any payment which moved to `Fulfilled` on LDK 0.0.104 or later.
payment_hash: Option<PaymentHash>,
timer_ticks_without_htlcs: u8,
},
Expand Down Expand Up @@ -1168,9 +1169,11 @@ impl OutboundPayments {
if let hash_map::Entry::Occupied(mut payment) = outbounds.entry(payment_id) {
assert!(payment.get().is_fulfilled());
if payment.get_mut().remove(&session_priv_bytes, None) {
let payment_hash = payment.get().payment_hash();
debug_assert!(payment_hash.is_some());
pending_events.push_back((events::Event::PaymentPathSuccessful {
payment_id,
payment_hash: payment.get().payment_hash(),
payment_hash,
path,
}, None));
}
Expand Down