Skip to content

Commit 0a0c54c

Browse files
authored
Merge pull request #2269 from TheBlueMatt/2023-05-doc-events-present
Document when event fields are `Some`
2 parents 570db8b + d8c0a2b commit 0a0c54c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lightning/src/events/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ pub enum Event {
498498
payment_id: PaymentId,
499499
/// The hash that was given to [`ChannelManager::send_payment`].
500500
///
501+
/// This will be `Some` for all payments which completed on LDK 0.0.104 or later.
502+
///
501503
/// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
502504
payment_hash: Option<PaymentHash>,
503505
/// The payment path that was successful.
@@ -518,6 +520,8 @@ pub enum Event {
518520
PaymentPathFailed {
519521
/// The `payment_id` passed to [`ChannelManager::send_payment`].
520522
///
523+
/// This will be `Some` for all payment paths which failed on LDK 0.0.103 or later.
524+
///
521525
/// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
522526
/// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
523527
payment_id: Option<PaymentId>,

lightning/src/ln/outbound_payment.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub(crate) enum PendingOutboundPayment {
6060
/// and add a pending payment that was already fulfilled.
6161
Fulfilled {
6262
session_privs: HashSet<[u8; 32]>,
63+
/// Filled in for any payment which moved to `Fulfilled` on LDK 0.0.104 or later.
6364
payment_hash: Option<PaymentHash>,
6465
timer_ticks_without_htlcs: u8,
6566
},
@@ -1168,9 +1169,11 @@ impl OutboundPayments {
11681169
if let hash_map::Entry::Occupied(mut payment) = outbounds.entry(payment_id) {
11691170
assert!(payment.get().is_fulfilled());
11701171
if payment.get_mut().remove(&session_priv_bytes, None) {
1172+
let payment_hash = payment.get().payment_hash();
1173+
debug_assert!(payment_hash.is_some());
11711174
pending_events.push_back((events::Event::PaymentPathSuccessful {
11721175
payment_id,
1173-
payment_hash: payment.get().payment_hash(),
1176+
payment_hash,
11741177
path,
11751178
}, None));
11761179
}

0 commit comments

Comments
 (0)