Skip to content

Commit 8fcfaeb

Browse files
Test util: separate out code to construct a blinded path.
1 parent 32ab7a9 commit 8fcfaeb

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lightning/src/ln/blinded_payment_tests.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ use crate::ln::msgs::ChannelMessageHandler;
2121
use crate::ln::onion_utils;
2222
use crate::ln::onion_utils::INVALID_ONION_BLINDING;
2323
use crate::ln::outbound_payment::Retry;
24+
use crate::offers::invoice::BlindedPayInfo;
2425
use crate::prelude::*;
2526
use crate::routing::router::{Payee, PaymentParameters, RouteParameters};
2627
use crate::util::config::UserConfig;
2728
use crate::util::test_utils;
2829

29-
pub fn get_blinded_route_parameters(
30-
amt_msat: u64, payment_secret: PaymentSecret, node_ids: Vec<PublicKey>,
30+
fn blinded_payment_path(
31+
payment_secret: PaymentSecret, node_ids: Vec<PublicKey>,
3132
channel_upds: &[&msgs::UnsignedChannelUpdate], keys_manager: &test_utils::TestKeysInterface
32-
) -> RouteParameters {
33+
) -> (BlindedPayInfo, BlindedPath) {
3334
let mut intermediate_nodes = Vec::new();
3435
for (node_id, chan_upd) in node_ids.iter().zip(channel_upds) {
3536
intermediate_nodes.push(ForwardNode {
@@ -58,13 +59,20 @@ pub fn get_blinded_route_parameters(
5859
},
5960
};
6061
let mut secp_ctx = Secp256k1::new();
61-
let blinded_path = BlindedPath::new_for_payment(
62+
BlindedPath::new_for_payment(
6263
&intermediate_nodes[..], *node_ids.last().unwrap(), payee_tlvs,
6364
channel_upds.last().unwrap().htlc_maximum_msat, keys_manager, &secp_ctx
64-
).unwrap();
65+
).unwrap()
66+
}
6567

68+
pub fn get_blinded_route_parameters(
69+
amt_msat: u64, payment_secret: PaymentSecret, node_ids: Vec<PublicKey>,
70+
channel_upds: &[&msgs::UnsignedChannelUpdate], keys_manager: &test_utils::TestKeysInterface
71+
) -> RouteParameters {
6672
RouteParameters::from_payment_params_and_value(
67-
PaymentParameters::blinded(vec![blinded_path]), amt_msat
73+
PaymentParameters::blinded(vec![
74+
blinded_payment_path(payment_secret, node_ids, channel_upds, keys_manager)
75+
]), amt_msat
6876
)
6977
}
7078

0 commit comments

Comments
 (0)