Skip to content

Commit e1394f3

Browse files
committed
Document when PaymentPathSuccessful::payment_hash is filled in.
The `payment_hash` field in `PaymentPathSuccessful` is always `Some` as long as the pening payment tracker has a `payment_hash`, which is true for all `Pending` payments as well as all `Fulfilled` payments starting with the commit which added `PaymentPathSuccessful` - 3b5c370b404e2f5a8f3c35093b97406f149a9340c177c05252574083d68df0da.
1 parent e94647c commit e1394f3

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lightning/src/events/mod.rs

Lines changed: 2 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.

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)