Skip to content

Commit 08b1ede

Browse files
committed
f: Append all available paths to offer and refund.
- Instead of appending just a single blinded path to offers and refunds, update the code to append all paths returned by create_blinded_paths. - This change allows MessageRouter to control the number of blinded paths appended to offers and refunds, providing flexibility for them to contain more than one path.
1 parent 0b9a90c commit 08b1ede

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9126,14 +9126,16 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
91269126
);
91279127
let builder = match blinded_path {
91289128
Some(blinded_path) => {
9129-
let path = $self
9129+
let paths = $self
91309130
.create_blinded_paths(context, blinded_path)
9131-
.and_then(|paths| paths.into_iter().next().ok_or(()))
91329131
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
91339132

9134-
OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx)
9135-
.chain_hash($self.chain_hash)
9136-
.path(path)
9133+
let offer_builder = OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx)
9134+
.chain_hash($self.chain_hash);
9135+
9136+
paths.into_iter().fold(offer_builder, |builder, path| {
9137+
builder.path(path)
9138+
})
91379139
}
91389140

91399141
None => OfferBuilder::deriving_signing_pubkey(node_id, expanded_key, nonce, secp_ctx)
@@ -9206,18 +9208,20 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
92069208

92079209
let builder = match blinded_path {
92089210
Some(blinded_path) => {
9209-
let path = $self
9211+
let paths = $self
92109212
.create_blinded_paths(context, blinded_path)
9211-
.and_then(|paths| paths.into_iter().next().ok_or(()))
92129213
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
92139214

9214-
RefundBuilder::deriving_signing_pubkey(
9215+
let refund_builder = RefundBuilder::deriving_signing_pubkey(
92159216
node_id, expanded_key, nonce, secp_ctx,
92169217
amount_msats, payment_id,
92179218
)?
92189219
.chain_hash($self.chain_hash)
9219-
.absolute_expiry(absolute_expiry)
9220-
.path(path)
9220+
.absolute_expiry(absolute_expiry);
9221+
9222+
paths.into_iter().fold(refund_builder, |builder, path| {
9223+
builder.path(path)
9224+
})
92219225
}
92229226

92239227
None => RefundBuilder::deriving_signing_pubkey(
@@ -9226,7 +9230,6 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
92269230
)?
92279231
.chain_hash($self.chain_hash)
92289232
.absolute_expiry(absolute_expiry)
9229-
.absolute_expiry(absolute_expiry),
92309233
};
92319234

92329235
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop($self);

lightning/src/ln/offers_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ fn prefers_more_connected_nodes_in_blinded_paths() {
369369
.build().unwrap();
370370
assert_ne!(offer.issuer_signing_pubkey(), Some(bob_id));
371371
assert!(!offer.paths().is_empty());
372-
for path in offer.paths() {
373-
let introduction_node_id = resolve_introduction_node(david, &path);
372+
if let Some(first_path) = offer.paths().iter().next() {
373+
let introduction_node_id = resolve_introduction_node(david, &first_path);
374374
assert_eq!(introduction_node_id, nodes[4].node.get_our_node_id());
375375
}
376376
}

0 commit comments

Comments
 (0)