]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Disambiguate blinded path `ForwardNode`s between payment + message 2024-08-globally-unique-names
authorMatt Corallo <git@bluematt.me>
Wed, 21 Aug 2024 16:46:24 +0000 (16:46 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 21 Aug 2024 19:48:34 +0000 (19:48 +0000)
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.

fuzz/src/invoice_request_deser.rs
fuzz/src/refund_deser.rs
lightning/src/blinded_path/message.rs
lightning/src/blinded_path/payment.rs
lightning/src/ln/blinded_payment_tests.rs
lightning/src/ln/channelmanager.rs
lightning/src/onion_message/functional_tests.rs
lightning/src/onion_message/messenger.rs
lightning/src/routing/router.rs
lightning/src/util/test_utils.rs

index 3abb0974e43660cb2a482c3bc955550cfd09ae13..f93199cf94c84e1bbd141dc0bba43f8889175d78 100644 (file)
@@ -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<T: secp256k1::Signing + secp256k1::Verification>(
                },
                payment_context,
        };
-       let intermediate_nodes = [ForwardNode {
+       let intermediate_nodes = [PaymentForwardNode {
                tlvs: ForwardTlvs {
                        short_channel_id: 43,
                        payment_relay: PaymentRelay {
index 17f255081c46649fcf70376e8a808102d195ca57..b60b4f84491b2afe33f91c1481931d8aa24d12fc 100644 (file)
@@ -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<T: secp256k1::Signing + secp256k1::Verification>(
                },
                payment_context,
        };
-       let intermediate_nodes = [ForwardNode {
+       let intermediate_nodes = [PaymentForwardNode {
                tlvs: ForwardTlvs {
                        short_channel_id: 43,
                        payment_relay: PaymentRelay {
index 93d36d621c976fe1bb3546802a56c294a8218da5..5c8875d80ce61de88c99eaac9c46efd74868b9f3 100644 (file)
@@ -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<ES: Deref, T: secp256k1::Signing + secp256k1::Verification>(
-               intermediate_nodes: &[ForwardNode], recipient_node_id: PublicKey, context: MessageContext,
-               entropy_source: ES, secp_ctx: &Secp256k1<T>
+               intermediate_nodes: &[MessageForwardNode], recipient_node_id: PublicKey,
+               context: MessageContext, entropy_source: ES, secp_ctx: &Secp256k1<T>,
        ) -> Result<Self, ()> 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<u64>,
 }
 
@@ -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<T: secp256k1::Signing + secp256k1::Verification>(
-       secp_ctx: &Secp256k1<T>, intermediate_nodes: &[ForwardNode], recipient_node_id: PublicKey,
-       context: MessageContext, session_priv: &SecretKey
+       secp_ctx: &Secp256k1<T>, intermediate_nodes: &[MessageForwardNode],
+       recipient_node_id: PublicKey, context: MessageContext, session_priv: &SecretKey,
 ) -> Result<Vec<BlindedHop>, secp256k1::Error> {
        let pks = intermediate_nodes.iter().map(|node| &node.node_id)
                .chain(core::iter::once(&recipient_node_id));
index e128e6675205c3d908bae8114cb90b9b16048504..ea7d0545de8c6295563507b648fe0c49afa1ba4f 100644 (file)
@@ -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<ES: Deref, T: secp256k1::Signing + secp256k1::Verification>(
-               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<T>
+               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<T>,
        ) -> Result<Self, ()> 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<T: secp256k1::Signing + secp256k1::Verification>(
-       secp_ctx: &Secp256k1<T>, intermediate_nodes: &[ForwardNode],
-       payee_node_id: PublicKey, payee_tlvs: ReceiveTlvs, session_priv: &SecretKey
+       secp_ctx: &Secp256k1<T>, intermediate_nodes: &[PaymentForwardNode],
+       payee_node_id: PublicKey, payee_tlvs: ReceiveTlvs, session_priv: &SecretKey,
 ) -> Result<Vec<BlindedHop>, 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<BlindedPayInfo, ()> {
        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,
index eecbb9c4b923c140032e7de5c701794c5546a769..16dcef2ea092015987394e08aa2257a8d075299a 100644 (file)
@@ -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,
index 167ab0ac8fd8a16475abc99890939df39e372e6f..8a07e18a43330e2b13c9b5df477a6e4c6bb7a620 100644 (file)
@@ -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()
index 508e7982b408abde548f08da02a85597d1236385..bb0b816b1b7c15f6df555f2cdcc1c7ac460b60b8 100644 (file)
@@ -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
index 89aa4dbce682b9d9c759ca8fe892835d250feba4..ac2cf3c32ceba3bea667ede230d5efc611dee8c1 100644 (file)
@@ -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<ES, NS, L, NL, MR, OMH, APH, CMH> 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<ES, NS, L, NL, MR, OMH, APH, CMH> 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<ForwardNode>, secp_ctx: &Secp256k1<T>,
+               peers: Vec<MessageForwardNode>, secp_ctx: &Secp256k1<T>,
        ) -> Result<Vec<BlindedMessagePath>, ()> {
                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<Item = ForwardNode>,
+               I: ExactSizeIterator<Item = MessageForwardNode>,
                T: secp256k1::Signing + secp256k1::Verification
        >(
                network_graph: &G, recipient: PublicKey, context: MessageContext, peers: I,
@@ -613,7 +613,7 @@ where
        ) -> Result<Vec<BlindedMessagePath>, ()> {
                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<ForwardNode>, entropy_source: &ES, secp_ctx: &Secp256k1<T>,
+               peers: Vec<MessageForwardNode>, entropy_source: &ES, secp_ctx: &Secp256k1<T>,
        ) -> Result<Vec<BlindedMessagePath>, ()> {
                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<ForwardNode>, secp_ctx: &Secp256k1<T>,
+               &self, recipient: PublicKey, context: MessageContext, peers: Vec<MessageForwardNode>, secp_ctx: &Secp256k1<T>,
        ) -> Result<Vec<BlindedMessagePath>, ()> {
                Self::create_compact_blinded_paths(&self.network_graph, recipient, context, peers, &self.entropy_source, secp_ctx)
        }
index fa2bbac1d14fac17e92405c9d491629c02da6ecb..eb6194ed4d7186866a4d8fe6a4441f5bbd37d23e 100644 (file)
@@ -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<G: Deref<Target = NetworkGraph<L>>, 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<Target = NetworkGraph<L>>, 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<message::ForwardNode>, secp_ctx: &Secp256k1<T>,
+               &self, recipient: PublicKey, context: MessageContext, peers: Vec<MessageForwardNode>, secp_ctx: &Secp256k1<T>,
        ) -> Result<Vec<BlindedMessagePath>, ()> {
                DefaultMessageRouter::create_compact_blinded_paths(&self.network_graph, recipient, context, peers, &self.entropy_source, secp_ctx)
        }
index 5a7537b08cf31d0ada4a86653f8023ec1d7ea25c..b2871493560152bc1fc16270b6c55a581dc10b48 100644 (file)
@@ -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<ForwardNode>, secp_ctx: &Secp256k1<T>,
+               peers: Vec<MessageForwardNode>, secp_ctx: &Secp256k1<T>,
        ) -> Result<Vec<BlindedMessagePath>, ()> {
                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<T: secp256k1::Signing + secp256k1::Verification>(
                &self, recipient: PublicKey, context: MessageContext,
-               peers: Vec<ForwardNode>, secp_ctx: &Secp256k1<T>,
+               peers: Vec<MessageForwardNode>, secp_ctx: &Secp256k1<T>,
        ) -> Result<Vec<BlindedMessagePath>, ()> {
                self.inner.create_compact_blinded_paths(recipient, context, peers, secp_ctx)
        }