X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Frouting%2Frouter.rs;h=5b202604e371a5624a5cce671f2ec3fbe44a7eab;hb=a9dcfaf952584ed835d733cb4688d5f96e86349d;hp=28101991cf700c35fab7e781e7389979564a0361;hpb=73263348ba55c976fa8e17b8c3cf71bc6f117568;p=rust-lightning diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 28101991..5b202604 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -15,7 +15,8 @@ use crate::blinded_path::{BlindedHop, BlindedPath, Direction, IntroductionNode}; use crate::blinded_path::message; use crate::blinded_path::payment::{ForwardTlvs, PaymentConstraints, PaymentRelay, ReceiveTlvs, self}; use crate::ln::{PaymentHash, PaymentPreimage}; -use crate::ln::channelmanager::{ChannelDetails, PaymentId, MIN_FINAL_CLTV_EXPIRY_DELTA, RecipientOnionFields}; +use crate::ln::channel_state::ChannelDetails; +use crate::ln::channelmanager::{PaymentId, MIN_FINAL_CLTV_EXPIRY_DELTA, RecipientOnionFields}; use crate::ln::features::{BlindedHopFeatures, Bolt11InvoiceFeatures, Bolt12InvoiceFeatures, ChannelFeatures, NodeFeatures}; use crate::ln::msgs::{DecodeError, ErrorAction, LightningError, MAX_VALUE_MSAT}; use crate::ln::onion_utils; @@ -35,6 +36,11 @@ use core::{cmp, fmt}; use core::ops::Deref; /// A [`Router`] implemented using [`find_route`]. +/// +/// # Privacy +/// +/// Implements [`MessageRouter`] by delegating to [`DefaultMessageRouter`]. See those docs for +/// privacy implications. pub struct DefaultRouter> + Clone, L: Deref, ES: Deref, S: Deref, SP: Sized, Sc: ScoreLookUp> where L::Target: Logger, S::Target: for <'a> LockableScore<'a, ScoreLookUp = Sc>, @@ -172,10 +178,18 @@ impl< G: Deref> + Clone, L: Deref, ES: Deref, S: Deref, fn create_blinded_paths< T: secp256k1::Signing + secp256k1::Verification > ( - &self, recipient: PublicKey, peers: Vec, secp_ctx: &Secp256k1, + &self, recipient: PublicKey, peers: Vec, secp_ctx: &Secp256k1, ) -> Result, ()> { self.message_router.create_blinded_paths(recipient, peers, secp_ctx) } + + fn create_compact_blinded_paths< + T: secp256k1::Signing + secp256k1::Verification + > ( + &self, recipient: PublicKey, peers: Vec, secp_ctx: &Secp256k1, + ) -> Result, ()> { + self.message_router.create_compact_blinded_paths(recipient, peers, secp_ctx) + } } /// A trait defining behavior for routing a payment. @@ -2009,7 +2023,7 @@ where L::Target: Logger { true } else if let Some(payee) = payee_node_id_opt { network_nodes.get(&payee).map_or(false, |node| node.announcement_info.as_ref().map_or(false, - |info| info.features.supports_basic_mpp())) + |info| info.features().supports_basic_mpp())) } else { false }; let max_total_routing_fee_msat = route_params.max_total_routing_fee_msat.unwrap_or(u64::max_value()); @@ -2499,7 +2513,7 @@ where L::Target: Logger { } let features = if let Some(node_info) = $node.announcement_info.as_ref() { - &node_info.features + &node_info.features() } else { &default_node_features }; @@ -2828,7 +2842,7 @@ where L::Target: Logger { if !features_set { if let Some(node) = network_nodes.get(&target) { if let Some(node_info) = node.announcement_info.as_ref() { - ordered_hops.last_mut().unwrap().1 = node_info.features.clone(); + ordered_hops.last_mut().unwrap().1 = node_info.features().clone(); } else { ordered_hops.last_mut().unwrap().1 = default_node_features.clone(); } @@ -3321,6 +3335,7 @@ mod tests { use crate::routing::test_utils::{add_channel, add_or_update_node, build_graph, build_line_graph, id_to_feature_flags, get_nodes, update_channel}; use crate::chain::transaction::OutPoint; use crate::sign::EntropySource; + use crate::ln::channel_state::{ChannelCounterparty, ChannelDetails, ChannelShutdownState}; use crate::ln::types::ChannelId; use crate::ln::features::{BlindedHopFeatures, ChannelFeatures, InitFeatures, NodeFeatures}; use crate::ln::msgs::{ErrorAction, LightningError, UnsignedChannelUpdate, MAX_VALUE_MSAT}; @@ -3349,10 +3364,10 @@ mod tests { use crate::sync::Arc; fn get_channel_details(short_channel_id: Option, node_id: PublicKey, - features: InitFeatures, outbound_capacity_msat: u64) -> channelmanager::ChannelDetails { - channelmanager::ChannelDetails { + features: InitFeatures, outbound_capacity_msat: u64) -> ChannelDetails { + ChannelDetails { channel_id: ChannelId::new_zero(), - counterparty: channelmanager::ChannelCounterparty { + counterparty: ChannelCounterparty { features, node_id, unspendable_punishment_reserve: 0, @@ -3382,7 +3397,7 @@ mod tests { inbound_htlc_maximum_msat: None, config: None, feerate_sat_per_1000_weight: None, - channel_shutdown_state: Some(channelmanager::ChannelShutdownState::NotShuttingDown), + channel_shutdown_state: Some(ChannelShutdownState::NotShuttingDown), pending_inbound_htlcs: Vec::new(), pending_outbound_htlcs: Vec::new(), } @@ -8504,8 +8519,9 @@ pub(crate) mod bench_utils { use crate::chain::transaction::OutPoint; use crate::routing::scoring::ScoreUpdate; use crate::sign::KeysManager; + use crate::ln::channel_state::{ChannelCounterparty, ChannelShutdownState}; + use crate::ln::channelmanager; use crate::ln::types::ChannelId; - use crate::ln::channelmanager::{self, ChannelCounterparty}; use crate::util::config::UserConfig; use crate::util::test_utils::TestLogger; @@ -8590,7 +8606,7 @@ pub(crate) mod bench_utils { inbound_htlc_maximum_msat: None, config: None, feerate_sat_per_1000_weight: None, - channel_shutdown_state: Some(channelmanager::ChannelShutdownState::NotShuttingDown), + channel_shutdown_state: Some(ChannelShutdownState::NotShuttingDown), pending_inbound_htlcs: Vec::new(), pending_outbound_htlcs: Vec::new(), }