Skip to content

Commit 4524e2a

Browse files
invoice: rename Route to RouteHint (which is more accurate)
1 parent 6f7733b commit 4524e2a

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

lightning-invoice/src/de.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl FromBase32 for TaggedField {
430430
constants::TAG_FALLBACK =>
431431
Ok(TaggedField::Fallback(Fallback::from_base32(field_data)?)),
432432
constants::TAG_ROUTE =>
433-
Ok(TaggedField::Route(Route::from_base32(field_data)?)),
433+
Ok(TaggedField::Route(RouteHint::from_base32(field_data)?)),
434434
constants::TAG_PAYMENT_SECRET =>
435435
Ok(TaggedField::PaymentSecret(PaymentSecret::from_base32(field_data)?)),
436436
_ => {
@@ -567,10 +567,10 @@ impl FromBase32 for Fallback {
567567
}
568568
}
569569

570-
impl FromBase32 for Route {
570+
impl FromBase32 for RouteHint {
571571
type Err = ParseError;
572572

573-
fn from_base32(field_data: &[u5]) -> Result<Route, ParseError> {
573+
fn from_base32(field_data: &[u5]) -> Result<RouteHint, ParseError> {
574574
let bytes = Vec::<u8>::from_base32(field_data)?;
575575

576576
if bytes.len() % 51 != 0 {
@@ -602,7 +602,7 @@ impl FromBase32 for Route {
602602
route_hops.push(hop);
603603
}
604604

605-
Ok(Route(route_hops))
605+
Ok(RouteHint(route_hops))
606606
}
607607
}
608608

@@ -939,7 +939,7 @@ mod test {
939939
fn test_parse_route() {
940940
use lightning::routing::network_graph::RoutingFees;
941941
use lightning::routing::router::RouteHintHop;
942-
use ::Route;
942+
use ::RouteHint;
943943
use bech32::FromBase32;
944944

945945
let input = from_bech32(
@@ -983,10 +983,10 @@ mod test {
983983
htlc_maximum_msat: None
984984
});
985985

986-
assert_eq!(Route::from_base32(&input), Ok(Route(expected)));
986+
assert_eq!(RouteHint::from_base32(&input), Ok(RouteHint(expected)));
987987

988988
assert_eq!(
989-
Route::from_base32(&[u5::try_from_u8(0).unwrap(); 40][..]),
989+
RouteHint::from_base32(&[u5::try_from_u8(0).unwrap(); 40][..]),
990990
Err(ParseError::UnexpectedEndOfTaggedFields)
991991
);
992992
}

lightning-invoice/src/lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ pub enum TaggedField {
327327
ExpiryTime(ExpiryTime),
328328
MinFinalCltvExpiry(MinFinalCltvExpiry),
329329
Fallback(Fallback),
330-
Route(Route),
330+
Route(RouteHint),
331331
PaymentSecret(PaymentSecret),
332332
}
333333

@@ -387,7 +387,7 @@ pub struct Signature(pub RecoverableSignature);
387387
/// The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
388388
///
389389
#[derive(Eq, PartialEq, Debug, Clone)]
390-
pub struct Route(Vec<RouteHintHop>);
390+
pub struct RouteHint(Vec<RouteHintHop>);
391391

392392
/// Tag constants as specified in BOLT11
393393
#[allow(missing_docs)]
@@ -485,7 +485,7 @@ impl<D: tb::Bool, H: tb::Bool, T: tb::Bool> InvoiceBuilder<D, H, T> {
485485

486486
/// Adds a private route.
487487
pub fn route(mut self, route: Vec<RouteHintHop>) -> Self {
488-
match Route::new(route) {
488+
match RouteHint::new(route) {
489489
Ok(r) => self.tagged_fields.push(TaggedField::Route(r)),
490490
Err(e) => self.error = Some(e),
491491
}
@@ -817,11 +817,11 @@ impl RawInvoice {
817817
}).collect::<Vec<&Fallback>>()
818818
}
819819

820-
pub fn routes(&self) -> Vec<&Route> {
820+
pub fn routes(&self) -> Vec<&RouteHint> {
821821
self.known_tagged_fields().filter_map(|tf| match tf {
822822
&TaggedField::Route(ref r) => Some(r),
823823
_ => None,
824-
}).collect::<Vec<&Route>>()
824+
}).collect::<Vec<&RouteHint>>()
825825
}
826826

827827
pub fn amount_pico_btc(&self) -> Option<u64> {
@@ -1020,7 +1020,7 @@ impl Invoice {
10201020
}
10211021

10221022
/// Returns a list of all routes included in the invoice
1023-
pub fn routes(&self) -> Vec<&Route> {
1023+
pub fn routes(&self) -> Vec<&RouteHint> {
10241024
self.signed_invoice.routes()
10251025
}
10261026

@@ -1142,11 +1142,11 @@ impl ExpiryTime {
11421142
}
11431143
}
11441144

1145-
impl Route {
1145+
impl RouteHint {
11461146
/// Create a new (partial) route from a list of hops
1147-
pub fn new(hops: Vec<RouteHintHop>) -> Result<Route, CreationError> {
1147+
pub fn new(hops: Vec<RouteHintHop>) -> Result<RouteHint, CreationError> {
11481148
if hops.len() <= 12 {
1149-
Ok(Route(hops))
1149+
Ok(RouteHint(hops))
11501150
} else {
11511151
Err(CreationError::RouteTooLong)
11521152
}
@@ -1158,13 +1158,13 @@ impl Route {
11581158
}
11591159
}
11601160

1161-
impl Into<Vec<RouteHintHop>> for Route {
1161+
impl Into<Vec<RouteHintHop>> for RouteHint {
11621162
fn into(self) -> Vec<RouteHintHop> {
11631163
self.into_inner()
11641164
}
11651165
}
11661166

1167-
impl Deref for Route {
1167+
impl Deref for RouteHint {
11681168
type Target = Vec<RouteHintHop>;
11691169

11701170
fn deref(&self) -> &Vec<RouteHintHop> {
@@ -1573,7 +1573,7 @@ mod test {
15731573
assert_eq!(invoice.expiry_time(), Duration::from_secs(54321));
15741574
assert_eq!(invoice.min_final_cltv_expiry(), Some(&144));
15751575
assert_eq!(invoice.fallbacks(), vec![&Fallback::PubKeyHash([0;20])]);
1576-
assert_eq!(invoice.routes(), vec![&Route(route_1), &Route(route_2)]);
1576+
assert_eq!(invoice.routes(), vec![&RouteHint(route_1), &RouteHint(route_2)]);
15771577
assert_eq!(
15781578
invoice.description(),
15791579
InvoiceDescription::Hash(&Sha256(sha256::Hash::from_slice(&[3;32][..]).unwrap()))

lightning-invoice/src/ser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ impl Base32Len for Fallback {
365365
}
366366
}
367367

368-
impl ToBase32 for Route {
368+
impl ToBase32 for RouteHint {
369369
fn write_base32<W: WriteBase32>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err> {
370370
let mut converter = BytesToBase32::new(writer);
371371

@@ -401,7 +401,7 @@ impl ToBase32 for Route {
401401
}
402402
}
403403

404-
impl Base32Len for Route {
404+
impl Base32Len for RouteHint {
405405
fn base32_len(&self) -> usize {
406406
bytes_size_to_base32_size(self.0.len() * 51)
407407
}

0 commit comments

Comments
 (0)