@@ -236,7 +236,7 @@ pub struct InvoiceBuilder<D: tb::Bool, H: tb::Bool, T: tb::Bool, C: tb::Bool, S:
236
236
/// 1. using `InvoiceBuilder`
237
237
/// 2. using `Invoice::from_signed(SignedRawInvoice)`
238
238
/// 3. using `str::parse::<Invoice>(&str)`
239
- #[ derive( Eq , PartialEq , Debug , Clone ) ]
239
+ #[ derive( Eq , PartialEq , Debug , Clone , Hash ) ]
240
240
pub struct Invoice {
241
241
signed_invoice : SignedRawInvoice ,
242
242
}
@@ -260,7 +260,7 @@ pub enum InvoiceDescription<'f> {
260
260
///
261
261
/// # Invariants
262
262
/// The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`.
263
- #[ derive( Eq , PartialEq , Debug , Clone ) ]
263
+ #[ derive( Eq , PartialEq , Debug , Clone , Hash ) ]
264
264
pub struct SignedRawInvoice {
265
265
/// The rawInvoice that the signature belongs to
266
266
raw_invoice : RawInvoice ,
@@ -283,7 +283,7 @@ pub struct SignedRawInvoice {
283
283
/// De- and encoding should not lead to information loss but may lead to different hashes.
284
284
///
285
285
/// For methods without docs see the corresponding methods in `Invoice`.
286
- #[ derive( Eq , PartialEq , Debug , Clone ) ]
286
+ #[ derive( Eq , PartialEq , Debug , Clone , Hash ) ]
287
287
pub struct RawInvoice {
288
288
/// human readable part
289
289
pub hrp : RawHrp ,
@@ -295,7 +295,7 @@ pub struct RawInvoice {
295
295
/// Data of the `RawInvoice` that is encoded in the human readable part
296
296
///
297
297
/// (C-not exported) As we don't yet support Option<Enum>
298
- #[ derive( Eq , PartialEq , Debug , Clone ) ]
298
+ #[ derive( Eq , PartialEq , Debug , Clone , Hash ) ]
299
299
pub struct RawHrp {
300
300
/// The currency deferred from the 3rd and 4th character of the bech32 transaction
301
301
pub currency : Currency ,
@@ -308,7 +308,7 @@ pub struct RawHrp {
308
308
}
309
309
310
310
/// Data of the `RawInvoice` that is encoded in the data part
311
- #[ derive( Eq , PartialEq , Debug , Clone ) ]
311
+ #[ derive( Eq , PartialEq , Debug , Clone , Hash ) ]
312
312
pub struct RawDataPart {
313
313
/// generation time of the invoice
314
314
pub timestamp : PositiveTimestamp ,
@@ -323,11 +323,11 @@ pub struct RawDataPart {
323
323
///
324
324
/// The Unix timestamp representing the stored time has to be positive and no greater than
325
325
/// [`MAX_TIMESTAMP`].
326
- #[ derive( Eq , PartialEq , Debug , Clone ) ]
326
+ #[ derive( Eq , PartialEq , Debug , Clone , Hash ) ]
327
327
pub struct PositiveTimestamp ( Duration ) ;
328
328
329
329
/// SI prefixes for the human readable part
330
- #[ derive( Eq , PartialEq , Debug , Clone , Copy ) ]
330
+ #[ derive( Eq , PartialEq , Debug , Clone , Copy , Hash ) ]
331
331
pub enum SiPrefix {
332
332
/// 10^-3
333
333
Milli ,
@@ -1415,6 +1415,15 @@ impl Deref for SignedRawInvoice {
1415
1415
}
1416
1416
}
1417
1417
1418
+ impl core:: hash:: Hash for InvoiceSignature {
1419
+ fn hash < H : core:: hash:: Hasher > ( & self , state : & mut H ) {
1420
+ let ( recovery_id, sig) = self . 0 . serialize_compact ( ) ;
1421
+ let recovery_id = recovery_id. to_i32 ( ) ;
1422
+ state. write ( & sig) ;
1423
+ state. write_i32 ( recovery_id) ;
1424
+ }
1425
+ }
1426
+
1418
1427
/// Errors that may occur when constructing a new `RawInvoice` or `Invoice`
1419
1428
#[ derive( Eq , PartialEq , Debug , Clone ) ]
1420
1429
pub enum CreationError {
0 commit comments