mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-03-15 15:39:09 +01:00
Merge pull request #2768 from benthecarman/preimage-helper
Add helper function for getting preimage from PaymentPurpose
This commit is contained in:
commit
1eddd1ef8f
1 changed files with 10 additions and 0 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Reference in a new issue