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/rpc | |
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/rpc')
-rw-r--r-- | src/wallet/rpc/coins.cpp | 19 | ||||
-rw-r--r-- | src/wallet/rpc/spend.cpp | 4 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/wallet/rpc/coins.cpp b/src/wallet/rpc/coins.cpp index da961b97ef..837162ce07 100644 --- a/src/wallet/rpc/coins.cpp +++ b/src/wallet/rpc/coins.cpp @@ -591,11 +591,8 @@ RPCHelpMan listunspent() include_unsafe = request.params[3].get_bool(); } - CAmount nMinimumAmount = 0; - CAmount nMaximumAmount = MAX_MONEY; - CAmount nMinimumSumAmount = MAX_MONEY; - uint64_t nMaximumCount = 0; - bool include_immature_coinbase{false}; + CoinFilterParams filter_coins; + filter_coins.nMinimumAmount = 0; if (!request.params[4].isNull()) { const UniValue& options = request.params[4].get_obj(); @@ -611,19 +608,19 @@ RPCHelpMan listunspent() true, true); if (options.exists("minimumAmount")) - nMinimumAmount = AmountFromValue(options["minimumAmount"]); + filter_coins.nMinimumAmount = AmountFromValue(options["minimumAmount"]); if (options.exists("maximumAmount")) - nMaximumAmount = AmountFromValue(options["maximumAmount"]); + filter_coins.nMaximumAmount = AmountFromValue(options["maximumAmount"]); if (options.exists("minimumSumAmount")) - nMinimumSumAmount = AmountFromValue(options["minimumSumAmount"]); + filter_coins.nMinimumSumAmount = AmountFromValue(options["minimumSumAmount"]); if (options.exists("maximumCount")) - nMaximumCount = options["maximumCount"].getInt<int64_t>(); + filter_coins.nMaximumCount = options["maximumCount"].getInt<int64_t>(); if (options.exists("include_immature_coinbase")) { - include_immature_coinbase = options["include_immature_coinbase"].get_bool(); + filter_coins.include_immature_coinbase = options["include_immature_coinbase"].get_bool(); } } @@ -640,7 +637,7 @@ RPCHelpMan listunspent() cctl.m_max_depth = nMaxDepth; cctl.m_include_unsafe_inputs = include_unsafe; LOCK(pwallet->cs_wallet); - vecOutputs = AvailableCoinsListUnspent(*pwallet, &cctl, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount, include_immature_coinbase).All(); + vecOutputs = AvailableCoinsListUnspent(*pwallet, &cctl, filter_coins).All(); } LOCK(pwallet->cs_wallet); diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp index 6cb33fc11e..8cfd28d887 100644 --- a/src/wallet/rpc/spend.cpp +++ b/src/wallet/rpc/spend.cpp @@ -1385,7 +1385,9 @@ RPCHelpMan sendall() total_input_value += tx->tx->vout[input.prevout.n].nValue; } } else { - for (const COutput& output : AvailableCoins(*pwallet, &coin_control, fee_rate, /*nMinimumAmount=*/0).All()) { + CoinFilterParams coins_params; + coins_params.nMinimumAmount = 0; + for (const COutput& output : AvailableCoins(*pwallet, &coin_control, fee_rate, coins_params).All()) { CHECK_NONFATAL(output.input_bytes > 0); if (send_max && fee_rate.GetFee(output.input_bytes) > output.txout.nValue) { continue; |