]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add PaymentPurpose::is_keysend utility method
authorJeffrey Czyz <jkczyz@gmail.com>
Sat, 13 Apr 2024 02:21:00 +0000 (21:21 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Thu, 18 Apr 2024 14:15:22 +0000 (09:15 -0500)
lightning/src/events/mod.rs
lightning/src/ln/channelmanager.rs

index d6553ae3aa22989f60b6508f7a17a97d990121ed..41ba17806d35b5c5bf31cdb51423775a7d8120cd 100644 (file)
@@ -83,6 +83,13 @@ impl PaymentPurpose {
                        PaymentPurpose::SpontaneousPayment(preimage) => Some(*preimage),
                }
        }
+
+       pub(crate) fn is_keysend(&self) -> bool {
+               match self {
+                       PaymentPurpose::Bolt11InvoicePayment { .. } => false,
+                       PaymentPurpose::SpontaneousPayment(..) => true,
+               }
+       }
 }
 
 impl_writeable_tlv_based_enum!(PaymentPurpose,
index d9ce1940c64c7ff6bf5526b4a72fcf89d90b232c..0693f3c642ea735048d4c119d01754769c89514e 100644 (file)
@@ -5431,10 +5431,7 @@ where
                                                                macro_rules! check_total_value {
                                                                        ($purpose: expr) => {{
                                                                                let mut payment_claimable_generated = false;
-                                                                               let is_keysend = match $purpose {
-                                                                                       events::PaymentPurpose::SpontaneousPayment(_) => true,
-                                                                                       events::PaymentPurpose::Bolt11InvoicePayment { .. } => false,
-                                                                               };
+                                                                               let is_keysend = $purpose.is_keysend();
                                                                                let mut claimable_payments = self.claimable_payments.lock().unwrap();
                                                                                if claimable_payments.pending_claiming_payments.contains_key(&payment_hash) {
                                                                                        fail_htlc!(claimable_htlc, payment_hash);