From: Valentine Wallace Date: Mon, 5 Aug 2024 23:18:51 +0000 (-0700) Subject: Add BlindedMessagePath type to disambiguate from blinded payment paths. X-Git-Tag: v0.0.124-beta~10^2~10 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=e741a9a8e700462ae2f66f07c6bd73e0ba5f633e;p=rust-lightning Add BlindedMessagePath type to disambiguate from blinded payment paths. --- diff --git a/fuzz/src/chanmon_consistency.rs b/fuzz/src/chanmon_consistency.rs index 249d1e51b..74bfcb2ed 100644 --- a/fuzz/src/chanmon_consistency.rs +++ b/fuzz/src/chanmon_consistency.rs @@ -33,9 +33,8 @@ use bitcoin::hashes::sha256d::Hash as Sha256dHash; use bitcoin::hashes::Hash as TraitImport; use bitcoin::WPubkeyHash; -use lightning::blinded_path::message::MessageContext; +use lightning::blinded_path::message::{BlindedMessagePath, MessageContext}; use lightning::blinded_path::payment::{BlindedPaymentPath, ReceiveTlvs}; -use lightning::blinded_path::BlindedPath; use lightning::chain; use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator}; use lightning::chain::channelmonitor::{ChannelMonitor, MonitorEvent}; @@ -142,7 +141,7 @@ impl MessageRouter for FuzzRouter { fn create_blinded_paths( &self, _recipient: PublicKey, _context: MessageContext, _peers: Vec, _secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> Result, ()> { unreachable!() } } diff --git a/fuzz/src/full_stack.rs b/fuzz/src/full_stack.rs index ed5f123e8..974a1308b 100644 --- a/fuzz/src/full_stack.rs +++ b/fuzz/src/full_stack.rs @@ -30,9 +30,8 @@ use bitcoin::hashes::Hash as _; use bitcoin::hex::FromHex; use bitcoin::WPubkeyHash; -use lightning::blinded_path::message::MessageContext; +use lightning::blinded_path::message::{BlindedMessagePath, MessageContext}; use lightning::blinded_path::payment::{BlindedPaymentPath, ReceiveTlvs}; -use lightning::blinded_path::BlindedPath; use lightning::chain; use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator}; use lightning::chain::chainmonitor; @@ -179,7 +178,7 @@ impl MessageRouter for FuzzRouter { fn create_blinded_paths( &self, _recipient: PublicKey, _context: MessageContext, _peers: Vec, _secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> Result, ()> { unreachable!() } } diff --git a/fuzz/src/onion_message.rs b/fuzz/src/onion_message.rs index 48f184af7..a37f23f44 100644 --- a/fuzz/src/onion_message.rs +++ b/fuzz/src/onion_message.rs @@ -5,8 +5,8 @@ use bitcoin::secp256k1::ecdsa::RecoverableSignature; use bitcoin::secp256k1::schnorr; use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey}; -use lightning::blinded_path::message::{MessageContext, OffersContext}; -use lightning::blinded_path::{BlindedPath, EmptyNodeIdLookUp}; +use lightning::blinded_path::message::{BlindedMessagePath, MessageContext, OffersContext}; +use lightning::blinded_path::EmptyNodeIdLookUp; use lightning::ln::features::InitFeatures; use lightning::ln::msgs::{self, DecodeError, OnionMessageHandler}; use lightning::ln::script::ShutdownScript; @@ -98,7 +98,7 @@ impl MessageRouter for TestMessageRouter { fn create_blinded_paths( &self, _recipient: PublicKey, _context: MessageContext, _peers: Vec, _secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> Result, ()> { unreachable!() } } diff --git a/lightning/src/blinded_path/message.rs b/lightning/src/blinded_path/message.rs index 26019c036..846886dcc 100644 --- a/lightning/src/blinded_path/message.rs +++ b/lightning/src/blinded_path/message.rs @@ -7,9 +7,7 @@ // You may not use this file except in accordance with one or both of these // licenses. -//! Data structures and methods for constructing [`BlindedPath`]s to send a message over. -//! -//! [`BlindedPath`]: crate::blinded_path::BlindedPath +//! Data structures and methods for constructing [`BlindedMessagePath`]s to send a message over. use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey}; @@ -23,16 +21,68 @@ use crate::blinded_path::utils; use crate::io; use crate::io::Cursor; use crate::ln::channelmanager::PaymentId; +use crate::ln::msgs::DecodeError; use crate::ln::{PaymentHash, onion_utils}; use crate::offers::nonce::Nonce; use crate::onion_message::packet::ControlTlvs; -use crate::sign::{NodeSigner, Recipient}; +use crate::sign::{EntropySource, NodeSigner, Recipient}; use crate::crypto::streams::ChaChaPolyReadAdapter; -use crate::util::ser::{FixedLengthReader, LengthReadableArgs, Writeable, Writer}; +use crate::util::ser::{FixedLengthReader, LengthReadableArgs, Readable, Writeable, Writer}; use core::mem; use core::ops::Deref; +/// A [`BlindedPath`] to be used for sending or receiving a message, hiding the identity of the +/// recipient. +#[derive(Clone, Debug, Hash, PartialEq, Eq)] +pub struct BlindedMessagePath(pub BlindedPath); + +impl Writeable for BlindedMessagePath { + fn write(&self, w: &mut W) -> Result<(), io::Error> { + self.0.write(w) + } +} + +impl Readable for BlindedMessagePath { + fn read(r: &mut R) -> Result { + Ok(Self(BlindedPath::read(r)?)) + } +} + +impl BlindedMessagePath { + /// Create a one-hop blinded path for a message. + pub fn one_hop( + recipient_node_id: PublicKey, context: MessageContext, entropy_source: ES, secp_ctx: &Secp256k1 + ) -> Result where ES::Target: EntropySource { + Self::new(&[], recipient_node_id, context, entropy_source, secp_ctx) + } + + /// Create a path for an onion message, to be forwarded along `node_pks`. The last node + /// pubkey in `node_pks` will be the destination node. + /// + /// 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 + ) -> Result where ES::Target: EntropySource { + let introduction_node = IntroductionNode::NodeId( + intermediate_nodes.first().map_or(recipient_node_id, |n| n.node_id) + ); + let blinding_secret_bytes = entropy_source.get_secure_random_bytes(); + let blinding_secret = SecretKey::from_slice(&blinding_secret_bytes[..]).expect("RNG is busted"); + + Ok(Self(BlindedPath { + introduction_node, + blinding_point: PublicKey::from_secret_key(secp_ctx, &blinding_secret), + blinded_hops: blinded_hops( + secp_ctx, intermediate_nodes, recipient_node_id, + context, &blinding_secret, + ).map_err(|_| ())?, + })) + } +} + /// An intermediate node, and possibly a short channel id leading to the next node. #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] pub struct ForwardNode { @@ -88,10 +138,10 @@ impl Writeable for ReceiveTlvs { } } -/// Additional data included by the recipient in a [`BlindedPath`]. +/// Additional data included by the recipient in a [`BlindedMessagePath`]. /// /// This data is encrypted by the recipient and will be given to the corresponding message handler -/// when handling a message sent over the [`BlindedPath`]. The recipient can use this data to +/// when handling a message sent over the [`BlindedMessagePath`]. The recipient can use this data to /// authenticate the message or for further processing if needed. #[derive(Clone, Debug)] pub enum MessageContext { @@ -110,7 +160,7 @@ pub enum MessageContext { /// [`OffersMessage`]: crate::onion_message::offers::OffersMessage #[derive(Clone, Debug, Eq, PartialEq)] pub enum OffersContext { - /// Context used by a [`BlindedPath`] within an [`Offer`]. + /// Context used by a [`BlindedMessagePath`] within an [`Offer`]. /// /// This variant is intended to be received when handling an [`InvoiceRequest`]. /// @@ -124,7 +174,7 @@ pub enum OffersContext { /// [`Offer`]: crate::offers::offer::Offer nonce: Nonce, }, - /// Context used by a [`BlindedPath`] within a [`Refund`] or as a reply path for an + /// Context used by a [`BlindedMessagePath`] within a [`Refund`] or as a reply path for an /// [`InvoiceRequest`]. /// /// This variant is intended to be received when handling a [`Bolt12Invoice`] or an @@ -155,7 +205,7 @@ pub enum OffersContext { /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError hmac: Option>, }, - /// Context used by a [`BlindedPath`] as a reply path for a [`Bolt12Invoice`]. + /// Context used by a [`BlindedMessagePath`] as a reply path for a [`Bolt12Invoice`]. /// /// This variant is intended to be received when handling an [`InvoiceError`]. /// @@ -213,16 +263,16 @@ pub(super) fn blinded_hops( // // Will only modify `path` when returning `Ok`. pub(crate) fn advance_path_by_one( - path: &mut BlindedPath, node_signer: &NS, node_id_lookup: &NL, secp_ctx: &Secp256k1 + path: &mut BlindedMessagePath, node_signer: &NS, node_id_lookup: &NL, secp_ctx: &Secp256k1 ) -> Result<(), ()> where NS::Target: NodeSigner, NL::Target: NodeIdLookUp, T: secp256k1::Signing + secp256k1::Verification, { - let control_tlvs_ss = node_signer.ecdh(Recipient::Node, &path.blinding_point, None)?; + let control_tlvs_ss = node_signer.ecdh(Recipient::Node, &path.0.blinding_point, None)?; let rho = onion_utils::gen_rho_from_shared_secret(&control_tlvs_ss.secret_bytes()); - let encrypted_control_tlvs = &path.blinded_hops.get(0).ok_or(())?.encrypted_payload; + let encrypted_control_tlvs = &path.0.blinded_hops.get(0).ok_or(())?.encrypted_payload; let mut s = Cursor::new(encrypted_control_tlvs); let mut reader = FixedLengthReader::new(&mut s, encrypted_control_tlvs.len() as u64); match ChaChaPolyReadAdapter::read(&mut reader, rho) { @@ -239,13 +289,13 @@ where let mut new_blinding_point = match next_blinding_override { Some(blinding_point) => blinding_point, None => { - onion_utils::next_hop_pubkey(secp_ctx, path.blinding_point, + onion_utils::next_hop_pubkey(secp_ctx, path.0.blinding_point, control_tlvs_ss.as_ref()).map_err(|_| ())? } }; - mem::swap(&mut path.blinding_point, &mut new_blinding_point); - path.introduction_node = IntroductionNode::NodeId(next_node_id); - path.blinded_hops.remove(0); + mem::swap(&mut path.0.blinding_point, &mut new_blinding_point); + path.0.introduction_node = IntroductionNode::NodeId(next_node_id); + path.0.blinded_hops.remove(0); Ok(()) }, _ => Err(()) diff --git a/lightning/src/blinded_path/mod.rs b/lightning/src/blinded_path/mod.rs index be6d315af..2ffb0ca9b 100644 --- a/lightning/src/blinded_path/mod.rs +++ b/lightning/src/blinded_path/mod.rs @@ -13,13 +13,11 @@ pub mod payment; pub mod message; pub(crate) mod utils; -use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey}; -use message::MessageContext; +use bitcoin::secp256k1::PublicKey; use core::ops::Deref; use crate::ln::msgs::DecodeError; use crate::routing::gossip::{NodeId, ReadOnlyNetworkGraph}; -use crate::sign::EntropySource; use crate::util::ser::{Readable, Writeable, Writer}; use crate::util::scid_utils; @@ -121,38 +119,6 @@ pub struct BlindedHop { } impl BlindedPath { - /// Create a one-hop blinded path for a message. - pub fn one_hop_for_message( - recipient_node_id: PublicKey, context: MessageContext, entropy_source: ES, secp_ctx: &Secp256k1 - ) -> Result where ES::Target: EntropySource { - Self::new_for_message(&[], recipient_node_id, context, entropy_source, secp_ctx) - } - - /// Create a blinded path for an onion message, to be forwarded along `node_pks`. The last node - /// pubkey in `node_pks` will be the destination node. - /// - /// 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_for_message( - intermediate_nodes: &[message::ForwardNode], 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) - ); - let blinding_secret_bytes = entropy_source.get_secure_random_bytes(); - let blinding_secret = SecretKey::from_slice(&blinding_secret_bytes[..]).expect("RNG is busted"); - - Ok(BlindedPath { - introduction_node, - blinding_point: PublicKey::from_secret_key(secp_ctx, &blinding_secret), - blinded_hops: message::blinded_hops( - secp_ctx, intermediate_nodes, recipient_node_id, - context, &blinding_secret, - ).map_err(|_| ())?, - }) - } - /// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., /// it is found in the network graph). pub fn public_introduction_node_id<'a>( diff --git a/lightning/src/blinded_path/utils.rs b/lightning/src/blinded_path/utils.rs index 7e43f3145..384281c71 100644 --- a/lightning/src/blinded_path/utils.rs +++ b/lightning/src/blinded_path/utils.rs @@ -16,6 +16,7 @@ use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey, Scalar}; use bitcoin::secp256k1::ecdh::SharedSecret; use super::{BlindedHop, BlindedPath}; +use super::message::BlindedMessagePath; use crate::ln::msgs::DecodeError; use crate::ln::onion_utils; use crate::onion_message::messenger::Destination; @@ -97,7 +98,7 @@ where Destination::Node(pk) => { build_keys!(pk, false, None); }, - Destination::BlindedPath(BlindedPath { blinded_hops, .. }) => { + Destination::BlindedPath(BlindedMessagePath(BlindedPath { blinded_hops, .. })) => { for hop in blinded_hops { build_keys_in_loop!(hop.blinded_node_id, true, Some(hop.encrypted_payload)); } diff --git a/lightning/src/events/mod.rs b/lightning/src/events/mod.rs index 63f19ed22..d756eff1b 100644 --- a/lightning/src/events/mod.rs +++ b/lightning/src/events/mod.rs @@ -811,9 +811,9 @@ pub enum Event { payment_id: PaymentId, /// The invoice to pay. invoice: Bolt12Invoice, - /// The context of the [`BlindedPath`] used to send the invoice. + /// The context of the [`BlindedMessagePath`] used to send the invoice. /// - /// [`BlindedPath`]: crate::blinded_path::BlindedPath + /// [`BlindedMessagePath`]: crate::blinded_path::message::BlindedMessagePath context: Option, /// A responder for replying with an [`InvoiceError`] if needed. /// diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index e3e9bcfe8..641810f2f 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -32,8 +32,8 @@ use bitcoin::secp256k1::Secp256k1; use bitcoin::{secp256k1, Sequence}; use crate::blinded_path::message::{MessageContext, OffersContext}; -use crate::blinded_path::{BlindedPath, NodeIdLookUp}; -use crate::blinded_path::message::ForwardNode; +use crate::blinded_path::NodeIdLookUp; +use crate::blinded_path::message::{BlindedMessagePath, ForwardNode}; use crate::blinded_path::payment::{BlindedPaymentPath, Bolt12OfferContext, Bolt12RefundContext, PaymentConstraints, PaymentContext, ReceiveTlvs}; use crate::chain; use crate::chain::{Confirm, ChannelMonitorUpdateStatus, Watch, BestBlock}; @@ -2472,11 +2472,11 @@ const MAX_NO_CHANNEL_PEERS: usize = 250; /// short-lived, while anything with a greater expiration is considered long-lived. /// /// Using [`ChannelManager::create_offer_builder`] or [`ChannelManager::create_refund_builder`], -/// will included a [`BlindedPath`] created using: +/// will included a [`BlindedMessagePath`] created using: /// - [`MessageRouter::create_compact_blinded_paths`] when short-lived, and /// - [`MessageRouter::create_blinded_paths`] when long-lived. /// -/// Using compact [`BlindedPath`]s may provide better privacy as the [`MessageRouter`] could select +/// Using compact [`BlindedMessagePath`]s may provide better privacy as the [`MessageRouter`] could select /// more hops. However, since they use short channel ids instead of pubkeys, they are more likely to /// become invalid over time as channels are closed. Thus, they are only suitable for short-term use. pub const MAX_SHORT_LIVED_RELATIVE_EXPIRY: Duration = Duration::from_secs(60 * 60 * 24); @@ -8789,7 +8789,7 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => { /// /// # Privacy /// - /// Uses [`MessageRouter`] to construct a [`BlindedPath`] for the offer based on the given + /// Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the offer based on the given /// `absolute_expiry` according to [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. See those docs for /// privacy implications as well as those of the parameterized [`Router`], which implements /// [`MessageRouter`]. @@ -8856,7 +8856,7 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => { /// /// # Privacy /// - /// Uses [`MessageRouter`] to construct a [`BlindedPath`] for the refund based on the given + /// Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the refund based on the given /// `absolute_expiry` according to [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. See those docs for /// privacy implications as well as those of the parameterized [`Router`], which implements /// [`MessageRouter`]. @@ -8970,7 +8970,7 @@ where /// # Privacy /// /// For payer privacy, uses a derived payer id and uses [`MessageRouter::create_blinded_paths`] - /// to construct a [`BlindedPath`] for the reply path. For further privacy implications, see the + /// to construct a [`BlindedMessagePath`] for the reply path. For further privacy implications, see the /// docs of the parameterized [`Router`], which implements [`MessageRouter`]. /// /// # Limitations @@ -9273,7 +9273,7 @@ where /// [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. fn create_blinded_paths_using_absolute_expiry( &self, context: OffersContext, absolute_expiry: Option, - ) -> Result, ()> { + ) -> Result, ()> { let now = self.duration_since_epoch(); let max_short_lived_absolute_expiry = now.saturating_add(MAX_SHORT_LIVED_RELATIVE_EXPIRY); @@ -9301,7 +9301,7 @@ where /// [`MessageRouter::create_blinded_paths`]. /// /// Errors if the `MessageRouter` errors. - fn create_blinded_paths(&self, context: OffersContext) -> Result, ()> { + fn create_blinded_paths(&self, context: OffersContext) -> Result, ()> { let recipient = self.get_our_node_id(); let secp_ctx = &self.secp_ctx; @@ -9322,7 +9322,7 @@ where /// [`MessageRouter::create_compact_blinded_paths`]. /// /// Errors if the `MessageRouter` errors. - fn create_compact_blinded_paths(&self, context: OffersContext) -> Result, ()> { + fn create_compact_blinded_paths(&self, context: OffersContext) -> Result, ()> { let recipient = self.get_our_node_id(); let secp_ctx = &self.secp_ctx; diff --git a/lightning/src/ln/offers_tests.rs b/lightning/src/ln/offers_tests.rs index 9302227dc..b4134d493 100644 --- a/lightning/src/ln/offers_tests.rs +++ b/lightning/src/ln/offers_tests.rs @@ -43,7 +43,8 @@ use bitcoin::network::Network; use bitcoin::secp256k1::{PublicKey, Secp256k1}; use core::time::Duration; -use crate::blinded_path::{BlindedPath, IntroductionNode}; +use crate::blinded_path::IntroductionNode; +use crate::blinded_path::message::BlindedMessagePath; use crate::blinded_path::payment::{Bolt12OfferContext, Bolt12RefundContext, PaymentContext}; use crate::blinded_path::message::{MessageContext, OffersContext}; use crate::events::{Event, MessageSendEventsProvider, PaymentFailureReason, PaymentPurpose}; @@ -139,8 +140,8 @@ fn announce_node_address<'a, 'b, 'c>( } } -fn resolve_introduction_node<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, path: &BlindedPath) -> PublicKey { - path.public_introduction_node_id(&node.network_graph.read_only()) +fn resolve_introduction_node<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, path: &BlindedMessagePath) -> PublicKey { + path.0.public_introduction_node_id(&node.network_graph.read_only()) .and_then(|node_id| node_id.as_pubkey().ok()) .unwrap() } @@ -199,7 +200,7 @@ fn extract_offer_nonce<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, message: &OnionMessa fn extract_invoice_request<'a, 'b, 'c>( node: &Node<'a, 'b, 'c>, message: &OnionMessage -) -> (InvoiceRequest, BlindedPath) { +) -> (InvoiceRequest, BlindedMessagePath) { match node.onion_messenger.peel_onion_message(message) { Ok(PeeledOnion::Receive(message, _, reply_path)) => match message { ParsedOnionMessageContents::Offers(offers_message) => match offers_message { @@ -218,7 +219,7 @@ fn extract_invoice_request<'a, 'b, 'c>( } } -fn extract_invoice<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, message: &OnionMessage) -> (Bolt12Invoice, Option) { +fn extract_invoice<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, message: &OnionMessage) -> (Bolt12Invoice, Option) { match node.onion_messenger.peel_onion_message(message) { Ok(PeeledOnion::Receive(message, _, reply_path)) => match message { ParsedOnionMessageContents::Offers(offers_message) => match offers_message { @@ -401,7 +402,7 @@ fn creates_short_lived_offer() { for path in offer.paths() { let introduction_node_id = resolve_introduction_node(bob, &path); assert_eq!(introduction_node_id, alice_id); - assert!(matches!(path.introduction_node, IntroductionNode::DirectedShortChannelId(..))); + assert!(matches!(path.0.introduction_node, IntroductionNode::DirectedShortChannelId(..))); } } @@ -427,7 +428,7 @@ fn creates_long_lived_offer() { assert_eq!(offer.absolute_expiry(), Some(absolute_expiry)); assert!(!offer.paths().is_empty()); for path in offer.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(alice_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(alice_id)); } let offer = alice.node @@ -436,7 +437,7 @@ fn creates_long_lived_offer() { assert_eq!(offer.absolute_expiry(), None); assert!(!offer.paths().is_empty()); for path in offer.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(alice_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(alice_id)); } } @@ -465,7 +466,7 @@ fn creates_short_lived_refund() { for path in refund.paths() { let introduction_node_id = resolve_introduction_node(alice, &path); assert_eq!(introduction_node_id, bob_id); - assert!(matches!(path.introduction_node, IntroductionNode::DirectedShortChannelId(..))); + assert!(matches!(path.0.introduction_node, IntroductionNode::DirectedShortChannelId(..))); } } @@ -492,7 +493,7 @@ fn creates_long_lived_refund() { assert_eq!(refund.absolute_expiry(), Some(absolute_expiry)); assert!(!refund.paths().is_empty()); for path in refund.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(bob_id)); } } @@ -542,7 +543,7 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() { assert_ne!(offer.signing_pubkey(), Some(alice_id)); assert!(!offer.paths().is_empty()); for path in offer.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(bob_id)); } let payment_id = PaymentId([1; 32]); @@ -571,7 +572,7 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() { }); assert_eq!(invoice_request.amount_msats(), None); assert_ne!(invoice_request.payer_id(), david_id); - assert_eq!(reply_path.introduction_node, IntroductionNode::NodeId(charlie_id)); + assert_eq!(reply_path.0.introduction_node, IntroductionNode::NodeId(charlie_id)); let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap(); charlie.onion_messenger.handle_onion_message(&alice_id, &onion_message); @@ -643,7 +644,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() { assert_ne!(refund.payer_id(), david_id); assert!(!refund.paths().is_empty()); for path in refund.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(charlie_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(charlie_id)); } expect_recent_payment!(david, RecentPaymentDetails::AwaitingInvoice, payment_id); @@ -699,7 +700,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() { assert_ne!(offer.signing_pubkey(), Some(alice_id)); assert!(!offer.paths().is_empty()); for path in offer.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(alice_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(alice_id)); } let payment_id = PaymentId([1; 32]); @@ -720,7 +721,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() { }); assert_eq!(invoice_request.amount_msats(), None); assert_ne!(invoice_request.payer_id(), bob_id); - assert_eq!(reply_path.introduction_node, IntroductionNode::NodeId(bob_id)); + assert_eq!(reply_path.0.introduction_node, IntroductionNode::NodeId(bob_id)); let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap(); bob.onion_messenger.handle_onion_message(&alice_id, &onion_message); @@ -768,7 +769,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() { assert_ne!(refund.payer_id(), bob_id); assert!(!refund.paths().is_empty()); for path in refund.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(bob_id)); } expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id); @@ -943,7 +944,7 @@ fn send_invoice_requests_with_distinct_reply_path() { assert_ne!(offer.signing_pubkey(), Some(alice_id)); assert!(!offer.paths().is_empty()); for path in offer.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(bob_id)); } let payment_id = PaymentId([1; 32]); @@ -962,7 +963,7 @@ fn send_invoice_requests_with_distinct_reply_path() { alice.onion_messenger.handle_onion_message(&bob_id, &onion_message); let (_, reply_path) = extract_invoice_request(alice, &onion_message); - assert_eq!(reply_path.introduction_node, IntroductionNode::NodeId(charlie_id)); + assert_eq!(reply_path.0.introduction_node, IntroductionNode::NodeId(charlie_id)); // Send, extract and verify the second Invoice Request message let onion_message = david.onion_messenger.next_onion_message_for_peer(bob_id).unwrap(); @@ -972,7 +973,7 @@ fn send_invoice_requests_with_distinct_reply_path() { alice.onion_messenger.handle_onion_message(&bob_id, &onion_message); let (_, reply_path) = extract_invoice_request(alice, &onion_message); - assert_eq!(reply_path.introduction_node, IntroductionNode::NodeId(nodes[6].node.get_our_node_id())); + assert_eq!(reply_path.0.introduction_node, IntroductionNode::NodeId(nodes[6].node.get_our_node_id())); } /// This test checks that when multiple potential introduction nodes are available for the payee, @@ -1027,7 +1028,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() { .build().unwrap(); assert_ne!(refund.payer_id(), alice_id); for path in refund.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(bob_id)); } expect_recent_payment!(alice, RecentPaymentDetails::AwaitingInvoice, payment_id); @@ -1043,7 +1044,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() { let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap(); let (_, reply_path) = extract_invoice(alice, &onion_message); - assert_eq!(reply_path.unwrap().introduction_node, IntroductionNode::NodeId(charlie_id)); + assert_eq!(reply_path.unwrap().0.introduction_node, IntroductionNode::NodeId(charlie_id)); // Send, extract and verify the second Invoice Request message let onion_message = david.onion_messenger.next_onion_message_for_peer(bob_id).unwrap(); @@ -1052,7 +1053,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() { let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap(); let (_, reply_path) = extract_invoice(alice, &onion_message); - assert_eq!(reply_path.unwrap().introduction_node, IntroductionNode::NodeId(nodes[6].node.get_our_node_id())); + assert_eq!(reply_path.unwrap().0.introduction_node, IntroductionNode::NodeId(nodes[6].node.get_our_node_id())); } /// Checks that a deferred invoice can be paid asynchronously from an Event::InvoiceReceived. @@ -1164,7 +1165,7 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() { assert_ne!(offer.signing_pubkey(), Some(alice_id)); assert!(!offer.paths().is_empty()); for path in offer.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(bob_id)); } let payment_id = PaymentId([1; 32]); @@ -1184,7 +1185,7 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() { }, }); assert_ne!(invoice_request.payer_id(), bob_id); - assert_eq!(reply_path.introduction_node, IntroductionNode::NodeId(alice_id)); + assert_eq!(reply_path.0.introduction_node, IntroductionNode::NodeId(alice_id)); let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap(); bob.onion_messenger.handle_onion_message(&alice_id, &onion_message); @@ -1230,7 +1231,7 @@ fn creates_refund_with_blinded_path_using_unannounced_introduction_node() { assert_ne!(refund.payer_id(), bob_id); assert!(!refund.paths().is_empty()); for path in refund.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(alice_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(alice_id)); } expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id); @@ -1294,7 +1295,7 @@ fn fails_authentication_when_handling_invoice_request() { assert_ne!(offer.signing_pubkey(), Some(alice_id)); assert!(!offer.paths().is_empty()); for path in offer.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(bob_id)); } let invalid_path = alice.node @@ -1303,7 +1304,7 @@ fn fails_authentication_when_handling_invoice_request() { .build().unwrap() .paths().first().unwrap() .clone(); - assert_eq!(invalid_path.introduction_node, IntroductionNode::NodeId(bob_id)); + assert_eq!(invalid_path.0.introduction_node, IntroductionNode::NodeId(bob_id)); // Send the invoice request directly to Alice instead of using a blinded path. let payment_id = PaymentId([1; 32]); @@ -1327,7 +1328,7 @@ fn fails_authentication_when_handling_invoice_request() { let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message); assert_eq!(invoice_request.amount_msats(), None); assert_ne!(invoice_request.payer_id(), david_id); - assert_eq!(reply_path.introduction_node, IntroductionNode::NodeId(charlie_id)); + assert_eq!(reply_path.0.introduction_node, IntroductionNode::NodeId(charlie_id)); assert_eq!(alice.onion_messenger.next_onion_message_for_peer(charlie_id), None); @@ -1360,7 +1361,7 @@ fn fails_authentication_when_handling_invoice_request() { let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message); assert_eq!(invoice_request.amount_msats(), None); assert_ne!(invoice_request.payer_id(), david_id); - assert_eq!(reply_path.introduction_node, IntroductionNode::NodeId(charlie_id)); + assert_eq!(reply_path.0.introduction_node, IntroductionNode::NodeId(charlie_id)); assert_eq!(alice.onion_messenger.next_onion_message_for_peer(charlie_id), None); } @@ -1411,7 +1412,7 @@ fn fails_authentication_when_handling_invoice_for_offer() { assert_ne!(offer.signing_pubkey(), Some(alice_id)); assert!(!offer.paths().is_empty()); for path in offer.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(bob_id)); } // Initiate an invoice request, but abandon tracking it. @@ -1465,7 +1466,7 @@ fn fails_authentication_when_handling_invoice_for_offer() { let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message); assert_eq!(invoice_request.amount_msats(), None); assert_ne!(invoice_request.payer_id(), david_id); - assert_eq!(reply_path.introduction_node, IntroductionNode::NodeId(charlie_id)); + assert_eq!(reply_path.0.introduction_node, IntroductionNode::NodeId(charlie_id)); let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap(); charlie.onion_messenger.handle_onion_message(&alice_id, &onion_message); @@ -1522,7 +1523,7 @@ fn fails_authentication_when_handling_invoice_for_refund() { assert_ne!(refund.payer_id(), david_id); assert!(!refund.paths().is_empty()); for path in refund.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(charlie_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(charlie_id)); } expect_recent_payment!(david, RecentPaymentDetails::AwaitingInvoice, payment_id); @@ -1559,7 +1560,7 @@ fn fails_authentication_when_handling_invoice_for_refund() { assert_ne!(refund.payer_id(), david_id); assert!(!refund.paths().is_empty()); for path in refund.paths() { - assert_eq!(path.introduction_node, IntroductionNode::NodeId(charlie_id)); + assert_eq!(path.0.introduction_node, IntroductionNode::NodeId(charlie_id)); } let expected_invoice = alice.node.request_refund_payment(&refund).unwrap(); diff --git a/lightning/src/offers/invoice.rs b/lightning/src/offers/invoice.rs index af9f28d90..41ac2982e 100644 --- a/lightning/src/offers/invoice.rs +++ b/lightning/src/offers/invoice.rs @@ -110,7 +110,7 @@ use bitcoin::address::{Address, Payload}; use core::time::Duration; use core::hash::{Hash, Hasher}; use crate::io; -use crate::blinded_path::BlindedPath; +use crate::blinded_path::message::BlindedMessagePath; use crate::blinded_path::payment::BlindedPaymentPath; use crate::ln::types::PaymentHash; use crate::ln::channelmanager::PaymentId; @@ -699,7 +699,7 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => { /// From [`Offer::paths`] or [`Refund::paths`]. /// /// [`Offer::paths`]: crate::offers::offer::Offer::paths - pub fn message_paths(&$self) -> &[BlindedPath] { + pub fn message_paths(&$self) -> &[BlindedMessagePath] { $contents.message_paths() } @@ -798,7 +798,7 @@ impl Bolt12Invoice { } /// Verifies that the invoice was for a request or refund created using the given key by - /// checking a payment id and nonce included with the [`BlindedPath`] for which the invoice was + /// checking a payment id and nonce included with the [`BlindedMessagePath`] for which the invoice was /// sent through. pub fn verify_using_payer_data( &self, payment_id: PaymentId, nonce: Nonce, key: &ExpandedKey, secp_ctx: &Secp256k1 @@ -935,7 +935,7 @@ impl InvoiceContents { } } - fn message_paths(&self) -> &[BlindedPath] { + fn message_paths(&self) -> &[BlindedMessagePath] { match self { InvoiceContents::ForOffer { invoice_request, .. } => { invoice_request.inner.offer.paths() @@ -1203,7 +1203,7 @@ tlv_stream!(InvoiceTlvStream, InvoiceTlvStreamRef, 160..240, { (174, features: (Bolt12InvoiceFeatures, WithoutLength)), (176, node_id: PublicKey), // Only present in `StaticInvoice`s. - (238, message_paths: (Vec, WithoutLength)), + (238, message_paths: (Vec, WithoutLength)), }); pub(super) type BlindedPathIter<'a> = core::iter::Map< @@ -1415,7 +1415,7 @@ pub(super) fn check_invoice_signing_pubkey( (None, Some(paths)) => { if !paths .iter() - .filter_map(|path| path.blinded_hops.last()) + .filter_map(|path| path.0.blinded_hops.last()) .any(|last_hop| invoice_signing_pubkey == &last_hop.blinded_node_id) { return Err(Bolt12SemanticError::InvalidSigningPubkey); @@ -1442,6 +1442,7 @@ mod tests { use core::time::Duration; use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode}; + use crate::blinded_path::message::BlindedMessagePath; use crate::sign::KeyMaterial; use crate::ln::features::{Bolt12InvoiceFeatures, InvoiceRequestFeatures, OfferFeatures}; use crate::ln::inbound_payment::ExpandedKey; @@ -1790,14 +1791,14 @@ mod tests { let nonce = Nonce::from_entropy_source(&entropy); let secp_ctx = Secp256k1::new(); - let blinded_path = BlindedPath { + let blinded_path = BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(42), encrypted_payload: vec![0; 43] }, BlindedHop { blinded_node_id: node_id, encrypted_payload: vec![0; 44] }, ], - }; + }); #[cfg(c_bindings)] use crate::offers::offer::OfferWithDerivedMetadataBuilder as OfferBuilder; @@ -1866,14 +1867,14 @@ mod tests { let entropy = FixedEntropy {}; let secp_ctx = Secp256k1::new(); - let blinded_path = BlindedPath { + let blinded_path = BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(42), encrypted_payload: vec![0; 43] }, BlindedHop { blinded_node_id: node_id, encrypted_payload: vec![0; 44] }, ], - }; + }); let refund = RefundBuilder::new(vec![1; 32], payer_pubkey(), 1000).unwrap() .path(blinded_path) @@ -2370,22 +2371,22 @@ mod tests { #[test] fn parses_invoice_with_node_id_from_blinded_path() { let paths = vec![ - BlindedPath { + BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 43] }, BlindedHop { blinded_node_id: pubkey(44), encrypted_payload: vec![0; 44] }, ], - }, - BlindedPath { + }), + BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(45), encrypted_payload: vec![0; 45] }, BlindedHop { blinded_node_id: pubkey(46), encrypted_payload: vec![0; 46] }, ], - }, + }), ]; let blinded_node_id_sign = |message: &UnsignedBolt12Invoice| { @@ -2523,14 +2524,14 @@ mod tests { .build().unwrap() .sign(recipient_sign).unwrap(); - let blinded_path = BlindedPath { + let blinded_path = BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(42), encrypted_payload: vec![0; 43] }, BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 44] }, ], - }; + }); let mut tlv_stream = invoice.as_tlv_stream(); let message_paths = vec![blinded_path]; diff --git a/lightning/src/offers/invoice_request.rs b/lightning/src/offers/invoice_request.rs index 66ed8b1d0..01083b7b7 100644 --- a/lightning/src/offers/invoice_request.rs +++ b/lightning/src/offers/invoice_request.rs @@ -62,7 +62,7 @@ use bitcoin::network::Network; use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, self}; use bitcoin::secp256k1::schnorr::Signature; use crate::io; -use crate::blinded_path::BlindedPath; +use crate::blinded_path::message::BlindedMessagePath; use crate::blinded_path::payment::BlindedPaymentPath; use crate::ln::types::PaymentHash; use crate::ln::channelmanager::PaymentId; @@ -805,7 +805,7 @@ macro_rules! invoice_request_verify_method { ($self: ident, $self_type: ty) => { } /// Verifies that the request was for an offer created using the given key by checking a nonce - /// included with the [`BlindedPath`] for which the request was sent through. + /// included with the [`BlindedMessagePath`] for which the request was sent through. /// /// Returns the verified request which contains the derived keys needed to sign a /// [`Bolt12Invoice`] for the request if they could be extracted from the metadata. @@ -1058,7 +1058,7 @@ tlv_stream!(InvoiceRequestTlvStream, InvoiceRequestTlvStreamRef, INVOICE_REQUEST (INVOICE_REQUEST_PAYER_ID_TYPE, payer_id: PublicKey), (89, payer_note: (String, WithoutLength)), // Only used for Refund since the onion message of an InvoiceRequest has a reply path. - (90, paths: (Vec, WithoutLength)), + (90, paths: (Vec, WithoutLength)), }); type FullInvoiceRequestTlvStream = diff --git a/lightning/src/offers/offer.rs b/lightning/src/offers/offer.rs index e314f712c..39e0c5cf4 100644 --- a/lightning/src/offers/offer.rs +++ b/lightning/src/offers/offer.rs @@ -29,12 +29,12 @@ //! use lightning::offers::parse::Bolt12ParseError; //! use lightning::util::ser::{Readable, Writeable}; //! -//! # use lightning::blinded_path::BlindedPath; +//! # use lightning::blinded_path::message::BlindedMessagePath; //! # #[cfg(feature = "std")] //! # use std::time::SystemTime; //! # -//! # fn create_blinded_path() -> BlindedPath { unimplemented!() } -//! # fn create_another_blinded_path() -> BlindedPath { unimplemented!() } +//! # fn create_blinded_path() -> BlindedMessagePath { unimplemented!() } +//! # fn create_another_blinded_path() -> BlindedMessagePath { unimplemented!() } //! # //! # #[cfg(feature = "std")] //! # fn build() -> Result<(), Bolt12ParseError> { @@ -85,7 +85,7 @@ use core::num::NonZeroU64; use core::str::FromStr; use core::time::Duration; use crate::io; -use crate::blinded_path::BlindedPath; +use crate::blinded_path::message::BlindedMessagePath; use crate::ln::channelmanager::PaymentId; use crate::ln::features::OfferFeatures; use crate::ln::inbound_payment::{ExpandedKey, IV_LEN}; @@ -249,7 +249,7 @@ macro_rules! offer_derived_metadata_builder_methods { ($secp_context: ty) => { /// Also, sets the metadata when [`OfferBuilder::build`] is called such that it can be used by /// [`InvoiceRequest::verify_using_metadata`] to determine if the request was produced for the /// offer given an [`ExpandedKey`]. However, if [`OfferBuilder::path`] is called, then the - /// metadata will not be set and must be included in each [`BlindedPath`] instead. In this case, + /// metadata will not be set and must be included in each [`BlindedMessagePath`] instead. In this case, /// use [`InvoiceRequest::verify_using_recipient_data`]. /// /// [`InvoiceRequest::verify_using_metadata`]: crate::offers::invoice_request::InvoiceRequest::verify_using_metadata @@ -346,7 +346,7 @@ macro_rules! offer_builder_methods { ( /// /// Successive calls to this method will add another blinded path. Caller is responsible for not /// adding duplicate paths. - pub fn path($($self_mut)* $self: $self_type, path: BlindedPath) -> $return_type { + pub fn path($($self_mut)* $self: $self_type, path: BlindedMessagePath) -> $return_type { $self.offer.paths.get_or_insert_with(Vec::new).push(path); $return_value } @@ -540,7 +540,7 @@ for OfferBuilder<'a, DerivedMetadata, secp256k1::All> { /// Offers may be denominated in currency other than bitcoin but are ultimately paid using the /// latter. /// -/// Through the use of [`BlindedPath`]s, offers provide recipient privacy. +/// Through the use of [`BlindedMessagePath`]s, offers provide recipient privacy. /// /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice @@ -568,7 +568,7 @@ pub(super) struct OfferContents { features: OfferFeatures, absolute_expiry: Option, issuer: Option, - paths: Option>, + paths: Option>, supported_quantity: Quantity, signing_pubkey: Option, } @@ -622,7 +622,7 @@ macro_rules! offer_accessors { ($self: ident, $contents: expr) => { /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide /// recipient privacy by obfuscating its node id. - pub fn paths(&$self) -> &[$crate::blinded_path::BlindedPath] { + pub fn paths(&$self) -> &[$crate::blinded_path::message::BlindedMessagePath] { $contents.paths() } @@ -854,7 +854,7 @@ impl OfferContents { self.issuer.as_ref().map(|issuer| PrintableString(issuer.as_str())) } - pub fn paths(&self) -> &[BlindedPath] { + pub fn paths(&self) -> &[BlindedMessagePath] { self.paths.as_ref().map(|paths| paths.as_slice()).unwrap_or(&[]) } @@ -1074,7 +1074,7 @@ tlv_stream!(OfferTlvStream, OfferTlvStreamRef, OFFER_TYPES, { (10, description: (String, WithoutLength)), (12, features: (OfferFeatures, WithoutLength)), (14, absolute_expiry: (u64, HighZeroBytesDroppedBigSize)), - (16, paths: (Vec, WithoutLength)), + (16, paths: (Vec, WithoutLength)), (18, issuer: (String, WithoutLength)), (20, quantity_max: (u64, HighZeroBytesDroppedBigSize)), (OFFER_NODE_ID_TYPE, node_id: PublicKey), @@ -1178,6 +1178,7 @@ mod tests { use core::num::NonZeroU64; use core::time::Duration; use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode}; + use crate::blinded_path::message::BlindedMessagePath; use crate::sign::KeyMaterial; use crate::ln::features::OfferFeatures; use crate::ln::inbound_payment::ExpandedKey; @@ -1360,14 +1361,14 @@ mod tests { let nonce = Nonce::from_entropy_source(&entropy); let secp_ctx = Secp256k1::new(); - let blinded_path = BlindedPath { + let blinded_path = BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(42), encrypted_payload: vec![0; 43] }, BlindedHop { blinded_node_id: node_id, encrypted_payload: vec![0; 44] }, ], - }; + }); #[cfg(c_bindings)] use super::OfferWithDerivedMetadataBuilder as OfferBuilder; @@ -1544,22 +1545,22 @@ mod tests { #[test] fn builds_offer_with_paths() { let paths = vec![ - BlindedPath { + BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 43] }, BlindedHop { blinded_node_id: pubkey(44), encrypted_payload: vec![0; 44] }, ], - }, - BlindedPath { + }), + BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(45), encrypted_payload: vec![0; 45] }, BlindedHop { blinded_node_id: pubkey(46), encrypted_payload: vec![0; 46] }, ], - }, + }), ]; let offer = OfferBuilder::new(pubkey(42)) @@ -1747,22 +1748,22 @@ mod tests { #[test] fn parses_offer_with_paths() { let offer = OfferBuilder::new(pubkey(42)) - .path(BlindedPath { + .path(BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 43] }, BlindedHop { blinded_node_id: pubkey(44), encrypted_payload: vec![0; 44] }, ], - }) - .path(BlindedPath { + })) + .path(BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(45), encrypted_payload: vec![0; 45] }, BlindedHop { blinded_node_id: pubkey(46), encrypted_payload: vec![0; 46] }, ], - }) + })) .build() .unwrap(); if let Err(e) = offer.to_string().parse::() { @@ -1770,14 +1771,14 @@ mod tests { } let offer = OfferBuilder::new(pubkey(42)) - .path(BlindedPath { + .path(BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 43] }, BlindedHop { blinded_node_id: pubkey(44), encrypted_payload: vec![0; 44] }, ], - }) + })) .clear_signing_pubkey() .build() .unwrap(); diff --git a/lightning/src/offers/refund.rs b/lightning/src/offers/refund.rs index 1835a099f..c4a3d652e 100644 --- a/lightning/src/offers/refund.rs +++ b/lightning/src/offers/refund.rs @@ -34,12 +34,12 @@ //! use lightning::offers::refund::{Refund, RefundBuilder}; //! use lightning::util::ser::{Readable, Writeable}; //! -//! # use lightning::blinded_path::BlindedPath; +//! # use lightning::blinded_path::message::BlindedMessagePath; //! # #[cfg(feature = "std")] //! # use std::time::SystemTime; //! # -//! # fn create_blinded_path() -> BlindedPath { unimplemented!() } -//! # fn create_another_blinded_path() -> BlindedPath { unimplemented!() } +//! # fn create_blinded_path() -> BlindedMessagePath { unimplemented!() } +//! # fn create_another_blinded_path() -> BlindedMessagePath { unimplemented!() } //! # //! # #[cfg(feature = "std")] //! # fn build() -> Result<(), Bolt12ParseError> { @@ -91,7 +91,7 @@ use core::str::FromStr; use core::time::Duration; use crate::sign::EntropySource; use crate::io; -use crate::blinded_path::BlindedPath; +use crate::blinded_path::message::BlindedMessagePath; use crate::blinded_path::payment::BlindedPaymentPath; use crate::ln::types::PaymentHash; use crate::ln::channelmanager::PaymentId; @@ -194,7 +194,7 @@ macro_rules! refund_builder_methods { ( /// Also, sets the metadata when [`RefundBuilder::build`] is called such that it can be used by /// [`Bolt12Invoice::verify_using_metadata`] to determine if the invoice was produced for the /// refund given an [`ExpandedKey`]. However, if [`RefundBuilder::path`] is called, then the - /// metadata must be included in each [`BlindedPath`] instead. In this case, use + /// metadata must be included in each [`BlindedMessagePath`] instead. In this case, use /// [`Bolt12Invoice::verify_using_payer_data`]. /// /// The `payment_id` is encrypted in the metadata and should be unique. This ensures that only @@ -254,7 +254,7 @@ macro_rules! refund_builder_methods { ( /// /// Successive calls to this method will add another blinded path. Caller is responsible for not /// adding duplicate paths. - pub fn path($($self_mut)* $self: $self_type, path: BlindedPath) -> $return_type { + pub fn path($($self_mut)* $self: $self_type, path: BlindedMessagePath) -> $return_type { $self.refund.paths.get_or_insert_with(Vec::new).push(path); $return_value } @@ -437,7 +437,7 @@ pub(super) struct RefundContents { quantity: Option, payer_id: PublicKey, payer_note: Option, - paths: Option>, + paths: Option>, } impl Refund { @@ -473,7 +473,7 @@ impl Refund { /// Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender /// privacy by obfuscating its node id. - pub fn paths(&self) -> &[BlindedPath] { + pub fn paths(&self) -> &[BlindedMessagePath] { self.contents.paths() } @@ -694,7 +694,7 @@ impl RefundContents { self.issuer.as_ref().map(|issuer| PrintableString(issuer.as_str())) } - pub fn paths(&self) -> &[BlindedPath] { + pub fn paths(&self) -> &[BlindedMessagePath] { self.paths.as_ref().map(|paths| paths.as_slice()).unwrap_or(&[]) } @@ -939,6 +939,7 @@ mod tests { use core::time::Duration; use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode}; + use crate::blinded_path::message::BlindedMessagePath; use crate::sign::KeyMaterial; use crate::ln::channelmanager::PaymentId; use crate::ln::features::{InvoiceRequestFeatures, OfferFeatures}; @@ -1097,14 +1098,14 @@ mod tests { let secp_ctx = Secp256k1::new(); let payment_id = PaymentId([1; 32]); - let blinded_path = BlindedPath { + let blinded_path = BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 43] }, BlindedHop { blinded_node_id: node_id, encrypted_payload: vec![0; 44] }, ], - }; + }); let refund = RefundBuilder ::deriving_payer_id(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id) @@ -1190,22 +1191,22 @@ mod tests { #[test] fn builds_refund_with_paths() { let paths = vec![ - BlindedPath { + BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 43] }, BlindedHop { blinded_node_id: pubkey(44), encrypted_payload: vec![0; 44] }, ], - }, - BlindedPath { + }), + BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(45), encrypted_payload: vec![0; 45] }, BlindedHop { blinded_node_id: pubkey(46), encrypted_payload: vec![0; 46] }, ], - }, + }), ]; let refund = RefundBuilder::new(vec![1; 32], payer_pubkey(), 1000).unwrap() @@ -1407,22 +1408,22 @@ mod tests { fn parses_refund_with_optional_fields() { let past_expiry = Duration::from_secs(0); let paths = vec![ - BlindedPath { + BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 43] }, BlindedHop { blinded_node_id: pubkey(44), encrypted_payload: vec![0; 44] }, ], - }, - BlindedPath { + }), + BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(45), encrypted_payload: vec![0; 45] }, BlindedHop { blinded_node_id: pubkey(46), encrypted_payload: vec![0; 46] }, ], - }, + }), ]; let refund = RefundBuilder::new(vec![1; 32], payer_pubkey(), 1000).unwrap() diff --git a/lightning/src/offers/static_invoice.rs b/lightning/src/offers/static_invoice.rs index fad3bd689..0c4033cef 100644 --- a/lightning/src/offers/static_invoice.rs +++ b/lightning/src/offers/static_invoice.rs @@ -9,8 +9,8 @@ //! Data structures and encoding for static BOLT 12 invoices. +use crate::blinded_path::message::BlindedMessagePath; use crate::blinded_path::payment::BlindedPaymentPath; -use crate::blinded_path::BlindedPath; use crate::io; use crate::ln::features::{Bolt12InvoiceFeatures, OfferFeatures}; use crate::ln::inbound_payment::ExpandedKey; @@ -77,7 +77,7 @@ struct InvoiceContents { fallbacks: Option>, features: Bolt12InvoiceFeatures, signing_pubkey: PublicKey, - message_paths: Vec, + message_paths: Vec, } /// Builds a [`StaticInvoice`] from an [`Offer`]. @@ -98,7 +98,7 @@ impl<'a> StaticInvoiceBuilder<'a> { /// after `created_at`. pub fn for_offer_using_derived_keys( offer: &'a Offer, payment_paths: Vec<(BlindedPayInfo, BlindedPaymentPath)>, - message_paths: Vec, created_at: Duration, expanded_key: &ExpandedKey, + message_paths: Vec, created_at: Duration, expanded_key: &ExpandedKey, nonce: Nonce, secp_ctx: &Secp256k1, ) -> Result { if offer.chains().len() > 1 { @@ -224,13 +224,13 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => { /// publicly reachable nodes. Taken from [`Offer::paths`]. /// /// [`Offer::paths`]: crate::offers::offer::Offer::paths - pub fn offer_message_paths(&$self) -> &[BlindedPath] { + pub fn offer_message_paths(&$self) -> &[BlindedMessagePath] { $contents.offer_message_paths() } /// Paths to the recipient for indicating that a held HTLC is available to claim when they next /// come online. - pub fn message_paths(&$self) -> &[BlindedPath] { + pub fn message_paths(&$self) -> &[BlindedMessagePath] { $contents.message_paths() } @@ -327,7 +327,7 @@ impl InvoiceContents { fn new( offer: &Offer, payment_paths: Vec<(BlindedPayInfo, BlindedPaymentPath)>, - message_paths: Vec, created_at: Duration, signing_pubkey: PublicKey, + message_paths: Vec, created_at: Duration, signing_pubkey: PublicKey, ) -> Self { Self { offer: offer.contents.clone(), @@ -395,11 +395,11 @@ impl InvoiceContents { self.offer.issuer() } - fn offer_message_paths(&self) -> &[BlindedPath] { + fn offer_message_paths(&self) -> &[BlindedMessagePath] { self.offer.paths() } - fn message_paths(&self) -> &[BlindedPath] { + fn message_paths(&self) -> &[BlindedMessagePath] { &self.message_paths[..] } @@ -560,6 +560,7 @@ impl TryFrom for InvoiceContents { #[cfg(test)] mod tests { + use crate::blinded_path::message::BlindedMessagePath; use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode}; use crate::ln::features::{Bolt12InvoiceFeatures, OfferFeatures}; use crate::ln::inbound_payment::ExpandedKey; @@ -633,15 +634,15 @@ mod tests { .unwrap() } - fn blinded_path() -> BlindedPath { - BlindedPath { + fn blinded_path() -> BlindedMessagePath { + BlindedMessagePath(BlindedPath { introduction_node: IntroductionNode::NodeId(pubkey(40)), blinding_point: pubkey(41), blinded_hops: vec![ BlindedHop { blinded_node_id: pubkey(42), encrypted_payload: vec![0; 43] }, BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 44] }, ], - } + }) } #[test] diff --git a/lightning/src/onion_message/async_payments.rs b/lightning/src/onion_message/async_payments.rs index d0200101f..4a0801019 100644 --- a/lightning/src/onion_message/async_payments.rs +++ b/lightning/src/onion_message/async_payments.rs @@ -55,7 +55,7 @@ pub trait AsyncPaymentsMessageHandler { ) -> Vec<( AsyncPaymentsMessage, crate::onion_message::messenger::Destination, - Option, + Option, )> { vec![] } diff --git a/lightning/src/onion_message/functional_tests.rs b/lightning/src/onion_message/functional_tests.rs index 7df69b823..21e1fed3a 100644 --- a/lightning/src/onion_message/functional_tests.rs +++ b/lightning/src/onion_message/functional_tests.rs @@ -9,8 +9,8 @@ //! Onion message testing and test utilities live here. -use crate::blinded_path::{BlindedPath, EmptyNodeIdLookUp}; -use crate::blinded_path::message::{ForwardNode, MessageContext, OffersContext}; +use crate::blinded_path::EmptyNodeIdLookUp; +use crate::blinded_path::message::{BlindedMessagePath, ForwardNode, MessageContext, OffersContext}; use crate::events::{Event, EventsProvider}; use crate::ln::features::{ChannelFeatures, InitFeatures}; use crate::ln::msgs::{self, DecodeError, OnionMessageHandler}; @@ -373,7 +373,7 @@ fn one_blinded_hop() { let secp_ctx = Secp256k1::new(); let context = MessageContext::Custom(Vec::new()); - let blinded_path = BlindedPath::new_for_message(&[], nodes[1].node_id, context, &*nodes[1].entropy_source, &secp_ctx).unwrap(); + let blinded_path = BlindedMessagePath::new(&[], nodes[1].node_id, context, &*nodes[1].entropy_source, &secp_ctx).unwrap(); let destination = Destination::BlindedPath(blinded_path); nodes[0].messenger.send_onion_message(test_msg, destination, None).unwrap(); nodes[1].custom_message_handler.expect_message(TestCustomMessage::Pong); @@ -388,7 +388,7 @@ fn two_unblinded_two_blinded() { let secp_ctx = Secp256k1::new(); let intermediate_nodes = [ForwardNode { node_id: nodes[3].node_id, short_channel_id: None }]; let context = MessageContext::Custom(Vec::new()); - let blinded_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[4].node_id, context, &*nodes[4].entropy_source, &secp_ctx).unwrap(); + let blinded_path = BlindedMessagePath::new(&intermediate_nodes, nodes[4].node_id, context, &*nodes[4].entropy_source, &secp_ctx).unwrap(); let path = OnionMessagePath { intermediate_nodes: vec![nodes[1].node_id, nodes[2].node_id], destination: Destination::BlindedPath(blinded_path), @@ -411,7 +411,7 @@ fn three_blinded_hops() { ForwardNode { node_id: nodes[2].node_id, short_channel_id: None }, ]; let context = MessageContext::Custom(Vec::new()); - let blinded_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[3].node_id, context, &*nodes[3].entropy_source, &secp_ctx).unwrap(); + 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); nodes[0].messenger.send_onion_message(test_msg, destination, None).unwrap(); @@ -434,7 +434,7 @@ fn async_response_over_one_blinded_hop() { // 3. Simulate the creation of a Blinded Reply path provided by Bob. let secp_ctx = Secp256k1::new(); let context = MessageContext::Custom(Vec::new()); - let reply_path = BlindedPath::new_for_message(&[], nodes[1].node_id, context, &*nodes[1].entropy_source, &secp_ctx).unwrap(); + let reply_path = BlindedMessagePath::new(&[], nodes[1].node_id, context, &*nodes[1].entropy_source, &secp_ctx).unwrap(); // 4. Create a responder using the reply path for Alice. let responder = Some(Responder::new(reply_path)); @@ -470,7 +470,7 @@ fn async_response_with_reply_path_succeeds() { // Alice receives a message from Bob with an added reply_path for responding back. let message = TestCustomMessage::Ping; let context = MessageContext::Custom(Vec::new()); - let reply_path = BlindedPath::new_for_message(&[], bob.node_id, context, &*bob.entropy_source, &secp_ctx).unwrap(); + let reply_path = BlindedMessagePath::new(&[], bob.node_id, context, &*bob.entropy_source, &secp_ctx).unwrap(); // Alice asynchronously responds to Bob, expecting a response back from him. let responder = Responder::new(reply_path); @@ -507,7 +507,7 @@ fn async_response_with_reply_path_fails() { // Alice receives a message from Bob with an added reply_path for responding back. let message = TestCustomMessage::Ping; let context = MessageContext::Custom(Vec::new()); - let reply_path = BlindedPath::new_for_message(&[], bob.node_id, context, &*bob.entropy_source, &secp_ctx).unwrap(); + let reply_path = BlindedMessagePath::new(&[], bob.node_id, context, &*bob.entropy_source, &secp_ctx).unwrap(); // Alice tries to asynchronously respond to Bob, but fails because the nodes are unannounced and // disconnected. Thus, a reply path could no be created for the response. @@ -552,7 +552,7 @@ fn we_are_intro_node() { ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }, ]; let context = MessageContext::Custom(Vec::new()); - let blinded_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[2].node_id, context, &*nodes[2].entropy_source, &secp_ctx).unwrap(); + let blinded_path = BlindedMessagePath::new(&intermediate_nodes, nodes[2].node_id, context, &*nodes[2].entropy_source, &secp_ctx).unwrap(); let destination = Destination::BlindedPath(blinded_path); nodes[0].messenger.send_onion_message(test_msg.clone(), destination, None).unwrap(); @@ -562,7 +562,7 @@ fn we_are_intro_node() { // 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 context = MessageContext::Custom(Vec::new()); - let blinded_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[1].node_id, context, &*nodes[1].entropy_source, &secp_ctx).unwrap(); + 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); nodes[0].messenger.send_onion_message(test_msg, destination, None).unwrap(); nodes[1].custom_message_handler.expect_message(TestCustomMessage::Pong); @@ -579,8 +579,8 @@ fn invalid_blinded_path_error() { let secp_ctx = Secp256k1::new(); let intermediate_nodes = [ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }]; let context = MessageContext::Custom(Vec::new()); - let mut blinded_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[2].node_id, context, &*nodes[2].entropy_source, &secp_ctx).unwrap(); - blinded_path.blinded_hops.clear(); + let mut blinded_path = BlindedMessagePath::new(&intermediate_nodes, nodes[2].node_id, context, &*nodes[2].entropy_source, &secp_ctx).unwrap(); + blinded_path.0.blinded_hops.clear(); let destination = Destination::BlindedPath(blinded_path); let err = nodes[0].messenger.send_onion_message(test_msg, destination, None).unwrap_err(); assert_eq!(err, SendError::TooFewBlindedHops); @@ -603,7 +603,7 @@ fn reply_path() { ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }, ]; let context = MessageContext::Custom(Vec::new()); - let reply_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[0].node_id, context, &*nodes[0].entropy_source, &secp_ctx).unwrap(); + let reply_path = BlindedMessagePath::new(&intermediate_nodes, nodes[0].node_id, context, &*nodes[0].entropy_source, &secp_ctx).unwrap(); nodes[0].messenger.send_onion_message_using_path(path, test_msg.clone(), Some(reply_path)).unwrap(); nodes[3].custom_message_handler.expect_message(TestCustomMessage::Ping); pass_along_path(&nodes); @@ -618,14 +618,14 @@ fn reply_path() { ForwardNode { node_id: nodes[2].node_id, short_channel_id: None }, ]; let context = MessageContext::Custom(Vec::new()); - let blinded_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[3].node_id, context, &*nodes[3].entropy_source, &secp_ctx).unwrap(); + 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 }, ]; let context = MessageContext::Custom(Vec::new()); - let reply_path = BlindedPath::new_for_message(&intermediate_nodes, nodes[0].node_id, context, &*nodes[0].entropy_source, &secp_ctx).unwrap(); + let reply_path = BlindedMessagePath::new(&intermediate_nodes, nodes[0].node_id, context, &*nodes[0].entropy_source, &secp_ctx).unwrap(); nodes[0].messenger.send_onion_message(test_msg, destination, Some(reply_path)).unwrap(); nodes[3].custom_message_handler.expect_message(TestCustomMessage::Ping); @@ -707,7 +707,7 @@ fn requests_peer_connection_for_buffered_messages() { let intermediate_nodes = [ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }]; let context = MessageContext::Custom(Vec::new()); - let blinded_path = BlindedPath::new_for_message( + let blinded_path = BlindedMessagePath::new( &intermediate_nodes, nodes[2].node_id, context, &*nodes[0].entropy_source, &secp_ctx ).unwrap(); let destination = Destination::BlindedPath(blinded_path); @@ -746,7 +746,7 @@ fn drops_buffered_messages_waiting_for_peer_connection() { let intermediate_nodes = [ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }]; let context = MessageContext::Custom(Vec::new()); - let blinded_path = BlindedPath::new_for_message( + let blinded_path = BlindedMessagePath::new( &intermediate_nodes, nodes[2].node_id, context, &*nodes[0].entropy_source, &secp_ctx ).unwrap(); let destination = Destination::BlindedPath(blinded_path); @@ -797,7 +797,7 @@ fn intercept_offline_peer_oms() { let secp_ctx = Secp256k1::new(); let intermediate_nodes = [ForwardNode { node_id: nodes[1].node_id, short_channel_id: None }]; let context = MessageContext::Custom(Vec::new()); - let blinded_path = BlindedPath::new_for_message( + let blinded_path = BlindedMessagePath::new( &intermediate_nodes, nodes[2].node_id, context, &*nodes[2].entropy_source, &secp_ctx ).unwrap(); let destination = Destination::BlindedPath(blinded_path); diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index 24615e537..69b87b7a1 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::{BlindedPath, IntroductionNode, NextMessageHop, NodeIdLookUp}; -use crate::blinded_path::message::{advance_path_by_one, ForwardNode, ForwardTlvs, MessageContext, ReceiveTlvs}; +use crate::blinded_path::message::{advance_path_by_one, BlindedMessagePath, ForwardNode, ForwardTlvs, MessageContext, ReceiveTlvs}; use crate::blinded_path::utils; use crate::events::{Event, EventHandler, EventsProvider, ReplayEvent}; use crate::sign::{EntropySource, NodeSigner, Recipient}; @@ -147,8 +147,8 @@ for OnionMessenger where /// # use bitcoin::hashes::_export::_core::time::Duration; /// # use bitcoin::hex::FromHex; /// # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey, self}; -/// # use lightning::blinded_path::{BlindedPath, EmptyNodeIdLookUp}; -/// # use lightning::blinded_path::message::{ForwardNode, MessageContext}; +/// # use lightning::blinded_path::EmptyNodeIdLookUp; +/// # use lightning::blinded_path::message::{BlindedMessagePath, ForwardNode, MessageContext}; /// # use lightning::sign::{EntropySource, KeysManager}; /// # use lightning::ln::peer_handler::IgnoringMessageHandler; /// # use lightning::onion_message::messenger::{Destination, MessageRouter, OnionMessagePath, OnionMessenger}; @@ -176,7 +176,7 @@ for OnionMessenger where /// # } /// # fn create_blinded_paths( /// # &self, _recipient: PublicKey, _context: MessageContext, _peers: Vec, _secp_ctx: &Secp256k1 -/// # ) -> Result, ()> { +/// # ) -> Result, ()> { /// # unreachable!() /// # } /// # } @@ -229,7 +229,7 @@ for OnionMessenger where /// ForwardNode { node_id: hop_node_id4, short_channel_id: None }, /// ]; /// let context = MessageContext::Custom(Vec::new()); -/// let blinded_path = BlindedPath::new_for_message(&hops, your_node_id, context, &keys_manager, &secp_ctx).unwrap(); +/// let blinded_path = BlindedMessagePath::new(&hops, your_node_id, context, &keys_manager, &secp_ctx).unwrap(); /// /// // Send a custom onion message to a blinded path. /// let destination = Destination::BlindedPath(blinded_path); @@ -347,7 +347,7 @@ impl OnionMessageRecipient { #[derive(Clone, Debug, Eq, PartialEq)] pub struct Responder { /// The path along which a response can be sent. - reply_path: BlindedPath, + reply_path: BlindedMessagePath, } impl_writeable_tlv_based!(Responder, { @@ -356,7 +356,7 @@ impl_writeable_tlv_based!(Responder, { impl Responder { /// Creates a new [`Responder`] instance with the provided reply path. - pub(super) fn new(reply_path: BlindedPath) -> Self { + pub(super) fn new(reply_path: BlindedMessagePath) -> Self { Responder { reply_path, } @@ -386,7 +386,7 @@ impl Responder { /// This struct contains the information needed to reply to a received message. pub struct OnionMessageResponse { message: T, - reply_path: BlindedPath, + reply_path: BlindedMessagePath, } /// `ResponseInstruction` represents instructions for responding to received messages. @@ -414,7 +414,7 @@ pub struct PendingOnionMessage { pub destination: Destination, /// A reply path to include in the [`OnionMessage`] for a response. - pub reply_path: Option, + pub reply_path: Option, } #[cfg(c_bindings)] @@ -422,10 +422,10 @@ pub struct PendingOnionMessage { /// /// These are obtained when released from [`OnionMessenger`]'s handlers after which they are /// enqueued for sending. -pub type PendingOnionMessage = (T, Destination, Option); +pub type PendingOnionMessage = (T, Destination, Option); pub(crate) fn new_pending_onion_message( - contents: T, destination: Destination, reply_path: Option + contents: T, destination: Destination, reply_path: Option ) -> PendingOnionMessage { #[cfg(not(c_bindings))] return PendingOnionMessage { contents, destination, reply_path }; @@ -440,16 +440,16 @@ pub trait MessageRouter { &self, sender: PublicKey, peers: Vec, destination: Destination ) -> Result; - /// Creates [`BlindedPath`]s to the `recipient` node. The nodes in `peers` are assumed to be - /// direct peers with the `recipient`. + /// Creates [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are assumed to + /// be direct peers with the `recipient`. fn create_blinded_paths< T: secp256k1::Signing + secp256k1::Verification >( &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, - ) -> Result, ()>; + ) -> Result, ()>; - /// Creates compact [`BlindedPath`]s to the `recipient` node. The nodes in `peers` are assumed - /// to be direct peers with the `recipient`. + /// 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 @@ -466,7 +466,7 @@ pub trait MessageRouter { >( &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> Result, ()> { let peers = peers .into_iter() .map(|ForwardNode { node_id, short_channel_id: _ }| node_id) @@ -479,10 +479,10 @@ pub trait MessageRouter { /// /// # Privacy /// -/// Creating [`BlindedPath`]s may affect privacy since, if a suitable path cannot be found, it will -/// create a one-hop path using the recipient as the introduction node if it is a announced node. -/// Otherwise, there is no way to find a path to the introduction node in order to send a message, -/// and thus an `Err` is returned. +/// Creating [`BlindedMessagePath`]s may affect privacy since, if a suitable path cannot be found, +/// it will create a one-hop path using the recipient as the introduction node if it is a announced +/// node. Otherwise, there is no way to find a path to the introduction node in order to send a +/// message, and thus an `Err` is returned. pub struct DefaultMessageRouter>, L: Deref, ES: Deref> where L::Target: Logger, @@ -508,7 +508,7 @@ where >( network_graph: &G, recipient: PublicKey, context: MessageContext, peers: I, entropy_source: &ES, secp_ctx: &Secp256k1, compact_paths: bool, - ) -> Result, ()> { + ) -> Result, ()> { // Limit the number of blinded paths that are computed. const MAX_PATHS: usize = 3; @@ -546,7 +546,7 @@ where let paths = peer_info.into_iter() .map(|(peer, _, _)| { - BlindedPath::new_for_message(&[peer], recipient, context.clone(), &**entropy_source, secp_ctx) + BlindedMessagePath::new(&[peer], recipient, context.clone(), &**entropy_source, secp_ctx) }) .take(MAX_PATHS) .collect::, _>>(); @@ -555,7 +555,7 @@ where Ok(paths) if !paths.is_empty() => Ok(paths), _ => { if is_recipient_announced { - BlindedPath::one_hop_for_message(recipient, context, &**entropy_source, secp_ctx) + BlindedMessagePath::new(&[], recipient, context, &**entropy_source, secp_ctx) .map(|path| vec![path]) } else { Err(()) @@ -565,7 +565,7 @@ where if compact_paths { for path in &mut paths { - path.use_compact_introduction_node(&network_graph); + path.0.use_compact_introduction_node(&network_graph); } } @@ -610,7 +610,7 @@ where >( network_graph: &G, recipient: PublicKey, context: MessageContext, peers: Vec, entropy_source: &ES, secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> Result, ()> { let peers = peers .into_iter() .map(|node_id| ForwardNode { node_id, short_channel_id: None }); @@ -622,7 +622,7 @@ where >( network_graph: &G, recipient: PublicKey, context: MessageContext, peers: Vec, entropy_source: &ES, secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> Result, ()> { Self::create_blinded_paths_from_iter(network_graph, recipient, context, peers.into_iter(), entropy_source, secp_ctx, true) } } @@ -642,7 +642,7 @@ where T: secp256k1::Signing + secp256k1::Verification >( &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> Result, ()> { Self::create_blinded_paths(&self.network_graph, recipient, context, peers, &self.entropy_source, secp_ctx) } @@ -650,7 +650,7 @@ where T: secp256k1::Signing + secp256k1::Verification >( &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> Result, ()> { Self::create_compact_blinded_paths(&self.network_graph, recipient, context, peers, &self.entropy_source, secp_ctx) } @@ -688,7 +688,7 @@ pub enum Destination { /// We're sending this onion message to a node. Node(PublicKey), /// We're sending this onion message to a blinded path. - BlindedPath(BlindedPath), + BlindedPath(BlindedMessagePath), } impl Destination { @@ -697,12 +697,13 @@ impl Destination { /// provided [`ReadOnlyNetworkGraph`]. pub fn resolve(&mut self, network_graph: &ReadOnlyNetworkGraph) { if let Destination::BlindedPath(path) = self { - if let IntroductionNode::DirectedShortChannelId(..) = path.introduction_node { + if let IntroductionNode::DirectedShortChannelId(..) = path.0.introduction_node { if let Some(pubkey) = path + .0 .public_introduction_node_id(network_graph) .and_then(|node_id| node_id.as_pubkey().ok()) { - path.introduction_node = IntroductionNode::NodeId(pubkey); + path.0.introduction_node = IntroductionNode::NodeId(pubkey); } } } @@ -711,14 +712,14 @@ impl Destination { pub(super) fn num_hops(&self) -> usize { match self { Destination::Node(_) => 1, - Destination::BlindedPath(BlindedPath { blinded_hops, .. }) => blinded_hops.len(), + Destination::BlindedPath(BlindedMessagePath(BlindedPath { blinded_hops, .. })) => blinded_hops.len(), } } fn first_node(&self) -> Option { match self { Destination::Node(node_id) => Some(*node_id), - Destination::BlindedPath(BlindedPath { introduction_node, .. }) => { + Destination::BlindedPath(BlindedMessagePath(BlindedPath { introduction_node, .. })) => { match introduction_node { IntroductionNode::NodeId(pubkey) => Some(*pubkey), IntroductionNode::DirectedShortChannelId(..) => None, @@ -751,8 +752,8 @@ pub enum SendError { /// Because implementations such as Eclair will drop onion messages where the message packet /// exceeds 32834 bytes, we refuse to send messages where the packet exceeds this size. TooBigPacket, - /// The provided [`Destination`] was an invalid [`BlindedPath`] due to not having any blinded - /// hops. + /// The provided [`Destination`] was an invalid [`BlindedMessagePath`] due to not having any + /// blinded hops. TooFewBlindedHops, /// The first hop is not a peer and doesn't have a known [`SocketAddress`]. InvalidFirstHop(PublicKey), @@ -817,7 +818,7 @@ pub trait CustomOnionMessageHandler { /// Typically, this is used for messages initiating a message flow rather than in response to /// another message. The latter should use the return value of [`Self::handle_custom_message`]. #[cfg(c_bindings)] - fn release_pending_custom_messages(&self) -> Vec<(Self::CustomMessage, Destination, Option)>; + fn release_pending_custom_messages(&self) -> Vec<(Self::CustomMessage, Destination, Option)>; } /// A processed incoming onion message, containing either a Forward (another onion message) @@ -827,7 +828,7 @@ pub enum PeeledOnion { /// Forwarded onion, with the next node id and a new onion Forward(NextMessageHop, OnionMessage), /// Received onion message, with decrypted contents, context, and reply path - Receive(ParsedOnionMessageContents, Option, Option) + Receive(ParsedOnionMessageContents, Option, Option) } @@ -842,7 +843,7 @@ pub fn create_onion_message_resolving_destination< >( entropy_source: &ES, node_signer: &NS, node_id_lookup: &NL, network_graph: &ReadOnlyNetworkGraph, secp_ctx: &Secp256k1, - mut path: OnionMessagePath, contents: T, reply_path: Option, + mut path: OnionMessagePath, contents: T, reply_path: Option, ) -> Result<(PublicKey, OnionMessage, Option>), SendError> where ES::Target: EntropySource, @@ -869,7 +870,7 @@ where pub fn create_onion_message( entropy_source: &ES, node_signer: &NS, node_id_lookup: &NL, secp_ctx: &Secp256k1, path: OnionMessagePath, contents: T, - reply_path: Option, + reply_path: Option, ) -> Result<(PublicKey, OnionMessage, Option>), SendError> where ES::Target: EntropySource, @@ -877,7 +878,7 @@ where NL::Target: NodeIdLookUp, { let OnionMessagePath { intermediate_nodes, mut destination, first_node_addresses } = path; - if let Destination::BlindedPath(BlindedPath { ref blinded_hops, .. }) = destination { + if let Destination::BlindedPath(BlindedMessagePath(BlindedPath { ref blinded_hops, .. })) = destination { if blinded_hops.is_empty() { return Err(SendError::TooFewBlindedHops); } @@ -891,7 +892,7 @@ where if let Destination::BlindedPath(ref mut blinded_path) = destination { let our_node_id = node_signer.get_node_id(Recipient::Node) .map_err(|()| SendError::GetNodeIdFailed)?; - let introduction_node_id = match blinded_path.introduction_node { + let introduction_node_id = match blinded_path.0.introduction_node { IntroductionNode::NodeId(pubkey) => pubkey, IntroductionNode::DirectedShortChannelId(direction, scid) => { match node_id_lookup.next_node_id(scid) { @@ -914,7 +915,7 @@ where } else { match &destination { Destination::Node(pk) => (*pk, PublicKey::from_secret_key(&secp_ctx, &blinding_secret)), - Destination::BlindedPath(BlindedPath { introduction_node, blinding_point, .. }) => { + Destination::BlindedPath(BlindedMessagePath(BlindedPath { introduction_node, blinding_point, .. })) => { match introduction_node { IntroductionNode::NodeId(pubkey) => (*pubkey, *blinding_point), IntroductionNode::DirectedShortChannelId(..) => { @@ -1160,7 +1161,7 @@ where /// /// See [`OnionMessenger`] for example usage. pub fn send_onion_message( - &self, contents: T, destination: Destination, reply_path: Option + &self, contents: T, destination: Destination, reply_path: Option ) -> Result { self.find_path_and_enqueue_onion_message( contents, destination, reply_path, format_args!("") @@ -1168,7 +1169,7 @@ where } fn find_path_and_enqueue_onion_message( - &self, contents: T, destination: Destination, reply_path: Option, + &self, contents: T, destination: Destination, reply_path: Option, log_suffix: fmt::Arguments ) -> Result { let mut logger = WithContext::from(&self.logger, None, None, None); @@ -1219,7 +1220,7 @@ where .map_err(|_| SendError::PathNotFound) } - fn create_blinded_path(&self, context: MessageContext) -> Result { + fn create_blinded_path(&self, context: MessageContext) -> Result { let recipient = self.node_signer .get_node_id(Recipient::Node) .map_err(|_| SendError::GetNodeIdFailed)?; @@ -1238,7 +1239,7 @@ where } fn enqueue_onion_message( - &self, path: OnionMessagePath, contents: T, reply_path: Option, + &self, path: OnionMessagePath, contents: T, reply_path: Option, log_suffix: fmt::Arguments ) -> Result { log_trace!(self.logger, "Constructing onion message {}: {:?}", log_suffix, contents); @@ -1297,7 +1298,7 @@ where #[cfg(any(test, feature = "_test_utils"))] pub fn send_onion_message_using_path( - &self, path: OnionMessagePath, contents: T, reply_path: Option + &self, path: OnionMessagePath, contents: T, reply_path: Option ) -> Result { self.enqueue_onion_message(path, contents, reply_path, format_args!("")) } @@ -1785,7 +1786,7 @@ pub type SimpleRefOnionMessenger< /// `unblinded_path` to the given `destination`. fn packet_payloads_and_keys( secp_ctx: &Secp256k1, unblinded_path: &[PublicKey], destination: Destination, message: T, - mut reply_path: Option, session_priv: &SecretKey + mut reply_path: Option, session_priv: &SecretKey ) -> Result<(Vec<(Payload, [u8; 32])>, Vec), SendError> { let num_hops = unblinded_path.len() + destination.num_hops(); let mut payloads = Vec::with_capacity(num_hops); @@ -1793,7 +1794,7 @@ fn packet_payloads_and_keys (None, 0), - Destination::BlindedPath(BlindedPath { introduction_node, blinding_point, blinded_hops }) => { + Destination::BlindedPath(BlindedMessagePath(BlindedPath { introduction_node, blinding_point, blinded_hops })) => { let introduction_node_id = match introduction_node { IntroductionNode::NodeId(pubkey) => pubkey, IntroductionNode::DirectedShortChannelId(..) => { diff --git a/lightning/src/onion_message/mod.rs b/lightning/src/onion_message/mod.rs index 1693c5a99..8cdf098a3 100644 --- a/lightning/src/onion_message/mod.rs +++ b/lightning/src/onion_message/mod.rs @@ -18,7 +18,7 @@ //! information on its usage. //! //! [offers]: -//! [blinded paths]: crate::blinded_path::BlindedPath +//! [blinded paths]: crate::blinded_path::message::BlindedMessagePath //! [`OnionMessenger`]: self::messenger::OnionMessenger pub mod async_payments; diff --git a/lightning/src/onion_message/offers.rs b/lightning/src/onion_message/offers.rs index 6884ca77e..86268c621 100644 --- a/lightning/src/onion_message/offers.rs +++ b/lightning/src/onion_message/offers.rs @@ -61,7 +61,7 @@ pub trait OffersMessageHandler { /// Typically, this is used for messages initiating a payment flow rather than in response to /// another message. The latter should use the return value of [`Self::handle_message`]. #[cfg(c_bindings)] - fn release_pending_messages(&self) -> Vec<(OffersMessage, crate::onion_message::messenger::Destination, Option)> { vec![] } + fn release_pending_messages(&self) -> Vec<(OffersMessage, crate::onion_message::messenger::Destination, Option)> { vec![] } } /// Possible BOLT 12 Offers messages sent and received via an [`OnionMessage`]. diff --git a/lightning/src/onion_message/packet.rs b/lightning/src/onion_message/packet.rs index 49b3f6642..88302b106 100644 --- a/lightning/src/onion_message/packet.rs +++ b/lightning/src/onion_message/packet.rs @@ -12,8 +12,8 @@ use bitcoin::secp256k1::PublicKey; use bitcoin::secp256k1::ecdh::SharedSecret; -use crate::blinded_path::{BlindedPath, NextMessageHop}; -use crate::blinded_path::message::{ForwardTlvs, ReceiveTlvs}; +use crate::blinded_path::NextMessageHop; +use crate::blinded_path::message::{BlindedMessagePath, ForwardTlvs, ReceiveTlvs}; use crate::blinded_path::utils::Padding; use crate::ln::msgs::DecodeError; use crate::ln::onion_utils; @@ -118,7 +118,7 @@ pub(super) enum Payload { /// This payload is for the final hop. Receive { control_tlvs: ReceiveControlTlvs, - reply_path: Option, + reply_path: Option, message: T, } } @@ -246,7 +246,7 @@ for Payload::CustomM let v: BigSize = Readable::read(r)?; let mut rd = FixedLengthReader::new(r, v.0); - let mut reply_path: Option = None; + let mut reply_path: Option = None; let mut read_adapter: Option> = None; let rho = onion_utils::gen_rho_from_shared_secret(&encrypted_tlvs_ss.secret_bytes()); let mut message_type: Option = None; diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index b6be139c0..99a9e0086 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -11,8 +11,8 @@ use bitcoin::secp256k1::{PublicKey, Secp256k1, self}; -use crate::blinded_path::{BlindedHop, BlindedPath, Direction, IntroductionNode}; -use crate::blinded_path::message::{self, MessageContext}; +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::ln::{PaymentHash, PaymentPreimage}; use crate::ln::channel_state::ChannelDetails; @@ -197,7 +197,7 @@ impl< G: Deref>, L: Deref, ES: Deref, S: Deref, SP: Siz T: secp256k1::Signing + secp256k1::Verification > ( &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> Result, ()> { DefaultMessageRouter::create_blinded_paths(&self.network_graph, recipient, context, peers, &self.entropy_source, secp_ctx) } @@ -205,7 +205,7 @@ impl< G: Deref>, L: Deref, ES: Deref, S: Deref, SP: Siz T: secp256k1::Signing + secp256k1::Verification > ( &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> 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 2f2a48bd6..ef8a7c70f 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -8,8 +8,7 @@ // licenses. use crate::blinded_path::message::MessageContext; -use crate::blinded_path::BlindedPath; -use crate::blinded_path::message::ForwardNode; +use crate::blinded_path::message::{BlindedMessagePath, ForwardNode}; use crate::blinded_path::payment::{BlindedPaymentPath, ReceiveTlvs}; use crate::chain; use crate::chain::WatchedOutput; @@ -271,7 +270,7 @@ impl<'a> MessageRouter for TestRouter<'a> { >( &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> Result, ()> { self.router.create_blinded_paths(recipient, context, peers, secp_ctx) } @@ -280,7 +279,7 @@ impl<'a> MessageRouter for TestRouter<'a> { >( &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> Result, ()> { self.router.create_compact_blinded_paths(recipient, context, peers, secp_ctx) } } @@ -316,14 +315,14 @@ impl<'a> MessageRouter for TestMessageRouter<'a> { fn create_blinded_paths( &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> Result, ()> { self.inner.create_blinded_paths(recipient, context, peers, secp_ctx) } fn create_compact_blinded_paths( &self, recipient: PublicKey, context: MessageContext, peers: Vec, secp_ctx: &Secp256k1, - ) -> Result, ()> { + ) -> Result, ()> { self.inner.create_compact_blinded_paths(recipient, context, peers, secp_ctx) } }