wallet: CreateTransaction(): return out-params as (optional) struct

This commit is contained in:
Sebastian Falbesoner
2020-12-13 03:15:40 +01:00
parent c9fdaa5e3a
commit 4c5ceb040c
7 changed files with 52 additions and 71 deletions

View File

@@ -218,21 +218,20 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
// We cannot source new unconfirmed inputs(bip125 rule 2)
new_coin_control.m_min_depth = 1;
CTransactionRef tx_new;
CAmount fee_ret;
int change_pos_in_out = -1; // No requested location for change
constexpr int RANDOM_CHANGE_POSITION = -1;
bilingual_str fail_reason;
FeeCalculation fee_calc_out;
if (!CreateTransaction(wallet, recipients, tx_new, fee_ret, change_pos_in_out, fail_reason, new_coin_control, fee_calc_out, false)) {
std::optional<CreatedTransactionResult> txr = CreateTransaction(wallet, recipients, RANDOM_CHANGE_POSITION, fail_reason, new_coin_control, fee_calc_out, false);
if (!txr) {
errors.push_back(Untranslated("Unable to create transaction.") + Untranslated(" ") + fail_reason);
return Result::WALLET_ERROR;
}
// Write back new fee if successful
new_fee = fee_ret;
new_fee = txr->fee;
// Write back transaction
mtx = CMutableTransaction(*tx_new);
mtx = CMutableTransaction(*txr->tx);
return Result::OK;
}