@@ -560,7 +560,7 @@ mod integration {
560
560
// POST payjoin
561
561
let proposal =
562
562
session. process_res ( response. bytes ( ) . await ?. to_vec ( ) . as_slice ( ) , ctx) ?. unwrap ( ) ;
563
- let inputs = receiver_utxos. iter ( ) . map ( input_pair_from_list_unspent) . collect ( ) ;
563
+ let inputs = receiver_utxos. into_iter ( ) . map ( input_pair_from_list_unspent) . collect ( ) ;
564
564
let mut payjoin_proposal =
565
565
handle_directory_proposal ( & receiver, proposal, Some ( inputs) ) ;
566
566
assert ! ( !payjoin_proposal. is_output_substitution_disabled( ) ) ;
@@ -874,24 +874,18 @@ mod integration {
874
874
let inputs = match custom_inputs {
875
875
Some ( inputs) => inputs,
876
876
None => {
877
- let available_inputs =
878
- receiver. list_unspent ( None , None , None , None , None ) . unwrap ( ) ;
879
- let candidate_inputs: HashMap < Amount , OutPoint > = available_inputs
880
- . iter ( )
881
- . map ( |i| ( i. amount , OutPoint { txid : i. txid , vout : i. vout } ) )
882
- . collect ( ) ;
883
-
884
- let selected_outpoint = payjoin
877
+ let candidate_inputs = receiver
878
+ . list_unspent ( None , None , None , None , None )
879
+ . unwrap ( )
880
+ . into_iter ( )
881
+ . map ( input_pair_from_list_unspent) ;
882
+ let selected_input = payjoin
885
883
. try_preserving_privacy ( candidate_inputs)
886
- . expect ( "Failed to make privacy preserving selection" ) ;
887
- let selected_utxo = available_inputs
888
- . iter ( )
889
- . find ( |i| {
890
- i. txid == selected_outpoint. txid && i. vout == selected_outpoint. vout
884
+ . map_err ( |e| {
885
+ format ! ( "Failed to make privacy preserving selection: {:?}" , e)
891
886
} )
892
887
. unwrap ( ) ;
893
- let input_pair = input_pair_from_list_unspent ( selected_utxo) ;
894
- vec ! [ input_pair]
888
+ vec ! [ selected_input]
895
889
}
896
890
} ;
897
891
let payjoin = payjoin. contribute_inputs ( inputs) . unwrap ( ) . commit_inputs ( ) ;
@@ -1043,7 +1037,7 @@ mod integration {
1043
1037
. script_pubkey( ) ,
1044
1038
} ] ;
1045
1039
let drain_script = outputs[ 0 ] . script_pubkey . clone ( ) ;
1046
- let inputs = receiver_utxos. iter ( ) . map ( input_pair_from_list_unspent) . collect ( ) ;
1040
+ let inputs = receiver_utxos. into_iter ( ) . map ( input_pair_from_list_unspent) . collect ( ) ;
1047
1041
let response = handle_v1_pj_request (
1048
1042
req,
1049
1043
headers,
@@ -1309,21 +1303,14 @@ mod integration {
1309
1303
let inputs = match custom_inputs {
1310
1304
Some ( inputs) => inputs,
1311
1305
None => {
1312
- let available_inputs = receiver. list_unspent ( None , None , None , None , None ) ?;
1313
- let candidate_inputs: HashMap < Amount , OutPoint > = available_inputs
1314
- . iter ( )
1315
- . map ( |i| ( i. amount , OutPoint { txid : i. txid , vout : i. vout } ) )
1316
- . collect ( ) ;
1317
-
1318
- let selected_outpoint = payjoin
1306
+ let candidate_inputs = receiver
1307
+ . list_unspent ( None , None , None , None , None ) ?
1308
+ . into_iter ( )
1309
+ . map ( input_pair_from_list_unspent) ;
1310
+ let selected_input = payjoin
1319
1311
. try_preserving_privacy ( candidate_inputs)
1320
1312
. map_err ( |e| format ! ( "Failed to make privacy preserving selection: {:?}" , e) ) ?;
1321
- let selected_utxo = available_inputs
1322
- . iter ( )
1323
- . find ( |i| i. txid == selected_outpoint. txid && i. vout == selected_outpoint. vout )
1324
- . unwrap ( ) ;
1325
- let input_pair = input_pair_from_list_unspent ( selected_utxo) ;
1326
- vec ! [ input_pair]
1313
+ vec ! [ selected_input]
1327
1314
}
1328
1315
} ;
1329
1316
let payjoin = payjoin
@@ -1388,7 +1375,7 @@ mod integration {
1388
1375
}
1389
1376
1390
1377
fn input_pair_from_list_unspent (
1391
- utxo : & bitcoind:: bitcoincore_rpc:: bitcoincore_rpc_json:: ListUnspentResultEntry ,
1378
+ utxo : bitcoind:: bitcoincore_rpc:: bitcoincore_rpc_json:: ListUnspentResultEntry ,
1392
1379
) -> ( PsbtInput , TxIn ) {
1393
1380
let psbtin = PsbtInput {
1394
1381
// NOTE: non_witness_utxo is not necessary because bitcoin-cli always supplies
0 commit comments