]> git.bitcoin.ninja Git - rust-lightning/commitdiff
invoice: rename Route to RouteHint (which is more accurate)
authorValentine Wallace <vwallace@protonmail.com>
Mon, 19 Apr 2021 22:22:21 +0000 (18:22 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Tue, 20 Apr 2021 20:26:56 +0000 (16:26 -0400)
lightning-invoice/src/de.rs
lightning-invoice/src/lib.rs
lightning-invoice/src/ser.rs

index 17bbaf44d8f399cf1bce2dd7a362538451bf77fa..fe77a93a99b03f9707563f56ea556c56d5ac7c76 100644 (file)
@@ -430,7 +430,7 @@ impl FromBase32 for TaggedField {
                        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)?)),
                        _ => {
@@ -567,10 +567,10 @@ impl FromBase32 for Fallback {
        }
 }
 
-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 {
@@ -602,7 +602,7 @@ impl FromBase32 for Route {
                        route_hops.push(hop);
                }
 
-               Ok(Route(route_hops))
+               Ok(RouteHint(route_hops))
        }
 }
 
@@ -939,7 +939,7 @@ mod test {
        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;
 
@@ -984,10 +984,10 @@ mod test {
                        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)
                );
        }
index cdb293d1f1f6e41e3d1c9f20f88e95e2d597fbed..2ce022248d0ad2479247bb4b9e2d29ff7d0451ca 100644 (file)
@@ -327,7 +327,7 @@ pub enum TaggedField {
        ExpiryTime(ExpiryTime),
        MinFinalCltvExpiry(MinFinalCltvExpiry),
        Fallback(Fallback),
-       Route(Route),
+       Route(RouteHint),
        PaymentSecret(PaymentSecret),
 }
 
@@ -387,7 +387,7 @@ pub struct Signature(pub RecoverableSignature);
 /// 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)]
@@ -485,7 +485,7 @@ impl<D: tb::Bool, H: tb::Bool, T: tb::Bool> InvoiceBuilder<D, H, T> {
 
        /// 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),
                }
@@ -817,11 +817,11 @@ impl RawInvoice {
                }).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> {
@@ -1020,7 +1020,7 @@ impl Invoice {
        }
 
        /// 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()
        }
 
@@ -1142,11 +1142,11 @@ impl ExpiryTime {
        }
 }
 
-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)
                }
@@ -1158,13 +1158,13 @@ impl Route {
        }
 }
 
-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> {
@@ -1573,7 +1573,7 @@ mod test {
                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()))
index 68fbfcf127acdff376b2210c97a04579d47061e0..83888e8269da1af358cd8cbf851d6e8b2c0e06da 100644 (file)
@@ -365,7 +365,7 @@ impl Base32Len for Fallback {
        }
 }
 
-impl ToBase32 for Route {
+impl ToBase32 for RouteHint {
        fn write_base32<W: WriteBase32>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err> {
                let mut converter = BytesToBase32::new(writer);
 
@@ -401,7 +401,7 @@ impl ToBase32 for Route {
        }
 }
 
-impl Base32Len for Route {
+impl Base32Len for RouteHint {
        fn base32_len(&self) -> usize {
                bytes_size_to_base32_size(self.0.len() * 51)
        }