Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Add query options to listunspent RPC call #8952
Conversation
laanwj
added
the
RPC/REST/ZMQ
label
Oct 18, 2016
|
Concept ACK |
|
WDYT of adding new options like |
|
Yes, would make sense. Passing the JSON "query object" is a good idea. |
|
|
pedrobranco
changed the title from
Add selection options to listunspent RPC call
to
Add query options to listunspent RPC call
Oct 19, 2016
added a commit
to bitcoinknots/bitcoin
that referenced
this pull request
Dec 21, 2016
| + " \"minimumAmount\" (numeric or string, default=0) Minimum value of each UTXO in " + CURRENCY_UNIT + "\n" | ||
| + " \"maximumAmount\" (numeric or string, default=21000000=unlimited) Maximum value of each UTXO in " + CURRENCY_UNIT + "\n" | ||
| + " \"maximumCount\" (numeric or string, default=0=unlimited) Maximum number of UTXOs\n" | ||
| + " \"minimumSumAmount\" (numeric or string, default=21000000=unlimited) Minimum sum value all UTXOs in " + CURRENCY_UNIT + "\n" |
luke-jr
Feb 3, 2017
Member
Instead of the dual meanings, just say default=unlimited (and make sure 0 doesn't behave in such a manner).
|
Looks like it! but as we're past the feature freeze for 0.14 and this is a new feature, merging this will have to wait until 0.14 is branched off. |
|
About tests: there aren't any tests specifically for testing |
|
Yes, tests for that would be great. They'd make it possible to automatically detect when something breaks this functionality. |
| @@ -2399,15 +2399,22 @@ UniValue listunspent(const JSONRPCRequest& request) | ||
| "\nArguments:\n" |
kallewoof
Feb 28, 2017
Member
Need to add options to the first line, e.g.
"listunspent ( minconf maxconf [\"addresses\",...] [include_unsafe] [options] )\n"| + " \"minimumAmount\" (numeric or string, default=0) Minimum value of each UTXO in " + CURRENCY_UNIT + "\n" | ||
| + " \"maximumAmount\" (numeric or string, default=unlimited) Maximum value of each UTXO in " + CURRENCY_UNIT + "\n" | ||
| + " \"maximumCount\" (numeric or string, default=unlimited) Maximum number of UTXOs\n" | ||
| + " \"minimumSumAmount\" (numeric or string, default=unlimited) Minimum sum value all UTXOs in " + CURRENCY_UNIT + "\n" |
| + nTotal += pcoin->tx->vout[i].nValue; | ||
| + | ||
| + if (nTotal >= nMinimumSumAmount) { | ||
| + return; |
kallewoof
Feb 28, 2017
Member
Maybe I'm misreading, but this (nMinimumSumAmount) sounds like a maximum, not a minimum. Esp. since it defaults to MAX_MONEY rather than 0.
pedrobranco
Mar 2, 2017
Contributor
I see no issue here since is to be used like it was a minorant set of unspents which satisfies the passed value. If It it was called maximum it should not retrieve unspents which sum are greater than the passed value.
kallewoof
Mar 2, 2017
Member
You are collecting the sum of the nValue and once the total exceeds the minimum you stop. Generally speaking,
int minimumSum = 5;
int values[] = {1,2,3,2,3};
int sum = 0;
for (int i = 0; i < 5; i++) {
sum += values[i];
if (sum >= minimumSum) break;
}The above looks inverted to me, and will no doubt confuse the user. If you used the word minorant, it might help, but the minorant would be the vout set not the sum, I believe?
Anyway, if I'm the only one bothered by this feel free to keep as is.
@laanwj I'm already working on it. Can I submit in another PR? |
|
This needs a rebase. @pedrobranco Tests could be submitted in a follow-up PR. |
|
Ready. |
|
Any thoughts if this is going to be merged? /cc @laanwj |
| @@ -1954,12 +1954,15 @@ CAmount CWallet::GetImmatureWatchOnlyBalance() const | ||
| return nTotal; | ||
| } | ||
| -void CWallet::AvailableCoins(std::vector<COutput>& vCoins, bool fOnlySafe, const CCoinControl *coinControl, bool fIncludeZeroValue) const | ||
| +void CWallet::AvailableCoins(std::vector<COutput> &vCoins, bool fOnlySafe, const CCoinControl *coinControl, const CAmount &nMinimumAmount, const CAmount &nMaximumAmount, const CAmount &nMinimumSumAmount, const uint64_t &nMaximumCount, const int &nMinDepth, const int &nMaxDepth) const |
laanwj
May 17, 2017
•
Owner
Not necessary in this pull, but if we keep extending these arguments I think it'd be better to group then into a CoinConstraints structure and pass that in.
Speaking of which - isn't CCoinControl pretty much that?
added a commit
that referenced
this pull request
May 17, 2017
|
Merged (and rebased) via 9390845 |
|
Thank you @laanwj |
ryanofsky
referenced this pull request
May 17, 2017
Merged
[qt] Move some WalletModel functions into CWallet #10295
|
@laanwj I suppose you forgot to close after merging? |
sipa
closed this
May 18, 2017
|
Yes, did'nt automatically happen as I did a rebase locally. Thanks
…
|
pedrobranco commentedOct 18, 2016
•
Edited 1 time
-
pedrobranco
Oct 18, 2016
This PR adds a new optional JSON options for
listunspentRPC call:minimumAmount(default = 0).maximumAmount(default =MAX_MONEY= 21000000.0 BTC).maximumCount(default=0=unlimited).minimumSumAmount(default =MAX_MONEY= 21000000.0 BTC).When selecting unspents on client side in a wallet with a large set of small unspents makes the call
listunspentslow. Using withminimumAmountoption could improve the performance of the RPC call, performance which depends on the size of wallet, the distribution of the unspents and theminimumAmountselected.Example:
Note: this PR also changes/simplifies the code in
AvailableCoinsto make the longest calls later in execution time, which also could improve performance in somelistunspentresults.