@@ -528,11 +528,17 @@ where
528528 ( ( BASE_TX_SIZE + total_output_size) * WITNESS_SCALE_FACTOR as u64 ) ;
529529 let input_amount_sat = must_spend. iter ( ) . map ( |input| input. previous_utxo . value ) . sum ( ) ;
530530 let target_amount_sat = must_pay_to. iter ( ) . map ( |output| output. value ) . sum ( ) ;
531- let do_coin_selection = |force_conflicting_utxo_spend : bool ,
532- tolerate_high_network_feerates : bool | {
533- log_debug ! ( self . logger, "Attempting coin selection targeting {} sat/kW (force_conflicting_utxo_spend = {}, tolerate_high_network_feerates = {})" ,
534- target_feerate_sat_per_1000_weight, force_conflicting_utxo_spend, tolerate_high_network_feerates) ;
535- self . select_confirmed_utxos_internal (
531+
532+ let configs = [ ( false , false ) , ( false , true ) , ( true , false ) , ( true , true ) ] ;
533+ for ( force_conflicting_utxo_spend, tolerate_high_network_feerates) in configs {
534+ log_debug ! (
535+ self . logger,
536+ "Attempting coin selection targeting {} sat/kW (force_conflicting_utxo_spend = {}, tolerate_high_network_feerates = {})" ,
537+ target_feerate_sat_per_1000_weight,
538+ force_conflicting_utxo_spend,
539+ tolerate_high_network_feerates
540+ ) ;
541+ let attempt = self . select_confirmed_utxos_internal (
536542 & utxos,
537543 claim_id,
538544 force_conflicting_utxo_spend,
@@ -541,12 +547,12 @@ where
541547 preexisting_tx_weight,
542548 input_amount_sat,
543549 target_amount_sat,
544- )
545- } ;
546- do_coin_selection ( false , false )
547- . or_else ( |_| do_coin_selection ( false , true ) )
548- . or_else ( |_| do_coin_selection ( true , false ) )
549- . or_else ( |_| do_coin_selection ( true , true ) )
550+ ) ;
551+ if attempt . is_ok ( ) {
552+ return attempt ;
553+ }
554+ }
555+ Err ( ( ) )
550556 }
551557
552558 fn sign_psbt ( & self , psbt : Psbt ) -> Result < Transaction , ( ) > {
0 commit comments