Skip to content

Commit 7362f8e

Browse files
committed
refactor: make CoinsResult total amounts members private
1 parent 3282fad commit 7362f8e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/wallet/spend.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ CoinsResult AvailableCoins(const CWallet& wallet,
332332

333333
// Checks the sum amount of all UTXO's.
334334
if (params.min_sum_amount != MAX_MONEY) {
335-
if (result.total_amount >= params.min_sum_amount) {
335+
if (result.GetTotalAmount() >= params.min_sum_amount) {
336336
return result;
337337
}
338338
}
@@ -356,7 +356,7 @@ CoinsResult AvailableCoinsListUnspent(const CWallet& wallet, const CCoinControl*
356356
CAmount GetAvailableBalance(const CWallet& wallet, const CCoinControl* coinControl)
357357
{
358358
LOCK(wallet.cs_wallet);
359-
return AvailableCoins(wallet, coinControl).total_amount;
359+
return AvailableCoins(wallet, coinControl).GetTotalAmount();
360360
}
361361

362362
const CTxOut& FindNonChangeParentOutput(const CWallet& wallet, const CTransaction& tx, int output)
@@ -586,8 +586,8 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& a
586586

587587
// Return early if we cannot cover the target with the wallet's UTXO.
588588
// We use the total effective value if we are not subtracting fee from outputs and 'available_coins' contains the data.
589-
CAmount available_coins_total_amount = coin_selection_params.m_subtract_fee_outputs ? available_coins.total_amount :
590-
(available_coins.total_effective_amount.has_value() ? *available_coins.total_effective_amount : 0);
589+
CAmount available_coins_total_amount = coin_selection_params.m_subtract_fee_outputs ? available_coins.GetTotalAmount() :
590+
(available_coins.GetEffectiveTotalAmount().has_value() ? *available_coins.GetEffectiveTotalAmount() : 0);
591591
if (selection_target > available_coins_total_amount) {
592592
return std::nullopt; // Insufficient funds
593593
}

src/wallet/spend.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ struct CoinsResult {
5151
void Shuffle(FastRandomContext& rng_fast);
5252
void Add(OutputType type, const COutput& out);
5353

54+
CAmount GetTotalAmount() { return total_amount; }
55+
std::optional<CAmount> GetEffectiveTotalAmount() {return total_effective_amount; }
56+
57+
private:
5458
/** Sum of all available coins raw value */
5559
CAmount total_amount{0};
5660
/** Sum of all available coins effective value (each output value minus fees required to spend it) */

0 commit comments

Comments
 (0)