Skip to content

Commit 7f1c65c

Browse files
committed
f - fallback to one-hop path
1 parent 692052e commit 7f1c65c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lightning/src/onion_message/messenger.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ where
350350
const MIN_PEER_CHANNELS: usize = 3;
351351

352352
let network_graph = self.network_graph.deref().read_only();
353-
peers.into_iter()
353+
let paths = peers.into_iter()
354354
// Limit to peers with announced channels
355355
.filter(|pubkey|
356356
network_graph
@@ -362,7 +362,15 @@ where
362362
.map(|pubkey| vec![pubkey, recipient])
363363
.map(|node_pks| BlindedPath::new_for_message(&node_pks, entropy_source, secp_ctx))
364364
.take(MAX_PATHS)
365-
.collect()
365+
.collect::<Result<Vec<_>, _>>();
366+
367+
match paths {
368+
Ok(paths) if !paths.is_empty() => Ok(paths),
369+
_ => {
370+
BlindedPath::one_hop_for_message(recipient, entropy_source, secp_ctx)
371+
.map(|path| vec![path])
372+
},
373+
}
366374
}
367375
}
368376

0 commit comments

Comments
 (0)