From: Matt Corallo Date: Wed, 21 Aug 2024 16:46:24 +0000 (+0000) Subject: Disambiguate blinded path `ForwardNode`s between payment + message X-Git-Tag: v0.0.124-rc1~17^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=refs%2Fheads%2F2024-08-globally-unique-names;p=rust-lightning Disambiguate blinded path `ForwardNode`s between payment + message We currently have two structs with identical names in our public API - `blinded_path::message::ForwardNode` and `blinded_path::payment::ForwardNode`. This makes the API somewhat awkward to use - users have to try (and fail) to import `ForwardNode` twice only to then have to change their imports. More importantly, however, this makes the API very hard to use in some bindings languages where rename-imports or module imports aren't available. Thus, here, we rename both to give them context. --- diff --git a/fuzz/src/invoice_request_deser.rs b/fuzz/src/invoice_request_deser.rs index 3abb0974e..f93199cf9 100644 --- a/fuzz/src/invoice_request_deser.rs +++ b/fuzz/src/invoice_request_deser.rs @@ -11,8 +11,8 @@ use crate::utils::test_logger; use bitcoin::secp256k1::{self, Keypair, Parity, PublicKey, Secp256k1, SecretKey}; use core::convert::TryFrom; use lightning::blinded_path::payment::{ - BlindedPaymentPath, Bolt12OfferContext, ForwardNode, ForwardTlvs, PaymentConstraints, - PaymentContext, PaymentRelay, ReceiveTlvs, + BlindedPaymentPath, Bolt12OfferContext, ForwardTlvs, PaymentConstraints, PaymentContext, + PaymentForwardNode, PaymentRelay, ReceiveTlvs, }; use lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA; use lightning::ln::features::BlindedHopFeatures; @@ -100,7 +100,7 @@ fn build_response( }, payment_context, }; - let intermediate_nodes = [ForwardNode { + let intermediate_nodes = [PaymentForwardNode { tlvs: ForwardTlvs { short_channel_id: 43, payment_relay: PaymentRelay { diff --git a/fuzz/src/refund_deser.rs b/fuzz/src/refund_deser.rs index 17f255081..b60b4f844 100644 --- a/fuzz/src/refund_deser.rs +++ b/fuzz/src/refund_deser.rs @@ -11,8 +11,8 @@ use crate::utils::test_logger; use bitcoin::secp256k1::{self, Keypair, PublicKey, Secp256k1, SecretKey}; use core::convert::TryFrom; use lightning::blinded_path::payment::{ - BlindedPaymentPath, Bolt12RefundContext, ForwardNode, ForwardTlvs, PaymentConstraints, - PaymentContext, PaymentRelay, ReceiveTlvs, + BlindedPaymentPath, Bolt12RefundContext, ForwardTlvs, PaymentConstraints, PaymentContext, + PaymentForwardNode, PaymentRelay, ReceiveTlvs, }; use lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA; use lightning::ln::features::BlindedHopFeatures; @@ -78,7 +78,7 @@ fn build_response( }, payment_context, }; - let intermediate_nodes = [ForwardNode { + let intermediate_nodes = [PaymentForwardNode { tlvs: ForwardTlvs { short_channel_id: 43, payment_relay: PaymentRelay { diff --git a/lightning/src/blinded_path/message.rs b/lightning/src/blinded_path/message.rs index 93d36d621..5c8875d80 100644 --- a/lightning/src/blinded_path/message.rs +++ b/lightning/src/blinded_path/message.rs @@ -65,8 +65,8 @@ impl BlindedMessagePath { /// Errors if no hops are provided or if `node_pk`(s) are invalid. // TODO: make all payloads the same size with padding + add dummy hops pub fn new( - intermediate_nodes: &[ForwardNode], recipient_node_id: PublicKey, context: MessageContext, - entropy_source: ES, secp_ctx: &Secp256k1 + intermediate_nodes: &[MessageForwardNode], recipient_node_id: PublicKey, + context: MessageContext, entropy_source: ES, secp_ctx: &Secp256k1, ) -> Result where ES::Target: EntropySource { let introduction_node = IntroductionNode::NodeId( intermediate_nodes.first().map_or(recipient_node_id, |n| n.node_id) @@ -216,12 +216,12 @@ pub enum NextMessageHop { /// An intermediate node, and possibly a short channel id leading to the next node. #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] -pub struct ForwardNode { +pub struct MessageForwardNode { /// This node's pubkey. pub node_id: PublicKey, /// The channel between `node_id` and the next hop. If set, the constructed [`BlindedHop`]'s - /// `encrypted_payload` will use this instead of the next [`ForwardNode::node_id`] for a more - /// compact representation. + /// `encrypted_payload` will use this instead of the next [`MessageForwardNode::node_id`] for a + /// more compact representation. pub short_channel_id: Option, } @@ -371,8 +371,8 @@ impl_writeable_tlv_based_enum!(OffersContext, /// Construct blinded onion message hops for the given `intermediate_nodes` and `recipient_node_id`. pub(super) fn blinded_hops( - secp_ctx: &Secp256k1, intermediate_nodes: &[ForwardNode], recipient_node_id: PublicKey, - context: MessageContext, session_priv: &SecretKey + secp_ctx: &Secp256k1, intermediate_nodes: &[MessageForwardNode], + recipient_node_id: PublicKey, context: MessageContext, session_priv: &SecretKey, ) -> Result, secp256k1::Error> { let pks = intermediate_nodes.iter().map(|node| &node.node_id) .chain(core::iter::once(&recipient_node_id)); diff --git a/lightning/src/blinded_path/payment.rs b/lightning/src/blinded_path/payment.rs index e128e6675..ea7d0545d 100644 --- a/lightning/src/blinded_path/payment.rs +++ b/lightning/src/blinded_path/payment.rs @@ -103,9 +103,9 @@ impl BlindedPaymentPath { /// * any unknown features are required in the provided [`ForwardTlvs`] // TODO: make all payloads the same size with padding + add dummy hops pub fn new( - intermediate_nodes: &[ForwardNode], payee_node_id: PublicKey, payee_tlvs: ReceiveTlvs, - htlc_maximum_msat: u64, min_final_cltv_expiry_delta: u16, entropy_source: ES, - secp_ctx: &Secp256k1 + intermediate_nodes: &[PaymentForwardNode], payee_node_id: PublicKey, + payee_tlvs: ReceiveTlvs, htlc_maximum_msat: u64, min_final_cltv_expiry_delta: u16, + entropy_source: ES, secp_ctx: &Secp256k1, ) -> Result where ES::Target: EntropySource { let introduction_node = IntroductionNode::NodeId( intermediate_nodes.first().map_or(payee_node_id, |n| n.node_id) @@ -221,7 +221,7 @@ impl BlindedPaymentPath { /// An intermediate node, its outbound channel, and relay parameters. #[derive(Clone, Debug)] -pub struct ForwardNode { +pub struct PaymentForwardNode { /// The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also /// used for [`BlindedPayInfo`] construction. pub tlvs: ForwardTlvs, @@ -459,8 +459,8 @@ impl Readable for BlindedPaymentTlvs { /// Construct blinded payment hops for the given `intermediate_nodes` and payee info. pub(super) fn blinded_hops( - secp_ctx: &Secp256k1, intermediate_nodes: &[ForwardNode], - payee_node_id: PublicKey, payee_tlvs: ReceiveTlvs, session_priv: &SecretKey + secp_ctx: &Secp256k1, intermediate_nodes: &[PaymentForwardNode], + payee_node_id: PublicKey, payee_tlvs: ReceiveTlvs, session_priv: &SecretKey, ) -> Result, secp256k1::Error> { let pks = intermediate_nodes.iter().map(|node| &node.node_id) .chain(core::iter::once(&payee_node_id)); @@ -491,8 +491,8 @@ pub(crate) fn amt_to_forward_msat(inbound_amt_msat: u64, payment_relay: &Payment } pub(super) fn compute_payinfo( - intermediate_nodes: &[ForwardNode], payee_tlvs: &ReceiveTlvs, payee_htlc_maximum_msat: u64, - min_final_cltv_expiry_delta: u16 + intermediate_nodes: &[PaymentForwardNode], payee_tlvs: &ReceiveTlvs, + payee_htlc_maximum_msat: u64, min_final_cltv_expiry_delta: u16, ) -> Result { let mut curr_base_fee: u64 = 0; let mut curr_prop_mil: u64 = 0; @@ -628,7 +628,7 @@ impl_writeable_tlv_based!(Bolt12RefundContext, {}); #[cfg(test)] mod tests { use bitcoin::secp256k1::PublicKey; - use crate::blinded_path::payment::{ForwardNode, ForwardTlvs, ReceiveTlvs, PaymentConstraints, PaymentContext, PaymentRelay}; + use crate::blinded_path::payment::{PaymentForwardNode, ForwardTlvs, ReceiveTlvs, PaymentConstraints, PaymentContext, PaymentRelay}; use crate::ln::types::PaymentSecret; use crate::ln::features::BlindedHopFeatures; use crate::ln::functional_test_utils::TEST_FINAL_CLTV; @@ -638,7 +638,7 @@ mod tests { // Taken from the spec example for aggregating blinded payment info. See // https://github.com/lightning/bolts/blob/master/proposals/route-blinding.md#blinded-payments let dummy_pk = PublicKey::from_slice(&[2; 33]).unwrap(); - let intermediate_nodes = vec![ForwardNode { + let intermediate_nodes = vec![PaymentForwardNode { node_id: dummy_pk, tlvs: ForwardTlvs { short_channel_id: 0, @@ -655,7 +655,7 @@ mod tests { features: BlindedHopFeatures::empty(), }, htlc_maximum_msat: u64::max_value(), - }, ForwardNode { + }, PaymentForwardNode { node_id: dummy_pk, tlvs: ForwardTlvs { short_channel_id: 0, @@ -713,7 +713,7 @@ mod tests { // If no hops charge fees, the htlc_minimum_msat should just be the maximum htlc_minimum_msat // along the path. let dummy_pk = PublicKey::from_slice(&[2; 33]).unwrap(); - let intermediate_nodes = vec![ForwardNode { + let intermediate_nodes = vec![PaymentForwardNode { node_id: dummy_pk, tlvs: ForwardTlvs { short_channel_id: 0, @@ -730,7 +730,7 @@ mod tests { features: BlindedHopFeatures::empty(), }, htlc_maximum_msat: u64::max_value() - }, ForwardNode { + }, PaymentForwardNode { node_id: dummy_pk, tlvs: ForwardTlvs { short_channel_id: 0, @@ -766,7 +766,7 @@ mod tests { // Create a path with varying fees and htlc_mins, and make sure htlc_minimum_msat ends up as the // max (htlc_min - following_fees) along the path. let dummy_pk = PublicKey::from_slice(&[2; 33]).unwrap(); - let intermediate_nodes = vec![ForwardNode { + let intermediate_nodes = vec![PaymentForwardNode { node_id: dummy_pk, tlvs: ForwardTlvs { short_channel_id: 0, @@ -783,7 +783,7 @@ mod tests { features: BlindedHopFeatures::empty(), }, htlc_maximum_msat: u64::max_value() - }, ForwardNode { + }, PaymentForwardNode { node_id: dummy_pk, tlvs: ForwardTlvs { short_channel_id: 0, @@ -823,7 +823,7 @@ mod tests { // Create a path with varying fees and `htlc_maximum_msat`s, and make sure the aggregated max // htlc ends up as the min (htlc_max - following_fees) along the path. let dummy_pk = PublicKey::from_slice(&[2; 33]).unwrap(); - let intermediate_nodes = vec![ForwardNode { + let intermediate_nodes = vec![PaymentForwardNode { node_id: dummy_pk, tlvs: ForwardTlvs { short_channel_id: 0, @@ -840,7 +840,7 @@ mod tests { features: BlindedHopFeatures::empty(), }, htlc_maximum_msat: 5_000, - }, ForwardNode { + }, PaymentForwardNode { node_id: dummy_pk, tlvs: ForwardTlvs { short_channel_id: 0, diff --git a/lightning/src/ln/blinded_payment_tests.rs b/lightning/src/ln/blinded_payment_tests.rs index eecbb9c4b..16dcef2ea 100644 --- a/lightning/src/ln/blinded_payment_tests.rs +++ b/lightning/src/ln/blinded_payment_tests.rs @@ -12,7 +12,7 @@ use bitcoin::secp256k1::{PublicKey, Scalar, Secp256k1, SecretKey, schnorr}; use bitcoin::secp256k1::ecdh::SharedSecret; use bitcoin::secp256k1::ecdsa::{RecoverableSignature, Signature}; use crate::blinded_path; -use crate::blinded_path::payment::{BlindedPaymentPath, ForwardNode, ForwardTlvs, PaymentConstraints, PaymentContext, PaymentRelay, ReceiveTlvs}; +use crate::blinded_path::payment::{BlindedPaymentPath, PaymentForwardNode, ForwardTlvs, PaymentConstraints, PaymentContext, PaymentRelay, ReceiveTlvs}; use crate::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PaymentFailureReason}; use crate::ln::types::{ChannelId, PaymentHash, PaymentSecret}; use crate::ln::channelmanager; @@ -44,7 +44,7 @@ fn blinded_payment_path( let mut intro_node_min_htlc_opt = Some(intro_node_min_htlc); let mut intro_node_max_htlc_opt = Some(intro_node_max_htlc); for (idx, (node_id, chan_upd)) in node_ids.iter().zip(channel_upds).enumerate() { - intermediate_nodes.push(ForwardNode { + intermediate_nodes.push(PaymentForwardNode { node_id: *node_id, tlvs: ForwardTlvs { short_channel_id: chan_upd.short_channel_id, diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 167ab0ac8..8a07e18a4 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -34,7 +34,7 @@ use bitcoin::{secp256k1, Sequence}; use crate::blinded_path::message::{MessageContext, OffersContext}; use crate::blinded_path::NodeIdLookUp; -use crate::blinded_path::message::{BlindedMessagePath, ForwardNode}; +use crate::blinded_path::message::{BlindedMessagePath, MessageForwardNode}; use crate::blinded_path::payment::{BlindedPaymentPath, Bolt12OfferContext, Bolt12RefundContext, PaymentConstraints, PaymentContext, ReceiveTlvs}; use crate::chain; use crate::chain::{Confirm, ChannelMonitorUpdateStatus, Watch, BestBlock}; @@ -9354,7 +9354,7 @@ where .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap())) .filter(|(_, peer)| peer.is_connected) .filter(|(_, peer)| peer.latest_features.supports_onion_messages()) - .map(|(node_id, peer)| ForwardNode { + .map(|(node_id, peer)| MessageForwardNode { node_id: *node_id, short_channel_id: peer.channel_by_id .iter() diff --git a/lightning/src/onion_message/functional_tests.rs b/lightning/src/onion_message/functional_tests.rs index 508e7982b..bb0b816b1 100644 --- a/lightning/src/onion_message/functional_tests.rs +++ b/lightning/src/onion_message/functional_tests.rs @@ -10,7 +10,7 @@ //! Onion message testing and test utilities live here. use crate::blinded_path::EmptyNodeIdLookUp; -use crate::blinded_path::message::{BlindedMessagePath, ForwardNode, MessageContext, OffersContext}; +use crate::blinded_path::message::{BlindedMessagePath, MessageForwardNode, MessageContext, OffersContext}; use crate::events::{Event, EventsProvider}; use crate::ln::features::{ChannelFeatures, InitFeatures}; use crate::ln::msgs::{self, DecodeError, OnionMessageHandler}; @@ -386,7 +386,7 @@ fn two_unblinded_two_blinded() { let test_msg = TestCustomMessage::Pong; let secp_ctx = Secp256k1::new(); - let intermediate_nodes = [ForwardNode { node_id: nodes[3].node_id, short_channel_id: None }]; + let intermediate_nodes = [MessageForwardNode { node_id: nodes[3].node_id, short_channel_id: None }]; let context = MessageContext::Custom(Vec::new()); let blinded_path = BlindedMessagePath::new(&intermediate_nodes, nodes[4].node_id, context, &*nodes[4].entropy_source, &secp_ctx).unwrap(); let path = OnionMessagePath { @@ -407,8 +407,8 @@ fn three_blinded_hops() { let secp_ctx = Secp256k1::new(); let intermediate_nodes = [ - ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }, - ForwardNode { node_id: nodes[2].node_id, short_channel_id: None }, + MessageForwardNode { node_id: nodes[1].node_id, short_channel_id: None }, + MessageForwardNode { node_id: nodes[2].node_id, short_channel_id: None }, ]; let context = MessageContext::Custom(Vec::new()); let blinded_path = BlindedMessagePath::new(&intermediate_nodes, nodes[3].node_id, context, &*nodes[3].entropy_source, &secp_ctx).unwrap(); @@ -548,8 +548,8 @@ fn we_are_intro_node() { let secp_ctx = Secp256k1::new(); let intermediate_nodes = [ - ForwardNode { node_id: nodes[0].node_id, short_channel_id: None }, - ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }, + MessageForwardNode { node_id: nodes[0].node_id, short_channel_id: None }, + MessageForwardNode { node_id: nodes[1].node_id, short_channel_id: None }, ]; let context = MessageContext::Custom(Vec::new()); let blinded_path = BlindedMessagePath::new(&intermediate_nodes, nodes[2].node_id, context, &*nodes[2].entropy_source, &secp_ctx).unwrap(); @@ -560,7 +560,7 @@ fn we_are_intro_node() { pass_along_path(&nodes); // Try with a two-hop blinded path where we are the introduction node. - let intermediate_nodes = [ForwardNode { node_id: nodes[0].node_id, short_channel_id: None }]; + let intermediate_nodes = [MessageForwardNode { node_id: nodes[0].node_id, short_channel_id: None }]; let context = MessageContext::Custom(Vec::new()); let blinded_path = BlindedMessagePath::new(&intermediate_nodes, nodes[1].node_id, context, &*nodes[1].entropy_source, &secp_ctx).unwrap(); let destination = Destination::BlindedPath(blinded_path); @@ -577,7 +577,7 @@ fn invalid_blinded_path_error() { let test_msg = TestCustomMessage::Pong; let secp_ctx = Secp256k1::new(); - let intermediate_nodes = [ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }]; + let intermediate_nodes = [MessageForwardNode { node_id: nodes[1].node_id, short_channel_id: None }]; let context = MessageContext::Custom(Vec::new()); let mut blinded_path = BlindedMessagePath::new(&intermediate_nodes, nodes[2].node_id, context, &*nodes[2].entropy_source, &secp_ctx).unwrap(); blinded_path.clear_blinded_hops(); @@ -599,8 +599,8 @@ fn reply_path() { first_node_addresses: None, }; let intermediate_nodes = [ - ForwardNode { node_id: nodes[2].node_id, short_channel_id: None }, - ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }, + MessageForwardNode { node_id: nodes[2].node_id, short_channel_id: None }, + MessageForwardNode { node_id: nodes[1].node_id, short_channel_id: None }, ]; let context = MessageContext::Custom(Vec::new()); let reply_path = BlindedMessagePath::new(&intermediate_nodes, nodes[0].node_id, context, &*nodes[0].entropy_source, &secp_ctx).unwrap(); @@ -614,15 +614,15 @@ fn reply_path() { // Destination::BlindedPath let intermediate_nodes = [ - ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }, - ForwardNode { node_id: nodes[2].node_id, short_channel_id: None }, + MessageForwardNode { node_id: nodes[1].node_id, short_channel_id: None }, + MessageForwardNode { node_id: nodes[2].node_id, short_channel_id: None }, ]; let context = MessageContext::Custom(Vec::new()); let blinded_path = BlindedMessagePath::new(&intermediate_nodes, nodes[3].node_id, context, &*nodes[3].entropy_source, &secp_ctx).unwrap(); let destination = Destination::BlindedPath(blinded_path); let intermediate_nodes = [ - ForwardNode { node_id: nodes[2].node_id, short_channel_id: None }, - ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }, + MessageForwardNode { node_id: nodes[2].node_id, short_channel_id: None }, + MessageForwardNode { node_id: nodes[1].node_id, short_channel_id: None }, ]; let context = MessageContext::Custom(Vec::new()); let reply_path = BlindedMessagePath::new(&intermediate_nodes, nodes[0].node_id, context, &*nodes[0].entropy_source, &secp_ctx).unwrap(); @@ -705,7 +705,7 @@ fn requests_peer_connection_for_buffered_messages() { let secp_ctx = Secp256k1::new(); add_channel_to_graph(&nodes[0], &nodes[1], &secp_ctx, 42); - let intermediate_nodes = [ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }]; + let intermediate_nodes = [MessageForwardNode { node_id: nodes[1].node_id, short_channel_id: None }]; let context = MessageContext::Custom(Vec::new()); let blinded_path = BlindedMessagePath::new( &intermediate_nodes, nodes[2].node_id, context, &*nodes[0].entropy_source, &secp_ctx @@ -744,7 +744,7 @@ fn drops_buffered_messages_waiting_for_peer_connection() { let secp_ctx = Secp256k1::new(); add_channel_to_graph(&nodes[0], &nodes[1], &secp_ctx, 42); - let intermediate_nodes = [ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }]; + let intermediate_nodes = [MessageForwardNode { node_id: nodes[1].node_id, short_channel_id: None }]; let context = MessageContext::Custom(Vec::new()); let blinded_path = BlindedMessagePath::new( &intermediate_nodes, nodes[2].node_id, context, &*nodes[0].entropy_source, &secp_ctx @@ -795,7 +795,7 @@ fn intercept_offline_peer_oms() { let message = TestCustomMessage::Pong; let secp_ctx = Secp256k1::new(); - let intermediate_nodes = [ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }]; + let intermediate_nodes = [MessageForwardNode { node_id: nodes[1].node_id, short_channel_id: None }]; let context = MessageContext::Custom(Vec::new()); let blinded_path = BlindedMessagePath::new( &intermediate_nodes, nodes[2].node_id, context, &*nodes[2].entropy_source, &secp_ctx diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index 89aa4dbce..ac2cf3c32 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -16,7 +16,7 @@ use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey}; use crate::blinded_path::{IntroductionNode, NodeIdLookUp}; -use crate::blinded_path::message::{BlindedMessagePath, ForwardNode, ForwardTlvs, MessageContext, NextMessageHop, ReceiveTlvs}; +use crate::blinded_path::message::{BlindedMessagePath, MessageForwardNode, ForwardTlvs, MessageContext, NextMessageHop, ReceiveTlvs}; use crate::blinded_path::utils; use crate::events::{Event, EventHandler, EventsProvider, ReplayEvent}; use crate::sign::{EntropySource, NodeSigner, Recipient}; @@ -148,7 +148,7 @@ for OnionMessenger where /// # use bitcoin::hex::FromHex; /// # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey, self}; /// # use lightning::blinded_path::EmptyNodeIdLookUp; -/// # use lightning::blinded_path::message::{BlindedMessagePath, ForwardNode, MessageContext}; +/// # use lightning::blinded_path::message::{BlindedMessagePath, MessageForwardNode, MessageContext}; /// # use lightning::sign::{EntropySource, KeysManager}; /// # use lightning::ln::peer_handler::IgnoringMessageHandler; /// # use lightning::onion_message::messenger::{Destination, MessageRouter, OnionMessagePath, OnionMessenger}; @@ -225,8 +225,8 @@ for OnionMessenger where /// // Create a blinded path to yourself, for someone to send an onion message to. /// # let your_node_id = hop_node_id1; /// let hops = [ -/// ForwardNode { node_id: hop_node_id3, short_channel_id: None }, -/// ForwardNode { node_id: hop_node_id4, short_channel_id: None }, +/// MessageForwardNode { node_id: hop_node_id3, short_channel_id: None }, +/// MessageForwardNode { node_id: hop_node_id4, short_channel_id: None }, /// ]; /// let context = MessageContext::Custom(Vec::new()); /// let blinded_path = BlindedMessagePath::new(&hops, your_node_id, context, &keys_manager, &secp_ctx).unwrap(); @@ -452,12 +452,12 @@ pub trait MessageRouter { /// 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 - /// [`ForwardNode`] but may be `None` for graceful degradation. + /// 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 - /// [`ForwardNode`] with `Some` short channel id, if possible. Similarly, implementations should - /// call [`BlindedMessagePath::use_compact_introduction_node`]. + /// [`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. @@ -465,11 +465,11 @@ pub trait MessageRouter { T: secp256k1::Signing + secp256k1::Verification >( &self, recipient: PublicKey, context: MessageContext, - peers: Vec, secp_ctx: &Secp256k1, + peers: Vec, secp_ctx: &Secp256k1, ) -> Result, ()> { let peers = peers .into_iter() - .map(|ForwardNode { node_id, short_channel_id: _ }| node_id) + .map(|MessageForwardNode { node_id, short_channel_id: _ }| node_id) .collect(); self.create_blinded_paths(recipient, context, peers, secp_ctx) } @@ -503,7 +503,7 @@ where } fn create_blinded_paths_from_iter< - I: ExactSizeIterator, + I: ExactSizeIterator, T: secp256k1::Signing + secp256k1::Verification >( network_graph: &G, recipient: PublicKey, context: MessageContext, peers: I, @@ -613,7 +613,7 @@ where ) -> Result, ()> { let peers = peers .into_iter() - .map(|node_id| ForwardNode { node_id, short_channel_id: None }); + .map(|node_id| MessageForwardNode { node_id, short_channel_id: None }); Self::create_blinded_paths_from_iter(network_graph, recipient, context, peers.into_iter(), entropy_source, secp_ctx, false) } @@ -621,7 +621,7 @@ where T: secp256k1::Signing + secp256k1::Verification >( network_graph: &G, recipient: PublicKey, context: MessageContext, - peers: Vec, entropy_source: &ES, secp_ctx: &Secp256k1, + peers: Vec, entropy_source: &ES, secp_ctx: &Secp256k1, ) -> Result, ()> { Self::create_blinded_paths_from_iter(network_graph, recipient, context, peers.into_iter(), entropy_source, secp_ctx, true) } @@ -649,7 +649,7 @@ where fn create_compact_blinded_paths< T: secp256k1::Signing + secp256k1::Verification >( - &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, + &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, ) -> Result, ()> { Self::create_compact_blinded_paths(&self.network_graph, recipient, context, peers, &self.entropy_source, secp_ctx) } diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index fa2bbac1d..eb6194ed4 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -12,8 +12,8 @@ use bitcoin::secp256k1::{PublicKey, Secp256k1, self}; use crate::blinded_path::{BlindedHop, Direction, IntroductionNode}; -use crate::blinded_path::message::{self, BlindedMessagePath, MessageContext}; -use crate::blinded_path::payment::{BlindedPaymentPath, ForwardTlvs, PaymentConstraints, PaymentRelay, ReceiveTlvs, self}; +use crate::blinded_path::message::{BlindedMessagePath, MessageContext, MessageForwardNode}; +use crate::blinded_path::payment::{BlindedPaymentPath, ForwardTlvs, PaymentConstraints, PaymentForwardNode, PaymentRelay, ReceiveTlvs}; use crate::ln::{PaymentHash, PaymentPreimage}; use crate::ln::channel_state::ChannelDetails; use crate::ln::channelmanager::{PaymentId, MIN_FINAL_CLTV_EXPIRY_DELTA, RecipientOnionFields}; @@ -146,7 +146,7 @@ impl>, L: Deref, ES: Deref, S: Deref, SP: Size max_cltv_expiry: tlvs.payment_constraints.max_cltv_expiry + cltv_expiry_delta, htlc_minimum_msat: details.inbound_htlc_minimum_msat.unwrap_or(0), }; - Some(payment::ForwardNode { + Some(PaymentForwardNode { tlvs: ForwardTlvs { short_channel_id, payment_relay, @@ -205,7 +205,7 @@ impl< G: Deref>, L: Deref, ES: Deref, S: Deref, SP: Siz fn create_compact_blinded_paths< T: secp256k1::Signing + secp256k1::Verification > ( - &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, + &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, ) -> Result, ()> { DefaultMessageRouter::create_compact_blinded_paths(&self.network_graph, recipient, context, peers, &self.entropy_source, secp_ctx) } diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index 5a7537b08..b28714935 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -8,7 +8,7 @@ // licenses. use crate::blinded_path::message::MessageContext; -use crate::blinded_path::message::{BlindedMessagePath, ForwardNode}; +use crate::blinded_path::message::{BlindedMessagePath, MessageForwardNode}; use crate::blinded_path::payment::{BlindedPaymentPath, ReceiveTlvs}; use crate::chain; use crate::chain::WatchedOutput; @@ -278,7 +278,7 @@ impl<'a> MessageRouter for TestRouter<'a> { T: secp256k1::Signing + secp256k1::Verification >( &self, recipient: PublicKey, context: MessageContext, - peers: Vec, secp_ctx: &Secp256k1, + peers: Vec, secp_ctx: &Secp256k1, ) -> Result, ()> { self.router.create_compact_blinded_paths(recipient, context, peers, secp_ctx) } @@ -321,7 +321,7 @@ impl<'a> MessageRouter for TestMessageRouter<'a> { fn create_compact_blinded_paths( &self, recipient: PublicKey, context: MessageContext, - peers: Vec, secp_ctx: &Secp256k1, + peers: Vec, secp_ctx: &Secp256k1, ) -> Result, ()> { self.inner.create_compact_blinded_paths(recipient, context, peers, secp_ctx) }