Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make blinded path public #3677

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lightning/src/blinded_path/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,15 @@ impl BlindedMessagePath {
&mut self.0.introduction_node
}

#[cfg(test)]
pub fn from_raw(
/// Creates a new [`BlindedMessagePath`] from its constituent parts.
///
/// Useful when you need to reconstruct a blinded path from previously serialized components.
///
/// Parameters:
/// * `introduction_node_id`: The public key of the introduction node in the path
/// * `blinding_point`: The public key used for blinding the path
/// * `blinded_hops`: The encrypted routing information for each hop in the path
pub fn from_blinded_path(
introduction_node_id: PublicKey, blinding_point: PublicKey, blinded_hops: Vec<BlindedHop>,
) -> Self {
Self(BlindedPath {
Expand Down
10 changes: 5 additions & 5 deletions lightning/src/offers/invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2181,7 +2181,7 @@ mod tests {
let secp_ctx = Secp256k1::new();
let payment_id = PaymentId([1; 32]);

let blinded_path = BlindedMessagePath::from_raw(
let blinded_path = BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
Expand Down Expand Up @@ -2276,7 +2276,7 @@ mod tests {
let entropy = FixedEntropy {};
let secp_ctx = Secp256k1::new();

let blinded_path = BlindedMessagePath::from_raw(
let blinded_path = BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
Expand Down Expand Up @@ -2982,15 +2982,15 @@ mod tests {
let payment_id = PaymentId([1; 32]);

let paths = vec![
BlindedMessagePath::from_raw(
BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 43] },
BlindedHop { blinded_node_id: pubkey(44), encrypted_payload: vec![0; 44] },
],
),
BlindedMessagePath::from_raw(
BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
Expand Down Expand Up @@ -3532,7 +3532,7 @@ mod tests {
.sign(recipient_sign)
.unwrap();

let blinded_path = BlindedMessagePath::from_raw(
let blinded_path = BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
Expand Down
12 changes: 6 additions & 6 deletions lightning/src/offers/offer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ mod tests {
let secp_ctx = Secp256k1::new();
let payment_id = PaymentId([1; 32]);

let blinded_path = BlindedMessagePath::from_raw(
let blinded_path = BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
Expand Down Expand Up @@ -1643,15 +1643,15 @@ mod tests {
#[test]
fn builds_offer_with_paths() {
let paths = vec![
BlindedMessagePath::from_raw(
BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 43] },
BlindedHop { blinded_node_id: pubkey(44), encrypted_payload: vec![0; 44] },
],
),
BlindedMessagePath::from_raw(
BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
Expand Down Expand Up @@ -1856,15 +1856,15 @@ mod tests {
#[test]
fn parses_offer_with_paths() {
let offer = OfferBuilder::new(pubkey(42))
.path(BlindedMessagePath::from_raw(
.path(BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 43] },
BlindedHop { blinded_node_id: pubkey(44), encrypted_payload: vec![0; 44] },
],
))
.path(BlindedMessagePath::from_raw(
.path(BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
Expand All @@ -1879,7 +1879,7 @@ mod tests {
}

let offer = OfferBuilder::new(pubkey(42))
.path(BlindedMessagePath::from_raw(
.path(BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
Expand Down
10 changes: 5 additions & 5 deletions lightning/src/offers/refund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ mod tests {
let secp_ctx = Secp256k1::new();
let payment_id = PaymentId([1; 32]);

let blinded_path = BlindedMessagePath::from_raw(
let blinded_path = BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
Expand Down Expand Up @@ -1332,15 +1332,15 @@ mod tests {
#[test]
fn builds_refund_with_paths() {
let paths = vec![
BlindedMessagePath::from_raw(
BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 43] },
BlindedHop { blinded_node_id: pubkey(44), encrypted_payload: vec![0; 44] },
],
),
BlindedMessagePath::from_raw(
BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
Expand Down Expand Up @@ -1585,15 +1585,15 @@ mod tests {
fn parses_refund_with_optional_fields() {
let past_expiry = Duration::from_secs(0);
let paths = vec![
BlindedMessagePath::from_raw(
BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 43] },
BlindedHop { blinded_node_id: pubkey(44), encrypted_payload: vec![0; 44] },
],
),
BlindedMessagePath::from_raw(
BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/offers/static_invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ mod tests {
}

fn blinded_path() -> BlindedMessagePath {
BlindedMessagePath::from_raw(
BlindedMessagePath::from_blinded_path(
pubkey(40),
pubkey(41),
vec![
Expand Down
Loading