@@ -474,9 +474,7 @@ where
474474 fn regenerate_spend_if_necessary (
475475 & self , sweeper_state : & mut SweeperState ,
476476 ) -> Option < Transaction > {
477- let cur_height = sweeper_state. best_block . height ;
478- let cur_hash = sweeper_state. best_block . block_hash ;
479- let filter_fn = |o : & TrackedSpendableOutput | {
477+ let filter_fn = |o : & TrackedSpendableOutput , cur_height : u32 | {
480478 if o. status . is_confirmed ( ) {
481479 // Don't rebroadcast confirmed txs.
482480 return false ;
@@ -495,8 +493,15 @@ where
495493 true
496494 } ;
497495
498- let respend_descriptors: Vec < & SpendableOutputDescriptor > =
499- sweeper_state. outputs . iter ( ) . filter ( |o| filter_fn ( * o) ) . map ( |o| & o. descriptor ) . collect ( ) ;
496+ let cur_height = sweeper_state. best_block . height ;
497+ let cur_hash = sweeper_state. best_block . block_hash ;
498+
499+ let respend_descriptors: Vec < & SpendableOutputDescriptor > = sweeper_state
500+ . outputs
501+ . iter ( )
502+ . filter ( |o| filter_fn ( * o, cur_height) )
503+ . map ( |o| & o. descriptor )
504+ . collect ( ) ;
500505
501506 if respend_descriptors. is_empty ( ) {
502507 // Nothing to do.
@@ -520,7 +525,8 @@ where
520525
521526 // As we didn't modify the state so far, the same filter_fn yields the same elements as
522527 // above.
523- let respend_outputs = sweeper_state. outputs . iter_mut ( ) . filter ( |o| filter_fn ( & * * o) ) ;
528+ let respend_outputs =
529+ sweeper_state. outputs . iter_mut ( ) . filter ( |o| filter_fn ( & * * o, cur_height) ) ;
524530 for output_info in respend_outputs {
525531 if let Some ( filter) = self . chain_data_source . as_ref ( ) {
526532 let watched_output = output_info. to_watched_output ( cur_hash) ;
0 commit comments