From 7e8a8aba57751eba7dc1feee7218f680093874fc Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Tue, 21 Jan 2025 16:00:58 +0100 Subject: [PATCH] Extend API to allow invoice creation with a description hash --- .../lightningdevkit/ldknode/LibraryTest.kt | 3 +- bindings/ldk_node.udl | 18 +- bindings/python/src/ldk_node/test_ldk_node.py | 3 +- src/liquidity.rs | 12 +- src/payment/bolt11.rs | 157 ++++++++++++++++-- src/payment/mod.rs | 1 + src/payment/unified_qr.rs | 25 ++- src/uniffi_types.rs | 2 + tests/common/mod.rs | 38 ++++- tests/integration_tests_cln.rs | 6 +- tests/integration_tests_rust.rs | 8 +- 11 files changed, 224 insertions(+), 49 deletions(-) diff --git a/bindings/kotlin/ldk-node-jvm/lib/src/test/kotlin/org/lightningdevkit/ldknode/LibraryTest.kt b/bindings/kotlin/ldk-node-jvm/lib/src/test/kotlin/org/lightningdevkit/ldknode/LibraryTest.kt index 786534b84..0feaccf1d 100644 --- a/bindings/kotlin/ldk-node-jvm/lib/src/test/kotlin/org/lightningdevkit/ldknode/LibraryTest.kt +++ b/bindings/kotlin/ldk-node-jvm/lib/src/test/kotlin/org/lightningdevkit/ldknode/LibraryTest.kt @@ -222,7 +222,8 @@ class LibraryTest { else -> return } - val invoice = node2.bolt11Payment().receive(2500000u, "asdf", 9217u) + val description = Bolt11InvoiceDescription.Direct("asdf") + val invoice = node2.bolt11Payment().receive(2500000u, description, 9217u) node1.bolt11Payment().send(invoice, null) diff --git a/bindings/ldk_node.udl b/bindings/ldk_node.udl index 5ea0e4173..2d93fb397 100644 --- a/bindings/ldk_node.udl +++ b/bindings/ldk_node.udl @@ -106,6 +106,12 @@ interface Node { boolean verify_signature([ByRef]sequence msg, [ByRef]string sig, [ByRef]PublicKey pkey); }; +[Enum] +interface Bolt11InvoiceDescription { + Hash(string hash); + Direct(string description); +}; + interface Bolt11Payment { [Throws=NodeError] PaymentId send([ByRef]Bolt11Invoice invoice, SendingParameters? sending_parameters); @@ -120,17 +126,17 @@ interface Bolt11Payment { [Throws=NodeError] void fail_for_hash(PaymentHash payment_hash); [Throws=NodeError] - Bolt11Invoice receive(u64 amount_msat, [ByRef]string description, u32 expiry_secs); + Bolt11Invoice receive(u64 amount_msat, [ByRef]Bolt11InvoiceDescription description, u32 expiry_secs); [Throws=NodeError] - Bolt11Invoice receive_for_hash(u64 amount_msat, [ByRef]string description, u32 expiry_secs, PaymentHash payment_hash); + Bolt11Invoice receive_for_hash(u64 amount_msat, [ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, PaymentHash payment_hash); [Throws=NodeError] - Bolt11Invoice receive_variable_amount([ByRef]string description, u32 expiry_secs); + Bolt11Invoice receive_variable_amount([ByRef]Bolt11InvoiceDescription description, u32 expiry_secs); [Throws=NodeError] - Bolt11Invoice receive_variable_amount_for_hash([ByRef]string description, u32 expiry_secs, PaymentHash payment_hash); + Bolt11Invoice receive_variable_amount_for_hash([ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, PaymentHash payment_hash); [Throws=NodeError] - Bolt11Invoice receive_via_jit_channel(u64 amount_msat, [ByRef]string description, u32 expiry_secs, u64? max_lsp_fee_limit_msat); + Bolt11Invoice receive_via_jit_channel(u64 amount_msat, [ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, u64? max_lsp_fee_limit_msat); [Throws=NodeError] - Bolt11Invoice receive_variable_amount_via_jit_channel([ByRef]string description, u32 expiry_secs, u64? max_proportional_lsp_fee_limit_ppm_msat); + Bolt11Invoice receive_variable_amount_via_jit_channel([ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, u64? max_proportional_lsp_fee_limit_ppm_msat); }; interface Bolt12Payment { diff --git a/bindings/python/src/ldk_node/test_ldk_node.py b/bindings/python/src/ldk_node/test_ldk_node.py index 82c493e32..4c5cdd828 100644 --- a/bindings/python/src/ldk_node/test_ldk_node.py +++ b/bindings/python/src/ldk_node/test_ldk_node.py @@ -185,7 +185,8 @@ def test_channel_full_cycle(self): print("EVENT:", channel_ready_event_2) node_2.event_handled() - invoice = node_2.bolt11_payment().receive(2500000, "asdf", 9217) + description = Bolt11InvoiceDescription.DIRECT("asdf") + invoice = node_2.bolt11_payment().receive(2500000, description, 9217) node_1.bolt11_payment().send(invoice, None) payment_successful_event_1 = node_1.wait_next_event() diff --git a/src/liquidity.rs b/src/liquidity.rs index 1dfb5453a..0188b939b 100644 --- a/src/liquidity.rs +++ b/src/liquidity.rs @@ -12,7 +12,7 @@ use crate::{Config, Error}; use lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA; use lightning::ln::msgs::SocketAddress; use lightning::routing::router::{RouteHint, RouteHintHop}; -use lightning_invoice::{Bolt11Invoice, InvoiceBuilder, RoutingFees}; +use lightning_invoice::{Bolt11Invoice, Bolt11InvoiceDescription, InvoiceBuilder, RoutingFees}; use lightning_liquidity::events::Event; use lightning_liquidity::lsps0::ser::RequestId; use lightning_liquidity::lsps2::event::LSPS2ClientEvent; @@ -196,7 +196,7 @@ where } pub(crate) async fn lsps2_receive_to_jit_channel( - &self, amount_msat: u64, description: &str, expiry_secs: u32, + &self, amount_msat: u64, description: &Bolt11InvoiceDescription, expiry_secs: u32, max_total_lsp_fee_limit_msat: Option, ) -> Result<(Bolt11Invoice, u64), Error> { let fee_response = self.lsps2_request_opening_fee_params().await?; @@ -256,7 +256,7 @@ where } pub(crate) async fn lsps2_receive_variable_amount_to_jit_channel( - &self, description: &str, expiry_secs: u32, + &self, description: &Bolt11InvoiceDescription, expiry_secs: u32, max_proportional_lsp_fee_limit_ppm_msat: Option, ) -> Result<(Bolt11Invoice, u64), Error> { let fee_response = self.lsps2_request_opening_fee_params().await?; @@ -373,8 +373,8 @@ where } fn lsps2_create_jit_invoice( - &self, buy_response: LSPS2BuyResponse, amount_msat: Option, description: &str, - expiry_secs: u32, + &self, buy_response: LSPS2BuyResponse, amount_msat: Option, + description: &Bolt11InvoiceDescription, expiry_secs: u32, ) -> Result { let lsps2_service = self.lsps2_service.as_ref().ok_or(Error::LiquiditySourceUnavailable)?; @@ -404,7 +404,7 @@ where let currency = self.config.network.into(); let mut invoice_builder = InvoiceBuilder::new(currency) - .description(description.to_string()) + .invoice_description(description.clone()) .payment_hash(payment_hash) .payment_secret(payment_secret) .current_timestamp() diff --git a/src/payment/bolt11.rs b/src/payment/bolt11.rs index d2a5840c0..96cc03986 100644 --- a/src/payment/bolt11.rs +++ b/src/payment/bolt11.rs @@ -12,6 +12,7 @@ use crate::config::{Config, LDK_PAYMENT_RETRY_TIMEOUT}; use crate::connection::ConnectionManager; use crate::error::Error; +use crate::hex_utils; use crate::liquidity::LiquiditySource; use crate::logger::{log_error, log_info, FilesystemLogger, Logger}; use crate::payment::store::{ @@ -30,11 +31,12 @@ use lightning::routing::router::{PaymentParameters, RouteParameters}; use lightning_types::payment::{PaymentHash, PaymentPreimage}; -use lightning_invoice::{Bolt11Invoice, Bolt11InvoiceDescription, Description}; +use lightning_invoice::{Bolt11Invoice, Description}; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::hashes::Hash; +use std::str::FromStr; use std::sync::{Arc, RwLock}; /// A payment handler allowing to create and pay [BOLT 11] invoices. @@ -403,12 +405,23 @@ impl Bolt11Payment { /// given. /// /// The inbound payment will be automatically claimed upon arrival. + #[cfg(not(feature = "uniffi"))] pub fn receive( - &self, amount_msat: u64, description: &str, expiry_secs: u32, + &self, amount_msat: u64, description: &lightning_invoice::Bolt11InvoiceDescription, + expiry_secs: u32, ) -> Result { self.receive_inner(Some(amount_msat), description, expiry_secs, None) } + #[cfg(feature = "uniffi")] + pub fn receive( + &self, amount_msat: u64, description: &Bolt11InvoiceDescription, expiry_secs: u32, + ) -> Result { + let invoice_description = + lightning_invoice::Bolt11InvoiceDescription::try_from(description)?; + self.receive_inner(Some(amount_msat), &invoice_description, expiry_secs, None) + } + /// Returns a payable invoice that can be used to request a payment of the amount /// given for the given payment hash. /// @@ -423,22 +436,44 @@ impl Bolt11Payment { /// [`PaymentClaimable`]: crate::Event::PaymentClaimable /// [`claim_for_hash`]: Self::claim_for_hash /// [`fail_for_hash`]: Self::fail_for_hash + #[cfg(not(feature = "uniffi"))] pub fn receive_for_hash( - &self, amount_msat: u64, description: &str, expiry_secs: u32, payment_hash: PaymentHash, + &self, amount_msat: u64, description: &lightning_invoice::Bolt11InvoiceDescription, + expiry_secs: u32, payment_hash: PaymentHash, ) -> Result { self.receive_inner(Some(amount_msat), description, expiry_secs, Some(payment_hash)) } + #[cfg(feature = "uniffi")] + pub fn receive_for_hash( + &self, amount_msat: u64, description: &Bolt11InvoiceDescription, expiry_secs: u32, + payment_hash: PaymentHash, + ) -> Result { + let invoice_description = + lightning_invoice::Bolt11InvoiceDescription::try_from(description)?; + self.receive_inner(Some(amount_msat), &invoice_description, expiry_secs, Some(payment_hash)) + } + /// Returns a payable invoice that can be used to request and receive a payment for which the /// amount is to be determined by the user, also known as a "zero-amount" invoice. /// /// The inbound payment will be automatically claimed upon arrival. + #[cfg(not(feature = "uniffi"))] pub fn receive_variable_amount( - &self, description: &str, expiry_secs: u32, + &self, description: &lightning_invoice::Bolt11InvoiceDescription, expiry_secs: u32, ) -> Result { self.receive_inner(None, description, expiry_secs, None) } + #[cfg(feature = "uniffi")] + pub fn receive_variable_amount( + &self, description: &Bolt11InvoiceDescription, expiry_secs: u32, + ) -> Result { + let invoice_description = + lightning_invoice::Bolt11InvoiceDescription::try_from(description)?; + self.receive_inner(None, &invoice_description, expiry_secs, None) + } + /// Returns a payable invoice that can be used to request a payment for the given payment hash /// and the amount to be determined by the user, also known as a "zero-amount" invoice. /// @@ -453,24 +488,32 @@ impl Bolt11Payment { /// [`PaymentClaimable`]: crate::Event::PaymentClaimable /// [`claim_for_hash`]: Self::claim_for_hash /// [`fail_for_hash`]: Self::fail_for_hash + #[cfg(not(feature = "uniffi"))] pub fn receive_variable_amount_for_hash( - &self, description: &str, expiry_secs: u32, payment_hash: PaymentHash, + &self, description: &lightning_invoice::Bolt11InvoiceDescription, expiry_secs: u32, + payment_hash: PaymentHash, ) -> Result { self.receive_inner(None, description, expiry_secs, Some(payment_hash)) } - fn receive_inner( - &self, amount_msat: Option, description: &str, expiry_secs: u32, - manual_claim_payment_hash: Option, + #[cfg(feature = "uniffi")] + pub fn receive_variable_amount_for_hash( + &self, description: &Bolt11InvoiceDescription, expiry_secs: u32, payment_hash: PaymentHash, ) -> Result { - let invoice_description = Bolt11InvoiceDescription::Direct( - Description::new(description.to_string()).map_err(|_| Error::InvoiceCreationFailed)?, - ); + let invoice_description = + lightning_invoice::Bolt11InvoiceDescription::try_from(description)?; + self.receive_inner(None, &invoice_description, expiry_secs, Some(payment_hash)) + } + pub(crate) fn receive_inner( + &self, amount_msat: Option, + invoice_description: &lightning_invoice::Bolt11InvoiceDescription, expiry_secs: u32, + manual_claim_payment_hash: Option, + ) -> Result { let invoice = { let invoice_params = Bolt11InvoiceParameters { amount_msats: amount_msat, - description: invoice_description, + description: invoice_description.clone(), invoice_expiry_delta_secs: Some(expiry_secs), payment_hash: manual_claim_payment_hash, ..Default::default() @@ -530,9 +573,10 @@ impl Bolt11Payment { /// channel to us. We'll use its cheapest offer otherwise. /// /// [LSPS2]: https://github.com/BitcoinAndLightningLayerSpecs/lsp/blob/main/LSPS2/README.md + #[cfg(not(feature = "uniffi"))] pub fn receive_via_jit_channel( - &self, amount_msat: u64, description: &str, expiry_secs: u32, - max_total_lsp_fee_limit_msat: Option, + &self, amount_msat: u64, description: &lightning_invoice::Bolt11InvoiceDescription, + expiry_secs: u32, max_total_lsp_fee_limit_msat: Option, ) -> Result { self.receive_via_jit_channel_inner( Some(amount_msat), @@ -543,6 +587,22 @@ impl Bolt11Payment { ) } + #[cfg(feature = "uniffi")] + pub fn receive_via_jit_channel( + &self, amount_msat: u64, description: &Bolt11InvoiceDescription, expiry_secs: u32, + max_total_lsp_fee_limit_msat: Option, + ) -> Result { + let invoice_description = + lightning_invoice::Bolt11InvoiceDescription::try_from(description)?; + self.receive_via_jit_channel_inner( + Some(amount_msat), + &invoice_description, + expiry_secs, + max_total_lsp_fee_limit_msat, + None, + ) + } + /// Returns a payable invoice that can be used to request a variable amount payment (also known /// as "zero-amount" invoice) and receive it via a newly created just-in-time (JIT) channel. /// @@ -554,8 +614,9 @@ impl Bolt11Payment { /// We'll use its cheapest offer otherwise. /// /// [LSPS2]: https://github.com/BitcoinAndLightningLayerSpecs/lsp/blob/main/LSPS2/README.md + #[cfg(not(feature = "uniffi"))] pub fn receive_variable_amount_via_jit_channel( - &self, description: &str, expiry_secs: u32, + &self, description: &lightning_invoice::Bolt11InvoiceDescription, expiry_secs: u32, max_proportional_lsp_fee_limit_ppm_msat: Option, ) -> Result { self.receive_via_jit_channel_inner( @@ -567,9 +628,25 @@ impl Bolt11Payment { ) } + #[cfg(feature = "uniffi")] + pub fn receive_variable_amount_via_jit_channel( + &self, description: &Bolt11InvoiceDescription, expiry_secs: u32, + max_proportional_lsp_fee_limit_ppm_msat: Option, + ) -> Result { + let invoice_description = + lightning_invoice::Bolt11InvoiceDescription::try_from(description)?; + self.receive_via_jit_channel_inner( + None, + &invoice_description, + expiry_secs, + None, + max_proportional_lsp_fee_limit_ppm_msat, + ) + } + fn receive_via_jit_channel_inner( - &self, amount_msat: Option, description: &str, expiry_secs: u32, - max_total_lsp_fee_limit_msat: Option, + &self, amount_msat: Option, description: &lightning_invoice::Bolt11InvoiceDescription, + expiry_secs: u32, max_total_lsp_fee_limit_msat: Option, max_proportional_lsp_fee_limit_ppm_msat: Option, ) -> Result { let liquidity_source = @@ -740,3 +817,49 @@ impl Bolt11Payment { Ok(()) } } + +/// Represents the description of an invoice which has to be either a directly included string or +/// a hash of a description provided out of band. +pub enum Bolt11InvoiceDescription { + /// Contains a full description. + Direct { + /// Description of what the invoice is for + description: String, + }, + /// Contains a hash. + Hash { + /// Hash of the description of what the invoice is for + hash: String, + }, +} + +impl TryFrom<&Bolt11InvoiceDescription> for lightning_invoice::Bolt11InvoiceDescription { + type Error = Error; + + fn try_from(value: &Bolt11InvoiceDescription) -> Result { + match value { + Bolt11InvoiceDescription::Direct { description } => { + Description::new(description.clone()) + .map(lightning_invoice::Bolt11InvoiceDescription::Direct) + .map_err(|_| Error::InvoiceCreationFailed) + }, + Bolt11InvoiceDescription::Hash { hash } => Sha256::from_str(&hash) + .map(lightning_invoice::Sha256) + .map(lightning_invoice::Bolt11InvoiceDescription::Hash) + .map_err(|_| Error::InvoiceCreationFailed), + } + } +} + +impl From for Bolt11InvoiceDescription { + fn from(value: lightning_invoice::Bolt11InvoiceDescription) -> Self { + match value { + lightning_invoice::Bolt11InvoiceDescription::Direct(description) => { + Bolt11InvoiceDescription::Direct { description: description.to_string() } + }, + lightning_invoice::Bolt11InvoiceDescription::Hash(hash) => { + Bolt11InvoiceDescription::Hash { hash: hex_utils::to_string(hash.0.as_ref()) } + }, + } + } +} diff --git a/src/payment/mod.rs b/src/payment/mod.rs index 5c99cfcf8..609e1ac9d 100644 --- a/src/payment/mod.rs +++ b/src/payment/mod.rs @@ -14,6 +14,7 @@ mod spontaneous; pub(crate) mod store; mod unified_qr; +pub use bolt11::Bolt11InvoiceDescription; pub use bolt11::Bolt11Payment; pub use bolt12::Bolt12Payment; pub use onchain::OnchainPayment; diff --git a/src/payment/unified_qr.rs b/src/payment/unified_qr.rs index 029416b84..9c8a0c63b 100644 --- a/src/payment/unified_qr.rs +++ b/src/payment/unified_qr.rs @@ -18,7 +18,7 @@ use crate::Config; use lightning::ln::channelmanager::PaymentId; use lightning::offers::offer::Offer; -use lightning_invoice::Bolt11Invoice; +use lightning_invoice::{Bolt11Invoice, Bolt11InvoiceDescription, Description}; use bip21::de::ParamKind; use bip21::{DeserializationError, DeserializeParams, Param, SerializeParams}; @@ -99,14 +99,21 @@ impl UnifiedQrPayment { }, }; - let bolt11_invoice = - match self.bolt11_invoice.receive(amount_msats, description, expiry_sec) { - Ok(invoice) => Some(invoice), - Err(e) => { - log_error!(self.logger, "Failed to create invoice {}", e); - return Err(Error::InvoiceCreationFailed); - }, - }; + let invoice_description = Bolt11InvoiceDescription::Direct( + Description::new(description.to_string()).map_err(|_| Error::InvoiceCreationFailed)?, + ); + let bolt11_invoice = match self.bolt11_invoice.receive_inner( + Some(amount_msats), + &invoice_description, + expiry_sec, + None, + ) { + Ok(invoice) => Some(invoice), + Err(e) => { + log_error!(self.logger, "Failed to create invoice {}", e); + return Err(Error::InvoiceCreationFailed); + }, + }; let extras = Extras { bolt11_invoice, bolt12_offer }; diff --git a/src/uniffi_types.rs b/src/uniffi_types.rs index 89e11efc5..17b2ef625 100644 --- a/src/uniffi_types.rs +++ b/src/uniffi_types.rs @@ -36,6 +36,8 @@ pub use bip39::Mnemonic; pub use vss_client::headers::{VssHeaderProvider, VssHeaderProviderError}; +pub use crate::payment::Bolt11InvoiceDescription; + use crate::UniffiCustomTypeConverter; use crate::builder::sanitize_alias; diff --git a/tests/common/mod.rs b/tests/common/mod.rs index f3cff00dc..1e82fc60e 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -21,6 +21,7 @@ use lightning::routing::gossip::NodeAlias; use lightning::util::persist::KVStore; use lightning::util::test_utils::TestStore; +use lightning_invoice::{Bolt11InvoiceDescription, Description}; use lightning_types::payment::{PaymentHash, PaymentPreimage}; use lightning_persister::fs_store::FilesystemStore; @@ -552,7 +553,12 @@ pub(crate) fn do_channel_full_cycle( println!("\nB receive"); let invoice_amount_1_msat = 2500_000; - let invoice = node_b.bolt11_payment().receive(invoice_amount_1_msat, &"asdf", 9217).unwrap(); + let invoice_description: Bolt11InvoiceDescription = + Bolt11InvoiceDescription::Direct(Description::new(String::from("asdf")).unwrap()); + let invoice = node_b + .bolt11_payment() + .receive(invoice_amount_1_msat, &invoice_description.clone().into(), 9217) + .unwrap(); println!("\nA send"); let payment_id = node_a.bolt11_payment().send(&invoice, None).unwrap(); @@ -598,7 +604,10 @@ pub(crate) fn do_channel_full_cycle( // Test under-/overpayment let invoice_amount_2_msat = 2500_000; - let invoice = node_b.bolt11_payment().receive(invoice_amount_2_msat, &"asdf", 9217).unwrap(); + let invoice = node_b + .bolt11_payment() + .receive(invoice_amount_2_msat, &invoice_description.clone().into(), 9217) + .unwrap(); let underpaid_amount = invoice_amount_2_msat - 1; assert_eq!( @@ -607,7 +616,10 @@ pub(crate) fn do_channel_full_cycle( ); println!("\nB overpaid receive"); - let invoice = node_b.bolt11_payment().receive(invoice_amount_2_msat, &"asdf", 9217).unwrap(); + let invoice = node_b + .bolt11_payment() + .receive(invoice_amount_2_msat, &invoice_description.clone().into(), 9217) + .unwrap(); let overpaid_amount_msat = invoice_amount_2_msat + 100; println!("\nA overpaid send"); @@ -636,8 +648,10 @@ pub(crate) fn do_channel_full_cycle( // Test "zero-amount" invoice payment println!("\nB receive_variable_amount_payment"); - let variable_amount_invoice = - node_b.bolt11_payment().receive_variable_amount(&"asdf", 9217).unwrap(); + let variable_amount_invoice = node_b + .bolt11_payment() + .receive_variable_amount(&invoice_description.clone().into(), 9217) + .unwrap(); let determined_amount_msat = 2345_678; assert_eq!( Err(NodeError::InvalidInvoice), @@ -676,7 +690,12 @@ pub(crate) fn do_channel_full_cycle( let manual_payment_hash = PaymentHash(Sha256::hash(&manual_preimage.0).to_byte_array()); let manual_invoice = node_b .bolt11_payment() - .receive_for_hash(invoice_amount_3_msat, &"asdf", 9217, manual_payment_hash) + .receive_for_hash( + invoice_amount_3_msat, + &invoice_description.clone().into(), + 9217, + manual_payment_hash, + ) .unwrap(); let manual_payment_id = node_a.bolt11_payment().send(&manual_invoice, None).unwrap(); @@ -714,7 +733,12 @@ pub(crate) fn do_channel_full_cycle( PaymentHash(Sha256::hash(&manual_fail_preimage.0).to_byte_array()); let manual_fail_invoice = node_b .bolt11_payment() - .receive_for_hash(invoice_amount_3_msat, &"asdf", 9217, manual_fail_payment_hash) + .receive_for_hash( + invoice_amount_3_msat, + &invoice_description.into(), + 9217, + manual_fail_payment_hash, + ) .unwrap(); let manual_fail_payment_id = node_a.bolt11_payment().send(&manual_fail_invoice, None).unwrap(); diff --git a/tests/integration_tests_cln.rs b/tests/integration_tests_cln.rs index c3ade673f..02d091215 100644 --- a/tests/integration_tests_cln.rs +++ b/tests/integration_tests_cln.rs @@ -13,6 +13,7 @@ use ldk_node::bitcoin::secp256k1::PublicKey; use ldk_node::bitcoin::Amount; use ldk_node::lightning::ln::msgs::SocketAddress; use ldk_node::{Builder, Event}; +use lightning_invoice::{Bolt11InvoiceDescription, Description}; use clightningrpc::lightningrpc::LightningRPC; use clightningrpc::responses::NetworkAddress; @@ -107,7 +108,10 @@ fn test_cln() { // Send a payment to LDK let rand_label: String = (0..7).map(|_| rng.sample(Alphanumeric) as char).collect(); - let ldk_invoice = node.bolt11_payment().receive(10_000_000, &rand_label, 3600).unwrap(); + let invoice_description = + Bolt11InvoiceDescription::Direct(Description::new(rand_label).unwrap()); + let ldk_invoice = + node.bolt11_payment().receive(10_000_000, &invoice_description, 3600).unwrap(); cln_client.pay(&ldk_invoice.to_string(), Default::default()).unwrap(); common::expect_event!(node, PaymentReceived); diff --git a/tests/integration_tests_rust.rs b/tests/integration_tests_rust.rs index 2737a3d18..3a546effc 100644 --- a/tests/integration_tests_rust.rs +++ b/tests/integration_tests_rust.rs @@ -24,6 +24,7 @@ use lightning::util::persist::KVStore; use bitcoincore_rpc::RpcApi; use bitcoin::Amount; +use lightning_invoice::{Bolt11InvoiceDescription, Description}; use std::sync::Arc; @@ -189,7 +190,12 @@ fn multi_hop_sending() { max_channel_saturation_power_of_half: Some(2), }; - let invoice = nodes[4].bolt11_payment().receive(2_500_000, &"asdf", 9217).unwrap(); + let invoice_description = + Bolt11InvoiceDescription::Direct(Description::new(String::from("asdf")).unwrap()); + let invoice = nodes[4] + .bolt11_payment() + .receive(2_500_000, &invoice_description.clone().into(), 9217) + .unwrap(); nodes[0].bolt11_payment().send(&invoice, Some(sending_params)).unwrap(); expect_event!(nodes[1], PaymentForwarded);