@@ -13,6 +13,7 @@ use lightning::util::ser::Writeable;
1313use bitcoin:: secp256k1:: Secp256k1 ;
1414use bitcoin:: { BlockHash , BlockHeader , LockTime , PackedLockTime , Transaction , Txid } ;
1515
16+ use std:: collections:: HashSet ;
1617use std:: ops:: Deref ;
1718use std:: sync:: { Arc , Mutex } ;
1819
@@ -267,18 +268,14 @@ where
267268
268269 let mut locked_outputs = self . outputs . lock ( ) . unwrap ( ) ;
269270
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.
271272 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+ {
278276 let output_descriptors = vec ! [ output_info. descriptor. clone( ) ] ;
279277 match self . get_spending_tx ( & output_descriptors, height) {
280278 Ok ( Some ( spending_tx) ) => {
281- self . wallet . broadcast_transactions ( & [ & spending_tx] ) ;
282279 if let Some ( filter) = self . chain_source . as_ref ( ) {
283280 if let Some ( tx_out) = spending_tx. output . first ( ) {
284281 filter. register_tx ( & spending_tx. txid ( ) , & tx_out. script_pubkey ) ;
@@ -333,6 +330,13 @@ where
333330 }
334331 true
335332 } ) ;
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 < _ > > ( ) ) ;
336340 }
337341
338342 fn get_relevant_txids ( & self ) -> Vec < ( Txid , Option < BlockHash > ) > {
0 commit comments