X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-invoice%2Fsrc%2Fser.rs;h=5c7b4aa8978456aebda20014a43c4ea165a2effb;hb=8ffc2d1742ff1171a87b0410b21cbbd557ff8247;hp=8f0ff31b904b78b42f4708ea3af8c4b7fd099a04;hpb=3b67be235a46d8f9a9a6faf7ca7c5872ffbd8646;p=rust-lightning diff --git a/lightning-invoice/src/ser.rs b/lightning-invoice/src/ser.rs index 8f0ff31b..5c7b4aa8 100644 --- a/lightning-invoice/src/ser.rs +++ b/lightning-invoice/src/ser.rs @@ -2,7 +2,8 @@ use std::fmt; use std::fmt::{Display, Formatter}; use bech32::{ToBase32, u5, WriteBase32, Base32Len}; -use ::*; +use super::{Invoice, Sha256, TaggedField, ExpiryTime, MinFinalCltvExpiry, Fallback, PayeePubKey, InvoiceSignature, PositiveTimestamp, + PrivateRoute, Description, RawTaggedField, Currency, RawHrp, SiPrefix, constants, SignedRawInvoice, RawDataPart}; /// Converts a stream of bytes written to it to base32. On finalization the according padding will /// be applied. That means the results of writing two data blocks with one or two `BytesToBase32` @@ -122,6 +123,7 @@ impl Display for SignedRawInvoice { } } +/// (C-not exported) impl Display for RawHrp { fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> { let amount = match self.raw_amount { @@ -151,6 +153,7 @@ impl Display for Currency { Currency::BitcoinTestnet => "tb", Currency::Regtest => "bcrt", Currency::Simnet => "sb", + Currency::Signet => "tbs", }; write!(f, "{}", currency_code) } @@ -353,11 +356,11 @@ impl Base32Len for Fallback { } } -impl ToBase32 for RouteHint { +impl ToBase32 for PrivateRoute { fn write_base32(&self, writer: &mut W) -> Result<(), ::Err> { let mut converter = BytesToBase32::new(writer); - for hop in self.iter() { + for hop in (self.0).0.iter() { converter.append(&hop.src_node_id.serialize()[..])?; let short_channel_id = try_stretch( encode_int_be_base256(hop.short_channel_id), @@ -389,9 +392,9 @@ impl ToBase32 for RouteHint { } } -impl Base32Len for RouteHint { +impl Base32Len for PrivateRoute { fn base32_len(&self) -> usize { - bytes_size_to_base32_size(self.0.len() * 51) + bytes_size_to_base32_size((self.0).0.len() * 51) } } @@ -436,8 +439,8 @@ impl ToBase32 for TaggedField { TaggedField::Fallback(ref fallback_address) => { write_tagged_field(writer, constants::TAG_FALLBACK, fallback_address) }, - TaggedField::Route(ref route_hops) => { - write_tagged_field(writer, constants::TAG_ROUTE, route_hops) + TaggedField::PrivateRoute(ref route_hops) => { + write_tagged_field(writer, constants::TAG_PRIVATE_ROUTE, route_hops) }, TaggedField::PaymentSecret(ref payment_secret) => { write_tagged_field(writer, constants::TAG_PAYMENT_SECRET, payment_secret) @@ -471,6 +474,7 @@ mod test { assert_eq!("tb", Currency::BitcoinTestnet.to_string()); assert_eq!("bcrt", Currency::Regtest.to_string()); assert_eq!("sb", Currency::Simnet.to_string()); + assert_eq!("tbs", Currency::Signet.to_string()); } #[test]