@@ -820,7 +820,7 @@ enum PackageMalleability {
820
820
///
821
821
/// As packages are time-sensitive, we fee-bump and rebroadcast them at scheduled intervals.
822
822
/// Failing to confirm a package translate as a loss of funds for the user.
823
- #[ derive( Clone , Debug , PartialEq , Eq ) ]
823
+ #[ derive( Clone , Debug , Eq ) ]
824
824
pub struct PackageTemplate {
825
825
// List of onchain outputs and solving data to generate satisfying witnesses.
826
826
inputs : Vec < ( BitcoinOutPoint , PackageSolvingData ) > ,
@@ -849,6 +849,50 @@ pub struct PackageTemplate {
849
849
height_timer : u32 ,
850
850
}
851
851
852
+ impl PartialEq for PackageTemplate {
853
+ fn eq ( & self , o : & Self ) -> bool {
854
+ if self . inputs != o. inputs
855
+ || self . malleability != o. malleability
856
+ || self . feerate_previous != o. feerate_previous
857
+ || self . height_timer != o. height_timer
858
+ {
859
+ return false ;
860
+ }
861
+ #[ cfg( test) ]
862
+ {
863
+ // In some cases we may reset `counterparty_spendable_height` to zero on reload, which
864
+ // can cause our test assertions that ChannelMonitors round-trip exactly to trip. Here
865
+ // we allow exactly the same case as we tweak in the `PackageTemplate` `Readable`
866
+ // implementation.
867
+ if self . counterparty_spendable_height == 0 {
868
+ for ( _, input) in self . inputs . iter ( ) {
869
+ if let PackageSolvingData :: RevokedHTLCOutput ( RevokedHTLCOutput {
870
+ htlc, ..
871
+ } ) = input
872
+ {
873
+ if !htlc. offered && htlc. cltv_expiry != 0 {
874
+ return true ;
875
+ }
876
+ }
877
+ }
878
+ }
879
+ if o. counterparty_spendable_height == 0 {
880
+ for ( _, input) in o. inputs . iter ( ) {
881
+ if let PackageSolvingData :: RevokedHTLCOutput ( RevokedHTLCOutput {
882
+ htlc, ..
883
+ } ) = input
884
+ {
885
+ if !htlc. offered && htlc. cltv_expiry != 0 {
886
+ return true ;
887
+ }
888
+ }
889
+ }
890
+ }
891
+ }
892
+ self . counterparty_spendable_height == o. counterparty_spendable_height
893
+ }
894
+ }
895
+
852
896
impl PackageTemplate {
853
897
pub ( crate ) fn can_merge_with ( & self , other : & PackageTemplate , cur_height : u32 ) -> bool {
854
898
match ( self . malleability , other. malleability ) {
0 commit comments