Skip to content

Commit 6d7a99f

Browse files
Make BlindedPath type private.
Users should use Blinded{Message,Payment}Path types instead.
1 parent ca5e3eb commit 6d7a99f

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

fuzz/src/router.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use bitcoin::blockdata::script::Builder;
1313
use bitcoin::blockdata::transaction::TxOut;
1414

1515
use lightning::blinded_path::payment::BlindedPaymentPath;
16-
use lightning::blinded_path::{BlindedHop, BlindedPath, IntroductionNode};
16+
use lightning::blinded_path::BlindedHop;
1717
use lightning::chain::transaction::OutPoint;
1818
use lightning::ln::channel_state::{ChannelCounterparty, ChannelDetails, ChannelShutdownState};
1919
use lightning::ln::channelmanager;
@@ -403,11 +403,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
403403
}
404404
(
405405
payinfo,
406-
BlindedPaymentPath(BlindedPath {
407-
introduction_node: IntroductionNode::NodeId(hop.src_node_id),
408-
blinding_point: dummy_pk,
409-
blinded_hops,
410-
}),
406+
BlindedPaymentPath::from_raw(hop.src_node_id, dummy_pk, blinded_hops),
411407
)
412408
})
413409
.collect();

lightning/src/blinded_path/message.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ use crate::util::ser::{FixedLengthReader, LengthReadableArgs, Readable, Writeabl
3030
use core::mem;
3131
use core::ops::Deref;
3232

33-
/// A [`BlindedPath`] to be used for sending or receiving a message, hiding the identity of the
33+
/// A blinded path to be used for sending or receiving a message, hiding the identity of the
3434
/// recipient.
3535
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
36-
pub struct BlindedMessagePath(pub BlindedPath);
36+
pub struct BlindedMessagePath(pub(crate) BlindedPath);
3737

3838
impl Writeable for BlindedMessagePath {
3939
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {

lightning/src/blinded_path/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub enum NextMessageHop {
3838
/// Onion messages and payments can be sent and received to blinded paths, which serve to hide the
3939
/// identity of the recipient.
4040
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
41-
pub struct BlindedPath {
41+
pub(crate) struct BlindedPath {
4242
/// To send to a blinded path, the sender first finds a route to the unblinded
4343
/// `introduction_node`, which can unblind its [`encrypted_payload`] to find out the onion
4444
/// message or payment's next hop and forward it along.
@@ -56,7 +56,7 @@ pub struct BlindedPath {
5656

5757
/// The unblinded node in a [`BlindedPath`].
5858
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
59-
pub enum IntroductionNode {
59+
pub(crate) enum IntroductionNode {
6060
/// The node id of the introduction node.
6161
NodeId(PublicKey),
6262
/// The short channel id of the channel leading to the introduction node. The [`Direction`]

lightning/src/blinded_path/payment.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ use core::ops::Deref;
3333
#[allow(unused_imports)]
3434
use crate::prelude::*;
3535

36-
/// A [`BlindedPath`] to be used for sending or receiving a payment, hiding the identity of the
36+
/// A blinded path to be used for sending or receiving a payment, hiding the identity of the
3737
/// recipient.
3838
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
39-
pub struct BlindedPaymentPath(pub BlindedPath);
39+
pub struct BlindedPaymentPath(pub(crate) BlindedPath);
4040

4141
impl Writeable for BlindedPaymentPath {
4242
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
@@ -80,6 +80,17 @@ impl BlindedPaymentPath {
8080
).map_err(|_| ())?,
8181
})))
8282
}
83+
84+
#[cfg(fuzzing)]
85+
pub fn from_raw(
86+
introduction_node_id: PublicKey, blinding_point: PublicKey, blinded_hops: Vec<BlindedHop>
87+
) -> Self {
88+
Self(BlindedPath {
89+
introduction_node: IntroductionNode::NodeId(introduction_node_id),
90+
blinding_point,
91+
blinded_hops,
92+
})
93+
}
8394
}
8495

8596
/// An intermediate node, its outbound channel, and relay parameters.

0 commit comments

Comments
 (0)