@@ -151,6 +151,8 @@ pub fn check_platform() {
151
151
/// * `D`: exactly one `Description` or `DescriptionHash`
152
152
/// * `H`: exactly one `PaymentHash`
153
153
/// * `T`: the timestamp is set
154
+ ///
155
+ /// (C-not exported) as we likely need to manually select one set of boolean type parameters.
154
156
#[ derive( Eq , PartialEq , Debug , Clone ) ]
155
157
pub struct InvoiceBuilder < D : tb:: Bool , H : tb:: Bool , T : tb:: Bool > {
156
158
currency : Currency ,
@@ -178,6 +180,9 @@ pub struct Invoice {
178
180
179
181
/// Represents the description of an invoice which has to be either a directly included string or
180
182
/// a hash of a description provided out of band.
183
+ ///
184
+ /// (C-not exported) As we don't have a good way to map the reference lifetimes making this
185
+ /// practically impossible to use safely in languages like C.
181
186
#[ derive( Eq , PartialEq , Debug , Clone ) ]
182
187
pub enum InvoiceDescription < ' f > {
183
188
/// Reference to the directly supplied description in the invoice
@@ -207,7 +212,7 @@ pub struct SignedRawInvoice {
207
212
hash : [ u8 ; 32 ] ,
208
213
209
214
/// signature of the payment request
210
- signature : Signature ,
215
+ signature : InvoiceSignature ,
211
216
}
212
217
213
218
/// Represents an syntactically correct Invoice for a payment on the lightning network,
@@ -225,6 +230,8 @@ pub struct RawInvoice {
225
230
}
226
231
227
232
/// Data of the `RawInvoice` that is encoded in the human readable part
233
+ ///
234
+ /// (C-not exported) As we don't yet support Option<Enum>
228
235
#[ derive( Eq , PartialEq , Debug , Clone ) ]
229
236
pub struct RawHrp {
230
237
/// The currency deferred from the 3rd and 4th character of the bech32 transaction
@@ -283,6 +290,9 @@ impl SiPrefix {
283
290
284
291
/// Returns all enum variants of `SiPrefix` sorted in descending order of their associated
285
292
/// multiplier.
293
+ ///
294
+ /// (C-not exported) As we don't yet support a slice of enums, and also because this function
295
+ /// isn't the most critical to expose.
286
296
pub fn values_desc ( ) -> & ' static [ SiPrefix ] {
287
297
use SiPrefix :: * ;
288
298
static VALUES : [ SiPrefix ; 4 ] = [ Milli , Micro , Nano , Pico ] ;
@@ -381,7 +391,7 @@ pub enum Fallback {
381
391
382
392
/// Recoverable signature
383
393
#[ derive( Eq , PartialEq , Debug , Clone ) ]
384
- pub struct Signature ( pub RecoverableSignature ) ;
394
+ pub struct InvoiceSignature ( pub RecoverableSignature ) ;
385
395
386
396
/// Private routing information
387
397
///
@@ -630,7 +640,7 @@ impl SignedRawInvoice {
630
640
/// 1. raw invoice
631
641
/// 2. hash of the raw invoice
632
642
/// 3. signature
633
- pub fn into_parts ( self ) -> ( RawInvoice , [ u8 ; 32 ] , Signature ) {
643
+ pub fn into_parts ( self ) -> ( RawInvoice , [ u8 ; 32 ] , InvoiceSignature ) {
634
644
( self . raw_invoice , self . hash , self . signature )
635
645
}
636
646
@@ -644,8 +654,8 @@ impl SignedRawInvoice {
644
654
& self . hash
645
655
}
646
656
647
- /// Signature for the invoice.
648
- pub fn signature ( & self ) -> & Signature {
657
+ /// InvoiceSignature for the invoice.
658
+ pub fn signature ( & self ) -> & InvoiceSignature {
649
659
& self . signature
650
660
}
651
661
@@ -760,6 +770,9 @@ impl RawInvoice {
760
770
/// Signs the invoice using the supplied `sign_function`. This function MAY fail with an error
761
771
/// of type `E`. Since the signature of a `SignedRawInvoice` is not required to be valid there
762
772
/// are no constraints regarding the validity of the produced signature.
773
+ ///
774
+ /// (C-not exported) As we don't currently support passing function pointers into methods
775
+ /// explicitly.
763
776
pub fn sign < F , E > ( self , sign_method : F ) -> Result < SignedRawInvoice , E >
764
777
where F : FnOnce ( & Message ) -> Result < RecoverableSignature , E >
765
778
{
@@ -771,11 +784,13 @@ impl RawInvoice {
771
784
Ok ( SignedRawInvoice {
772
785
raw_invoice : self ,
773
786
hash : raw_hash,
774
- signature : Signature ( signature) ,
787
+ signature : InvoiceSignature ( signature) ,
775
788
} )
776
789
}
777
790
778
791
/// Returns an iterator over all tagged fields with known semantics.
792
+ ///
793
+ /// (C-not exported) As there is not yet a manual mapping for a FilterMap
779
794
pub fn known_tagged_fields ( & self )
780
795
-> FilterMap < Iter < RawTaggedField > , fn ( & RawTaggedField ) -> Option < & TaggedField > >
781
796
{
@@ -824,6 +839,7 @@ impl RawInvoice {
824
839
find_extract ! ( self . known_tagged_fields( ) , TaggedField :: Features ( ref x) , x)
825
840
}
826
841
842
+ /// (C-not exported) as we don't support Vec<&NonOpaqueType>
827
843
pub fn fallbacks ( & self ) -> Vec < & Fallback > {
828
844
self . known_tagged_fields ( ) . filter_map ( |tf| match tf {
829
845
& TaggedField :: Fallback ( ref f) => Some ( f) ,
@@ -981,6 +997,8 @@ impl Invoice {
981
997
}
982
998
983
999
/// Returns an iterator over all tagged fields of this Invoice.
1000
+ ///
1001
+ /// (C-not exported) As there is not yet a manual mapping for a FilterMap
984
1002
pub fn tagged_fields ( & self )
985
1003
-> FilterMap < Iter < RawTaggedField > , fn ( & RawTaggedField ) -> Option < & TaggedField > > {
986
1004
self . signed_invoice . raw_invoice ( ) . known_tagged_fields ( )
@@ -992,6 +1010,8 @@ impl Invoice {
992
1010
}
993
1011
994
1012
/// Return the description or a hash of it for longer ones
1013
+ ///
1014
+ /// (C-not exported) because we don't yet export InvoiceDescription
995
1015
pub fn description ( & self ) -> InvoiceDescription {
996
1016
if let Some ( ref direct) = self . signed_invoice . description ( ) {
997
1017
return InvoiceDescription :: Direct ( direct) ;
@@ -1029,11 +1049,13 @@ impl Invoice {
1029
1049
}
1030
1050
1031
1051
/// Returns the invoice's `min_cltv_expiry` time if present
1032
- pub fn min_final_cltv_expiry ( & self ) -> Option < & u64 > {
1033
- self . signed_invoice . min_final_cltv_expiry ( ) . map ( |x| & x. 0 )
1052
+ pub fn min_final_cltv_expiry ( & self ) -> Option < u64 > {
1053
+ self . signed_invoice . min_final_cltv_expiry ( ) . map ( |x| x. 0 )
1034
1054
}
1035
1055
1036
1056
/// Returns a list of all fallback addresses
1057
+ ///
1058
+ /// (C-not exported) as we don't support Vec<&NonOpaqueType>
1037
1059
pub fn fallbacks ( & self ) -> Vec < & Fallback > {
1038
1060
self . signed_invoice . fallbacks ( )
1039
1061
}
@@ -1192,7 +1214,7 @@ impl Deref for RouteHint {
1192
1214
}
1193
1215
}
1194
1216
1195
- impl Deref for Signature {
1217
+ impl Deref for InvoiceSignature {
1196
1218
type Target = RecoverableSignature ;
1197
1219
1198
1220
fn deref ( & self ) -> & RecoverableSignature {
@@ -1277,6 +1299,8 @@ impl std::error::Error for SemanticError { }
1277
1299
1278
1300
/// When signing using a fallible method either an user-supplied `SignError` or a `CreationError`
1279
1301
/// may occur.
1302
+ ///
1303
+ /// (C-not exported) As we don't support unbounded generics
1280
1304
#[ derive( Eq , PartialEq , Debug , Clone ) ]
1281
1305
pub enum SignOrCreationError < S > {
1282
1306
/// An error occurred during signing
@@ -1354,7 +1378,7 @@ mod test {
1354
1378
use secp256k1:: Secp256k1 ;
1355
1379
use secp256k1:: recovery:: { RecoveryId , RecoverableSignature } ;
1356
1380
use secp256k1:: key:: { SecretKey , PublicKey } ;
1357
- use { SignedRawInvoice , Signature , RawInvoice , RawHrp , RawDataPart , Currency , Sha256 ,
1381
+ use { SignedRawInvoice , InvoiceSignature , RawInvoice , RawHrp , RawDataPart , Currency , Sha256 ,
1358
1382
PositiveTimestamp } ;
1359
1383
1360
1384
let invoice = SignedRawInvoice {
@@ -1383,7 +1407,7 @@ mod test {
1383
1407
0x7b , 0x1d , 0x85 , 0x8d , 0xb1 , 0xd1 , 0xf7 , 0xab , 0x71 , 0x37 , 0xdc , 0xb7 ,
1384
1408
0x83 , 0x5d , 0xb2 , 0xec , 0xd5 , 0x18 , 0xe1 , 0xc9
1385
1409
] ,
1386
- signature : Signature ( RecoverableSignature :: from_compact (
1410
+ signature : InvoiceSignature ( RecoverableSignature :: from_compact (
1387
1411
& [
1388
1412
0x38u8 , 0xec , 0x68 , 0x91 , 0x34 , 0x5e , 0x20 , 0x41 , 0x45 , 0xbe , 0x8a ,
1389
1413
0x3a , 0x99 , 0xde , 0x38 , 0xe9 , 0x8a , 0x39 , 0xd6 , 0xa5 , 0x69 , 0x43 ,
@@ -1591,7 +1615,7 @@ mod test {
1591
1615
) ;
1592
1616
assert_eq ! ( invoice. payee_pub_key( ) , Some ( & public_key) ) ;
1593
1617
assert_eq ! ( invoice. expiry_time( ) , Duration :: from_secs( 54321 ) ) ;
1594
- assert_eq ! ( invoice. min_final_cltv_expiry( ) , Some ( & 144 ) ) ;
1618
+ assert_eq ! ( invoice. min_final_cltv_expiry( ) , Some ( 144 ) ) ;
1595
1619
assert_eq ! ( invoice. fallbacks( ) , vec![ & Fallback :: PubKeyHash ( [ 0 ; 20 ] ) ] ) ;
1596
1620
assert_eq ! ( invoice. routes( ) , vec![ & RouteHint ( route_1) , & RouteHint ( route_2) ] ) ;
1597
1621
assert_eq ! (
0 commit comments