@@ -82,13 +82,21 @@ impl< G: Deref<Target = NetworkGraph<L>>, L: Deref, S: Deref, SP: Sized, Sc: Sco
82
82
83
83
/// A trait defining behavior for routing a payment.
84
84
pub trait Router {
85
- /// Finds a [`Route`] between `payer` and `payee` for a payment with the given values.
85
+ /// Finds a [`Route`] for a payment between the given `payer` and a payee.
86
+ ///
87
+ /// The `payee` and the payment's value are given in [`RouteParameters::payment_params`]
88
+ /// and [`RouteParameters::final_value_msat`], respectively.
86
89
fn find_route (
87
90
& self , payer : & PublicKey , route_params : & RouteParameters ,
88
91
first_hops : Option < & [ & ChannelDetails ] > , inflight_htlcs : InFlightHtlcs
89
92
) -> Result < Route , LightningError > ;
90
- /// Finds a [`Route`] between `payer` and `payee` for a payment with the given values. Includes
91
- /// `PaymentHash` and `PaymentId` to be able to correlate the request with a specific payment.
93
+ /// Finds a [`Route`] for a payment between the given `payer` and a payee.
94
+ ///
95
+ /// The `payee` and the payment's value are given in [`RouteParameters::payment_params`]
96
+ /// and [`RouteParameters::final_value_msat`], respectively.
97
+ ///
98
+ /// Includes a [`PaymentHash`] and a [`PaymentId`] to be able to correlate the request with a specific
99
+ /// payment.
92
100
fn find_route_with_id (
93
101
& self , payer : & PublicKey , route_params : & RouteParameters ,
94
102
first_hops : Option < & [ & ChannelDetails ] > , inflight_htlcs : InFlightHtlcs ,
@@ -346,19 +354,17 @@ pub struct Route {
346
354
/// [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be
347
355
/// the same.
348
356
pub paths : Vec < Path > ,
349
- /// The `payment_params` parameter passed to [`find_route`].
350
- /// This is used by `ChannelManager` to track information which may be required for retries,
351
- /// provided back to you via [`Event::PaymentPathFailed`].
357
+ /// The `payment_params` parameter passed via [`RouteParameters`] to [`find_route`].
352
358
///
353
- /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
359
+ /// This is used by `ChannelManager` to track information which may be required for retries.
354
360
pub payment_params : Option < PaymentParameters > ,
355
361
}
356
362
357
363
impl Route {
358
364
/// Returns the total amount of fees paid on this [`Route`].
359
365
///
360
366
/// This doesn't include any extra payment made to the recipient, which can happen in excess of
361
- /// the amount passed to [`find_route`]'s `params .final_value_msat`.
367
+ /// the amount passed to [`find_route`]'s `route_params .final_value_msat`.
362
368
pub fn get_total_fees ( & self ) -> u64 {
363
369
self . paths . iter ( ) . map ( |path| path. fee_msat ( ) ) . sum ( )
364
370
}
@@ -436,10 +442,7 @@ impl Readable for Route {
436
442
437
443
/// Parameters needed to find a [`Route`].
438
444
///
439
- /// Passed to [`find_route`] and [`build_route_from_hops`], but also provided in
440
- /// [`Event::PaymentPathFailed`].
441
- ///
442
- /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
445
+ /// Passed to [`find_route`] and [`build_route_from_hops`].
443
446
#[ derive( Clone , Debug , PartialEq , Eq ) ]
444
447
pub struct RouteParameters {
445
448
/// The parameters of the failed payment path.
@@ -1375,10 +1378,12 @@ fn sort_first_hop_channels(
1375
1378
1376
1379
/// Finds a route from us (payer) to the given target node (payee).
1377
1380
///
1378
- /// If the payee provided features in their invoice, they should be provided via `params.payee`.
1381
+ /// If the payee provided features in their invoice, they should be provided via the `payee` field
1382
+ /// in the given [`RouteParameters::payment_params`].
1379
1383
/// Without this, MPP will only be used if the payee's features are available in the network graph.
1380
1384
///
1381
- /// Private routing paths between a public node and the target may be included in `params.payee`.
1385
+ /// Private routing paths between a public node and the target may be included in the `payee` field
1386
+ /// of [`RouteParameters::payment_params`].
1382
1387
///
1383
1388
/// If some channels aren't announced, it may be useful to fill in `first_hops` with the results
1384
1389
/// from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels
@@ -1388,15 +1393,9 @@ fn sort_first_hop_channels(
1388
1393
/// However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
1389
1394
/// `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
1390
1395
///
1391
- /// # Note
1392
- ///
1393
- /// May be used to re-compute a [`Route`] when handling a [`Event::PaymentPathFailed`]. Any
1394
- /// adjustments to the [`NetworkGraph`] and channel scores should be made prior to calling this
1395
- /// function.
1396
- ///
1397
1396
/// # Panics
1398
1397
///
1399
- /// Panics if first_hops contains channels without short_channel_ids ;
1398
+ /// Panics if first_hops contains channels without `short_channel_id`s ;
1400
1399
/// [`ChannelManager::list_usable_channels`] will never include such channels.
1401
1400
///
1402
1401
/// [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
0 commit comments