Skip to content

Commit 8be652e

Browse files
committed
Merge bitcoin/bitcoin#25005: wallet: remove extra wtx lookup in 'AvailableCoins' + several code cleanups.
fd5c996 wallet: GetAvailableBalance, remove double walk-through every available coin (furszy) 162d4ad wallet: add 'only_spendable' filter to AvailableCoins (furszy) cdf185c wallet: remove unused IsSpentKey(hash, index) method (furszy) 4b83bf8 wallet: avoid extra IsSpentKey -> GetWalletTx lookups (furszy) 3d8a282 wallet: decouple IsSpentKey(scriptPubKey) from IsSpentKey(hash, n) (furszy) a06fa94 wallet: IsSpent, 'COutPoint' arg instead of (hash, index) (furszy) 91902b7 wallet: IsLockedCoin, 'COutPoint' arg instead of (hash, index) (furszy) 9472ca0 wallet: AvailableCoins, don't call 'wtx.tx->vout[i]' multiple times (furszy) 4ce235e wallet: return 'CoinsResult' struct in `AvailableCoins` (furszy) Pull request description: This started in #24845 but grew out of scope of it. So, points tackled: 1) Avoid extra `GetWalletTx` lookups inside `AvailableCoins -> IsSpentKey`. `IsSpentKey` was receiving the tx hash and index to internally lookup the tx inside the wallet's map. As all the `IsSpentKey` function callers already have the wtx available, them can provide the `scriptPubKey` directly. 2) Most of the time, we call `Wallet::AvailableCoins`, and later on the process, skip the non-spendable coins from the result in subsequent for-loops. So to speedup the process: introduced the ability to filter by "only_spendable" coins inside `Wallet::AvailableCoins` directly. (the non-spendable coins skip examples are inside `AttemptSelection->GroupOutputs` and `GetAvailableBalance`). 4) Refactored `AvailableCoins` in several ways: a) Now it will return a new struct `CoinsResult` instead of receiving the vCoins vector reference (which was being cleared at the beginning of the method anyway). --> this is coming from #24845 but cherry-picked it here too to make the following commits look nicer. b) Unified all the 'wtx.tx->vout[I]' calls into a single call (coming from this comment bitcoin/bitcoin#24699 (comment)). 5) The wallet `IsLockedCoin` and `IsSpent` methods now accept an `OutPoint` instead of a hash:index. Which let me cleanup a bunch of extra code. 6) Speeded up the wallet 'GetAvailableBalance': filtering `AvailableCoins` by spendable outputs only and using the 'AvailableCoins' retrieved `total_amount` instead of looping over all the retrieved coins once more. ------------------------------------------------------- Side topic, all this process will look even nicer with #25218 ACKs for top commit: achow101: ACK fd5c996 brunoerg: crACK fd5c996 w0xlt: Code Review ACK bitcoin/bitcoin@fd5c996 Tree-SHA512: 376a85476f907f4f7d1fc3de74b3dbe159b8cc24687374d8739711ad202ea07a33e86f4e66dece836da3ae6985147119fe584f6e672f11d0450ba6bd165b3220
2 parents f8586b2 + fd5c996 commit 8be652e

File tree

9 files changed

+118
-107
lines changed

9 files changed

+118
-107
lines changed

src/wallet/interfaces.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ WalletTxOut MakeWalletTxOut(const CWallet& wallet,
110110
result.txout = wtx.tx->vout[n];
111111
result.time = wtx.GetTxTime();
112112
result.depth_in_main_chain = depth;
113-
result.is_spent = wallet.IsSpent(wtx.GetHash(), n);
113+
result.is_spent = wallet.IsSpent(COutPoint(wtx.GetHash(), n));
114114
return result;
115115
}
116116

@@ -121,7 +121,7 @@ WalletTxOut MakeWalletTxOut(const CWallet& wallet,
121121
result.txout = output.txout;
122122
result.time = output.time;
123123
result.depth_in_main_chain = output.depth;
124-
result.is_spent = wallet.IsSpent(output.outpoint.hash, output.outpoint.n);
124+
result.is_spent = wallet.IsSpent(output.outpoint);
125125
return result;
126126
}
127127

