Skip to content

Commit 1e9cd51

Browse files
Parameterize send_probe with Path instead of Vec<RouteHop>
Just-in-time unblinded probing can happen as soon as a BOLT11 invoice is scanned. The same can't be same for blinded paths, which are provided after a round trip with the recipient, making JIT probing them less feasible. Nonetheless, we should support it.
1 parent 4aee13b commit 1e9cd51

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,10 +2764,10 @@ where
27642764
/// Send a payment that is probing the given route for liquidity. We calculate the
27652765
/// [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows
27662766
/// us to easily discern them from real payments.
2767-
pub fn send_probe(&self, hops: Vec<RouteHop>) -> Result<(PaymentHash, PaymentId), PaymentSendFailure> {
2767+
pub fn send_probe(&self, path: Path) -> Result<(PaymentHash, PaymentId), PaymentSendFailure> {
27682768
let best_block_height = self.best_block.read().unwrap().height();
27692769
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
2770-
self.pending_outbound_payments.send_probe(hops, self.probing_cookie_secret, &self.entropy_source, &self.node_signer, best_block_height,
2770+
self.pending_outbound_payments.send_probe(path, self.probing_cookie_secret, &self.entropy_source, &self.node_signer, best_block_height,
27712771
|path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
27722772
self.send_payment_along_path(path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv))
27732773
}

lightning/src/ln/outbound_payment.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::events;
1818
use crate::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
1919
use crate::ln::channelmanager::{ChannelDetails, HTLCSource, IDEMPOTENCY_TIMEOUT_TICKS, PaymentId};
2020
use crate::ln::onion_utils::HTLCFailReason;
21-
use crate::routing::router::{InFlightHtlcs, Path, PaymentParameters, Route, RouteHop, RouteParameters, Router};
21+
use crate::routing::router::{InFlightHtlcs, Path, PaymentParameters, Route, RouteParameters, Router};
2222
use crate::util::errors::APIError;
2323
use crate::util::logger::Logger;
2424
use crate::util::time::Time;
@@ -799,8 +799,8 @@ impl OutboundPayments {
799799
}
800800

801801
pub(super) fn send_probe<ES: Deref, NS: Deref, F>(
802-
&self, hops: Vec<RouteHop>, probing_cookie_secret: [u8; 32], entropy_source: &ES,
803-
node_signer: &NS, best_block_height: u32, send_payment_along_path: F
802+
&self, path: Path, probing_cookie_secret: [u8; 32], entropy_source: &ES, node_signer: &NS,
803+
best_block_height: u32, send_payment_along_path: F
804804
) -> Result<(PaymentHash, PaymentId), PaymentSendFailure>
805805
where
806806
ES::Target: EntropySource,
@@ -812,13 +812,13 @@ impl OutboundPayments {
812812

813813
let payment_hash = probing_cookie_from_id(&payment_id, probing_cookie_secret);
814814

815-
if hops.len() < 2 {
815+
if path.len() < 2 {
816816
return Err(PaymentSendFailure::ParameterError(APIError::APIMisuseError {
817817
err: "No need probing a path with less than two hops".to_string()
818818
}))
819819
}
820820

821-
let route = Route { paths: vec![Path { hops, blinded_tail: None }], payment_params: None };
821+
let route = Route { paths: vec![path], payment_params: None };
822822
let onion_session_privs = self.add_new_pending_payment(payment_hash, None, payment_id, None, &route, None, None, entropy_source, best_block_height)?;
823823

824824
match self.pay_route_internal(&route, payment_hash, &None, None, payment_id, None, onion_session_privs, node_signer, best_block_height, &send_payment_along_path) {

lightning/src/ln/payment_tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,12 +878,12 @@ fn sent_probe_is_probe_of_sending_node() {
878878

879879
// First check we refuse to build a single-hop probe
880880
let (route, _, _, _) = get_route_and_payment_hash!(&nodes[0], nodes[1], 100_000);
881-
assert!(nodes[0].node.send_probe(route.paths[0].hops.clone()).is_err());
881+
assert!(nodes[0].node.send_probe(route.paths[0].clone()).is_err());
882882

883883
// Then build an actual two-hop probing path
884884
let (route, _, _, _) = get_route_and_payment_hash!(&nodes[0], nodes[2], 100_000);
885885

886-
match nodes[0].node.send_probe(route.paths[0].hops.clone()) {
886+
match nodes[0].node.send_probe(route.paths[0].clone()) {
887887
Ok((payment_hash, payment_id)) => {
888888
assert!(nodes[0].node.payment_is_probe(&payment_hash, &payment_id));
889889
assert!(!nodes[1].node.payment_is_probe(&payment_hash, &payment_id));
@@ -908,7 +908,7 @@ fn successful_probe_yields_event() {
908908

909909
let (route, _, _, _) = get_route_and_payment_hash!(&nodes[0], nodes[2], 100_000);
910910

911-
let (payment_hash, payment_id) = nodes[0].node.send_probe(route.paths[0].hops.clone()).unwrap();
911+
let (payment_hash, payment_id) = nodes[0].node.send_probe(route.paths[0].clone()).unwrap();
912912

913913
// node[0] -- update_add_htlcs -> node[1]
914914
check_added_monitors!(nodes[0], 1);
@@ -965,7 +965,7 @@ fn failed_probe_yields_event() {
965965

966966
let (route, _, _, _) = get_route_and_payment_hash!(&nodes[0], nodes[2], &payment_params, 9_998_000, 42);
967967

968-
let (payment_hash, payment_id) = nodes[0].node.send_probe(route.paths[0].hops.clone()).unwrap();
968+
let (payment_hash, payment_id) = nodes[0].node.send_probe(route.paths[0].clone()).unwrap();
969969

970970
// node[0] -- update_add_htlcs -> node[1]
971971
check_added_monitors!(nodes[0], 1);
@@ -1013,7 +1013,7 @@ fn onchain_failed_probe_yields_event() {
10131013

10141014
// Send a dust HTLC, which will be treated as if it timed out once the channel hits the chain.
10151015
let (route, _, _, _) = get_route_and_payment_hash!(&nodes[0], nodes[2], &payment_params, 1_000, 42);
1016-
let (payment_hash, payment_id) = nodes[0].node.send_probe(route.paths[0].hops.clone()).unwrap();
1016+
let (payment_hash, payment_id) = nodes[0].node.send_probe(route.paths[0].clone()).unwrap();
10171017

10181018
// node[0] -- update_add_htlcs -> node[1]
10191019
check_added_monitors!(nodes[0], 1);

0 commit comments

Comments
 (0)