aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/spend.h
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2022-06-02 14:45:04 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2022-06-08 11:30:25 -0300
commit162d4ad10f28c5fa38551d69ce9b296ab3933c77 (patch)
tree2feac567b475a83267f9658a565bb1a3bacf24df /src/wallet/spend.h
parentcdf185ccfb2085e5a4bf82d833392d74b748aeff (diff)
downloadbitcoin-162d4ad10f28c5fa38551d69ce9b296ab3933c77.tar.xz
wallet: add 'only_spendable' filter to AvailableCoins
We are skipping the non-spendable coins that appear in vCoins ('AvailableCoins' result) later, in several parts of the CreateTransaction and GetBalance flows: GetAvailableBalance (1) gets all the available coins calling AvailableCoins and, right away, walk through the entire vector, skipping the non-spendable coins, to calculate the total balance. Inside CreateTransactionInternal —> SelectCoins(vCoins,...), we have several calls to AttemptSelection which, on each of them internally, we call twice to GroupOutputs which internally has two for-loops over the entire vCoins vector that skip the non-spendable coins. So, Purpose is not add the non-spendable coins into the AvailableCoins result (vCoins) in the first place for the processes that aren’t using them at all, so we don’t waste resources skipping them later so many times. Note: this speedup is for all the processes that call to CreateTransaction and GetBalance* internally.
Diffstat (limited to 'src/wallet/spend.h')
-rw-r--r--src/wallet/spend.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/wallet/spend.h b/src/wallet/spend.h
index dde2523eb7..84628517b0 100644
--- a/src/wallet/spend.h
+++ b/src/wallet/spend.h
@@ -39,8 +39,16 @@ struct CoinsResult {
};
/**
* Return vector of available COutputs.
+ * By default, returns only the spendable coins.
*/
-CoinsResult AvailableCoins(const CWallet& wallet, 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);
+CoinsResult AvailableCoins(const CWallet& wallet,
+ 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,
+ bool only_spendable = true) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
/**
* Wrapper function for AvailableCoins which skips the `feerate` parameter. Use this function