extern crate core;
pub mod payment;
+pub mod routing;
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+//! Various types which describe routes or information about partial routes within the lightning
+//! network.
+
+use alloc::vec::Vec;
+
+use bitcoin::secp256k1::PublicKey;
+
+/// Fees for routing via a given channel or a node
+#[derive(Eq, PartialEq, Copy, Clone, Debug, Hash, Ord, PartialOrd)]
+pub struct RoutingFees {
+ /// Flat routing fee in millisatoshis.
+ pub base_msat: u32,
+ /// Liquidity-based routing fee in millionths of a routed amount.
+ /// In other words, 10000 is 1%.
+ pub proportional_millionths: u32,
+}
+
+/// A list of hops along a payment path terminating with a channel to the recipient.
+#[derive(Clone, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)]
+pub struct RouteHint(pub Vec<RouteHintHop>);
+
+/// A channel descriptor for a hop along a payment path.
+///
+/// While this generally comes from BOLT 11's `r` field, this struct includes more fields than are
+/// available in BOLT 11. Thus, encoding and decoding this via `lightning-invoice` is lossy, as
+/// fields not supported in BOLT 11 will be stripped.
+#[derive(Clone, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)]
+pub struct RouteHintHop {
+ /// The node_id of the non-target end of the route
+ pub src_node_id: PublicKey,
+ /// The short_channel_id of this channel
+ pub short_channel_id: u64,
+ /// The fees which must be paid to use this channel
+ pub fees: RoutingFees,
+ /// The difference in CLTV values between this node and the next node.
+ pub cltv_expiry_delta: u16,
+ /// The minimum value, in msat, which must be relayed to the next hop.
+ pub htlc_minimum_msat: Option<u64>,
+ /// The maximum value in msat available for routing with a single HTLC.
+ pub htlc_maximum_msat: Option<u64>,
+}
use core::sync::atomic::{AtomicUsize, Ordering};
use core::{cmp, fmt};
+pub use lightning_types::routing::RoutingFees;
+
#[cfg(feature = "std")]
use std::time::{SystemTime, UNIX_EPOCH};
}
}
-/// Fees for routing via a given channel or a node
-#[derive(Eq, PartialEq, Copy, Clone, Debug, Hash, Ord, PartialOrd)]
-pub struct RoutingFees {
- /// Flat routing fee in millisatoshis.
- pub base_msat: u32,
- /// Liquidity-based routing fee in millionths of a routed amount.
- /// In other words, 10000 is 1%.
- pub proportional_millionths: u32,
-}
-
impl_writeable_tlv_based!(RoutingFees, {
(0, base_msat, required),
(2, proportional_millionths, required)
use crate::ln::onion_utils;
use crate::offers::invoice::{BlindedPayInfo, Bolt12Invoice};
use crate::onion_message::messenger::{DefaultMessageRouter, Destination, MessageRouter, OnionMessagePath};
-use crate::routing::gossip::{DirectedChannelInfo, EffectiveCapacity, ReadOnlyNetworkGraph, NetworkGraph, NodeId, RoutingFees};
+use crate::routing::gossip::{DirectedChannelInfo, EffectiveCapacity, ReadOnlyNetworkGraph, NetworkGraph, NodeId};
use crate::routing::scoring::{ChannelUsage, LockableScore, ScoreLookUp};
use crate::sign::EntropySource;
use crate::util::ser::{Writeable, Readable, ReadableArgs, Writer};
use core::{cmp, fmt};
use core::ops::Deref;
+use lightning_types::routing::RoutingFees;
+
+pub use lightning_types::routing::{RouteHint, RouteHintHop};
+
/// A [`Router`] implemented using [`find_route`].
///
/// # Privacy
}
}
-/// A list of hops along a payment path terminating with a channel to the recipient.
-#[derive(Clone, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)]
-pub struct RouteHint(pub Vec<RouteHintHop>);
-
impl Writeable for RouteHint {
fn write<W: crate::util::ser::Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
(self.0.len() as u64).write(writer)?;
}
}
-/// A channel descriptor for a hop along a payment path.
-///
-/// While this generally comes from BOLT 11's `r` field, this struct includes more fields than are
-/// available in BOLT 11. Thus, encoding and decoding this via `lightning-invoice` is lossy, as
-/// fields not supported in BOLT 11 will be stripped.
-#[derive(Clone, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)]
-pub struct RouteHintHop {
- /// The node_id of the non-target end of the route
- pub src_node_id: PublicKey,
- /// The short_channel_id of this channel
- pub short_channel_id: u64,
- /// The fees which must be paid to use this channel
- pub fees: RoutingFees,
- /// The difference in CLTV values between this node and the next node.
- pub cltv_expiry_delta: u16,
- /// The minimum value, in msat, which must be relayed to the next hop.
- pub htlc_minimum_msat: Option<u64>,
- /// The maximum value in msat available for routing with a single HTLC.
- pub htlc_maximum_msat: Option<u64>,
-}
-
impl_writeable_tlv_based!(RouteHintHop, {
(0, src_node_id, required),
(1, htlc_minimum_msat, option),