Trait Router

Source
pub trait Router {
    // Required methods
    fn find_route(
        &self,
        payer: &PublicKey,
        route_params: &RouteParameters,
        first_hops: Option<&[&ChannelDetails]>,
        inflight_htlcs: InFlightHtlcs,
    ) -> Result<Route, LightningError>;
    fn create_blinded_payment_paths<T: Signing + Verification>(
        &self,
        recipient: PublicKey,
        first_hops: Vec<ChannelDetails>,
        tlvs: ReceiveTlvs,
        amount_msats: u64,
        secp_ctx: &Secp256k1<T>,
    ) -> Result<Vec<BlindedPaymentPath>, ()>;

    // Provided method
    fn find_route_with_id(
        &self,
        payer: &PublicKey,
        route_params: &RouteParameters,
        first_hops: Option<&[&ChannelDetails]>,
        inflight_htlcs: InFlightHtlcs,
        _payment_hash: PaymentHash,
        _payment_id: PaymentId,
    ) -> Result<Route, LightningError> { ... }
}
Expand description

A trait defining behavior for routing a payment.

Required Methods§

Source

fn find_route( &self, payer: &PublicKey, route_params: &RouteParameters, first_hops: Option<&[&ChannelDetails]>, inflight_htlcs: InFlightHtlcs, ) -> Result<Route, LightningError>

Finds a Route for a payment between the given payer and a payee.

The payee and the payment’s value are given in RouteParameters::payment_params and RouteParameters::final_value_msat, respectively.

Source

fn create_blinded_payment_paths<T: Signing + Verification>( &self, recipient: PublicKey, first_hops: Vec<ChannelDetails>, tlvs: ReceiveTlvs, amount_msats: u64, secp_ctx: &Secp256k1<T>, ) -> Result<Vec<BlindedPaymentPath>, ()>

Creates BlindedPaymentPaths for payment to the recipient node. The channels in first_hops are assumed to be with the recipient’s peers. The payment secret and any constraints are given in tlvs.

Provided Methods§

Source

fn find_route_with_id( &self, payer: &PublicKey, route_params: &RouteParameters, first_hops: Option<&[&ChannelDetails]>, inflight_htlcs: InFlightHtlcs, _payment_hash: PaymentHash, _payment_id: PaymentId, ) -> Result<Route, LightningError>

Finds a Route for a payment between the given payer and a payee.

The payee and the payment’s value are given in RouteParameters::payment_params and RouteParameters::final_value_msat, respectively.

Includes a PaymentHash and a PaymentId to be able to correlate the request with a specific payment.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: Deref, S: Deref, SP: Sized, Sc: ScoreLookUp<ScoreParams = SP>> Router for DefaultRouter<G, L, ES, S, SP, Sc>
where L::Target: Logger, S::Target: for<'a> LockableScore<'a, ScoreLookUp = Sc>, ES::Target: EntropySource,