Skip to content

Commit a5d24da

Browse files
committed
Move send_probe_along_path
1 parent 585f8d8 commit a5d24da

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

lightning-invoice/src/payment.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -434,23 +434,6 @@ where
434434
.map_err(|e| { self.payment_cache.lock().unwrap().remove(&payment_hash); e })
435435
}
436436

437-
/// Sends a probe payment along the given path. The resulting payment will not be cached and
438-
/// resulting failures will be handled differently from regular payments.
439-
pub fn send_probe_along_path(
440-
&self, pubkey: PublicKey, hops: &[PublicKey], amount_msats: u64, final_cltv_expiry_delta: u32
441-
) -> Result<PaymentId, PaymentError> {
442-
let route_params = RouteParameters {
443-
payment_params: PaymentParameters::for_keysend(pubkey),
444-
final_value_msat: amount_msats,
445-
final_cltv_expiry_delta,
446-
};
447-
let payer = self.payer.node_id();
448-
let route = self.router.build_route_from_hops(&payer, hops, &route_params)
449-
.map_err(|e| PaymentError::Routing(e))?;
450-
451-
self.payer.send_probe_payment(&route).map_err(|e| PaymentError::Sending(e))
452-
}
453-
454437
fn pay_internal<F: FnOnce(&Route) -> Result<PaymentId, PaymentSendFailure> + Copy>(
455438
&self, params: &RouteParameters, payment_hash: PaymentHash, send_payment: F,
456439
) -> Result<PaymentId, PaymentError> {
@@ -565,6 +548,24 @@ where
565548
pub fn remove_cached_payment(&self, payment_hash: &PaymentHash) {
566549
self.payment_cache.lock().unwrap().remove(payment_hash);
567550
}
551+
552+
/// Sends a probe payment along the given path. The resulting payment will not be cached and
553+
/// resulting failures will be handled differently from regular payments.
554+
pub fn send_probe_along_path(
555+
&self, pubkey: PublicKey, hops: &[PublicKey], amount_msats: u64, final_cltv_expiry_delta: u32
556+
) -> Result<PaymentId, PaymentError> {
557+
let route_params = RouteParameters {
558+
payment_params: PaymentParameters::for_keysend(pubkey),
559+
final_value_msat: amount_msats,
560+
final_cltv_expiry_delta,
561+
};
562+
let payer = self.payer.node_id();
563+
let route = self.router.build_route_from_hops(&payer, hops, &route_params)
564+
.map_err(|e| PaymentError::Routing(e))?;
565+
566+
self.payer.send_probe_payment(&route).map_err(|e| PaymentError::Sending(e))
567+
}
568+
568569
}
569570

570571
fn expiry_time_from_unix_epoch(invoice: &Invoice) -> Duration {

0 commit comments

Comments
 (0)