projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #2667 from wpaulino/random-htlc-holder-sigs-non-anchors
[rust-lightning]
/
lightning
/
src
/
onion_message
/
messenger.rs
diff --git
a/lightning/src/onion_message/messenger.rs
b/lightning/src/onion_message/messenger.rs
index ba343ec6eae8a026f6df8ce7aeab07d9cd2f2549..723e105d044cf549cfd8f392e206782b38a479af 100644
(file)
--- a/
lightning/src/onion_message/messenger.rs
+++ b/
lightning/src/onion_message/messenger.rs
@@
-177,14
+177,18
@@
pub trait MessageRouter {
) -> Result<OnionMessagePath, ()>;
}
) -> Result<OnionMessagePath, ()>;
}
-/// A [`MessageRouter`] that
always fails
.
+/// A [`MessageRouter`] that
can only route to a directly connected [`Destination`]
.
pub struct DefaultMessageRouter;
impl MessageRouter for DefaultMessageRouter {
fn find_path(
pub struct DefaultMessageRouter;
impl MessageRouter for DefaultMessageRouter {
fn find_path(
- &self, _sender: PublicKey,
_peers: Vec<PublicKey>, _
destination: Destination
+ &self, _sender: PublicKey,
peers: Vec<PublicKey>,
destination: Destination
) -> Result<OnionMessagePath, ()> {
) -> Result<OnionMessagePath, ()> {
- Err(())
+ if peers.contains(&destination.first_node()) {
+ Ok(OnionMessagePath { intermediate_nodes: vec![], destination })
+ } else {
+ Err(())
+ }
}
}
}
}
@@
-214,6
+218,13
@@
impl Destination {
Destination::BlindedPath(BlindedPath { blinded_hops, .. }) => blinded_hops.len(),
}
}
Destination::BlindedPath(BlindedPath { blinded_hops, .. }) => blinded_hops.len(),
}
}
+
+ fn first_node(&self) -> PublicKey {
+ match self {
+ Destination::Node(node_id) => *node_id,
+ Destination::BlindedPath(BlindedPath { introduction_node_id: node_id, .. }) => *node_id,
+ }
+ }
}
/// Errors that may occur when [sending an onion message].
}
/// Errors that may occur when [sending an onion message].