18
18
//! invoices and functions to create, encode and decode these. If you just want to use the standard
19
19
//! en-/decoding functionality this should get you started:
20
20
//!
21
- //! * For parsing use `str::parse::<Invoice>(&self)` (see the docs of `impl FromStr for Invoice`)
22
- //! * For constructing invoices use the `InvoiceBuilder`
23
- //! * For serializing invoices use the `Display`/`ToString` traits
21
+ //! * For parsing use `str::parse::<Invoice>(&self)` (see [`Invoice::from_str`])
22
+ //! * For constructing invoices use the [`InvoiceBuilder`]
23
+ //! * For serializing invoices use the [`Display`]/[`ToString`] traits
24
+ //!
25
+ //! [`Invoice::from_str`]: crate::Invoice#impl-FromStr
24
26
25
27
#[ cfg( not( any( feature = "std" , feature = "no-std" ) ) ) ]
26
28
compile_error ! ( "at least one of the `std` or `no-std` features must be enabled" ) ;
@@ -160,7 +162,7 @@ pub const DEFAULT_EXPIRY_TIME: u64 = 3600;
160
162
/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
161
163
pub const DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA : u64 = 18 ;
162
164
163
- /// Builder for `Invoice`s. It's the most convenient and advised way to use this library. It ensures
165
+ /// Builder for [ `Invoice`] s. It's the most convenient and advised way to use this library. It ensures
164
166
/// that only a semantically and syntactically correct Invoice can be built using it.
165
167
///
166
168
/// ```
@@ -212,8 +214,8 @@ pub const DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA: u64 = 18;
212
214
/// # Type parameters
213
215
/// The two parameters `D` and `H` signal if the builder already contains the correct amount of the
214
216
/// given field:
215
- /// * `D`: exactly one ` Description` or ` DescriptionHash`
216
- /// * `H`: exactly one ` PaymentHash`
217
+ /// * `D`: exactly one [`TaggedField:: Description`] or [`TaggedField:: DescriptionHash`]
218
+ /// * `H`: exactly one [`TaggedField:: PaymentHash`]
217
219
/// * `T`: the timestamp is set
218
220
///
219
221
/// (C-not exported) as we likely need to manually select one set of boolean type parameters.
@@ -236,9 +238,11 @@ pub struct InvoiceBuilder<D: tb::Bool, H: tb::Bool, T: tb::Bool, C: tb::Bool, S:
236
238
/// Represents a syntactically and semantically correct lightning BOLT11 invoice.
237
239
///
238
240
/// There are three ways to construct an `Invoice`:
239
- /// 1. using `InvoiceBuilder`
240
- /// 2. using `Invoice::from_signed(SignedRawInvoice)`
241
- /// 3. using `str::parse::<Invoice>(&str)`
241
+ /// 1. using [`InvoiceBuilder`]
242
+ /// 2. using [`Invoice::from_signed`]
243
+ /// 3. using `str::parse::<Invoice>(&str)` (see [`Invoice::from_str`])
244
+ ///
245
+ /// [`Invoice::from_str`]: crate::Invoice#impl-FromStr
242
246
#[ derive( Eq , PartialEq , Debug , Clone , Hash ) ]
243
247
pub struct Invoice {
244
248
signed_invoice : SignedRawInvoice ,
@@ -258,34 +262,34 @@ pub enum InvoiceDescription<'f> {
258
262
Hash ( & ' f Sha256 ) ,
259
263
}
260
264
261
- /// Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be
265
+ /// Represents a signed [ `RawInvoice`] with cached hash. The signature is not checked and may be
262
266
/// invalid.
263
267
///
264
268
/// # Invariants
265
- /// The hash has to be either from the deserialized invoice or from the serialized `raw_invoice` .
269
+ /// The hash has to be either from the deserialized invoice or from the serialized [`RawInvoice`] .
266
270
#[ derive( Eq , PartialEq , Debug , Clone , Hash ) ]
267
271
pub struct SignedRawInvoice {
268
272
/// The rawInvoice that the signature belongs to
269
273
raw_invoice : RawInvoice ,
270
274
271
- /// Hash of the `RawInvoice` that will be used to check the signature.
275
+ /// Hash of the [ `RawInvoice`] that will be used to check the signature.
272
276
///
273
277
/// * if the `SignedRawInvoice` was deserialized the hash is of from the original encoded form,
274
278
/// since it's not guaranteed that encoding it again will lead to the same result since integers
275
279
/// could have been encoded with leading zeroes etc.
276
280
/// * if the `SignedRawInvoice` was constructed manually the hash will be the calculated hash
277
- /// from the `RawInvoice`
281
+ /// from the [ `RawInvoice`]
278
282
hash : [ u8 ; 32 ] ,
279
283
280
284
/// signature of the payment request
281
285
signature : InvoiceSignature ,
282
286
}
283
287
284
- /// Represents an syntactically correct Invoice for a payment on the lightning network,
288
+ /// Represents an syntactically correct [` Invoice`] for a payment on the lightning network,
285
289
/// but without the signature information.
286
- /// De- and encoding should not lead to information loss but may lead to different hashes.
290
+ /// Decoding and encoding should not lead to information loss but may lead to different hashes.
287
291
///
288
- /// For methods without docs see the corresponding methods in `Invoice`.
292
+ /// For methods without docs see the corresponding methods in [ `Invoice`] .
289
293
#[ derive( Eq , PartialEq , Debug , Clone , Hash ) ]
290
294
pub struct RawInvoice {
291
295
/// human readable part
@@ -295,7 +299,7 @@ pub struct RawInvoice {
295
299
pub data : RawDataPart ,
296
300
}
297
301
298
- /// Data of the `RawInvoice` that is encoded in the human readable part
302
+ /// Data of the [ `RawInvoice`] that is encoded in the human readable part.
299
303
///
300
304
/// (C-not exported) As we don't yet support `Option<Enum>`
301
305
#[ derive( Eq , PartialEq , Debug , Clone , Hash ) ]
@@ -310,7 +314,7 @@ pub struct RawHrp {
310
314
pub si_prefix : Option < SiPrefix > ,
311
315
}
312
316
313
- /// Data of the `RawInvoice` that is encoded in the data part
317
+ /// Data of the [ `RawInvoice`] that is encoded in the data part
314
318
#[ derive( Eq , PartialEq , Debug , Clone , Hash ) ]
315
319
pub struct RawDataPart {
316
320
/// generation time of the invoice
@@ -564,7 +568,8 @@ impl<D: tb::Bool, H: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool> InvoiceBui
564
568
}
565
569
566
570
impl < D : tb:: Bool , H : tb:: Bool , C : tb:: Bool , S : tb:: Bool > InvoiceBuilder < D , H , tb:: True , C , S > {
567
- /// Builds a `RawInvoice` if no `CreationError` occurred while construction any of the fields.
571
+ /// Builds a [`RawInvoice`] if no [`CreationError`] occurred while construction any of the
572
+ /// fields.
568
573
pub fn build_raw ( self ) -> Result < RawInvoice , CreationError > {
569
574
570
575
// If an error occurred at any time before, return it now
@@ -741,17 +746,17 @@ impl SignedRawInvoice {
741
746
( self . raw_invoice , self . hash , self . signature )
742
747
}
743
748
744
- /// The `RawInvoice` which was signed.
749
+ /// The [ `RawInvoice`] which was signed.
745
750
pub fn raw_invoice ( & self ) -> & RawInvoice {
746
751
& self . raw_invoice
747
752
}
748
753
749
- /// The hash of the `RawInvoice` that was signed.
754
+ /// The hash of the [ `RawInvoice`] that was signed.
750
755
pub fn signable_hash ( & self ) -> & [ u8 ; 32 ] {
751
756
& self . hash
752
757
}
753
758
754
- /// InvoiceSignature for the invoice.
759
+ /// Signature for the invoice.
755
760
pub fn signature ( & self ) -> & InvoiceSignature {
756
761
& self . signature
757
762
}
@@ -869,8 +874,8 @@ impl RawInvoice {
869
874
)
870
875
}
871
876
872
- /// Signs the invoice using the supplied `sign_function `. This function MAY fail with an error
873
- /// of type `E`. Since the signature of a `SignedRawInvoice` is not required to be valid there
877
+ /// Signs the invoice using the supplied `sign_method `. This function MAY fail with an error of
878
+ /// type `E`. Since the signature of a [ `SignedRawInvoice`] is not required to be valid there
874
879
/// are no constraints regarding the validity of the produced signature.
875
880
///
876
881
/// (C-not exported) As we don't currently support passing function pointers into methods
@@ -1125,7 +1130,7 @@ impl Invoice {
1125
1130
Ok ( ( ) )
1126
1131
}
1127
1132
1128
- /// Constructs an `Invoice` from a `SignedRawInvoice` by checking all its invariants.
1133
+ /// Constructs an `Invoice` from a [ `SignedRawInvoice`] by checking all its invariants.
1129
1134
/// ```
1130
1135
/// use lightning_invoice::*;
1131
1136
///
@@ -1315,7 +1320,7 @@ impl TaggedField {
1315
1320
impl Description {
1316
1321
1317
1322
/// Creates a new `Description` if `description` is at most 1023 __bytes__ long,
1318
- /// returns `CreationError::DescriptionTooLong` otherwise
1323
+ /// returns [ `CreationError::DescriptionTooLong`] otherwise
1319
1324
///
1320
1325
/// Please note that single characters may use more than one byte due to UTF8 encoding.
1321
1326
pub fn new ( description : String ) -> Result < Description , CreationError > {
@@ -1326,7 +1331,7 @@ impl Description {
1326
1331
}
1327
1332
}
1328
1333
1329
- /// Returns the underlying description `String`
1334
+ /// Returns the underlying description [ `String`]
1330
1335
pub fn into_inner ( self ) -> String {
1331
1336
self . 0
1332
1337
}
@@ -1366,7 +1371,7 @@ impl ExpiryTime {
1366
1371
ExpiryTime ( Duration :: from_secs ( seconds) )
1367
1372
}
1368
1373
1369
- /// Construct an `ExpiryTime` from a `Duration`, dropping the sub-second part.
1374
+ /// Construct an `ExpiryTime` from a [ `Duration`] , dropping the sub-second part.
1370
1375
pub fn from_duration ( duration : Duration ) -> ExpiryTime {
1371
1376
Self :: from_seconds ( duration. as_secs ( ) )
1372
1377
}
@@ -1376,7 +1381,7 @@ impl ExpiryTime {
1376
1381
self . 0 . as_secs ( )
1377
1382
}
1378
1383
1379
- /// Returns a reference to the underlying `Duration` (=expiry time)
1384
+ /// Returns a reference to the underlying [ `Duration`] (=expiry time)
1380
1385
pub fn as_duration ( & self ) -> & Duration {
1381
1386
& self . 0
1382
1387
}
@@ -1428,10 +1433,10 @@ impl Deref for SignedRawInvoice {
1428
1433
}
1429
1434
}
1430
1435
1431
- /// Errors that may occur when constructing a new `RawInvoice` or `Invoice`
1436
+ /// Errors that may occur when constructing a new [ `RawInvoice`] or [ `Invoice`]
1432
1437
#[ derive( Eq , PartialEq , Debug , Clone ) ]
1433
1438
pub enum CreationError {
1434
- /// The supplied description string was longer than 639 __bytes__ (see [`Description::new(…)`](./struct.Description.html#method.new) )
1439
+ /// The supplied description string was longer than 639 __bytes__ (see [`Description::new`] )
1435
1440
DescriptionTooLong ,
1436
1441
1437
1442
/// The specified route has too many hops and can't be encoded
@@ -1472,7 +1477,7 @@ impl Display for CreationError {
1472
1477
#[ cfg( feature = "std" ) ]
1473
1478
impl std:: error:: Error for CreationError { }
1474
1479
1475
- /// Errors that may occur when converting a `RawInvoice` to an `Invoice`. They relate to the
1480
+ /// Errors that may occur when converting a [ `RawInvoice`] to an [ `Invoice`] . They relate to the
1476
1481
/// requirements sections in BOLT #11
1477
1482
#[ derive( Eq , PartialEq , Debug , Clone ) ]
1478
1483
pub enum SemanticError {
@@ -1528,7 +1533,7 @@ impl Display for SemanticError {
1528
1533
#[ cfg( feature = "std" ) ]
1529
1534
impl std:: error:: Error for SemanticError { }
1530
1535
1531
- /// When signing using a fallible method either an user-supplied `SignError` or a `CreationError`
1536
+ /// When signing using a fallible method either an user-supplied `SignError` or a [ `CreationError`]
1532
1537
/// may occur.
1533
1538
#[ derive( Eq , PartialEq , Debug , Clone ) ]
1534
1539
pub enum SignOrCreationError < S = ( ) > {
0 commit comments