Skip to content

Commit 625785c

Browse files
committed
Update create_refund_builder to use create_blinded_paths
Aligned the `create_refund_builder` logic with `create_offer_builder` by updating it to use `create_blinded_paths`. Now that custom routers can be passed via `create_refund_builder_using_router`, the default builder can consistently generate full-length blinded paths without branching logic. This simplifies the default behavior while keeping flexibility available for custom use cases.
1 parent ec8b5b9 commit 625785c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10287,8 +10287,7 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
1028710287
///
1028810288
/// # Privacy
1028910289
///
10290-
/// Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the refund based on the given
10291-
/// `absolute_expiry` according to [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. See those docs for
10290+
/// Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the refund. See those docs for
1029210291
/// privacy implications as well as those of the parameterized [`Router`], which implements
1029310292
/// [`MessageRouter`].
1029410293
///
@@ -10320,8 +10319,8 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
1032010319
let secp_ctx = &$self.secp_ctx;
1032110320

1032210321
let nonce = Nonce::from_entropy_source(entropy);
10323-
let context = OffersContext::OutboundPayment { payment_id, nonce, hmac: None };
10324-
let path = $self.create_blinded_paths_using_absolute_expiry(context, Some(absolute_expiry))
10322+
let context = MessageContext::Offers(OffersContext::OutboundPayment { payment_id, nonce, hmac: None });
10323+
let path = $self.create_blinded_paths(context)
1032510324
.and_then(|paths| paths.into_iter().next().ok_or(()))
1032610325
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
1032710326

lightning/src/ln/offers_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,11 @@ fn creates_short_lived_refund() {
454454
let bob = &nodes[1];
455455
let bob_id = bob.node.get_our_node_id();
456456

457+
let router = CompactMessageRouter::new(alice.network_graph, alice.node.entropy_source);
457458
let absolute_expiry = bob.node.duration_since_epoch() + MAX_SHORT_LIVED_RELATIVE_EXPIRY;
458459
let payment_id = PaymentId([1; 32]);
459460
let refund = bob.node
460-
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), RouteParametersConfig::default())
461+
.create_refund_builder_using_router(router, 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), RouteParametersConfig::default())
461462
.unwrap()
462463
.build().unwrap();
463464
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));

0 commit comments

Comments
 (0)