use util::ser::{Writeable, Readable};
use util::logger::Logger;
+use io;
use prelude::*;
use alloc::collections::BinaryHeap;
use core::cmp;
const MIN_SERIALIZATION_VERSION: u8 = 1;
impl Writeable for Route {
- fn write<W: ::util::ser::Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
+ fn write<W: ::util::ser::Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
write_ver_prefix!(writer, SERIALIZATION_VERSION, MIN_SERIALIZATION_VERSION);
(self.paths.len() as u64).write(writer)?;
for hops in self.paths.iter() {
}
impl Readable for Route {
- fn read<R: ::std::io::Read>(reader: &mut R) -> Result<Route, DecodeError> {
+ fn read<R: io::Read>(reader: &mut R) -> Result<Route, DecodeError> {
let _ver = read_ver_prefix!(reader, SERIALIZATION_VERSION);
let path_count: u64 = Readable::read(reader)?;
let mut paths = Vec::with_capacity(cmp::min(path_count, 128) as usize);
}
}
+/// Gets a keysend route from us (payer) to the given target node (payee). This is needed because
+/// keysend payments do not have an invoice from which to pull the payee's supported features, which
+/// makes it tricky to otherwise supply the `payee_features` parameter of `get_route`.
+pub fn get_keysend_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, payee:
+ &PublicKey, first_hops: Option<&[&ChannelDetails]>, last_hops: &[&RouteHint],
+ final_value_msat: u64, final_cltv: u32, logger: L) -> Result<Route,
+ LightningError> where L::Target: Logger {
+ let invoice_features = InvoiceFeatures::for_keysend();
+ get_route(our_node_id, network, payee, Some(invoice_features), first_hops, last_hops,
+ final_value_msat, final_cltv, logger)
+}
+
/// Gets a route from us (payer) to the given target node (payee).
///
/// If the payee provided features in their invoice, they should be provided via payee_features.
}
}
- #[cfg(not(feature = "no_std"))]
+ #[cfg(not(feature = "no-std"))]
pub(super) fn random_init_seed() -> u64 {
// Because the default HashMap in std pulls OS randomness, we can use it as a (bad) RNG.
use core::hash::{BuildHasher, Hasher};
println!("Using seed of {}", seed);
seed
}
- #[cfg(not(feature = "no_std"))]
+ #[cfg(not(feature = "no-std"))]
use util::ser::Readable;
#[test]
- #[cfg(not(feature = "no_std"))]
+ #[cfg(not(feature = "no-std"))]
fn generate_routes() {
let mut d = match super::test_utils::get_route_file() {
Ok(f) => f,
}
#[test]
- #[cfg(not(feature = "no_std"))]
+ #[cfg(not(feature = "no-std"))]
fn generate_routes_mpp() {
let mut d = match super::test_utils::get_route_file() {
Ok(f) => f,
}
}
-#[cfg(all(test, not(feature = "no_std")))]
+#[cfg(all(test, not(feature = "no-std")))]
pub(crate) mod test_utils {
use std::fs::File;
/// Tries to open a network graph file, or panics with a URL to fetch it.
}
}
-#[cfg(all(test, feature = "unstable", not(feature = "no_std")))]
+#[cfg(all(test, feature = "unstable", not(feature = "no-std")))]
mod benches {
use super::*;
use util::logger::{Logger, Record};