@@ -245,7 +245,7 @@ class WalletImpl : public Wallet
245245
bool isLockedCoin(const COutPoint& output) override
246246
{
247247
LOCK(m_wallet->cs_wallet);
248-
return m_wallet->IsLockedCoin(output.hash, output.n);
248+
return m_wallet->IsLockedCoin(output);
249249
}
250250
void listLockedCoins(std::vector<COutPoint>& outputs) override
251251
{

src/wallet/receive.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,9 @@ CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx,
204204
bool allow_used_addresses = (filter & ISMINE_USED) || !wallet.IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE);
205205
CAmount nCredit = 0;
206206
uint256 hashTx = wtx.GetHash();
207-
for (unsigned int i = 0; i < wtx.tx->vout.size(); i++)
208-
{
209-
if (!wallet.IsSpent(hashTx, i) && (allow_used_addresses || !wallet.IsSpentKey(hashTx, i))) {
210-
const CTxOut &txout = wtx.tx->vout[i];
207+
for (unsigned int i = 0; i < wtx.tx->vout.size(); i++) {
208+
const CTxOut& txout = wtx.tx->vout[i];
209+
if (!wallet.IsSpent(COutPoint(hashTx, i)) && (allow_used_addresses || !wallet.IsSpentKey(txout.scriptPubKey))) {
211210
nCredit += OutputGetCredit(wallet, txout, filter);
212211
if (!MoneyRange(nCredit))
213212
throw std::runtime_error(std::string(__func__) + " : value out of range");
@@ -371,15 +370,15 @@ std::map<CTxDestination, CAmount> GetAddressBalances(const CWallet& wallet)
371370
if (nDepth < (CachedTxIsFromMe(wallet, wtx, ISMINE_ALL) ? 0 : 1))
372371
continue;
373372

374-
for (unsigned int i = 0; i < wtx.tx->vout.size(); i++)
375-
{
373+
for (unsigned int i = 0; i < wtx.tx->vout.size(); i++) {
374+
const auto& output = wtx.tx->vout[i];
376375
CTxDestination addr;
377-
if (!wallet.IsMine(wtx.tx->vout[i]))
376+
if (!wallet.IsMine(output))
378377
continue;
379-
if(!ExtractDestination(wtx.tx->vout[i].scriptPubKey, addr))
378+
if(!ExtractDestination(output.scriptPubKey, addr))
380379
continue;
381380

382-
CAmount n = wallet.IsSpent(walletEntry.first, i) ? 0 : wtx.tx->vout[i].nValue;
381+
CAmount n = wallet.IsSpent(COutPoint(walletEntry.first, i)) ? 0 : output.nValue;
383382
balances[addr] += n;
384383
}
385384
}

src/wallet/rpc/coins.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,11 @@ RPCHelpMan lockunspent()
341341
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout index out of bounds");
342342
}
343343

344-
if (pwallet->IsSpent(outpt.hash, outpt.n)) {
344+
if (pwallet->IsSpent(outpt)) {
345345
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected unspent output");
346346
}
347347

348-
const bool is_locked = pwallet->IsLockedCoin(outpt.hash, outpt.n);
348+
const bool is_locked = pwallet->IsLockedCoin(outpt);
349349

350350
if (fUnlock && !is_locked) {
351351
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected locked output");
@@ -638,7 +638,7 @@ RPCHelpMan listunspent()
638638
cctl.m_max_depth = nMaxDepth;
639639
cctl.m_include_unsafe_inputs = include_unsafe;
640640
LOCK(pwallet->cs_wallet);
641-
AvailableCoinsListUnspent(*pwallet, vecOutputs, &cctl, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount);
641+
vecOutputs = AvailableCoinsListUnspent(*pwallet, &cctl, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount).coins;
642642
}
643643

644644
LOCK(pwallet->cs_wallet);
@@ -649,7 +649,7 @@ RPCHelpMan listunspent()
649649
CTxDestination address;
650650
const CScript& scriptPubKey = out.txout.scriptPubKey;
651651
bool fValidAddress = ExtractDestination(scriptPubKey, address);
652-
bool reused = avoid_reuse && pwallet->IsSpentKey(out.outpoint.hash, out.outpoint.n);
652+
bool reused = avoid_reuse && pwallet->IsSpentKey(scriptPubKey);
653653

654654
if (destinations.size() && (!fValidAddress || !destinations.count(address)))
655655
continue;

src/wallet/rpc/spend.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,15 +1367,14 @@ RPCHelpMan sendall()
13671367

13681368
CMutableTransaction rawTx{ConstructTransaction(options["inputs"], recipient_key_value_pairs, options["locktime"], rbf)};
13691369
LOCK(pwallet->cs_wallet);
1370-
std::vector<COutput> all_the_utxos;
13711370

13721371
CAmount total_input_value(0);
13731372
bool send_max{options.exists("send_max") ? options["send_max"].get_bool() : false};
13741373
if (options.exists("inputs") && options.exists("send_max")) {
13751374
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot combine send_max with specific inputs.");
13761375
} else if (options.exists("inputs")) {
13771376
for (const CTxIn& input : rawTx.vin) {
1378-
if (pwallet->IsSpent(input.prevout.hash, input.prevout.n)) {
1377+
if (pwallet->IsSpent(input.prevout)) {
13791378
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Input not available. UTXO (%s:%d) was already spent.", input.prevout.hash.ToString(), input.prevout.n));
13801379
}
13811380
const CWalletTx* tx{pwallet->GetWalletTx(input.prevout.hash)};
@@ -1385,8 +1384,7 @@ RPCHelpMan sendall()
13851384
total_input_value += tx->tx->vout[input.prevout.n].nValue;
13861385
}
13871386
} else {
1388-
AvailableCoins(*pwallet, all_the_utxos, &coin_control, fee_rate, /*nMinimumAmount=*/0);
1389-
for (const COutput& output : all_the_utxos) {
1387+
for (const COutput& output : AvailableCoins(*pwallet, &coin_control, fee_rate, /*nMinimumAmount=*/0).coins) {
13901388
CHECK_NONFATAL(output.input_bytes > 0);
13911389
if (send_max && fee_rate.GetFee(output.input_bytes) > output.txout.nValue) {
13921390
continue;

src/wallet/spend.cpp

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,18 @@ TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *walle
8484
return CalculateMaximumSignedTxSize(tx, wallet, txouts, coin_control);
8585
}
8686

87-
void AvailableCoins(const CWallet& wallet, std::vector<COutput>& vCoins, const CCoinControl* coinControl, std::optional<CFeeRate> feerate, const CAmount& nMinimumAmount, const CAmount& nMaximumAmount, const CAmount& nMinimumSumAmount, const uint64_t nMaximumCount)
87+
CoinsResult AvailableCoins(const CWallet& wallet,
88+
const CCoinControl* coinControl,
89+
std::optional<CFeeRate> feerate,
90+
const CAmount& nMinimumAmount,
91+
const CAmount& nMaximumAmount,
92+
const CAmount& nMinimumSumAmount,
93+
const uint64_t nMaximumCount,
94+
bool only_spendable)
8895
{
8996
AssertLockHeld(wallet.cs_wallet);
9097

91-
vCoins.clear();
92-
CAmount nTotal = 0;
98+
CoinsResult result;
9399
// Either the WALLET_FLAG_AVOID_REUSE flag is not set (in which case we always allow), or we default to avoiding, and only in the case where
94100
// a coin control object is provided, and has the avoid address reuse flag set to false, do we allow already used addresses
95101
bool allow_used_addresses = !wallet.IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE) || (coinControl && !coinControl->m_avoid_address_reuse);
@@ -159,76 +165,81 @@ void AvailableCoins(const CWallet& wallet, std::vector<COutput>& vCoins, const C
159165
bool tx_from_me = CachedTxIsFromMe(wallet, wtx, ISMINE_ALL);
160166

161167
for (unsigned int i = 0; i < wtx.tx->vout.size(); i++) {
168+
const CTxOut& output = wtx.tx->vout[i];
169+
const COutPoint outpoint(wtxid, i);
170+
162171
// Only consider selected coins if add_inputs is false
163-
if (coinControl && !coinControl->m_add_inputs && !coinControl->IsSelected(COutPoint(entry.first, i))) {
172+
if (coinControl && !coinControl->m_add_inputs && !coinControl->IsSelected(outpoint)) {
164173
continue;
165174
}
166175

167-
if (wtx.tx->vout[i].nValue < nMinimumAmount || wtx.tx->vout[i].nValue > nMaximumAmount)
176+
if (output.nValue < nMinimumAmount || output.nValue > nMaximumAmount)
168177
continue;
169178

170-
if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs && !coinControl->IsSelected(COutPoint(entry.first, i)))
179+
if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs && !coinControl->IsSelected(outpoint))
171180
continue;
172181

173-
if (wallet.IsLockedCoin(entry.first, i))
182+
if (wallet.IsLockedCoin(outpoint))
174183
continue;
175184

176-
if (wallet.IsSpent(wtxid, i))
185+
if (wallet.IsSpent(outpoint))
177186
continue;
178187

179-
isminetype mine = wallet.IsMine(wtx.tx->vout[i]);
188+
isminetype mine = wallet.IsMine(output);
180189

181190
if (mine == ISMINE_NO) {
182191
continue;
183192
}
184193

185-
if (!allow_used_addresses && wallet.IsSpentKey(wtxid, i)) {
194+
if (!allow_used_addresses && wallet.IsSpentKey(output.scriptPubKey)) {
186195
continue;
187196
}
188197

189-
std::unique_ptr<SigningProvider> provider = wallet.GetSolvingProvider(wtx.tx->vout[i].scriptPubKey);
198+
std::unique_ptr<SigningProvider> provider = wallet.GetSolvingProvider(output.scriptPubKey);
190199

191-
bool solvable = provider ? IsSolvable(*provider, wtx.tx->vout[i].scriptPubKey) : false;
200+
bool solvable = provider ? IsSolvable(*provider, output.scriptPubKey) : false;
192201
bool spendable = ((mine & ISMINE_SPENDABLE) != ISMINE_NO) || (((mine & ISMINE_WATCH_ONLY) != ISMINE_NO) && (coinControl && coinControl->fAllowWatchOnly && solvable));
193-
int input_bytes = GetTxSpendSize(wallet, wtx, i, (coinControl && coinControl->fAllowWatchOnly));
194202

195-
vCoins.emplace_back(COutPoint(wtx.GetHash(), i), wtx.tx->vout.at(i), nDepth, input_bytes, spendable, solvable, safeTx, wtx.GetTxTime(), tx_from_me, feerate);
203+
// Filter by spendable outputs only
204+
if (!spendable && only_spendable) continue;
205+
206+
int input_bytes = GetTxSpendSize(wallet, wtx, i, (coinControl && coinControl->fAllowWatchOnly));
207+
result.coins.emplace_back(outpoint, output, nDepth, input_bytes, spendable, solvable, safeTx, wtx.GetTxTime(), tx_from_me, feerate);
208+
result.total_amount += output.nValue;
196209

197210
// Checks the sum amount of all UTXO's.
198211
if (nMinimumSumAmount != MAX_MONEY) {
199-
nTotal += wtx.tx->vout[i].nValue;
200-
201-
if (nTotal >= nMinimumSumAmount) {
202-
return;
212+
if (result.total_amount >= nMinimumSumAmount) {
213+
return result;
203214
}
204215
}
205216

206217
// Checks the maximum number of UTXO's.
207-
if (nMaximumCount > 0 && vCoins.size() >= nMaximumCount) {
208-
return;
218+
if (nMaximumCount > 0 && result.coins.size() >= nMaximumCount) {
219+
return result;
209220
}
210221
}
211222
}
223+
224+
return result;
212225
}
213226

214-
void AvailableCoinsListUnspent(const CWallet& wallet, std::vector<COutput>& vCoins, const CCoinControl* coinControl, const CAmount& nMinimumAmount, const CAmount& nMaximumAmount, const CAmount& nMinimumSumAmount, const uint64_t nMaximumCount)
227+
CoinsResult AvailableCoinsListUnspent(const CWallet& wallet, const CCoinControl* coinControl, const CAmount& nMinimumAmount, const CAmount& nMaximumAmount, const CAmount& nMinimumSumAmount, const uint64_t nMaximumCount)
215228
{
216-
AvailableCoins(wallet, vCoins, coinControl, /*feerate=*/ std::nullopt, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount);
229+
return AvailableCoins(wallet, coinControl, /*feerate=*/ std::nullopt, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount, /*only_spendable=*/false);
217230
}
218231

219232
CAmount GetAvailableBalance(const CWallet& wallet, const CCoinControl* coinControl)
220233
{
221234
LOCK(wallet.cs_wallet);
222-
223-
CAmount balance = 0;
224-
std::vector<COutput> vCoins;
225-
AvailableCoinsListUnspent(wallet, vCoins, coinControl);
226-
for (const COutput& out : vCoins) {
227-
if (out.spendable) {
228-
balance += out.txout.nValue;
229-
}
230-
}
231-
return balance;
235+
return AvailableCoins(wallet,
236+
coinControl,
237+
std::nullopt, /*feerate=*/
238+
1, /*nMinimumAmount*/
239+
MAX_MONEY, /*nMaximumAmount*/
240+
MAX_MONEY, /*nMinimumSumAmount*/
241+
0 /*nMaximumCount*/
242+
).total_amount;
232243
}
233244

234245
const CTxOut& FindNonChangeParentOutput(const CWallet& wallet, const CTransaction& tx, int output)
@@ -260,11 +271,8 @@ std::map<CTxDestination, std::vector<COutput>> ListCoins(const CWallet& wallet)
260271
AssertLockHeld(wallet.cs_wallet);
261272

262273
std::map<CTxDestination, std::vector<COutput>> result;
263-
std::vector<COutput> availableCoins;
264-
265-
AvailableCoinsListUnspent(wallet, availableCoins);
266274

267-
for (const COutput& coin : availableCoins) {
275+
for (const COutput& coin : AvailableCoinsListUnspent(wallet).coins) {
268276
CTxDestination address;
269277
if ((coin.spendable || (wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) && coin.solvable)) &&
270278
ExtractDestination(FindNonChangeParentOutput(wallet, coin.outpoint).scriptPubKey, address)) {
@@ -791,11 +799,16 @@ static std::optional<CreatedTransactionResult> CreateTransactionInternal(
791799
CAmount selection_target = recipients_sum + not_input_fees;
792800

793801
// Get available coins
794-
std::vector<COutput> vAvailableCoins;
795-
AvailableCoins(wallet, vAvailableCoins, &coin_control, coin_selection_params.m_effective_feerate, 1, MAX_MONEY, MAX_MONEY, 0);
802+
auto res_available_coins = AvailableCoins(wallet,
803+
&coin_control,
804+
coin_selection_params.m_effective_feerate,
805+
1, /*nMinimumAmount*/
806+
MAX_MONEY, /*nMaximumAmount*/
807+
MAX_MONEY, /*nMinimumSumAmount*/
808+
0); /*nMaximumCount*/
796809

797810
// Choose coins to use
798-
std::optional<SelectionResult> result = SelectCoins(wallet, vAvailableCoins, /*nTargetValue=*/selection_target, coin_control, coin_selection_params);
811+
std::optional<SelectionResult> result = SelectCoins(wallet, res_available_coins.coins, /*nTargetValue=*/selection_target, coin_control, coin_selection_params);
799812
if (!result) {
800813
error = _("Insufficient funds");
801814
return std::nullopt;

src/wallet/spend.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,29 @@ struct TxSize {
3434
TxSize CalculateMaximumSignedTxSize(const CTransaction& tx, const CWallet* wallet, const std::vector<CTxOut>& txouts, const CCoinControl* coin_control = nullptr);
3535
TxSize CalculateMaximumSignedTxSize(const CTransaction& tx, const CWallet* wallet, const CCoinControl* coin_control = nullptr) EXCLUSIVE_LOCKS_REQUIRED(wallet->cs_wallet);
3636

37+
struct CoinsResult {
38+
std::vector<COutput> coins;
39+
// Sum of all the coins amounts
40+
CAmount total_amount{0};
41+
};
3742
/**
38-
* populate vCoins with vector of available COutputs.
43+
* Return vector of available COutputs.
44+
* By default, returns only the spendable coins.
3945
*/
40-
void AvailableCoins(const CWallet& wallet, std::vector<COutput>& vCoins, const CCoinControl* coinControl = nullptr, std::optional<CFeeRate> feerate = std::nullopt, const CAmount& nMinimumAmount = 1, const CAmount& nMaximumAmount = MAX_MONEY, const CAmount& nMinimumSumAmount = MAX_MONEY, const uint64_t nMaximumCount = 0) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
46+
CoinsResult AvailableCoins(const CWallet& wallet,
47+
const CCoinControl* coinControl = nullptr,
48+
std::optional<CFeeRate> feerate = std::nullopt,
49+
const CAmount& nMinimumAmount = 1,
50+
const CAmount& nMaximumAmount = MAX_MONEY,
51+
const CAmount& nMinimumSumAmount = MAX_MONEY,
52+
const uint64_t nMaximumCount = 0,
53+
bool only_spendable = true) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
4154

4255
/**
4356
* Wrapper function for AvailableCoins which skips the `feerate` parameter. Use this function
4457
* to list all available coins (e.g. listunspent RPC) while not intending to fund a transaction.
4558
*/
46-
void AvailableCoinsListUnspent(const CWallet& wallet, std::vector<COutput>& vCoins, const CCoinControl* coinControl = nullptr, const CAmount& nMinimumAmount = 1, const CAmount& nMaximumAmount = MAX_MONEY, const CAmount& nMinimumSumAmount = MAX_MONEY, const uint64_t nMaximumCount = 0) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
59+
CoinsResult AvailableCoinsListUnspent(const CWallet& wallet, const CCoinControl* coinControl = nullptr, const CAmount& nMinimumAmount = 1, const CAmount& nMaximumAmount = MAX_MONEY, const CAmount& nMinimumSumAmount = MAX_MONEY, const uint64_t nMaximumCount = 0) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
4760

4861
CAmount GetAvailableBalance(const CWallet& wallet, const CCoinControl* coinControl = nullptr);
4962

src/wallet/test/wallet_tests.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,7 @@ BOOST_FIXTURE_TEST_CASE(ListCoinsTest, ListCoinsTestingSetup)
583583
// Lock both coins. Confirm number of available coins drops to 0.
584584
{
585585
LOCK(wallet->cs_wallet);
586-
std::vector<COutput> available;
587-
AvailableCoinsListUnspent(*wallet, available);
588-
BOOST_CHECK_EQUAL(available.size(), 2U);
586+
BOOST_CHECK_EQUAL(AvailableCoinsListUnspent(*wallet).coins.size(), 2U);
589587
}
590588
for (const auto& group : list) {
591589
for (const auto& coin : group.second) {
@@ -595,9 +593,7 @@ BOOST_FIXTURE_TEST_CASE(ListCoinsTest, ListCoinsTestingSetup)
595593
}
596594
{
597595
LOCK(wallet->cs_wallet);
598-
std::vector<COutput> available;
599-
AvailableCoinsListUnspent(*wallet, available);
600-
BOOST_CHECK_EQUAL(available.size(), 0U);
596+
BOOST_CHECK_EQUAL(AvailableCoinsListUnspent(*wallet).coins.size(), 0U);
601597
}
602598
// Confirm ListCoins still returns same result as before, despite coins
603599
// being locked.

0 commit comments

Comments
 (0)