@@ -251,7 +251,7 @@ pub struct InvoiceBuilder<D: tb::Bool, H: tb::Bool, T: tb::Bool, C: tb::Bool, S:
251
251
/// [`Bolt11Invoice::from_str`]: crate::Bolt11Invoice#impl-FromStr
252
252
#[ derive( Eq , PartialEq , Debug , Clone , Hash , Ord , PartialOrd ) ]
253
253
pub struct Bolt11Invoice {
254
- signed_invoice : SignedRawInvoice ,
254
+ signed_invoice : SignedRawBolt11Invoice ,
255
255
}
256
256
257
257
/// Represents the description of an invoice which has to be either a directly included string or
@@ -268,23 +268,23 @@ pub enum InvoiceDescription<'f> {
268
268
Hash ( & ' f Sha256 ) ,
269
269
}
270
270
271
- /// Represents a signed [`RawInvoice `] with cached hash. The signature is not checked and may be
271
+ /// Represents a signed [`RawBolt11Invoice `] with cached hash. The signature is not checked and may be
272
272
/// invalid.
273
273
///
274
274
/// # Invariants
275
- /// The hash has to be either from the deserialized invoice or from the serialized [`RawInvoice `].
275
+ /// The hash has to be either from the deserialized invoice or from the serialized [`RawBolt11Invoice `].
276
276
#[ derive( Eq , PartialEq , Debug , Clone , Hash , Ord , PartialOrd ) ]
277
- pub struct SignedRawInvoice {
278
- /// The rawInvoice that the signature belongs to
279
- raw_invoice : RawInvoice ,
277
+ pub struct SignedRawBolt11Invoice {
278
+ /// The raw invoice that the signature belongs to
279
+ raw_invoice : RawBolt11Invoice ,
280
280
281
- /// Hash of the [`RawInvoice `] that will be used to check the signature.
281
+ /// Hash of the [`RawBolt11Invoice `] that will be used to check the signature.
282
282
///
283
- /// * if the `SignedRawInvoice ` was deserialized the hash is of from the original encoded form,
283
+ /// * if the `SignedRawBolt11Invoice ` was deserialized the hash is of from the original encoded form,
284
284
/// since it's not guaranteed that encoding it again will lead to the same result since integers
285
285
/// could have been encoded with leading zeroes etc.
286
- /// * if the `SignedRawInvoice ` was constructed manually the hash will be the calculated hash
287
- /// from the [`RawInvoice `]
286
+ /// * if the `SignedRawBolt11Invoice ` was constructed manually the hash will be the calculated hash
287
+ /// from the [`RawBolt11Invoice `]
288
288
hash : [ u8 ; 32 ] ,
289
289
290
290
/// signature of the payment request
@@ -297,15 +297,15 @@ pub struct SignedRawInvoice {
297
297
///
298
298
/// For methods without docs see the corresponding methods in [`Bolt11Invoice`].
299
299
#[ derive( Eq , PartialEq , Debug , Clone , Hash , Ord , PartialOrd ) ]
300
- pub struct RawInvoice {
300
+ pub struct RawBolt11Invoice {
301
301
/// human readable part
302
302
pub hrp : RawHrp ,
303
303
304
304
/// data part
305
305
pub data : RawDataPart ,
306
306
}
307
307
308
- /// Data of the [`RawInvoice `] that is encoded in the human readable part.
308
+ /// Data of the [`RawBolt11Invoice `] that is encoded in the human readable part.
309
309
///
310
310
/// This is not exported to bindings users as we don't yet support `Option<Enum>`
311
311
#[ derive( Eq , PartialEq , Debug , Clone , Hash , Ord , PartialOrd ) ]
@@ -320,7 +320,7 @@ pub struct RawHrp {
320
320
pub si_prefix : Option < SiPrefix > ,
321
321
}
322
322
323
- /// Data of the [`RawInvoice `] that is encoded in the data part
323
+ /// Data of the [`RawBolt11Invoice `] that is encoded in the data part
324
324
#[ derive( Eq , PartialEq , Debug , Clone , Hash , Ord , PartialOrd ) ]
325
325
pub struct RawDataPart {
326
326
/// generation time of the invoice
@@ -621,9 +621,9 @@ impl<D: tb::Bool, H: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool, M: tb::Boo
621
621
}
622
622
623
623
impl < D : tb:: Bool , H : tb:: Bool , C : tb:: Bool , S : tb:: Bool , M : tb:: Bool > InvoiceBuilder < D , H , tb:: True , C , S , M > {
624
- /// Builds a [`RawInvoice `] if no [`CreationError`] occurred while construction any of the
624
+ /// Builds a [`RawBolt11Invoice `] if no [`CreationError`] occurred while construction any of the
625
625
/// fields.
626
- pub fn build_raw ( self ) -> Result < RawInvoice , CreationError > {
626
+ pub fn build_raw ( self ) -> Result < RawBolt11Invoice , CreationError > {
627
627
628
628
// If an error occurred at any time before, return it now
629
629
if let Some ( e) = self . error {
@@ -647,7 +647,7 @@ impl<D: tb::Bool, H: tb::Bool, C: tb::Bool, S: tb::Bool, M: tb::Bool> InvoiceBui
647
647
tagged_fields,
648
648
} ;
649
649
650
- Ok ( RawInvoice {
650
+ Ok ( RawBolt11Invoice {
651
651
hrp,
652
652
data,
653
653
} )
@@ -850,21 +850,21 @@ impl<M: tb::Bool> InvoiceBuilder<tb::True, tb::True, tb::True, tb::True, tb::Tru
850
850
}
851
851
852
852
853
- impl SignedRawInvoice {
854
- /// Disassembles the `SignedRawInvoice ` into its three parts:
853
+ impl SignedRawBolt11Invoice {
854
+ /// Disassembles the `SignedRawBolt11Invoice ` into its three parts:
855
855
/// 1. raw invoice
856
856
/// 2. hash of the raw invoice
857
857
/// 3. signature
858
- pub fn into_parts ( self ) -> ( RawInvoice , [ u8 ; 32 ] , InvoiceSignature ) {
858
+ pub fn into_parts ( self ) -> ( RawBolt11Invoice , [ u8 ; 32 ] , InvoiceSignature ) {
859
859
( self . raw_invoice , self . hash , self . signature )
860
860
}
861
861
862
- /// The [`RawInvoice `] which was signed.
863
- pub fn raw_invoice ( & self ) -> & RawInvoice {
862
+ /// The [`RawBolt11Invoice `] which was signed.
863
+ pub fn raw_invoice ( & self ) -> & RawBolt11Invoice {
864
864
& self . raw_invoice
865
865
}
866
866
867
- /// The hash of the [`RawInvoice `] that was signed.
867
+ /// The hash of the [`RawBolt11Invoice `] that was signed.
868
868
pub fn signable_hash ( & self ) -> & [ u8 ; 32 ] {
869
869
& self . hash
870
870
}
@@ -968,7 +968,7 @@ macro_rules! find_all_extract {
968
968
}
969
969
970
970
#[ allow( missing_docs) ]
971
- impl RawInvoice {
971
+ impl RawBolt11Invoice {
972
972
/// Hash the HRP as bytes and signatureless data part.
973
973
fn hash_from_parts ( hrp_bytes : & [ u8 ] , data_without_signature : & [ u5 ] ) -> [ u8 ; 32 ] {
974
974
let preimage = construct_invoice_preimage ( hrp_bytes, data_without_signature) ;
@@ -977,31 +977,31 @@ impl RawInvoice {
977
977
hash
978
978
}
979
979
980
- /// Calculate the hash of the encoded `RawInvoice ` which should be signed.
980
+ /// Calculate the hash of the encoded `RawBolt11Invoice ` which should be signed.
981
981
pub fn signable_hash ( & self ) -> [ u8 ; 32 ] {
982
982
use bech32:: ToBase32 ;
983
983
984
- RawInvoice :: hash_from_parts (
984
+ RawBolt11Invoice :: hash_from_parts (
985
985
self . hrp . to_string ( ) . as_bytes ( ) ,
986
986
& self . data . to_base32 ( )
987
987
)
988
988
}
989
989
990
990
/// Signs the invoice using the supplied `sign_method`. This function MAY fail with an error of
991
- /// type `E`. Since the signature of a [`SignedRawInvoice `] is not required to be valid there
991
+ /// type `E`. Since the signature of a [`SignedRawBolt11Invoice `] is not required to be valid there
992
992
/// are no constraints regarding the validity of the produced signature.
993
993
///
994
994
/// This is not exported to bindings users as we don't currently support passing function pointers into methods
995
995
/// explicitly.
996
- pub fn sign < F , E > ( self , sign_method : F ) -> Result < SignedRawInvoice , E >
996
+ pub fn sign < F , E > ( self , sign_method : F ) -> Result < SignedRawBolt11Invoice , E >
997
997
where F : FnOnce ( & Message ) -> Result < RecoverableSignature , E >
998
998
{
999
999
let raw_hash = self . signable_hash ( ) ;
1000
1000
let hash = Message :: from_slice ( & raw_hash[ ..] )
1001
1001
. expect ( "Hash is 32 bytes long, same as MESSAGE_SIZE" ) ;
1002
1002
let signature = sign_method ( & hash) ?;
1003
1003
1004
- Ok ( SignedRawInvoice {
1004
+ Ok ( SignedRawBolt11Invoice {
1005
1005
raw_invoice : self ,
1006
1006
hash : raw_hash,
1007
1007
signature : InvoiceSignature ( signature) ,
@@ -1143,13 +1143,13 @@ impl From<PositiveTimestamp> for SystemTime {
1143
1143
}
1144
1144
1145
1145
impl Bolt11Invoice {
1146
- /// The hash of the [`RawInvoice `] that was signed.
1146
+ /// The hash of the [`RawBolt11Invoice `] that was signed.
1147
1147
pub fn signable_hash ( & self ) -> [ u8 ; 32 ] {
1148
1148
self . signed_invoice . hash
1149
1149
}
1150
1150
1151
1151
/// Transform the `Bolt11Invoice` into its unchecked version.
1152
- pub fn into_signed_raw ( self ) -> SignedRawInvoice {
1152
+ pub fn into_signed_raw ( self ) -> SignedRawBolt11Invoice {
1153
1153
self . signed_invoice
1154
1154
}
1155
1155
@@ -1252,7 +1252,7 @@ impl Bolt11Invoice {
1252
1252
Ok ( ( ) )
1253
1253
}
1254
1254
1255
- /// Constructs a `Bolt11Invoice` from a [`SignedRawInvoice `] by checking all its invariants.
1255
+ /// Constructs a `Bolt11Invoice` from a [`SignedRawBolt11Invoice `] by checking all its invariants.
1256
1256
/// ```
1257
1257
/// use lightning_invoice::*;
1258
1258
///
@@ -1268,11 +1268,11 @@ impl Bolt11Invoice {
1268
1268
/// 8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\
1269
1269
/// j5r6drg6k6zcqj0fcwg";
1270
1270
///
1271
- /// let signed = invoice.parse::<SignedRawInvoice >().unwrap();
1271
+ /// let signed = invoice.parse::<SignedRawBolt11Invoice >().unwrap();
1272
1272
///
1273
1273
/// assert!(Bolt11Invoice::from_signed(signed).is_ok());
1274
1274
/// ```
1275
- pub fn from_signed ( signed_invoice : SignedRawInvoice ) -> Result < Self , SemanticError > {
1275
+ pub fn from_signed ( signed_invoice : SignedRawBolt11Invoice ) -> Result < Self , SemanticError > {
1276
1276
let invoice = Bolt11Invoice {
1277
1277
signed_invoice,
1278
1278
} ;
@@ -1599,15 +1599,15 @@ impl Deref for InvoiceSignature {
1599
1599
}
1600
1600
}
1601
1601
1602
- impl Deref for SignedRawInvoice {
1603
- type Target = RawInvoice ;
1602
+ impl Deref for SignedRawBolt11Invoice {
1603
+ type Target = RawBolt11Invoice ;
1604
1604
1605
- fn deref ( & self ) -> & RawInvoice {
1605
+ fn deref ( & self ) -> & RawBolt11Invoice {
1606
1606
& self . raw_invoice
1607
1607
}
1608
1608
}
1609
1609
1610
- /// Errors that may occur when constructing a new [`RawInvoice `] or [`Bolt11Invoice`]
1610
+ /// Errors that may occur when constructing a new [`RawBolt11Invoice `] or [`Bolt11Invoice`]
1611
1611
#[ derive( Eq , PartialEq , Debug , Clone ) ]
1612
1612
pub enum CreationError {
1613
1613
/// The supplied description string was longer than 639 __bytes__ (see [`Description::new`])
@@ -1651,7 +1651,7 @@ impl Display for CreationError {
1651
1651
#[ cfg( feature = "std" ) ]
1652
1652
impl std:: error:: Error for CreationError { }
1653
1653
1654
- /// Errors that may occur when converting a [`RawInvoice `] to a [`Bolt11Invoice`]. They relate to
1654
+ /// Errors that may occur when converting a [`RawBolt11Invoice `] to a [`Bolt11Invoice`]. They relate to
1655
1655
/// the requirements sections in BOLT #11
1656
1656
#[ derive( Eq , PartialEq , Debug , Clone ) ]
1657
1657
pub enum SemanticError {
@@ -1760,10 +1760,10 @@ mod test {
1760
1760
1761
1761
#[ test]
1762
1762
fn test_calc_invoice_hash ( ) {
1763
- use crate :: { RawInvoice , RawHrp , RawDataPart , Currency , PositiveTimestamp } ;
1763
+ use crate :: { RawBolt11Invoice , RawHrp , RawDataPart , Currency , PositiveTimestamp } ;
1764
1764
use crate :: TaggedField :: * ;
1765
1765
1766
- let invoice = RawInvoice {
1766
+ let invoice = RawBolt11Invoice {
1767
1767
hrp : RawHrp {
1768
1768
currency : Currency :: Bitcoin ,
1769
1769
raw_amount : None ,
@@ -1797,11 +1797,11 @@ mod test {
1797
1797
use secp256k1:: Secp256k1 ;
1798
1798
use secp256k1:: ecdsa:: { RecoveryId , RecoverableSignature } ;
1799
1799
use secp256k1:: { SecretKey , PublicKey } ;
1800
- use crate :: { SignedRawInvoice , InvoiceSignature , RawInvoice , RawHrp , RawDataPart , Currency , Sha256 ,
1800
+ use crate :: { SignedRawBolt11Invoice , InvoiceSignature , RawBolt11Invoice , RawHrp , RawDataPart , Currency , Sha256 ,
1801
1801
PositiveTimestamp } ;
1802
1802
1803
- let invoice = SignedRawInvoice {
1804
- raw_invoice : RawInvoice {
1803
+ let invoice = SignedRawBolt11Invoice {
1804
+ raw_invoice : RawBolt11Invoice {
1805
1805
hrp : RawHrp {
1806
1806
currency : Currency :: Bitcoin ,
1807
1807
raw_amount : None ,
@@ -1866,12 +1866,12 @@ mod test {
1866
1866
use lightning:: ln:: features:: InvoiceFeatures ;
1867
1867
use secp256k1:: Secp256k1 ;
1868
1868
use secp256k1:: SecretKey ;
1869
- use crate :: { Bolt11Invoice , RawInvoice , RawHrp , RawDataPart , Currency , Sha256 , PositiveTimestamp ,
1869
+ use crate :: { Bolt11Invoice , RawBolt11Invoice , RawHrp , RawDataPart , Currency , Sha256 , PositiveTimestamp ,
1870
1870
SemanticError } ;
1871
1871
1872
1872
let private_key = SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ;
1873
1873
let payment_secret = lightning:: ln:: PaymentSecret ( [ 21 ; 32 ] ) ;
1874
- let invoice_template = RawInvoice {
1874
+ let invoice_template = RawBolt11Invoice {
1875
1875
hrp : RawHrp {
1876
1876
currency : Currency :: Bitcoin ,
1877
1877
raw_amount : None ,
0 commit comments