diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2022-10-12 23:37:02 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2022-10-29 08:50:38 -0300 |
commit | 61c2265629fdf11a2cc266fad54ceb0a1247bb5e (patch) | |
tree | b36d12a82b1b7ad9d11d1900db0b408292123860 /src/wallet/spend.h | |
parent | f0f6a3577bef2e9ebd084fe35850e4e9580128a9 (diff) | |
download | bitcoin-61c2265629fdf11a2cc266fad54ceb0a1247bb5e.tar.xz |
wallet: group AvailableCoins filtering parameters in a single struct
Plus clean callers that use the params default values
Diffstat (limited to 'src/wallet/spend.h')
-rw-r--r-- | src/wallet/spend.h | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/wallet/spend.h b/src/wallet/spend.h index 1d4570dcbb..fc7f7bc535 100644 --- a/src/wallet/spend.h +++ b/src/wallet/spend.h @@ -55,24 +55,34 @@ struct CoinsResult { CAmount total_amount{0}; }; +struct CoinFilterParams { + // Outputs below the minimum amount will not get selected + CAmount nMinimumAmount{1}; + // Outputs above the maximum amount will not get selected + CAmount nMaximumAmount{MAX_MONEY}; + // Return outputs until the minimum sum amount is covered + CAmount nMinimumSumAmount{MAX_MONEY}; + // Maximum number of outputs that can be returned + uint64_t nMaximumCount{0}; + // By default, return only spendable outputs + bool only_spendable{true}; + // By default, do not include immature coinbase outputs + bool include_immature_coinbase{false}; +}; + /** * Populate the CoinsResult struct with vectors of available COutputs, organized by OutputType. */ 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, - bool include_immature_coinbase = false) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet); + const CoinFilterParams& params = {}) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet); /** - * Wrapper function for AvailableCoins which skips the `feerate` parameter. Use this function + * Wrapper function for AvailableCoins which skips the `feerate` and `CoinFilterParams::only_spendable` parameters. Use this function * to list all available coins (e.g. listunspent RPC) while not intending to fund a transaction. */ -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, bool include_immature_coinbase = false) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet); +CoinsResult AvailableCoinsListUnspent(const CWallet& wallet, const CCoinControl* coinControl = nullptr, CoinFilterParams params = {}) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet); CAmount GetAvailableBalance(const CWallet& wallet, const CCoinControl* coinControl = nullptr); |