@@ -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
@@ -205,11 +205,11 @@ impl SiPrefix {
205
205
/// Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix.
206
206
/// This is effectively 10^12 * the prefix multiplier
207
207
pub fn multiplier ( & self ) -> u64 {
208
- match self {
209
- & SiPrefix :: Milli => 1_000_000_000 ,
210
- & SiPrefix :: Micro => 1_000_000 ,
211
- & SiPrefix :: Nano => 1_000 ,
212
- & SiPrefix :: Pico => 1 ,
208
+ match * self {
209
+ SiPrefix :: Milli => 1_000_000_000 ,
210
+ SiPrefix :: Micro => 1_000_000 ,
211
+ SiPrefix :: Nano => 1_000 ,
212
+ SiPrefix :: Pico => 1 ,
213
213
}
214
214
}
215
215
@@ -311,8 +311,6 @@ pub struct RouteHop {
311
311
}
312
312
313
313
pub mod constants {
314
- use bech32:: u5;
315
-
316
314
pub const TAG_PAYMENT_HASH : u8 = 1 ;
317
315
pub const TAG_DESCRIPTION : u8 = 13 ;
318
316
pub const TAG_PAYEE_PUB_KEY : u8 = 19 ;
@@ -323,17 +321,6 @@ pub mod constants {
323
321
pub const TAG_ROUTE : u8 = 3 ;
324
322
}
325
323
326
- /// FOR INTERNAL USE ONLY! READ BELOW!
327
- ///
328
- /// It's a convenience function to convert `u8` tags to `u5` tags. Therefore `tag` has to
329
- /// be in range `[0..32]`.
330
- ///
331
- /// # Panics
332
- /// If the `tag` value is not in the range `[0..32]`.
333
- fn as_u5 ( tag : u8 ) -> u5 {
334
- u5:: try_from_u8 ( tag) . unwrap ( )
335
- }
336
-
337
324
impl InvoiceBuilder < tb:: False , tb:: False , tb:: False > {
338
325
/// Construct new, empty `InvoiceBuilder`. All necessary fields have to be filled first before
339
326
/// `InvoiceBuilder::build(self)` becomes available.
@@ -597,7 +584,7 @@ impl SignedRawInvoice {
597
584
recovered_pub_key = Some ( recovered) ;
598
585
}
599
586
600
- let pub_key = included_pub_key. or ( recovered_pub_key. as_ref ( ) )
587
+ let pub_key = included_pub_key. or_else ( || recovered_pub_key. as_ref ( ) )
601
588
. expect ( "One is always present" ) ;
602
589
603
590
let hash = Message :: from_slice ( & self . hash [ ..] )
@@ -635,8 +622,8 @@ impl SignedRawInvoice {
635
622
/// ```
636
623
macro_rules! find_extract {
637
624
( $iter: expr, $enm: pat, $enm_var: ident) => {
638
- $iter. filter_map( |tf| match tf {
639
- & $enm => Some ( $enm_var) ,
625
+ $iter. filter_map( |tf| match * tf {
626
+ $enm => Some ( $enm_var) ,
640
627
_ => None ,
641
628
} ) . next( )
642
629
} ;
@@ -705,8 +692,8 @@ impl RawInvoice {
705
692
// function's type signature.
706
693
// TODO: refactor once impl Trait is available
707
694
fn match_raw ( raw : & RawTaggedField ) -> Option < & TaggedField > {
708
- match raw {
709
- & RawTaggedField :: KnownSemantics ( ref tf) => Some ( tf) ,
695
+ match * raw {
696
+ RawTaggedField :: KnownSemantics ( ref tf) => Some ( tf) ,
710
697
_ => None ,
711
698
}
712
699
}
@@ -741,14 +728,14 @@ impl RawInvoice {
741
728
pub fn fallbacks ( & self ) -> Vec < & Fallback > {
742
729
self . known_tagged_fields ( ) . filter_map ( |tf| match tf {
743
730
& TaggedField :: Fallback ( ref f) => Some ( f) ,
744
- num_traits => None ,
731
+ _ => None ,
745
732
} ) . collect :: < Vec < & Fallback > > ( )
746
733
}
747
734
748
735
pub fn routes ( & self ) -> Vec < & Route > {
749
736
self . known_tagged_fields ( ) . filter_map ( |tf| match tf {
750
737
& TaggedField :: Route ( ref r) => Some ( r) ,
751
- num_traits => None ,
738
+ _ => None ,
752
739
} ) . collect :: < Vec < & Route > > ( )
753
740
}
754
741
@@ -819,7 +806,7 @@ impl Deref for PositiveTimestamp {
819
806
}
820
807
821
808
impl Invoice {
822
- fn into_signed_raw ( self ) -> SignedRawInvoice {
809
+ pub fn into_signed_raw ( self ) -> SignedRawInvoice {
823
810
self . signed_invoice
824
811
}
825
812
@@ -1132,22 +1119,21 @@ mod test {
1132
1119
1133
1120
#[ test]
1134
1121
fn test_system_time_bounds_assumptions ( ) {
1135
- use std:: time:: { Duration , SystemTime , UNIX_EPOCH } ;
1136
-
1137
- /// The upper and lower bounds of `SystemTime` are not part of its public contract and are
1138
- /// platform specific. That's why we have to test if our assumptions regarding these bounds
1139
- /// hold on the target platform.
1140
- ///
1141
- /// If this test fails on your platform, please don't use the library and open an issue
1142
- /// instead so we can resolve the situation. Currently this library is tested on:
1143
- /// * Linux (64bit)
1122
+ use std:: time:: { Duration , UNIX_EPOCH } ;
1123
+
1124
+ // The upper and lower bounds of `SystemTime` are not part of its public contract and are
1125
+ // platform specific. That's why we have to test if our assumptions regarding these bounds
1126
+ // hold on the target platform.
1127
+ //
1128
+ // If this test fails on your platform, please don't use the library and open an issue
1129
+ // instead so we can resolve the situation. Currently this library is tested on:
1130
+ // * Linux (64bit)
1144
1131
let _ = UNIX_EPOCH + Duration :: from_secs ( :: std:: i64:: MAX as u64 ) ;
1145
1132
}
1146
1133
1147
1134
#[ test]
1148
1135
fn test_calc_invoice_hash ( ) {
1149
1136
use :: { RawInvoice , RawHrp , RawDataPart , Currency , PositiveTimestamp } ;
1150
- use secp256k1:: * ;
1151
1137
use :: TaggedField :: * ;
1152
1138
1153
1139
let invoice = RawInvoice {
@@ -1186,7 +1172,7 @@ mod test {
1186
1172
use { SignedRawInvoice , Signature , RawInvoice , RawHrp , RawDataPart , Currency , Sha256 ,
1187
1173
PositiveTimestamp } ;
1188
1174
1189
- let mut invoice = SignedRawInvoice {
1175
+ let invoice = SignedRawInvoice {
1190
1176
raw_invoice : RawInvoice {
1191
1177
hrp : RawHrp {
1192
1178
currency : Currency :: Bitcoin ,
0 commit comments