aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/spend.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/spend.cpp')
-rw-r--r--src/wallet/spend.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index 9a7e166e68..b9b4666208 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -4,10 +4,12 @@
#include <algorithm>
#include <common/args.h>
+#include <common/messages.h>
#include <common/system.h>
#include <consensus/amount.h>
#include <consensus/validation.h>
#include <interfaces/chain.h>
+#include <node/types.h>
#include <numeric>
#include <policy/policy.h>
#include <primitives/transaction.h>
@@ -15,7 +17,6 @@
#include <script/signingprovider.h>
#include <script/solver.h>
#include <util/check.h>
-#include <util/fees.h>
#include <util/moneystr.h>
#include <util/rbf.h>
#include <util/trace.h>
@@ -29,7 +30,10 @@
#include <cmath>
+using common::StringForFeeReason;
+using common::TransactionErrorString;
using interfaces::FoundBlock;
+using node::TransactionError;
namespace wallet {
static constexpr size_t OUTPUT_GROUP_MAX_ENTRIES{100};
@@ -132,7 +136,7 @@ static std::optional<int64_t> GetSignedTxinWeight(const CWallet* wallet, const C
// txouts needs to be in the order of tx.vin
TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const std::vector<CTxOut>& txouts, const CCoinControl* coin_control)
{
- // nVersion + nLockTime + input count + output count
+ // version + nLockTime + input count + output count
int64_t weight = (4 + 4 + GetSizeOfCompactSize(tx.vin.size()) + GetSizeOfCompactSize(tx.vout.size())) * WITNESS_SCALE_FACTOR;
// Whether any input spends a witness program. Necessary to run before the next loop over the
// inputs in order to accurately compute the compactSize length for the witness data per input.
@@ -256,7 +260,7 @@ static OutputType GetOutputType(TxoutType type, bool is_from_p2sh)
// Fetch and validate the coin control selected inputs.
// Coins could be internal (from the wallet) or external.
util::Result<PreSelectedInputs> FetchSelectedInputs(const CWallet& wallet, const CCoinControl& coin_control,
- const CoinSelectionParams& coin_selection_params) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
+ const CoinSelectionParams& coin_selection_params)
{
PreSelectedInputs result;
const bool can_grind_r = wallet.CanGrindR();
@@ -711,7 +715,7 @@ util::Result<SelectionResult> ChooseSelectionResult(interfaces::Chain& chain, co
if (coin_selection_params.m_effective_feerate > CFeeRate{3 * coin_selection_params.m_long_term_feerate}) { // Minimize input set for feerates of at least 3×LTFRE (default: 30 ṩ/vB+)
if (auto cg_result{CoinGrinder(groups.positive_group, nTargetValue, coin_selection_params.m_min_change_target, max_inputs_weight)}) {
- cg_result->ComputeAndSetWaste(coin_selection_params.min_viable_change, coin_selection_params.m_cost_of_change, coin_selection_params.m_change_fee);
+ cg_result->RecalculateWaste(coin_selection_params.min_viable_change, coin_selection_params.m_cost_of_change, coin_selection_params.m_change_fee);
results.push_back(*cg_result);
} else {
append_error(std::move(cg_result));
@@ -746,7 +750,7 @@ util::Result<SelectionResult> ChooseSelectionResult(interfaces::Chain& chain, co
if (bump_fee_overestimate) {
result.SetBumpFeeDiscount(bump_fee_overestimate);
}
- result.ComputeAndSetWaste(coin_selection_params.min_viable_change, coin_selection_params.m_cost_of_change, coin_selection_params.m_change_fee);
+ result.RecalculateWaste(coin_selection_params.min_viable_change, coin_selection_params.m_cost_of_change, coin_selection_params.m_change_fee);
}
// Choose the result with the least waste
@@ -771,7 +775,7 @@ util::Result<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& av
if (selection_target <= 0) {
SelectionResult result(nTargetValue, SelectionAlgorithm::MANUAL);
result.AddInputs(pre_set_inputs.coins, coin_selection_params.m_subtract_fee_outputs);
- result.ComputeAndSetWaste(coin_selection_params.min_viable_change, coin_selection_params.m_cost_of_change, coin_selection_params.m_change_fee);
+ result.RecalculateWaste(coin_selection_params.min_viable_change, coin_selection_params.m_cost_of_change, coin_selection_params.m_change_fee);
return result;
}
@@ -792,7 +796,7 @@ util::Result<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& av
SelectionResult preselected(pre_set_inputs.total_amount, SelectionAlgorithm::MANUAL);
preselected.AddInputs(pre_set_inputs.coins, coin_selection_params.m_subtract_fee_outputs);
op_selection_result->Merge(preselected);
- op_selection_result->ComputeAndSetWaste(coin_selection_params.min_viable_change,
+ op_selection_result->RecalculateWaste(coin_selection_params.min_viable_change,
coin_selection_params.m_cost_of_change,
coin_selection_params.m_change_fee);
}
@@ -985,7 +989,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
CMutableTransaction txNew; // The resulting transaction that we make
if (coin_control.m_version) {
- txNew.nVersion = coin_control.m_version.value();
+ txNew.version = coin_control.m_version.value();
}
CoinSelectionParams coin_selection_params{rng_fast}; // Parameters for coin selection, init with dummy
@@ -1084,7 +1088,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
const auto change_spend_fee = coin_selection_params.m_discard_feerate.GetFee(coin_selection_params.change_spend_size);
coin_selection_params.min_viable_change = std::max(change_spend_fee + 1, dust);
- // Static vsize overhead + outputs vsize. 4 nVersion, 4 nLocktime, 1 input count, 1 witness overhead (dummy, flag, stack size)
+ // Static vsize overhead + outputs vsize. 4 version, 4 nLocktime, 1 input count, 1 witness overhead (dummy, flag, stack size)
coin_selection_params.tx_noinputs_size = 10 + GetSizeOfCompactSize(vecSend.size()); // bytes for output count
// vouts to the payees
@@ -1394,7 +1398,7 @@ util::Result<CreatedTransactionResult> FundTransaction(CWallet& wallet, const CM
coinControl.m_locktime = tx.nLockTime;
// Set the user desired version
- coinControl.m_version = tx.nVersion;
+ coinControl.m_version = tx.version;
// Acquire the locks to prevent races to the new locked unspents between the
// CreateTransaction call and LockCoin calls (when lockUnspents is true).