@@ -37,8 +37,8 @@ const MAX_EXPIRY_TIME: u64 = 60 * 60 * 24 * 356;
37
37
/// please open an issue. If all tests pass you should be able to use this library safely by just
38
38
/// removing this function till we patch it accordingly.
39
39
fn __system_time_size_check ( ) {
40
- /// Use 2 * sizeof(u64) as expected size since the expected underlying implementation is storing
41
- /// a `Duration` since `SystemTime::UNIX_EPOCH`.
40
+ // Use 2 * sizeof(u64) as expected size since the expected underlying implementation is storing
41
+ // a `Duration` since `SystemTime::UNIX_EPOCH`.
42
42
unsafe { std:: mem:: transmute :: < SystemTime , [ u8 ; 16 ] > ( UNIX_EPOCH ) ; }
43
43
}
44
44
@@ -246,11 +246,11 @@ impl SiPrefix {
246
246
/// Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix.
247
247
/// This is effectively 10^12 * the prefix multiplier
248
248
pub fn multiplier ( & self ) -> u64 {
249
- match self {
250
- & SiPrefix :: Milli => 1_000_000_000 ,
251
- & SiPrefix :: Micro => 1_000_000 ,
252
- & SiPrefix :: Nano => 1_000 ,
253
- & SiPrefix :: Pico => 1 ,
249
+ match * self {
250
+ SiPrefix :: Milli => 1_000_000_000 ,
251
+ SiPrefix :: Micro => 1_000_000 ,
252
+ SiPrefix :: Nano => 1_000 ,
253
+ SiPrefix :: Pico => 1 ,
254
254
}
255
255
}
256
256
@@ -354,8 +354,6 @@ pub struct RouteHop {
354
354
}
355
355
356
356
pub mod constants {
357
- use bech32:: u5;
358
-
359
357
pub const TAG_PAYMENT_HASH : u8 = 1 ;
360
358
pub const TAG_DESCRIPTION : u8 = 13 ;
361
359
pub const TAG_PAYEE_PUB_KEY : u8 = 19 ;
@@ -366,17 +364,6 @@ pub mod constants {
366
364
pub const TAG_ROUTE : u8 = 3 ;
367
365
}
368
366
369
- /// FOR INTERNAL USE ONLY! READ BELOW!
370
- ///
371
- /// It's a convenience function to convert `u8` tags to `u5` tags. Therefore `tag` has to
372
- /// be in range `[0..32]`.
373
- ///
374
- /// # Panics
375
- /// If the `tag` value is not in the range `[0..32]`.
376
- fn as_u5 ( tag : u8 ) -> u5 {
377
- u5:: try_from_u8 ( tag) . unwrap ( )
378
- }
379
-
380
367
impl InvoiceBuilder < tb:: False , tb:: False , tb:: False > {
381
368
/// Construct new, empty `InvoiceBuilder`. All necessary fields have to be filled first before
382
369
/// `InvoiceBuilder::build(self)` becomes available.
@@ -633,7 +620,7 @@ impl SignedRawInvoice {
633
620
recovered_pub_key = Some ( recovered) ;
634
621
}
635
622
636
- let pub_key = included_pub_key. or ( recovered_pub_key. as_ref ( ) )
623
+ let pub_key = included_pub_key. or_else ( || recovered_pub_key. as_ref ( ) )
637
624
. expect ( "One is always present" ) ;
638
625
639
626
let hash = Message :: from_slice ( & self . hash [ ..] )
@@ -671,8 +658,8 @@ impl SignedRawInvoice {
671
658
/// ```
672
659
macro_rules! find_extract {
673
660
( $iter: expr, $enm: pat, $enm_var: ident) => {
674
- $iter. filter_map( |tf| match tf {
675
- & $enm => Some ( $enm_var) ,
661
+ $iter. filter_map( |tf| match * tf {
662
+ $enm => Some ( $enm_var) ,
676
663
_ => None ,
677
664
} ) . next( )
678
665
} ;
@@ -741,8 +728,8 @@ impl RawInvoice {
741
728
// function's type signature.
742
729
// TODO: refactor once impl Trait is available
743
730
fn match_raw ( raw : & RawTaggedField ) -> Option < & TaggedField > {
744
- match raw {
745
- & RawTaggedField :: KnownSemantics ( ref tf) => Some ( tf) ,
731
+ match * raw {
732
+ RawTaggedField :: KnownSemantics ( ref tf) => Some ( tf) ,
746
733
_ => None ,
747
734
}
748
735
}
@@ -777,14 +764,14 @@ impl RawInvoice {
777
764
pub fn fallbacks ( & self ) -> Vec < & Fallback > {
778
765
self . known_tagged_fields ( ) . filter_map ( |tf| match tf {
779
766
& TaggedField :: Fallback ( ref f) => Some ( f) ,
780
- num_traits => None ,
767
+ _ => None ,
781
768
} ) . collect :: < Vec < & Fallback > > ( )
782
769
}
783
770
784
771
pub fn routes ( & self ) -> Vec < & Route > {
785
772
self . known_tagged_fields ( ) . filter_map ( |tf| match tf {
786
773
& TaggedField :: Route ( ref r) => Some ( r) ,
787
- num_traits => None ,
774
+ _ => None ,
788
775
} ) . collect :: < Vec < & Route > > ( )
789
776
}
790
777
@@ -854,7 +841,7 @@ impl Deref for PositiveTimestamp {
854
841
}
855
842
856
843
impl Invoice {
857
- fn into_signed_raw ( self ) -> SignedRawInvoice {
844
+ pub fn into_signed_raw ( self ) -> SignedRawInvoice {
858
845
self . signed_invoice
859
846
}
860
847
@@ -1183,7 +1170,6 @@ mod test {
1183
1170
#[ test]
1184
1171
fn test_calc_invoice_hash ( ) {
1185
1172
use :: { RawInvoice , RawHrp , RawDataPart , Currency , PositiveTimestamp } ;
1186
- use secp256k1:: * ;
1187
1173
use :: TaggedField :: * ;
1188
1174
1189
1175
let invoice = RawInvoice {
@@ -1222,7 +1208,7 @@ mod test {
1222
1208
use { SignedRawInvoice , Signature , RawInvoice , RawHrp , RawDataPart , Currency , Sha256 ,
1223
1209
PositiveTimestamp } ;
1224
1210
1225
- let mut invoice = SignedRawInvoice {
1211
+ let invoice = SignedRawInvoice {
1226
1212
raw_invoice : RawInvoice {
1227
1213
hrp : RawHrp {
1228
1214
currency : Currency :: Bitcoin ,
0 commit comments