104
104
105
105
use bitcoin:: blockdata:: constants:: ChainHash ;
106
106
use bitcoin:: hash_types:: { WPubkeyHash , WScriptHash } ;
107
- use bitcoin:: hashes:: Hash ;
108
107
use bitcoin:: network:: constants:: Network ;
109
108
use bitcoin:: secp256k1:: { KeyPair , PublicKey , Secp256k1 , self } ;
110
109
use bitcoin:: secp256k1:: schnorr:: Signature ;
111
110
use bitcoin:: address:: { Address , Payload , WitnessProgram , WitnessVersion } ;
112
111
use bitcoin:: key:: TweakedPublicKey ;
113
112
use core:: convert:: { AsRef , TryFrom } ;
114
113
use core:: time:: Duration ;
114
+ use core:: hash:: { Hash , Hasher } ;
115
115
use crate :: io;
116
116
use crate :: blinded_path:: BlindedPath ;
117
117
use crate :: ln:: PaymentHash ;
@@ -390,6 +390,7 @@ macro_rules! invoice_builder_methods { (
390
390
/// Successive calls to this method will add another address. Caller is responsible for not
391
391
/// adding duplicate addresses and only calling if capable of receiving to P2WSH addresses.
392
392
pub fn fallback_v0_p2wsh( $( $self_mut) * $self: $self_type, script_hash: & WScriptHash ) -> $return_type {
393
+ use bitcoin:: hashes:: Hash ;
393
394
let address = FallbackAddress {
394
395
version: WitnessVersion :: V0 . to_num( ) ,
395
396
program: Vec :: from( script_hash. to_byte_array( ) ) ,
@@ -403,6 +404,7 @@ macro_rules! invoice_builder_methods { (
403
404
/// Successive calls to this method will add another address. Caller is responsible for not
404
405
/// adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses.
405
406
pub fn fallback_v0_p2wpkh( $( $self_mut) * $self: $self_type, pubkey_hash: & WPubkeyHash ) -> $return_type {
407
+ use bitcoin:: hashes:: Hash ;
406
408
let address = FallbackAddress {
407
409
version: WitnessVersion :: V0 . to_num( ) ,
408
410
program: Vec :: from( pubkey_hash. to_byte_array( ) ) ,
@@ -614,7 +616,6 @@ impl AsRef<TaggedHash> for UnsignedBolt12Invoice {
614
616
/// [`Refund`]: crate::offers::refund::Refund
615
617
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
616
618
#[ derive( Clone , Debug ) ]
617
- #[ cfg_attr( test, derive( PartialEq ) ) ]
618
619
pub struct Bolt12Invoice {
619
620
bytes : Vec < u8 > ,
620
621
contents : InvoiceContents ,
@@ -886,6 +887,20 @@ impl Bolt12Invoice {
886
887
}
887
888
}
888
889
890
+ impl PartialEq for Bolt12Invoice {
891
+ fn eq ( & self , other : & Self ) -> bool {
892
+ self . bytes . eq ( & other. bytes )
893
+ }
894
+ }
895
+
896
+ impl Eq for Bolt12Invoice { }
897
+
898
+ impl Hash for Bolt12Invoice {
899
+ fn hash < H : Hasher > ( & self , state : & mut H ) {
900
+ self . bytes . hash ( state) ;
901
+ }
902
+ }
903
+
889
904
impl InvoiceContents {
890
905
/// Whether the original offer or refund has expired.
891
906
#[ cfg( feature = "std" ) ]
0 commit comments