From 27ca6caf9d245cb1713ae79ac78833e8c13473e2 Mon Sep 17 00:00:00 2001 From: shaavan Date: Tue, 13 Aug 2024 14:25:18 +0530 Subject: [PATCH] Remove `create_blinded_path_using_absolute_expiry` 1. This function was initially introduced in commit `8012c2b213127372bdad150cdc354920d971087d` to allow using compact or full-length blinded paths based on the lifetime of Offers and Refunds. 2. With the introduction of `BlindedPathParams`, users can now explicitly specify the type of blinded path to be used, rendering this functionality redundant. 3. As a result, the corresponding `create_blinded_path` variant is removed. 4. The params parameter is introduced as an option, that allows the user to create Offers and Refund without BlindedPath if needed. --- lightning/src/ln/channelmanager.rs | 79 +++-- .../src/ln/max_payment_path_len_tests.rs | 7 +- lightning/src/ln/offers_tests.rs | 284 ++++++++++++++---- 3 files changed, 264 insertions(+), 106 deletions(-) diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 1ade2eba5dd..c1cee36fa5e 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -1704,12 +1704,16 @@ where /// # use lightning::events::{Event, EventsProvider, PaymentPurpose}; /// # use lightning::ln::channelmanager::AChannelManager; /// # use lightning::offers::parse::Bolt12SemanticError; +/// # use lightning::onion_message::messenger::BlindedPathParams; /// # /// # fn example(channel_manager: T) -> Result<(), Bolt12SemanticError> { /// # let channel_manager = channel_manager.get_cm(); -/// # let absolute_expiry = None; +/// # let params = BlindedPathParams { +/// # paths: 0, +/// # is_compact: false, +/// # }; /// let offer = channel_manager -/// .create_offer_builder(absolute_expiry)? +/// .create_offer_builder(Some(params))? /// # ; /// # // Needed for compiling for c_bindings /// # let builder: lightning::offers::offer::OfferBuilder<_, _> = offer.into(); @@ -1807,16 +1811,21 @@ where /// # use lightning::events::{Event, EventsProvider}; /// # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry}; /// # use lightning::offers::parse::Bolt12SemanticError; +/// # use lightning::onion_message::messenger::BlindedPathParams; /// # /// # fn example( /// # channel_manager: T, amount_msats: u64, absolute_expiry: Duration, retry: Retry, /// # max_total_routing_fee_msat: Option /// # ) -> Result<(), Bolt12SemanticError> { /// # let channel_manager = channel_manager.get_cm(); -/// let payment_id = PaymentId([42; 32]); +/// # let params = BlindedPathParams { +/// # paths: 0, +/// # is_compact: false, +/// # }; +/// # let payment_id = PaymentId([42; 32]); /// let refund = channel_manager /// .create_refund_builder( -/// amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat +/// Some(params), amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat /// )? /// # ; /// # // Needed for compiling for c_bindings @@ -8808,7 +8817,7 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => { /// [`Offer`]: crate::offers::offer::Offer /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest pub fn create_offer_builder( - &$self, absolute_expiry: Option + &$self, params: Option, ) -> Result<$builder, Bolt12SemanticError> { let node_id = $self.get_our_node_id(); let expanded_key = &$self.inbound_payment_key; @@ -8817,17 +8826,15 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => { let nonce = Nonce::from_entropy_source(entropy); let context = OffersContext::InvoiceRequest { nonce }; - let path = $self.create_blinded_paths_using_absolute_expiry(context, absolute_expiry) + let mut builder = OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx) + .chain_hash($self.chain_hash); + if let Some(params) = params { + let path = $self.create_blinded_paths(params, context) .and_then(|paths| paths.into_iter().next().ok_or(())) .map_err(|_| Bolt12SemanticError::MissingPaths)?; - let builder = OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx) - .chain_hash($self.chain_hash) - .path(path); - - let builder = match absolute_expiry { - None => builder, - Some(absolute_expiry) => builder.absolute_expiry(absolute_expiry), - }; + + builder = builder.path(path); + } Ok(builder.into()) } @@ -8880,7 +8887,8 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => { /// [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths /// [Avoiding Duplicate Payments]: #avoiding-duplicate-payments pub fn create_refund_builder( - &$self, amount_msats: u64, absolute_expiry: Duration, payment_id: PaymentId, + &$self, params: Option, amount_msats: u64, + absolute_expiry: Duration, payment_id: PaymentId, retry_strategy: Retry, max_total_routing_fee_msat: Option ) -> Result<$builder, Bolt12SemanticError> { let node_id = $self.get_our_node_id(); @@ -8891,15 +8899,19 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => { let nonce = Nonce::from_entropy_source(entropy); let context = OffersContext::OutboundPayment { payment_id, nonce, hmac: None }; - let path = $self.create_blinded_paths_using_absolute_expiry(context, Some(absolute_expiry)) - .and_then(|paths| paths.into_iter().next().ok_or(())) - .map_err(|_| Bolt12SemanticError::MissingPaths)?; - let builder = RefundBuilder::deriving_payer_id( + let mut builder = RefundBuilder::deriving_payer_id( node_id, expanded_key, nonce, secp_ctx, amount_msats, payment_id )? .chain_hash($self.chain_hash) - .absolute_expiry(absolute_expiry) - .path(path); + .absolute_expiry(absolute_expiry); + + if let Some(params) = params { + let path = $self.create_blinded_paths(params, context) + .and_then(|paths| paths.into_iter().next().ok_or(())) + .map_err(|_| Bolt12SemanticError::MissingPaths)?; + + builder = builder.path(path); + }; let _persistence_guard = PersistenceNotifierGuard::notify_on_drop($self); @@ -9273,29 +9285,7 @@ where inbound_payment::get_payment_preimage(payment_hash, payment_secret, &self.inbound_payment_key) } - /// Creates a collection of blinded paths by delegating to [`MessageRouter`] based on - /// the path's intended lifetime. - /// - /// Whether or not the path is compact depends on whether the path is short-lived or long-lived, - /// respectively, based on the given `absolute_expiry` as seconds since the Unix epoch. See - /// [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. - fn create_blinded_paths_using_absolute_expiry( - &self, context: OffersContext, absolute_expiry: Option, - ) -> Result, ()> { - let now = self.duration_since_epoch(); - let max_short_lived_absolute_expiry = now.saturating_add(MAX_SHORT_LIVED_RELATIVE_EXPIRY); - - if absolute_expiry.unwrap_or(Duration::MAX) <= max_short_lived_absolute_expiry { - self.create_compact_blinded_paths(context) - } else { - let params = BlindedPathParams { - paths: PATHS_PLACEHOLDER, - is_compact: false - }; - self.create_blinded_paths(params, context) - } - } - + #[cfg(test)] pub(super) fn duration_since_epoch(&self) -> Duration { #[cfg(not(feature = "std"))] let now = Duration::from_secs( @@ -9334,6 +9324,7 @@ where /// [`MessageRouter::create_compact_blinded_paths`]. /// /// Errors if the `MessageRouter` errors. + #[allow(unused)] fn create_compact_blinded_paths(&self, context: OffersContext) -> Result, ()> { let recipient = self.get_our_node_id(); let secp_ctx = &self.secp_ctx; diff --git a/lightning/src/ln/max_payment_path_len_tests.rs b/lightning/src/ln/max_payment_path_len_tests.rs index 096bcf9633c..f6365c8fde9 100644 --- a/lightning/src/ln/max_payment_path_len_tests.rs +++ b/lightning/src/ln/max_payment_path_len_tests.rs @@ -25,6 +25,7 @@ use crate::ln::onion_utils; use crate::ln::onion_utils::MIN_FINAL_VALUE_ESTIMATE_WITH_OVERPAY; use crate::ln::outbound_payment::{RecipientOnionFields, Retry, RetryableSendFailure}; use crate::offers::invoice::BlindedPayInfo; +use crate::onion_message::messenger::{BlindedPathParams, PATHS_PLACEHOLDER}; use crate::prelude::*; use crate::routing::router::{DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA, PaymentParameters, RouteParameters}; use crate::util::errors::APIError; @@ -379,7 +380,11 @@ fn bolt12_invoice_too_large_blinded_paths() { } )]); - let offer = nodes[1].node.create_offer_builder(None).unwrap().build().unwrap(); + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; + let offer = nodes[1].node.create_offer_builder(Some(params)).unwrap().build().unwrap(); let payment_id = PaymentId([1; 32]); nodes[0].node.pay_for_offer(&offer, None, Some(5000), None, payment_id, Retry::Attempts(0), None).unwrap(); let invreq_om = nodes[0].onion_messenger.next_onion_message_for_peer(nodes[1].node.get_our_node_id()).unwrap(); diff --git a/lightning/src/ln/offers_tests.rs b/lightning/src/ln/offers_tests.rs index fd496b5f639..32ce4e9bb62 100644 --- a/lightning/src/ln/offers_tests.rs +++ b/lightning/src/ln/offers_tests.rs @@ -58,7 +58,7 @@ use crate::offers::invoice_error::InvoiceError; use crate::offers::invoice_request::{InvoiceRequest, InvoiceRequestFields}; use crate::offers::nonce::Nonce; use crate::offers::parse::Bolt12SemanticError; -use crate::onion_message::messenger::{Destination, PeeledOnion, new_pending_onion_message}; +use crate::onion_message::messenger::{BlindedPathParams, Destination, PeeledOnion, PATHS_PLACEHOLDER, new_pending_onion_message}; use crate::onion_message::offers::OffersMessage; use crate::onion_message::packet::ParsedOnionMessageContents; use crate::routing::gossip::{NodeAlias, NodeId}; @@ -299,8 +299,12 @@ fn prefers_non_tor_nodes_in_blinded_paths() { let tor = SocketAddress::OnionV2([255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 38, 7]); announce_node_address(charlie, &[alice, bob, david, &nodes[4], &nodes[5]], tor.clone()); + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = bob.node - .create_offer_builder(None).unwrap() + .create_offer_builder(Some(params)).unwrap() .amount_msats(10_000_000) .build().unwrap(); assert_ne!(offer.signing_pubkey(), Some(bob_id)); @@ -315,8 +319,12 @@ fn prefers_non_tor_nodes_in_blinded_paths() { announce_node_address(&nodes[4], &[alice, bob, charlie, david, &nodes[5]], tor.clone()); announce_node_address(&nodes[5], &[alice, bob, charlie, david, &nodes[4]], tor.clone()); + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = bob.node - .create_offer_builder(None).unwrap() + .create_offer_builder(Some(params)).unwrap() .amount_msats(10_000_000) .build().unwrap(); assert_ne!(offer.signing_pubkey(), Some(bob_id)); @@ -366,8 +374,12 @@ fn prefers_more_connected_nodes_in_blinded_paths() { disconnect_peers(alice, &[charlie, david, &nodes[4], &nodes[5]]); disconnect_peers(david, &[bob, &nodes[4], &nodes[5]]); + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = bob.node - .create_offer_builder(None).unwrap() + .create_offer_builder(Some(params)).unwrap() .amount_msats(10_000_000) .build().unwrap(); assert_ne!(offer.signing_pubkey(), Some(bob_id)); @@ -391,10 +403,15 @@ fn creates_short_lived_offer() { let alice = &nodes[0]; let alice_id = alice.node.get_our_node_id(); let bob = &nodes[1]; - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: true, + }; let absolute_expiry = alice.node.duration_since_epoch() + MAX_SHORT_LIVED_RELATIVE_EXPIRY; let offer = alice.node - .create_offer_builder(Some(absolute_expiry)).unwrap() + .create_offer_builder(Some(params)).unwrap() + .absolute_expiry(absolute_expiry) .build().unwrap(); assert_eq!(offer.absolute_expiry(), Some(absolute_expiry)); assert!(!offer.paths().is_empty()); @@ -417,12 +434,17 @@ fn creates_long_lived_offer() { let alice = &nodes[0]; let alice_id = alice.node.get_our_node_id(); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let absolute_expiry = alice.node.duration_since_epoch() + MAX_SHORT_LIVED_RELATIVE_EXPIRY + Duration::from_secs(1); let offer = alice.node - .create_offer_builder(Some(absolute_expiry)) + .create_offer_builder(Some(params)) .unwrap() + .absolute_expiry(absolute_expiry) .build().unwrap(); assert_eq!(offer.absolute_expiry(), Some(absolute_expiry)); assert!(!offer.paths().is_empty()); @@ -430,8 +452,12 @@ fn creates_long_lived_offer() { assert_eq!(path.introduction_node, IntroductionNode::NodeId(alice_id)); } + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None).unwrap() + .create_offer_builder(Some(params)).unwrap() .build().unwrap(); assert_eq!(offer.absolute_expiry(), None); assert!(!offer.paths().is_empty()); @@ -453,11 +479,15 @@ fn creates_short_lived_refund() { let alice = &nodes[0]; let bob = &nodes[1]; let bob_id = bob.node.get_our_node_id(); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: true, + }; let absolute_expiry = bob.node.duration_since_epoch() + MAX_SHORT_LIVED_RELATIVE_EXPIRY; let payment_id = PaymentId([1; 32]); let refund = bob.node - .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) + .create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) .unwrap() .build().unwrap(); assert_eq!(refund.absolute_expiry(), Some(absolute_expiry)); @@ -485,8 +515,13 @@ fn creates_long_lived_refund() { let absolute_expiry = bob.node.duration_since_epoch() + MAX_SHORT_LIVED_RELATIVE_EXPIRY + Duration::from_secs(1); let payment_id = PaymentId([1; 32]); + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let refund = bob.node - .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) + .create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) .unwrap() .build().unwrap(); assert_eq!(refund.absolute_expiry(), Some(absolute_expiry)); @@ -533,9 +568,13 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() { disconnect_peers(alice, &[charlie, david, &nodes[4], &nodes[5]]); disconnect_peers(david, &[bob, &nodes[4], &nodes[5]]); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None) + .create_offer_builder(Some(params)) .unwrap() .amount_msats(10_000_000) .build().unwrap(); @@ -631,11 +670,15 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() { disconnect_peers(alice, &[charlie, david, &nodes[4], &nodes[5]]); disconnect_peers(david, &[bob, &nodes[4], &nodes[5]]); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let absolute_expiry = Duration::from_secs(u64::MAX); let payment_id = PaymentId([1; 32]); let refund = david.node - .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) + .create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) .unwrap() .build().unwrap(); assert_eq!(refund.amount_msats(), 10_000_000); @@ -691,9 +734,13 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() { let alice_id = alice.node.get_our_node_id(); let bob = &nodes[1]; let bob_id = bob.node.get_our_node_id(); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None).unwrap() + .create_offer_builder(Some(params)).unwrap() .amount_msats(10_000_000) .build().unwrap(); assert_ne!(offer.signing_pubkey(), Some(alice_id)); @@ -759,8 +806,13 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() { let absolute_expiry = Duration::from_secs(u64::MAX); let payment_id = PaymentId([1; 32]); + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let refund = bob.node - .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) + .create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) .unwrap() .build().unwrap(); assert_eq!(refund.amount_msats(), 10_000_000); @@ -811,9 +863,13 @@ fn pays_for_offer_without_blinded_paths() { let alice_id = alice.node.get_our_node_id(); let bob = &nodes[1]; let bob_id = bob.node.get_our_node_id(); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None).unwrap() + .create_offer_builder(Some(params)).unwrap() .clear_paths() .amount_msats(10_000_000) .build().unwrap(); @@ -866,8 +922,13 @@ fn pays_for_refund_without_blinded_paths() { let absolute_expiry = Duration::from_secs(u64::MAX); let payment_id = PaymentId([1; 32]); + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let refund = bob.node - .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) + .create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) .unwrap() .clear_paths() .build().unwrap(); @@ -934,9 +995,13 @@ fn send_invoice_requests_with_distinct_reply_path() { disconnect_peers(alice, &[charlie, david, &nodes[4], &nodes[5], &nodes[6]]); disconnect_peers(david, &[bob, &nodes[4], &nodes[5]]); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None) + .create_offer_builder(Some(params)) .unwrap() .amount_msats(10_000_000) .build().unwrap(); @@ -1018,11 +1083,15 @@ fn send_invoice_for_refund_with_distinct_reply_path() { disconnect_peers(alice, &[charlie, david, &nodes[4], &nodes[5], &nodes[6]]); disconnect_peers(david, &[bob, &nodes[4], &nodes[5]]); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let absolute_expiry = Duration::from_secs(u64::MAX); let payment_id = PaymentId([1; 32]); let refund = alice.node - .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) + .create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) .unwrap() .build().unwrap(); assert_ne!(refund.payer_id(), alice_id); @@ -1072,9 +1141,13 @@ fn pays_bolt12_invoice_asynchronously() { let alice_id = alice.node.get_our_node_id(); let bob = &nodes[1]; let bob_id = bob.node.get_our_node_id(); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None).unwrap() + .create_offer_builder(Some(params)).unwrap() .amount_msats(10_000_000) .build().unwrap(); @@ -1156,9 +1229,13 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() { let alice_id = alice.node.get_our_node_id(); let bob = &nodes[1]; let bob_id = bob.node.get_our_node_id(); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None).unwrap() + .create_offer_builder(Some(params)).unwrap() .amount_msats(10_000_000) .build().unwrap(); assert_ne!(offer.signing_pubkey(), Some(alice_id)); @@ -1220,11 +1297,15 @@ fn creates_refund_with_blinded_path_using_unannounced_introduction_node() { let alice_id = alice.node.get_our_node_id(); let bob = &nodes[1]; let bob_id = bob.node.get_our_node_id(); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let absolute_expiry = Duration::from_secs(u64::MAX); let payment_id = PaymentId([1; 32]); let refund = bob.node - .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) + .create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) .unwrap() .build().unwrap(); assert_ne!(refund.payer_id(), bob_id); @@ -1284,9 +1365,13 @@ fn fails_authentication_when_handling_invoice_request() { disconnect_peers(alice, &[charlie, david, &nodes[4], &nodes[5]]); disconnect_peers(david, &[bob, &nodes[4], &nodes[5]]); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None) + .create_offer_builder(Some(params)) .unwrap() .amount_msats(10_000_000) .build().unwrap(); @@ -1297,8 +1382,12 @@ fn fails_authentication_when_handling_invoice_request() { assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id)); } + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let invalid_path = alice.node - .create_offer_builder(None) + .create_offer_builder(Some(params)) .unwrap() .build().unwrap() .paths().first().unwrap() @@ -1402,9 +1491,13 @@ fn fails_authentication_when_handling_invoice_for_offer() { disconnect_peers(alice, &[charlie, david, &nodes[4], &nodes[5]]); disconnect_peers(david, &[bob, &nodes[4], &nodes[5]]); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None) + .create_offer_builder(Some(params)) .unwrap() .amount_msats(10_000_000) .build().unwrap(); @@ -1515,8 +1608,13 @@ fn fails_authentication_when_handling_invoice_for_refund() { let absolute_expiry = Duration::from_secs(u64::MAX); let payment_id = PaymentId([1; 32]); + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let refund = david.node - .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) + .create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) .unwrap() .build().unwrap(); assert_ne!(refund.payer_id(), david_id); @@ -1552,8 +1650,12 @@ fn fails_authentication_when_handling_invoice_for_refund() { // Send the invoice to David using an invalid blinded path. let invalid_path = refund.paths().first().unwrap().clone(); let payment_id = PaymentId([2; 32]); + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let refund = david.node - .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) + .create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) .unwrap() .build().unwrap(); assert_ne!(refund.payer_id(), david_id); @@ -1609,8 +1711,11 @@ fn fails_creating_or_paying_for_offer_without_connected_peers() { disconnect_peers(alice, &[bob, charlie, david, &nodes[4], &nodes[5]]); disconnect_peers(david, &[bob, charlie, &nodes[4], &nodes[5]]); - let absolute_expiry = alice.node.duration_since_epoch() + MAX_SHORT_LIVED_RELATIVE_EXPIRY; - match alice.node.create_offer_builder(Some(absolute_expiry)) { + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; + match alice.node.create_offer_builder(Some(params)) { Ok(_) => panic!("Expected error"), Err(e) => assert_eq!(e, Bolt12SemanticError::MissingPaths), } @@ -1618,9 +1723,15 @@ fn fails_creating_or_paying_for_offer_without_connected_peers() { let mut args = ReconnectArgs::new(alice, bob); args.send_channel_ready = (true, true); reconnect_nodes(args); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; + let absolute_expiry = alice.node.duration_since_epoch() + MAX_SHORT_LIVED_RELATIVE_EXPIRY; let offer = alice.node - .create_offer_builder(Some(absolute_expiry)).unwrap() + .create_offer_builder(Some(params)).unwrap() + .absolute_expiry(absolute_expiry) .amount_msats(10_000_000) .build().unwrap(); @@ -1682,7 +1793,11 @@ fn fails_creating_refund_or_sending_invoice_without_connected_peers() { let absolute_expiry = david.node.duration_since_epoch() + MAX_SHORT_LIVED_RELATIVE_EXPIRY; let payment_id = PaymentId([1; 32]); - match david.node.create_refund_builder( + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; + match david.node.create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None ) { Ok(_) => panic!("Expected error"), @@ -1692,9 +1807,13 @@ fn fails_creating_refund_or_sending_invoice_without_connected_peers() { let mut args = ReconnectArgs::new(charlie, david); args.send_channel_ready = (true, true); reconnect_nodes(args); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let refund = david.node - .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) + .create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) .unwrap() .build().unwrap(); @@ -1722,9 +1841,13 @@ fn fails_creating_invoice_request_for_unsupported_chain() { let alice = &nodes[0]; let bob = &nodes[1]; - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None).unwrap() + .create_offer_builder(Some(params)).unwrap() .clear_chains() .chain(Network::Signet) .build().unwrap(); @@ -1751,8 +1874,13 @@ fn fails_sending_invoice_with_unsupported_chain_for_refund() { let absolute_expiry = Duration::from_secs(u64::MAX); let payment_id = PaymentId([1; 32]); + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let refund = bob.node - .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) + .create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) .unwrap() .chain(Network::Signet) .build().unwrap(); @@ -1781,9 +1909,13 @@ fn fails_creating_invoice_request_without_blinded_reply_path() { disconnect_peers(alice, &[charlie, david, &nodes[4], &nodes[5]]); disconnect_peers(david, &[bob, charlie, &nodes[4], &nodes[5]]); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None).unwrap() + .create_offer_builder(Some(params)).unwrap() .amount_msats(10_000_000) .build().unwrap(); @@ -1815,9 +1947,13 @@ fn fails_creating_invoice_request_with_duplicate_payment_id() { let (alice, _bob, charlie, david) = (&nodes[0], &nodes[1], &nodes[2], &nodes[3]); disconnect_peers(alice, &[charlie, david, &nodes[4], &nodes[5]]); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None).unwrap() + .create_offer_builder(Some(params)).unwrap() .amount_msats(10_000_000) .build().unwrap(); @@ -1848,15 +1984,23 @@ fn fails_creating_refund_with_duplicate_payment_id() { let absolute_expiry = Duration::from_secs(u64::MAX); let payment_id = PaymentId([1; 32]); + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; assert!( nodes[0].node.create_refund_builder( - 10_000, absolute_expiry, payment_id, Retry::Attempts(0), None + Some(params), 10_000, absolute_expiry, payment_id, Retry::Attempts(0), None ).is_ok() ); expect_recent_payment!(nodes[0], RecentPaymentDetails::AwaitingInvoice, payment_id); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; match nodes[0].node.create_refund_builder( - 10_000, absolute_expiry, payment_id, Retry::Attempts(0), None + Some(params), 10_000, absolute_expiry, payment_id, Retry::Attempts(0), None ) { Ok(_) => panic!("Expected error"), Err(e) => assert_eq!(e, Bolt12SemanticError::DuplicatePaymentId), @@ -1901,9 +2045,13 @@ fn fails_sending_invoice_without_blinded_payment_paths_for_offer() { disconnect_peers(alice, &[charlie, david, &nodes[4], &nodes[5]]); disconnect_peers(david, &[bob, &nodes[4], &nodes[5]]); - + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None).unwrap() + .create_offer_builder(Some(params)).unwrap() .amount_msats(10_000_000) .build().unwrap(); @@ -1975,8 +2123,13 @@ fn fails_sending_invoice_without_blinded_payment_paths_for_refund() { let absolute_expiry = Duration::from_secs(u64::MAX); let payment_id = PaymentId([1; 32]); + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let refund = david.node - .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) + .create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) .unwrap() .build().unwrap(); @@ -2024,8 +2177,13 @@ fn fails_paying_invoice_more_than_once() { let absolute_expiry = Duration::from_secs(u64::MAX); let payment_id = PaymentId([1; 32]); + + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let refund = david.node - .create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) + .create_refund_builder(Some(params), 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None) .unwrap() .build().unwrap(); expect_recent_payment!(david, RecentPaymentDetails::AwaitingInvoice, payment_id); @@ -2111,8 +2269,12 @@ fn fails_paying_invoice_with_unknown_required_features() { disconnect_peers(alice, &[charlie, david, &nodes[4], &nodes[5]]); disconnect_peers(david, &[bob, &nodes[4], &nodes[5]]); + let params = BlindedPathParams { + paths: PATHS_PLACEHOLDER, + is_compact: false, + }; let offer = alice.node - .create_offer_builder(None).unwrap() + .create_offer_builder(Some(params)).unwrap() .amount_msats(10_000_000) .build().unwrap();