Skip to content

Commit 4845404

Browse files
committed
Rename from_raw to from_blinded_path_and_payinfo
Similar to 8ce438c, we rename `from_raw` function used in test/fuzzy scenarios to build `BlindedPaymentPath` to a public function `from_blinded_path_and_payinfo`. This function is useful when reconstructing a blinded path based on already serialized components.
1 parent 63a5e03 commit 4845404

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

fuzz/src/router.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
401401
encrypted_payload: Vec::new(),
402402
});
403403
}
404-
BlindedPaymentPath::from_raw(
404+
BlindedPaymentPath::from_blinded_path_and_payinfo(
405405
hop.src_node_id,
406406
dummy_pk,
407407
blinded_hops,

lightning/src/blinded_path/payment.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,16 @@ impl BlindedPaymentPath {
246246
Self { inner_path, payinfo }
247247
}
248248

249-
#[cfg(any(test, fuzzing))]
250-
pub fn from_raw(
249+
/// Builds a new [`BlindedPaymentPath`] from its constituent parts.
250+
///
251+
/// Useful when reconstructing a blinded path from previously serialized components.
252+
///
253+
/// Parameters:
254+
/// * `introduction_node_id`: The public key of the introduction node in the path.
255+
/// * `blinding_point`: The public key used for blinding the path.
256+
/// * `blinded_hops`: The encrypted routing information for each hop in the path.
257+
/// * `payinfo`: The [`BlindedPayInfo`] for the blinded path.
258+
pub fn from_blinded_path_and_payinfo(
251259
introduction_node_id: PublicKey, blinding_point: PublicKey, blinded_hops: Vec<BlindedHop>,
252260
payinfo: BlindedPayInfo,
253261
) -> Self {

lightning/src/ln/max_payment_path_len_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ fn bolt12_invoice_too_large_blinded_paths() {
373373
create_announced_chan_between_nodes(&nodes, 0, 1);
374374

375375
nodes[1].router.expect_blinded_payment_paths(vec![
376-
BlindedPaymentPath::from_raw(
376+
BlindedPaymentPath::from_blinded_path_and_payinfo(
377377
PublicKey::from_slice(&[2; 33]).unwrap(), PublicKey::from_slice(&[2; 33]).unwrap(),
378378
vec![
379379
BlindedHop {

lightning/src/ln/msgs.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3426,7 +3426,8 @@ where
34263426
}),
34273427
} => {
34283428
if amt.is_some()
3429-
|| cltv_value.is_some() || total_msat.is_some()
3429+
|| cltv_value.is_some()
3430+
|| total_msat.is_some()
34303431
|| keysend_preimage.is_some()
34313432
|| invoice_request.is_some()
34323433
{
@@ -3576,7 +3577,8 @@ where
35763577
}),
35773578
} => {
35783579
if amt.is_some()
3579-
|| cltv_value.is_some() || total_msat.is_some()
3580+
|| cltv_value.is_some()
3581+
|| total_msat.is_some()
35803582
|| keysend_preimage.is_some()
35813583
|| invoice_request.is_some()
35823584
{
@@ -6055,7 +6057,7 @@ mod tests {
60556057
let trampoline_payload = OutboundTrampolinePayload::LegacyBlindedPathEntry {
60566058
amt_to_forward: 150_000_000,
60576059
outgoing_cltv_value: 800_000,
6058-
payment_paths: vec![BlindedPaymentPath::from_raw(
6060+
payment_paths: vec![BlindedPaymentPath::from_blinded_path_and_payinfo(
60596061
introduction_node,
60606062
blinding_point,
60616063
vec![],

lightning/src/offers/test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub(super) fn privkey(byte: u8) -> SecretKey {
7474

7575
pub(crate) fn payment_paths() -> Vec<BlindedPaymentPath> {
7676
vec![
77-
BlindedPaymentPath::from_raw(
77+
BlindedPaymentPath::from_blinded_path_and_payinfo(
7878
pubkey(40),
7979
pubkey(41),
8080
vec![
@@ -90,7 +90,7 @@ pub(crate) fn payment_paths() -> Vec<BlindedPaymentPath> {
9090
features: BlindedHopFeatures::empty(),
9191
},
9292
),
93-
BlindedPaymentPath::from_raw(
93+
BlindedPaymentPath::from_blinded_path_and_payinfo(
9494
pubkey(40),
9595
pubkey(41),
9696
vec![

lightning/src/routing/router.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,7 +3825,7 @@ mod tests {
38253825
}
38263826

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

38383838
fn dummy_one_hop_blinded_path(intro_node: PublicKey, payinfo: BlindedPayInfo) -> BlindedPaymentPath {
3839-
BlindedPaymentPath::from_raw(
3839+
BlindedPaymentPath::from_blinded_path_and_payinfo(
38403840
intro_node, ln_test_utils::pubkey(42),
38413841
vec![
38423842
BlindedHop { blinded_node_id: ln_test_utils::pubkey(42 as u8), encrypted_payload: Vec::new() },
@@ -7869,7 +7869,9 @@ mod tests {
78697869
cltv_expiry_delta: 15,
78707870
features: BlindedHopFeatures::empty(),
78717871
};
7872-
let blinded_path = BlindedPaymentPath::from_raw(nodes[2], ln_test_utils::pubkey(42), blinded_hops, blinded_payinfo.clone());
7872+
let blinded_path = BlindedPaymentPath::from_blinded_path_and_payinfo(
7873+
nodes[2], ln_test_utils::pubkey(42), blinded_hops, blinded_payinfo.clone()
7874+
);
78737875
let payment_params = PaymentParameters::blinded(vec![blinded_path.clone(), blinded_path.clone()]);
78747876

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

79917993
let mut blinded_payinfo_2 = blinded_payinfo_1;
79927994
blinded_payinfo_2.htlc_maximum_msat = 70_000;
7993-
let blinded_path_2 = BlindedPaymentPath::from_raw(nodes[2], ln_test_utils::pubkey(43),
7995+
let blinded_path_2 = BlindedPaymentPath::from_blinded_path_and_payinfo(
7996+
nodes[2],
7997+
ln_test_utils::pubkey(43),
79947998
vec![
79957999
BlindedHop { blinded_node_id: ln_test_utils::pubkey(42 as u8), encrypted_payload: Vec::new() },
79968000
BlindedHop { blinded_node_id: ln_test_utils::pubkey(42 as u8), encrypted_payload: Vec::new() }

0 commit comments

Comments
 (0)