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