]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Document when `PaymentPathSuccessful::payment_hash` is filled in.
authorMatt Corallo <git@bluematt.me>
Fri, 5 May 2023 03:33:54 +0000 (03:33 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 5 May 2023 03:33:54 +0000 (03:33 +0000)
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.

lightning/src/events/mod.rs
lightning/src/ln/outbound_payment.rs

index 4d8b8cee94b32c906784dfdd1b79ad282c75acb2..046eb22f731535ca3b001a8e6b9b03c25adc50f1 100644 (file)
@@ -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.
index 569e664bad18302ec9cc801ef401874da9d7f2e4..f107f3b558395fe7ea9da8f8a8194f8f52a9f634 100644 (file)
@@ -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,
        },
@@ -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));
                                        }