Rename `DirectedChannelInfo::outbound` to `from_node_one`
[rust-lightning] / lightning / src / events / mod.rs
index adbc7faf7e0f9d0acf1fa3349495733669d41193..4e04a3634e10d3f9152ae6d074bb19365bf989a4 100644 (file)
@@ -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),