lightning_types/routing.rs
1// This file is Copyright its original authors, visible in version control
2// history.
3//
4// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
5// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
7// You may not use this file except in accordance with one or both of these
8// licenses.
9
10//! Various types which describe routes or information about partial routes within the lightning
11//! network.
12
13use alloc::vec::Vec;
14
15use bitcoin::secp256k1::PublicKey;
16
17/// Fees for routing via a given channel or a node
18#[derive(Eq, PartialEq, Copy, Clone, Debug, Hash, Ord, PartialOrd)]
19pub struct RoutingFees {
20 /// Flat routing fee in millisatoshis.
21 pub base_msat: u32,
22 /// Liquidity-based routing fee in millionths of a routed amount.
23 /// In other words, 10000 is 1%.
24 pub proportional_millionths: u32,
25}
26
27/// A list of hops along a payment path terminating with a channel to the recipient.
28#[derive(Clone, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)]
29pub struct RouteHint(pub Vec<RouteHintHop>);
30
31/// A channel descriptor for a hop along a payment path.
32///
33/// While this generally comes from BOLT 11's `r` field, this struct includes more fields than are
34/// available in BOLT 11. Thus, encoding and decoding this via `lightning-invoice` is lossy, as
35/// fields not supported in BOLT 11 will be stripped.
36#[derive(Clone, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)]
37pub struct RouteHintHop {
38 /// The node_id of the non-target end of the route
39 pub src_node_id: PublicKey,
40 /// The short_channel_id of this channel
41 pub short_channel_id: u64,
42 /// The fees which must be paid to use this channel
43 pub fees: RoutingFees,
44 /// The difference in CLTV values between this node and the next node.
45 pub cltv_expiry_delta: u16,
46 /// The minimum value, in msat, which must be relayed to the next hop.
47 pub htlc_minimum_msat: Option<u64>,
48 /// The maximum value in msat available for routing with a single HTLC.
49 pub htlc_maximum_msat: Option<u64>,
50}