/// Onion messages and payments can be sent and received to blinded paths, which serve to hide the
/// identity of the recipient.
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
-pub struct BlindedPath {
+struct BlindedPath {
/// To send to a blinded path, the sender first finds a route to the unblinded
/// `introduction_node`, which can unblind its [`encrypted_payload`] to find out the onion
/// message or payment's next hop and forward it along.
pub blinded_hops: Vec<BlindedHop>,
}
-/// The unblinded node in a [`BlindedPath`].
+/// The unblinded node in a blinded path.
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub enum IntroductionNode {
/// The node id of the introduction node.
DirectedShortChannelId(Direction, u64),
}
-/// The side of a channel that is the [`IntroductionNode`] in a [`BlindedPath`]. [BOLT 7] defines
-/// which nodes is which in the [`ChannelAnnouncement`] message.
+/// The side of a channel that is the [`IntroductionNode`] in a blinded path. [BOLT 7] defines which
+/// nodes is which in the [`ChannelAnnouncement`] message.
///
/// [BOLT 7]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
/// [`ChannelAnnouncement`]: crate::ln::msgs::ChannelAnnouncement
/// and thus can be used to hide the identity of the recipient.
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct BlindedHop {
- /// The blinded node id of this hop in a [`BlindedPath`].
+ /// The blinded node id of this hop in a blinded path.
pub blinded_node_id: PublicKey,
- /// The encrypted payload intended for this hop in a [`BlindedPath`].
+ /// The encrypted payload intended for this hop in a blinded path.
// The node sending to this blinded path will later encode this payload into the onion packet for
// this hop.
pub encrypted_payload: Vec<u8>,
#[cfg(test)]
mod tests {
- use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode};
+ use crate::blinded_path::BlindedHop;
use crate::blinded_path::payment::BlindedPaymentPath;
use crate::routing::gossip::{NetworkGraph, P2PGossipSync, NodeId, EffectiveCapacity};
use crate::routing::utxo::UtxoResult;
#[test]
fn blinded_route_ser() {
- let blinded_path_1 = BlindedPath {
- introduction_node: IntroductionNode::NodeId(ln_test_utils::pubkey(42)),
- blinding_point: ln_test_utils::pubkey(43),
- blinded_hops: vec![
- BlindedHop { blinded_node_id: ln_test_utils::pubkey(44), encrypted_payload: Vec::new() },
- BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() }
- ],
- };
- let blinded_path_2 = BlindedPath {
- introduction_node: IntroductionNode::NodeId(ln_test_utils::pubkey(46)),
- blinding_point: ln_test_utils::pubkey(47),
- blinded_hops: vec![
- BlindedHop { blinded_node_id: ln_test_utils::pubkey(48), encrypted_payload: Vec::new() },
- BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }
- ],
- };
// (De)serialize a Route with 1 blinded path out of two total paths.
let mut route = Route { paths: vec![Path {
hops: vec![RouteHop {
maybe_announced_channel: true,
}],
blinded_tail: Some(BlindedTail {
- hops: blinded_path_1.blinded_hops,
- blinding_point: blinded_path_1.blinding_point,
+ hops: vec![
+ BlindedHop { blinded_node_id: ln_test_utils::pubkey(44), encrypted_payload: Vec::new() },
+ BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() }
+ ],
+ blinding_point: ln_test_utils::pubkey(43),
excess_final_cltv_expiry_delta: 40,
final_value_msat: 100,
})}, Path {
// (De)serialize a Route with two paths, each containing a blinded tail.
route.paths[1].blinded_tail = Some(BlindedTail {
- hops: blinded_path_2.blinded_hops,
- blinding_point: blinded_path_2.blinding_point,
+ hops: vec![
+ BlindedHop { blinded_node_id: ln_test_utils::pubkey(48), encrypted_payload: Vec::new() },
+ BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }
+ ],
+ blinding_point: ln_test_utils::pubkey(47),
excess_final_cltv_expiry_delta: 41,
final_value_msat: 101,
});
// Ensure we'll score the channel that's inbound to a blinded path's introduction node, and
// account for the blinded tail's final amount_msat.
let mut inflight_htlcs = InFlightHtlcs::new();
- let blinded_path = BlindedPath {
- introduction_node: IntroductionNode::NodeId(ln_test_utils::pubkey(43)),
- blinding_point: ln_test_utils::pubkey(48),
- blinded_hops: vec![BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }],
- };
let path = Path {
hops: vec![RouteHop {
pubkey: ln_test_utils::pubkey(42),
maybe_announced_channel: false,
}],
blinded_tail: Some(BlindedTail {
- hops: blinded_path.blinded_hops,
- blinding_point: blinded_path.blinding_point,
+ hops: vec![BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }],
+ blinding_point: ln_test_utils::pubkey(48),
excess_final_cltv_expiry_delta: 0,
final_value_msat: 200,
}),
#[test]
fn blinded_path_cltv_shadow_offset() {
// Make sure we add a shadow offset when sending to blinded paths.
- let blinded_path = BlindedPath {
- introduction_node: IntroductionNode::NodeId(ln_test_utils::pubkey(43)),
- blinding_point: ln_test_utils::pubkey(44),
- blinded_hops: vec![
- BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() },
- BlindedHop { blinded_node_id: ln_test_utils::pubkey(46), encrypted_payload: Vec::new() }
- ],
- };
let mut route = Route { paths: vec![Path {
hops: vec![RouteHop {
pubkey: ln_test_utils::pubkey(42),
}
],
blinded_tail: Some(BlindedTail {
- hops: blinded_path.blinded_hops,
- blinding_point: blinded_path.blinding_point,
+ hops: vec![
+ BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() },
+ BlindedHop { blinded_node_id: ln_test_utils::pubkey(46), encrypted_payload: Vec::new() }
+ ],
+ blinding_point: ln_test_utils::pubkey(44),
excess_final_cltv_expiry_delta: 0,
final_value_msat: 200,
}),
#[cfg(test)]
mod tests {
use super::{ChannelLiquidity, HistoricalBucketRangeTracker, ProbabilisticScoringFeeParameters, ProbabilisticScoringDecayParameters, ProbabilisticScorer};
- use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode};
+ use crate::blinded_path::BlindedHop;
use crate::util::config::UserConfig;
use crate::ln::channelmanager;
let mut path = payment_path_for_amount(768);
let recipient_hop = path.hops.pop().unwrap();
- let blinded_path = BlindedPath {
- introduction_node: IntroductionNode::NodeId(path.hops.last().as_ref().unwrap().pubkey),
- blinding_point: test_utils::pubkey(42),
- blinded_hops: vec![
- BlindedHop { blinded_node_id: test_utils::pubkey(44), encrypted_payload: Vec::new() }
- ],
- };
path.blinded_tail = Some(BlindedTail {
- hops: blinded_path.blinded_hops,
- blinding_point: blinded_path.blinding_point,
+ hops: vec![BlindedHop { blinded_node_id: test_utils::pubkey(44), encrypted_payload: Vec::new() }],
+ blinding_point: test_utils::pubkey(42),
excess_final_cltv_expiry_delta: recipient_hop.cltv_expiry_delta,
final_value_msat: recipient_hop.fee_msat,
});