Skip to content

Commit 7efad83

Browse files
committed
Add payment_hash to payment details
1 parent fb0b1af commit 7efad83

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,19 +1209,28 @@ impl ChannelDetails {
12091209
pub enum PendingPaymentDetails {
12101210
/// When a payment is still being sent and awaiting successful delivery.
12111211
Retryable {
1212+
/// Hash of the payment that is currently being sent but has yet to be fulfilled or
1213+
/// abandoned.
1214+
payment_hash: PaymentHash,
12121215
/// Total amount (in msat) across all paths for this payment, not just the amount currently
12131216
/// inflight.
1214-
total_msat: u64
1217+
total_msat: u64,
12151218
},
12161219
/// When a pending payment is fulfilled, we continue tracking it until all pending HTLCs have
12171220
/// been resolved. These payments will only cease being tracked upon receiving or handling
12181221
/// [`Event::PaymentSent`].
1219-
Fulfilled,
1222+
Fulfilled {
1223+
/// Hash of the payment that was claimed.
1224+
payment_hash: Option<PaymentHash>,
1225+
},
12201226
/// After a payment is explicitly abandoned by calling [`ChannelManager::abandon_payment`], they
12211227
/// are marked as abandoned until an [`Event::PaymentFailed`] event is generated. A payment
12221228
/// could also be marked as abandoned if pathfinding fails repeatedly and we will no longer
12231229
/// retry sending.
1224-
Abandoned,
1230+
Abandoned {
1231+
/// Hash of the payment that we have given up trying to send.
1232+
payment_hash: PaymentHash,
1233+
},
12251234
}
12261235

12271236
/// If a payment fails to send, it can be in one of several states. This enum is returned as the
@@ -1795,14 +1804,17 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
17951804
pub fn list_pending_payments(&self) -> Vec<PendingPaymentDetails> {
17961805
self.pending_outbound_payments.lock().unwrap().iter()
17971806
.filter_map(|(_, pending_outbound_payment)| match pending_outbound_payment {
1798-
PendingOutboundPayment::Retryable { total_msat, .. } => {
1799-
Some(PendingPaymentDetails::Retryable { total_msat: *total_msat })
1807+
PendingOutboundPayment::Retryable { payment_hash, total_msat, .. } => {
1808+
Some(PendingPaymentDetails::Retryable {
1809+
payment_hash: *payment_hash,
1810+
total_msat: *total_msat,
1811+
})
18001812
},
1801-
PendingOutboundPayment::Abandoned { .. } => {
1802-
Some(PendingPaymentDetails::Abandoned)
1813+
PendingOutboundPayment::Abandoned { payment_hash, .. } => {
1814+
Some(PendingPaymentDetails::Abandoned { payment_hash: *payment_hash })
18031815
},
1804-
PendingOutboundPayment::Fulfilled { .. } => {
1805-
Some(PendingPaymentDetails::Fulfilled)
1816+
PendingOutboundPayment::Fulfilled { payment_hash, .. } => {
1817+
Some(PendingPaymentDetails::Fulfilled { payment_hash: *payment_hash })
18061818
},
18071819
PendingOutboundPayment::Legacy { .. } => None
18081820
})

0 commit comments

Comments
 (0)