projects
/
rust-lightning
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6b43153
)
Add helper function for getting preimage from PaymentPurpose
author
benthecarman
<benthecarman@live.com>
Sun, 3 Dec 2023 18:42:17 +0000
(12:42 -0600)
committer
benthecarman
<benthecarman@live.com>
Sun, 3 Dec 2023 18:42:17 +0000
(12:42 -0600)
lightning/src/events/mod.rs
patch
|
blob
|
history
diff --git
a/lightning/src/events/mod.rs
b/lightning/src/events/mod.rs
index adbc7faf7e0f9d0acf1fa3349495733669d41193..4e04a3634e10d3f9152ae6d074bb19365bf989a4 100644
(file)
--- a/
lightning/src/events/mod.rs
+++ b/
lightning/src/events/mod.rs
@@
-72,6
+72,16
@@
pub enum PaymentPurpose {
SpontaneousPayment(PaymentPreimage),
}
+impl PaymentPurpose {
+ /// Returns the preimage for this payment, if it is known.
+ pub fn preimage(&self) -> Option<PaymentPreimage> {
+ match self {
+ PaymentPurpose::InvoicePayment { payment_preimage, .. } => *payment_preimage,
+ PaymentPurpose::SpontaneousPayment(preimage) => Some(*preimage),
+ }
+ }
+}
+
impl_writeable_tlv_based_enum!(PaymentPurpose,
(0, InvoicePayment) => {
(0, payment_preimage, option),