We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6b43153 commit 00f578aCopy full SHA for 00f578a
lightning/src/events/mod.rs
@@ -72,6 +72,16 @@ pub enum PaymentPurpose {
72
SpontaneousPayment(PaymentPreimage),
73
}
74
75
+impl PaymentPurpose {
76
+ /// Returns the preimage for this payment, if it is known.
77
+ pub fn preimage(&self) -> Option<PaymentPreimage> {
78
+ match self {
79
+ PaymentPurpose::InvoicePayment { payment_preimage, .. } => *payment_preimage,
80
+ PaymentPurpose::SpontaneousPayment(preimage) => Some(*preimage),
81
+ }
82
83
+}
84
+
85
impl_writeable_tlv_based_enum!(PaymentPurpose,
86
(0, InvoicePayment) => {
87
(0, payment_preimage, option),
0 commit comments