From a4672f6802f53a11fb553c7b3a3796592fb63d00 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Fri, 1 Mar 2024 22:37:56 +0100 Subject: [PATCH] Add string-serialized bolt11 invoice to PaymentDetails. --- bindings/ldk_node.udl | 1 + src/event.rs | 1 + src/lib.rs | 8 ++++++++ src/payment_store.rs | 6 +++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bindings/ldk_node.udl b/bindings/ldk_node.udl index ec5d8f993..e353b4054 100644 --- a/bindings/ldk_node.udl +++ b/bindings/ldk_node.udl @@ -209,6 +209,7 @@ dictionary PaymentDetails { PaymentDirection direction; PaymentStatus status; LSPFeeLimits? lsp_fee_limits; + string? bolt11_invoice; }; // [NonExhaustive] diff --git a/src/event.rs b/src/event.rs index bf683838a..00b33d274 100644 --- a/src/event.rs +++ b/src/event.rs @@ -556,6 +556,7 @@ where direction: PaymentDirection::Inbound, status: PaymentStatus::Succeeded, lsp_fee_limits: None, + bolt11_invoice: None, }; match self.payment_store.insert(payment) { diff --git a/src/lib.rs b/src/lib.rs index d0b6e9993..87b6ecb42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1089,6 +1089,7 @@ impl Node { direction: PaymentDirection::Outbound, status: PaymentStatus::Pending, lsp_fee_limits: None, + bolt11_invoice: Some(invoice.to_string()), }; self.payment_store.insert(payment)?; @@ -1109,6 +1110,7 @@ impl Node { direction: PaymentDirection::Outbound, status: PaymentStatus::Failed, lsp_fee_limits: None, + bolt11_invoice: Some(invoice.to_string()), }; self.payment_store.insert(payment)?; @@ -1197,6 +1199,7 @@ impl Node { direction: PaymentDirection::Outbound, status: PaymentStatus::Pending, lsp_fee_limits: None, + bolt11_invoice: Some(invoice.to_string()), }; self.payment_store.insert(payment)?; @@ -1218,6 +1221,7 @@ impl Node { direction: PaymentDirection::Outbound, status: PaymentStatus::Failed, lsp_fee_limits: None, + bolt11_invoice: Some(invoice.to_string()), }; self.payment_store.insert(payment)?; @@ -1273,6 +1277,7 @@ impl Node { direction: PaymentDirection::Outbound, amount_msat: Some(amount_msat), lsp_fee_limits: None, + bolt11_invoice: None, }; self.payment_store.insert(payment)?; @@ -1294,6 +1299,7 @@ impl Node { direction: PaymentDirection::Outbound, amount_msat: Some(amount_msat), lsp_fee_limits: None, + bolt11_invoice: None, }; self.payment_store.insert(payment)?; @@ -1468,6 +1474,7 @@ impl Node { direction: PaymentDirection::Inbound, status: PaymentStatus::Pending, lsp_fee_limits: None, + bolt11_invoice: Some(invoice.to_string()), }; self.payment_store.insert(payment)?; @@ -1595,6 +1602,7 @@ impl Node { direction: PaymentDirection::Inbound, status: PaymentStatus::Pending, lsp_fee_limits, + bolt11_invoice: Some(invoice.to_string()), }; self.payment_store.insert(payment)?; diff --git a/src/payment_store.rs b/src/payment_store.rs index 704966878..6fd13ee5f 100644 --- a/src/payment_store.rs +++ b/src/payment_store.rs @@ -39,6 +39,8 @@ pub struct PaymentDetails { /// /// [`LdkChannelConfig::accept_underpaying_htlcs`]: lightning::util::config::ChannelConfig::accept_underpaying_htlcs pub lsp_fee_limits: Option, + /// The invoice that was paid. + pub bolt11_invoice: Option, } impl_writeable_tlv_based!(PaymentDetails, { @@ -48,7 +50,8 @@ impl_writeable_tlv_based!(PaymentDetails, { (4, secret, required), (6, amount_msat, required), (8, direction, required), - (10, status, required) + (10, status, required), + (131072, bolt11_invoice, option), }); /// Represents the direction of a payment. @@ -284,6 +287,7 @@ mod tests { direction: PaymentDirection::Inbound, status: PaymentStatus::Pending, lsp_fee_limits: None, + bolt11_invoice: None, }; assert_eq!(Ok(false), payment_store.insert(payment.clone()));