use lightning::ln::channelmanager::ChannelDetails;
use lightning::ln::features::InitFeatures;
use lightning::ln::msgs;
-use lightning::routing::router::{get_route, RouteHint};
+use lightning::routing::router::{get_route, RouteHintHop};
use lightning::util::logger::Logger;
use lightning::util::ser::Readable;
use lightning::routing::network_graph::{NetworkGraph, RoutingFees};
for _ in 0..count {
scid += 1;
let rnid = node_pks.iter().skip(slice_to_be16(get_slice!(2))as usize % node_pks.len()).next().unwrap();
- last_hops_vec.push(RouteHint {
+ last_hops_vec.push(RouteHintHop {
src_node_id: *rnid,
short_channel_id: scid,
fees: RoutingFees {
use bitcoin_hashes::Hash;
use bitcoin_hashes::sha256;
use lightning::routing::network_graph::RoutingFees;
-use lightning::routing::router::RouteHint;
+use lightning::routing::router::RouteHintHop;
use num_traits::{CheckedAdd, CheckedMul};
return Err(ParseError::UnexpectedEndOfTaggedFields);
}
- let mut route_hops = Vec::<RouteHint>::new();
+ let mut route_hops = Vec::<RouteHintHop>::new();
let mut bytes = bytes.as_slice();
while !bytes.is_empty() {
let mut channel_id: [u8; 8] = Default::default();
channel_id.copy_from_slice(&hop_bytes[33..41]);
- let hop = RouteHint {
+ let hop = RouteHintHop {
src_node_id: PublicKey::from_slice(&hop_bytes[0..33])?,
short_channel_id: parse_int_be(&channel_id, 256).expect("short chan ID slice too big?"),
fees: RoutingFees {
#[test]
fn test_parse_route() {
use lightning::routing::network_graph::RoutingFees;
- use lightning::routing::router::RouteHint;
+ use lightning::routing::router::RouteHintHop;
use ::Route;
use bech32::FromBase32;
use de::parse_int_be;
fqxu92d8lr6fvg0r5gv0heeeqgcrqlnm6jhphu9y00rrhy4grqszsvpcgpy9qqqqqqgqqqqq7qqzq".as_bytes()
);
- let mut expected = Vec::<RouteHint>::new();
- expected.push(RouteHint {
+ let mut expected = Vec::<RouteHintHop>::new();
+ expected.push(RouteHintHop {
src_node_id: PublicKey::from_slice(
&[
0x02u8, 0x9e, 0x03, 0xa9, 0x01, 0xb8, 0x55, 0x34, 0xff, 0x1e, 0x92, 0xc4, 0x3c,
htlc_minimum_msat: None,
htlc_maximum_msat: None
});
- expected.push(RouteHint {
+ expected.push(RouteHintHop {
src_node_id: PublicKey::from_slice(
&[
0x03u8, 0x9e, 0x03, 0xa9, 0x01, 0xb8, 0x55, 0x34, 0xff, 0x1e, 0x92, 0xc4, 0x3c,
use bitcoin_hashes::sha256;
#[cfg(any(doc, test))]
use lightning::routing::network_graph::RoutingFees;
-use lightning::routing::router::RouteHint;
+use lightning::routing::router::RouteHintHop;
use secp256k1::key::PublicKey;
use secp256k1::{Message, Secp256k1};
/// The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
///
#[derive(Eq, PartialEq, Debug, Clone)]
-pub struct Route(Vec<RouteHint>);
+pub struct Route(Vec<RouteHintHop>);
/// Tag constants as specified in BOLT11
#[allow(missing_docs)]
}
/// Adds a private route.
- pub fn route(mut self, route: Vec<RouteHint>) -> Self {
+ pub fn route(mut self, route: Vec<RouteHintHop>) -> Self {
match Route::new(route) {
Ok(r) => self.tagged_fields.push(TaggedField::Route(r)),
Err(e) => self.error = Some(e),
impl Route {
/// Create a new (partial) route from a list of hops
- pub fn new(hops: Vec<RouteHint>) -> Result<Route, CreationError> {
+ pub fn new(hops: Vec<RouteHintHop>) -> Result<Route, CreationError> {
if hops.len() <= 12 {
Ok(Route(hops))
} else {
}
/// Returrn the underlying vector of hops
- pub fn into_inner(self) -> Vec<RouteHint> {
+ pub fn into_inner(self) -> Vec<RouteHintHop> {
self.0
}
}
-impl Into<Vec<RouteHint>> for Route {
- fn into(self) -> Vec<RouteHint> {
+impl Into<Vec<RouteHintHop>> for Route {
+ fn into(self) -> Vec<RouteHintHop> {
self.into_inner()
}
}
impl Deref for Route {
- type Target = Vec<RouteHint>;
+ type Target = Vec<RouteHintHop>;
- fn deref(&self) -> &Vec<RouteHint> {
+ fn deref(&self) -> &Vec<RouteHintHop> {
&self.0
}
}
.build_raw();
assert_eq!(long_desc_res, Err(CreationError::DescriptionTooLong));
- let route_hop = RouteHint {
+ let route_hop = RouteHintHop {
src_node_id: PublicKey::from_slice(
&[
0x03, 0x9e, 0x03, 0xa9, 0x01, 0xb8, 0x55, 0x34, 0xff, 0x1e, 0x92, 0xc4,
let public_key = PublicKey::from_secret_key(&secp_ctx, &private_key);
let route_1 = vec![
- RouteHint {
+ RouteHintHop {
src_node_id: public_key.clone(),
short_channel_id: de::parse_int_be(&[123; 8], 256).expect("short chan ID slice too big?"),
fees: RoutingFees {
htlc_minimum_msat: None,
htlc_maximum_msat: None,
},
- RouteHint {
+ RouteHintHop {
src_node_id: public_key.clone(),
short_channel_id: de::parse_int_be(&[42; 8], 256).expect("short chan ID slice too big?"),
fees: RoutingFees {
];
let route_2 = vec![
- RouteHint {
+ RouteHintHop {
src_node_id: public_key.clone(),
short_channel_id: 0,
fees: RoutingFees {
htlc_minimum_msat: None,
htlc_maximum_msat: None,
},
- RouteHint {
+ RouteHintHop {
src_node_id: public_key.clone(),
short_channel_id: de::parse_int_be(&[1; 8], 256).expect("short chan ID slice too big?"),
fees: RoutingFees {
/// A channel descriptor which provides a last-hop route to get_route
#[derive(Eq, PartialEq, Debug, Clone)]
-pub struct RouteHint {
+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
/// These fee values are useful to choose hops as we traverse the graph "payee-to-payer".
#[derive(Clone)]
struct PathBuildingHop<'a> {
- // The RouteHint fields which will eventually be used if this hop is used in a final Route.
+ // The RouteHintHop fields which will eventually be used if this hop is used in a final Route.
// Note that node_features is calculated separately after our initial graph walk.
pubkey: PublicKey,
short_channel_id: u64,
/// equal), however the enabled/disabled bit on such channels as well as the
/// htlc_minimum_msat/htlc_maximum_msat *are* checked as they may change based on the receiving node.
pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, payee: &PublicKey, payee_features: Option<InvoiceFeatures>, first_hops: Option<&[&ChannelDetails]>,
- last_hops: &[&RouteHint], final_value_msat: u64, final_cltv: u32, logger: L) -> Result<Route, LightningError> where L::Target: Logger {
+ last_hops: &[&RouteHintHop], final_value_msat: u64, final_cltv: u32, logger: L) -> Result<Route, LightningError> where L::Target: Logger {
// TODO: Obviously *only* using total fee cost sucks. We should consider weighting by
// uptime/success in using a node in the past.
if *payee == *our_node_id {
#[cfg(test)]
mod tests {
- use routing::router::{get_route, RouteHint, RoutingFees};
+ use routing::router::{get_route, RouteHintHop, RoutingFees};
use routing::network_graph::{NetworkGraph, NetGraphMsgHandler};
use ln::features::{ChannelFeatures, InitFeatures, InvoiceFeatures, NodeFeatures};
use ln::msgs::{ErrorAction, LightningError, OptionalField, UnsignedChannelAnnouncement, ChannelAnnouncement, RoutingMessageHandler,
assert_eq!(route.paths[0][1].channel_features.le_flags(), &id_to_feature_flags(13));
}
- fn last_hops(nodes: &Vec<PublicKey>) -> Vec<RouteHint> {
+ fn last_hops(nodes: &Vec<PublicKey>) -> Vec<RouteHintHop> {
let zero_fees = RoutingFees {
base_msat: 0,
proportional_millionths: 0,
};
- vec!(RouteHint {
+ vec!(RouteHintHop {
src_node_id: nodes[3].clone(),
short_channel_id: 8,
fees: zero_fees,
cltv_expiry_delta: (8 << 8) | 1,
htlc_minimum_msat: None,
htlc_maximum_msat: None,
- }, RouteHint {
+ }, RouteHintHop {
src_node_id: nodes[4].clone(),
short_channel_id: 9,
fees: RoutingFees {
cltv_expiry_delta: (9 << 8) | 1,
htlc_minimum_msat: None,
htlc_maximum_msat: None,
- }, RouteHint {
+ }, RouteHintHop {
src_node_id: nodes[5].clone(),
short_channel_id: 10,
fees: zero_fees,
// Simple test across 2, 3, 5, and 4 via a last_hop channel
// First check that lst hop can't have its source as the payee.
- let invalid_last_hop = RouteHint {
+ let invalid_last_hop = RouteHintHop {
src_node_id: nodes[6],
short_channel_id: 8,
fees: RoutingFees {
let target_node_id = PublicKey::from_secret_key(&Secp256k1::new(), &SecretKey::from_slice(&hex::decode(format!("{:02}", 43).repeat(32)).unwrap()[..]).unwrap());
// If we specify a channel to a middle hop, that overrides our local channel view and that gets used
- let last_hops = vec![RouteHint {
+ let last_hops = vec![RouteHintHop {
src_node_id: middle_node_id,
short_channel_id: 8,
fees: RoutingFees {