@@ -13,6 +13,7 @@ use lightning::util::ser::Writeable;
13
13
use bitcoin:: secp256k1:: Secp256k1 ;
14
14
use bitcoin:: { BlockHash , BlockHeader , LockTime , PackedLockTime , Transaction , Txid } ;
15
15
16
+ use std:: collections:: HashSet ;
16
17
use std:: ops:: Deref ;
17
18
use std:: sync:: { Arc , Mutex } ;
18
19
@@ -267,18 +268,14 @@ where
267
268
268
269
let mut locked_outputs = self . outputs . lock ( ) . unwrap ( ) ;
269
270
270
- // Rebroadcast all outputs that didn't get confirmed by now.
271
+ // Regenerate spending tx and fee bump all outputs that didn't get confirmed by now.
271
272
for output_info in locked_outputs. iter_mut ( ) . filter ( |o| o. confirmed_in_block . is_none ( ) ) {
272
- let should_broadcast = if let Some ( bcast_height) = output_info. broadcast_height {
273
- height >= bcast_height + num_blocks_from_conf_target ( ConfirmationTarget :: Background )
274
- } else {
275
- true
276
- } ;
277
- if should_broadcast {
273
+ let bcast_height = output_info. broadcast_height . unwrap_or ( 0 ) ;
274
+ if height >= bcast_height + num_blocks_from_conf_target ( ConfirmationTarget :: Background )
275
+ {
278
276
let output_descriptors = vec ! [ output_info. descriptor. clone( ) ] ;
279
277
match self . get_spending_tx ( & output_descriptors, height) {
280
278
Ok ( Some ( spending_tx) ) => {
281
- self . wallet . broadcast_transactions ( & [ & spending_tx] ) ;
282
279
if let Some ( filter) = self . chain_source . as_ref ( ) {
283
280
if let Some ( tx_out) = spending_tx. output . first ( ) {
284
281
filter. register_tx ( & spending_tx. txid ( ) , & tx_out. script_pubkey ) ;
@@ -333,6 +330,13 @@ where
333
330
}
334
331
true
335
332
} ) ;
333
+
334
+ // Rebroadcast all pending spending txs
335
+ let mut txs = locked_outputs
336
+ . iter ( )
337
+ . filter_map ( |o| o. spending_tx . as_ref ( ) )
338
+ . collect :: < HashSet < & Transaction > > ( ) ;
339
+ self . wallet . broadcast_transactions ( & txs. drain ( ) . collect :: < Vec < _ > > ( ) ) ;
336
340
}
337
341
338
342
fn get_relevant_txids ( & self ) -> Vec < ( Txid , Option < BlockHash > ) > {
0 commit comments