From 8fcfaeb8d5348b739d861655942e8a4fc4764c55 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Tue, 9 Jan 2024 11:53:51 -0500 Subject: [PATCH] Test util: separate out code to construct a blinded path. --- lightning/src/ln/blinded_payment_tests.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lightning/src/ln/blinded_payment_tests.rs b/lightning/src/ln/blinded_payment_tests.rs index 9b580d1f..22fe1b1a 100644 --- a/lightning/src/ln/blinded_payment_tests.rs +++ b/lightning/src/ln/blinded_payment_tests.rs @@ -21,15 +21,16 @@ use crate::ln::msgs::ChannelMessageHandler; use crate::ln::onion_utils; use crate::ln::onion_utils::INVALID_ONION_BLINDING; use crate::ln::outbound_payment::Retry; +use crate::offers::invoice::BlindedPayInfo; use crate::prelude::*; use crate::routing::router::{Payee, PaymentParameters, RouteParameters}; use crate::util::config::UserConfig; use crate::util::test_utils; -pub fn get_blinded_route_parameters( - amt_msat: u64, payment_secret: PaymentSecret, node_ids: Vec, +fn blinded_payment_path( + payment_secret: PaymentSecret, node_ids: Vec, channel_upds: &[&msgs::UnsignedChannelUpdate], keys_manager: &test_utils::TestKeysInterface -) -> RouteParameters { +) -> (BlindedPayInfo, BlindedPath) { let mut intermediate_nodes = Vec::new(); for (node_id, chan_upd) in node_ids.iter().zip(channel_upds) { intermediate_nodes.push(ForwardNode { @@ -58,13 +59,20 @@ pub fn get_blinded_route_parameters( }, }; let mut secp_ctx = Secp256k1::new(); - let blinded_path = BlindedPath::new_for_payment( + BlindedPath::new_for_payment( &intermediate_nodes[..], *node_ids.last().unwrap(), payee_tlvs, channel_upds.last().unwrap().htlc_maximum_msat, keys_manager, &secp_ctx - ).unwrap(); + ).unwrap() +} +pub fn get_blinded_route_parameters( + amt_msat: u64, payment_secret: PaymentSecret, node_ids: Vec, + channel_upds: &[&msgs::UnsignedChannelUpdate], keys_manager: &test_utils::TestKeysInterface +) -> RouteParameters { RouteParameters::from_payment_params_and_value( - PaymentParameters::blinded(vec![blinded_path]), amt_msat + PaymentParameters::blinded(vec![ + blinded_payment_path(payment_secret, node_ids, channel_upds, keys_manager) + ]), amt_msat ) } -- 2.30.2