Skip to content

Commit

Permalink
update async__send_funds to re-use decoys across tx attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
j-berman committed Jul 12, 2022
1 parent e63fe57 commit fab3d09
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/monero_send_routine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,32 @@ void _reenterable_construct_and_send_tx(
] (
const property_tree::ptree &res
) -> void {
auto parsed_res = new__parsed_res__get_random_outs(res);
auto parsed_res = (res != boost::property_tree::ptree{})
? new__parsed_res__get_random_outs(res)
: LightwalletAPI_Res_GetRandomOuts{ boost::none/*err_msg*/, vector<RandomAmountOutputs>{}/*mix_outs*/ };
if (parsed_res.err_msg != none) {
SendFunds_Error_RetVals error_retVals;
error_retVals.explicit_errMsg = std::move(*(parsed_res.err_msg));
args.error_cb_fn(error_retVals);
return;
}

Tie_Outs_to_Mix_Outs_RetVals tie_outs_to_mix_outs_retVals;
monero_transfer_utils::pre_step2_tie_unspent_outs_to_mix_outs_for_all_future_tx_attempts(
tie_outs_to_mix_outs_retVals,
//
step1_retVals.using_outs,
*(parsed_res.mix_outs),
//
prior_attempt_unspent_outs_to_mix_outs
);
if (tie_outs_to_mix_outs_retVals.errCode != noError) {
SendFunds_Error_RetVals error_retVals;
error_retVals.errCode = tie_outs_to_mix_outs_retVals.errCode;
args.error_cb_fn(error_retVals);
return;
}

Send_Step2_RetVals step2_retVals;
monero_transfer_utils::send_step2__try_create_transaction(
step2_retVals,
Expand All @@ -406,7 +425,7 @@ void _reenterable_construct_and_send_tx(
step1_retVals.using_outs,
args.fee_per_b,
args.fee_quantization_mask,
*(parsed_res.mix_outs),
tie_outs_to_mix_outs_retVals.mix_outs,
std::move(use_fork_rules),
args.unlock_time,
args.nettype
Expand All @@ -430,7 +449,7 @@ void _reenterable_construct_and_send_tx(
args,
//
step2_retVals.fee_actually_needed, // -> reconstruction attempt's step1's prior_attempt_size_calcd_fee
prior_attempt_unspent_outs_to_mix_outs,
tie_outs_to_mix_outs_retVals.prior_attempt_unspent_outs_to_mix_outs_new,
constructionAttempt+1
);
return;
Expand Down Expand Up @@ -481,10 +500,16 @@ void _reenterable_construct_and_send_tx(
//
args.status_update_fn(fetchingDecoyOutputs);
//
args.get_random_outs_fn(
new__req_params__get_random_outs(step1_retVals.using_outs, prior_attempt_unspent_outs_to_mix_outs),
get_random_outs_fn__cb_fn
// we won't need to make request for random outs every tx construction attempt, if already passed in out for all outs
auto req_params = new__req_params__get_random_outs(
step1_retVals.using_outs,
prior_attempt_unspent_outs_to_mix_outs
);
if (req_params.amounts.size() > 0) {
args.get_random_outs_fn(req_params, get_random_outs_fn__cb_fn);
} else {
get_random_outs_fn__cb_fn(boost::property_tree::ptree{});
}
}
//
//
Expand Down

0 comments on commit fab3d09

Please sign in to comment.