@@ -525,11 +525,18 @@ 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
+ let mut last_err = None ;
531
+ for ( force_conflicting_utxo_spend, tolerate_high_network_feerates) in configs {
532
+ log_debug ! (
533
+ self . logger,
534
+ "Attempting coin selection targeting {} sat/kW (force_conflicting_utxo_spend = {}, tolerate_high_network_feerates = {})" ,
535
+ target_feerate_sat_per_1000_weight,
536
+ force_conflicting_utxo_spend,
537
+ tolerate_high_network_feerates
538
+ ) ;
539
+ let attempt = self . select_confirmed_utxos_internal (
533
540
& utxos,
534
541
claim_id,
535
542
force_conflicting_utxo_spend,
@@ -538,12 +545,13 @@ where
538
545
preexisting_tx_weight,
539
546
input_amount_sat,
540
547
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 ) )
548
+ ) ;
549
+ if attempt. is_ok ( ) {
550
+ return attempt;
551
+ }
552
+ last_err = Some ( attempt) ;
553
+ }
554
+ last_err. unwrap ( )
547
555
}
548
556
549
557
fn sign_psbt ( & self , psbt : Psbt ) -> Result < Transaction , ( ) > {
0 commit comments