@@ -474,9 +474,7 @@ where
474
474
fn regenerate_spend_if_necessary (
475
475
& self , sweeper_state : & mut SweeperState ,
476
476
) -> 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 | {
480
478
if o. status . is_confirmed ( ) {
481
479
// Don't rebroadcast confirmed txs.
482
480
return false ;
@@ -495,8 +493,15 @@ where
495
493
true
496
494
} ;
497
495
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 ( ) ;
500
505
501
506
if respend_descriptors. is_empty ( ) {
502
507
// Nothing to do.
@@ -520,7 +525,8 @@ where
520
525
521
526
// As we didn't modify the state so far, the same filter_fn yields the same elements as
522
527
// 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) ) ;
524
530
for output_info in respend_outputs {
525
531
if let Some ( filter) = self . chain_data_source . as_ref ( ) {
526
532
let watched_output = output_info. to_watched_output ( cur_hash) ;
0 commit comments