Skip to content

Rename from_raw to from_blinded_path_and_payinfo in BlindedPaymentPath #3807

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

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
2 changes: 1 addition & 1 deletion fuzz/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
encrypted_payload: Vec::new(),
});
}
BlindedPaymentPath::from_raw(
BlindedPaymentPath::from_blinded_path_and_payinfo(
hop.src_node_id,
dummy_pk,
blinded_hops,
Expand Down
18 changes: 13 additions & 5 deletions lightning/src/blinded_path/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,27 @@ impl BlindedPaymentPath {
Self { inner_path, payinfo }
}

#[cfg(any(test, fuzzing))]
pub fn from_raw(
/// Builds a new [`BlindedPaymentPath`] from its constituent parts.
///
/// Useful when reconstructing 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.
/// * `payinfo`: The [`BlindedPayInfo`] for the blinded path.
pub fn from_blinded_path_and_payinfo(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one could call into from_parts.

Or BlindedPath and from_parts could be made public instead and this method can be dropped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, the first one makes totally sense.

introduction_node_id: PublicKey, blinding_point: PublicKey, blinded_hops: Vec<BlindedHop>,
payinfo: BlindedPayInfo,
) -> Self {
Self {
inner_path: BlindedPath {
Self::from_parts(
BlindedPath {
introduction_node: IntroductionNode::NodeId(introduction_node_id),
blinding_point,
blinded_hops,
},
payinfo,
}
)
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/max_payment_path_len_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ fn bolt12_invoice_too_large_blinded_paths() {
create_announced_chan_between_nodes(&nodes, 0, 1);

nodes[1].router.expect_blinded_payment_paths(vec![
BlindedPaymentPath::from_raw(
BlindedPaymentPath::from_blinded_path_and_payinfo(
PublicKey::from_slice(&[2; 33]).unwrap(), PublicKey::from_slice(&[2; 33]).unwrap(),
vec![
BlindedHop {
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6055,7 +6055,7 @@ mod tests {
let trampoline_payload = OutboundTrampolinePayload::LegacyBlindedPathEntry {
amt_to_forward: 150_000_000,
outgoing_cltv_value: 800_000,
payment_paths: vec![BlindedPaymentPath::from_raw(
payment_paths: vec![BlindedPaymentPath::from_blinded_path_and_payinfo(
introduction_node,
blinding_point,
vec![],
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/offers/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub(super) fn privkey(byte: u8) -> SecretKey {

pub(crate) fn payment_paths() -> Vec<BlindedPaymentPath> {
vec![
BlindedPaymentPath::from_raw(
BlindedPaymentPath::from_blinded_path_and_payinfo(
pubkey(40),
pubkey(41),
vec![
Expand All @@ -90,7 +90,7 @@ pub(crate) fn payment_paths() -> Vec<BlindedPaymentPath> {
features: BlindedHopFeatures::empty(),
},
),
BlindedPaymentPath::from_raw(
BlindedPaymentPath::from_blinded_path_and_payinfo(
pubkey(40),
pubkey(41),
vec![
Expand Down
12 changes: 8 additions & 4 deletions lightning/src/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3825,7 +3825,7 @@ mod tests {
}

fn dummy_blinded_path(intro_node: PublicKey, payinfo: BlindedPayInfo) -> BlindedPaymentPath {
BlindedPaymentPath::from_raw(
BlindedPaymentPath::from_blinded_path_and_payinfo(
intro_node, ln_test_utils::pubkey(42),
vec![
BlindedHop { blinded_node_id: ln_test_utils::pubkey(42 as u8), encrypted_payload: Vec::new() },
Expand All @@ -3836,7 +3836,7 @@ mod tests {
}

fn dummy_one_hop_blinded_path(intro_node: PublicKey, payinfo: BlindedPayInfo) -> BlindedPaymentPath {
BlindedPaymentPath::from_raw(
BlindedPaymentPath::from_blinded_path_and_payinfo(
intro_node, ln_test_utils::pubkey(42),
vec![
BlindedHop { blinded_node_id: ln_test_utils::pubkey(42 as u8), encrypted_payload: Vec::new() },
Expand Down Expand Up @@ -7869,7 +7869,9 @@ mod tests {
cltv_expiry_delta: 15,
features: BlindedHopFeatures::empty(),
};
let blinded_path = BlindedPaymentPath::from_raw(nodes[2], ln_test_utils::pubkey(42), blinded_hops, blinded_payinfo.clone());
let blinded_path = BlindedPaymentPath::from_blinded_path_and_payinfo(
nodes[2], ln_test_utils::pubkey(42), blinded_hops, blinded_payinfo.clone()
);
let payment_params = PaymentParameters::blinded(vec![blinded_path.clone(), blinded_path.clone()]);

// Make sure we can round-trip read and write blinded payment params.
Expand Down Expand Up @@ -7990,7 +7992,9 @@ mod tests {

let mut blinded_payinfo_2 = blinded_payinfo_1;
blinded_payinfo_2.htlc_maximum_msat = 70_000;
let blinded_path_2 = BlindedPaymentPath::from_raw(nodes[2], ln_test_utils::pubkey(43),
let blinded_path_2 = BlindedPaymentPath::from_blinded_path_and_payinfo(
nodes[2],
ln_test_utils::pubkey(43),
vec![
BlindedHop { blinded_node_id: ln_test_utils::pubkey(42 as u8), encrypted_payload: Vec::new() },
BlindedHop { blinded_node_id: ln_test_utils::pubkey(42 as u8), encrypted_payload: Vec::new() }
Expand Down
Loading