This PR adds a new optional JSON options for listunspent
RPC call:
- Return unspents greater or equal than a specific amount in BTC:
minimumAmount
(default = 0). - Return unspents lower or equal than a specific amount in BTC:
maximumAmount
(default =MAX_MONEY
= 21000000.0 BTC). - Return unspents with a total number lower or equal than a specific number:
maximumCount
(default=0=unlimited). - Return unspents which total is greater or equal than a specific amount in BTC:
minimumSumAmount
(default =MAX_MONEY
= 21000000.0 BTC).
0> bitcoin-cli help listunspent
1...
25. query options (json, optional) JSON with query options
3 {
4 "minimumAmount" (numeric or string, default=0) Minimum value of each UTXO in BTC
5 "maximumAmount" (numeric or string, default=21000000=unlimited) Maximum value of each UTXO in BTC
6 "maximumCount" (numeric or string, default=0=unlimited) Maximum number of UTXOs
7 "minimumSumAmount" (numeric or string, default=21000000=unlimited) Minimum sum value all UTXOs in BTC
8 }
9...
When selecting unspents on client side in a wallet with a large set of small unspents makes the call listunspent
slow. Using with minimumAmount
option could improve the performance of the RPC call, performance which depends on the size of wallet, the distribution of the unspents and the minimumAmount
selected.
Example:
0> bitcoin-cli listunspent 0 9999999 '[]' true '{ "minimumAmount": 10, "maximumAmount": 80, "minimumSumAmount": 50, "maximumCount": 3 }'
Note: this PR also changes/simplifies the code in AvailableCoins
to make the longest calls later in execution time, which also could improve performance in some listunspent
results.