aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wallet/spend.cpp8
-rw-r--r--src/wallet/spend.h4
2 files changed, 8 insertions, 4 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index 19f9048dbf..52d10b74b5 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -332,7 +332,7 @@ CoinsResult AvailableCoins(const CWallet& wallet,
// Checks the sum amount of all UTXO's.
if (params.min_sum_amount != MAX_MONEY) {
- if (result.total_amount >= params.min_sum_amount) {
+ if (result.GetTotalAmount() >= params.min_sum_amount) {
return result;
}
}
@@ -356,7 +356,7 @@ CoinsResult AvailableCoinsListUnspent(const CWallet& wallet, const CCoinControl*
CAmount GetAvailableBalance(const CWallet& wallet, const CCoinControl* coinControl)
{
LOCK(wallet.cs_wallet);
- return AvailableCoins(wallet, coinControl).total_amount;
+ return AvailableCoins(wallet, coinControl).GetTotalAmount();
}
const CTxOut& FindNonChangeParentOutput(const CWallet& wallet, const CTransaction& tx, int output)
@@ -586,8 +586,8 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& a
// Return early if we cannot cover the target with the wallet's UTXO.
// We use the total effective value if we are not subtracting fee from outputs and 'available_coins' contains the data.
- CAmount available_coins_total_amount = coin_selection_params.m_subtract_fee_outputs ? available_coins.total_amount :
- (available_coins.total_effective_amount.has_value() ? *available_coins.total_effective_amount : 0);
+ CAmount available_coins_total_amount = coin_selection_params.m_subtract_fee_outputs ? available_coins.GetTotalAmount() :
+ (available_coins.GetEffectiveTotalAmount().has_value() ? *available_coins.GetEffectiveTotalAmount() : 0);
if (selection_target > available_coins_total_amount) {
return std::nullopt; // Insufficient funds
}
diff --git a/src/wallet/spend.h b/src/wallet/spend.h
index 8612ce49ad..2b861c2361 100644
--- a/src/wallet/spend.h
+++ b/src/wallet/spend.h
@@ -51,6 +51,10 @@ struct CoinsResult {
void Shuffle(FastRandomContext& rng_fast);
void Add(OutputType type, const COutput& out);
+ CAmount GetTotalAmount() { return total_amount; }
+ std::optional<CAmount> GetEffectiveTotalAmount() {return total_effective_amount; }
+
+private:
/** Sum of all available coins raw value */
CAmount total_amount{0};
/** Sum of all available coins effective value (each output value minus fees required to spend it) */