constants::TAG_FALLBACK =>
Ok(TaggedField::Fallback(Fallback::from_base32(field_data)?)),
constants::TAG_ROUTE =>
- Ok(TaggedField::Route(Route::from_base32(field_data)?)),
+ Ok(TaggedField::Route(RouteHint::from_base32(field_data)?)),
constants::TAG_PAYMENT_SECRET =>
Ok(TaggedField::PaymentSecret(PaymentSecret::from_base32(field_data)?)),
_ => {
}
}
-impl FromBase32 for Route {
+impl FromBase32 for RouteHint {
type Err = ParseError;
- fn from_base32(field_data: &[u5]) -> Result<Route, ParseError> {
+ fn from_base32(field_data: &[u5]) -> Result<RouteHint, ParseError> {
let bytes = Vec::<u8>::from_base32(field_data)?;
if bytes.len() % 51 != 0 {
route_hops.push(hop);
}
- Ok(Route(route_hops))
+ Ok(RouteHint(route_hops))
}
}
fn test_parse_route() {
use lightning::routing::network_graph::RoutingFees;
use lightning::routing::router::RouteHintHop;
- use ::Route;
+ use ::RouteHint;
use bech32::FromBase32;
use de::parse_int_be;
htlc_maximum_msat: None
});
- assert_eq!(Route::from_base32(&input), Ok(Route(expected)));
+ assert_eq!(RouteHint::from_base32(&input), Ok(RouteHint(expected)));
assert_eq!(
- Route::from_base32(&[u5::try_from_u8(0).unwrap(); 40][..]),
+ RouteHint::from_base32(&[u5::try_from_u8(0).unwrap(); 40][..]),
Err(ParseError::UnexpectedEndOfTaggedFields)
);
}
ExpiryTime(ExpiryTime),
MinFinalCltvExpiry(MinFinalCltvExpiry),
Fallback(Fallback),
- Route(Route),
+ Route(RouteHint),
PaymentSecret(PaymentSecret),
}
/// The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
///
#[derive(Eq, PartialEq, Debug, Clone)]
-pub struct Route(Vec<RouteHintHop>);
+pub struct RouteHint(Vec<RouteHintHop>);
/// Tag constants as specified in BOLT11
#[allow(missing_docs)]
/// Adds a private route.
pub fn route(mut self, route: Vec<RouteHintHop>) -> Self {
- match Route::new(route) {
+ match RouteHint::new(route) {
Ok(r) => self.tagged_fields.push(TaggedField::Route(r)),
Err(e) => self.error = Some(e),
}
}).collect::<Vec<&Fallback>>()
}
- pub fn routes(&self) -> Vec<&Route> {
+ pub fn routes(&self) -> Vec<&RouteHint> {
self.known_tagged_fields().filter_map(|tf| match tf {
&TaggedField::Route(ref r) => Some(r),
_ => None,
- }).collect::<Vec<&Route>>()
+ }).collect::<Vec<&RouteHint>>()
}
pub fn amount_pico_btc(&self) -> Option<u64> {
}
/// Returns a list of all routes included in the invoice
- pub fn routes(&self) -> Vec<&Route> {
+ pub fn routes(&self) -> Vec<&RouteHint> {
self.signed_invoice.routes()
}
}
}
-impl Route {
+impl RouteHint {
/// Create a new (partial) route from a list of hops
- pub fn new(hops: Vec<RouteHintHop>) -> Result<Route, CreationError> {
+ pub fn new(hops: Vec<RouteHintHop>) -> Result<RouteHint, CreationError> {
if hops.len() <= 12 {
- Ok(Route(hops))
+ Ok(RouteHint(hops))
} else {
Err(CreationError::RouteTooLong)
}
}
}
-impl Into<Vec<RouteHintHop>> for Route {
+impl Into<Vec<RouteHintHop>> for RouteHint {
fn into(self) -> Vec<RouteHintHop> {
self.into_inner()
}
}
-impl Deref for Route {
+impl Deref for RouteHint {
type Target = Vec<RouteHintHop>;
fn deref(&self) -> &Vec<RouteHintHop> {
assert_eq!(invoice.expiry_time(), Duration::from_secs(54321));
assert_eq!(invoice.min_final_cltv_expiry(), Some(&144));
assert_eq!(invoice.fallbacks(), vec![&Fallback::PubKeyHash([0;20])]);
- assert_eq!(invoice.routes(), vec![&Route(route_1), &Route(route_2)]);
+ assert_eq!(invoice.routes(), vec![&RouteHint(route_1), &RouteHint(route_2)]);
assert_eq!(
invoice.description(),
InvoiceDescription::Hash(&Sha256(sha256::Hash::from_slice(&[3;32][..]).unwrap()))