Trait MessageRouter
pub trait MessageRouter {
// Required methods
fn find_path(
&self,
sender: PublicKey,
peers: Vec<PublicKey>,
destination: Destination,
) -> Result<OnionMessagePath, ()>;
fn create_blinded_paths<T>(
&self,
recipient: PublicKey,
context: MessageContext,
peers: Vec<PublicKey>,
secp_ctx: &Secp256k1<T>,
) -> Result<Vec<BlindedMessagePath>, ()>
where T: Signing + Verification;
// Provided method
fn create_compact_blinded_paths<T>(
&self,
recipient: PublicKey,
context: MessageContext,
peers: Vec<MessageForwardNode>,
secp_ctx: &Secp256k1<T>,
) -> Result<Vec<BlindedMessagePath>, ()>
where T: Signing + Verification { ... }
}
Expand description
A trait defining behavior for routing an OnionMessage
.
Required Methods§
fn find_path(
&self,
sender: PublicKey,
peers: Vec<PublicKey>,
destination: Destination,
) -> Result<OnionMessagePath, ()>
fn find_path( &self, sender: PublicKey, peers: Vec<PublicKey>, destination: Destination, ) -> Result<OnionMessagePath, ()>
Returns a route for sending an OnionMessage
to the given Destination
.
fn create_blinded_paths<T>(
&self,
recipient: PublicKey,
context: MessageContext,
peers: Vec<PublicKey>,
secp_ctx: &Secp256k1<T>,
) -> Result<Vec<BlindedMessagePath>, ()>where
T: Signing + Verification,
fn create_blinded_paths<T>(
&self,
recipient: PublicKey,
context: MessageContext,
peers: Vec<PublicKey>,
secp_ctx: &Secp256k1<T>,
) -> Result<Vec<BlindedMessagePath>, ()>where
T: Signing + Verification,
Creates BlindedMessagePath
s to the recipient
node. The nodes in peers
are assumed to
be direct peers with the recipient
.
Provided Methods§
fn create_compact_blinded_paths<T>(
&self,
recipient: PublicKey,
context: MessageContext,
peers: Vec<MessageForwardNode>,
secp_ctx: &Secp256k1<T>,
) -> Result<Vec<BlindedMessagePath>, ()>where
T: Signing + Verification,
fn create_compact_blinded_paths<T>(
&self,
recipient: PublicKey,
context: MessageContext,
peers: Vec<MessageForwardNode>,
secp_ctx: &Secp256k1<T>,
) -> Result<Vec<BlindedMessagePath>, ()>where
T: Signing + Verification,
Creates compact BlindedMessagePath
s to the recipient
node. The nodes in peers
are
assumed to be direct peers with the recipient
.
Compact blinded paths use short channel ids instead of pubkeys for a smaller serialization,
which is beneficial when a QR code is used to transport the data. The SCID is passed using
a MessageForwardNode
but may be None
for graceful degradation.
Implementations using additional intermediate nodes are responsible for using a
MessageForwardNode
with Some
short channel id, if possible. Similarly, implementations
should call BlindedMessagePath::use_compact_introduction_node
.
The provided implementation simply delegates to MessageRouter::create_blinded_paths
,
ignoring the short channel ids.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.