|
|
|
@ -2470,9 +2470,9 @@ UniValue listunspent(const JSONRPCRequest& request)
@@ -2470,9 +2470,9 @@ UniValue listunspent(const JSONRPCRequest& request)
|
|
|
|
|
return NullUniValue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (request.fHelp || request.params.size() > 4) |
|
|
|
|
if (request.fHelp || request.params.size() > 5) |
|
|
|
|
throw std::runtime_error( |
|
|
|
|
"listunspent ( minconf maxconf [\"addresses\",...] [include_unsafe] )\n" |
|
|
|
|
"listunspent ( minconf maxconf [\"addresses\",...] [include_unsafe] [query_options])\n" |
|
|
|
|
"\nReturns array of unspent transaction outputs\n" |
|
|
|
|
"with between minconf and maxconf (inclusive) confirmations.\n" |
|
|
|
|
"Optionally filter to only include txouts paid to specified addresses.\n" |
|
|
|
@ -2486,6 +2486,13 @@ UniValue listunspent(const JSONRPCRequest& request)
@@ -2486,6 +2486,13 @@ UniValue listunspent(const JSONRPCRequest& request)
|
|
|
|
|
" ]\n" |
|
|
|
|
"4. include_unsafe (bool, optional, default=true) Include outputs that are not safe to spend\n" |
|
|
|
|
" See description of \"safe\" attribute below.\n" |
|
|
|
|
"5. query_options (json, optional) JSON with query options\n" |
|
|
|
|
" {\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 of all UTXOs in " + CURRENCY_UNIT + "\n" |
|
|
|
|
" }\n" |
|
|
|
|
"\nResult\n" |
|
|
|
|
"[ (array of json object)\n" |
|
|
|
|
" {\n" |
|
|
|
@ -2510,6 +2517,8 @@ UniValue listunspent(const JSONRPCRequest& request)
@@ -2510,6 +2517,8 @@ UniValue listunspent(const JSONRPCRequest& request)
|
|
|
|
|
+ HelpExampleCli("listunspent", "") |
|
|
|
|
+ HelpExampleCli("listunspent", "6 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") |
|
|
|
|
+ HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") |
|
|
|
|
+ HelpExampleCli("listunspent", "6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'") |
|
|
|
|
+ HelpExampleRpc("listunspent", "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ") |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
int nMinDepth = 1; |
|
|
|
@ -2545,15 +2554,34 @@ UniValue listunspent(const JSONRPCRequest& request)
@@ -2545,15 +2554,34 @@ UniValue listunspent(const JSONRPCRequest& request)
|
|
|
|
|
include_unsafe = request.params[3].get_bool(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CAmount nMinimumAmount = 0; |
|
|
|
|
CAmount nMaximumAmount = MAX_MONEY; |
|
|
|
|
CAmount nMinimumSumAmount = MAX_MONEY; |
|
|
|
|
uint64_t nMaximumCount = 0; |
|
|
|
|
|
|
|
|
|
if (request.params.size() > 4) { |
|
|
|
|
const UniValue& options = request.params[4].get_obj(); |
|
|
|
|
|
|
|
|
|
if (options.exists("minimumAmount")) |
|
|
|
|
nMinimumAmount = AmountFromValue(options["minimumAmount"]); |
|
|
|
|
|
|
|
|
|
if (options.exists("maximumAmount")) |
|
|
|
|
nMaximumAmount = AmountFromValue(options["maximumAmount"]); |
|
|
|
|
|
|
|
|
|
if (options.exists("minimumSumAmount")) |
|
|
|
|
nMinimumSumAmount = AmountFromValue(options["minimumSumAmount"]); |
|
|
|
|
|
|
|
|
|
if (options.exists("maximumCount")) |
|
|
|
|
nMaximumCount = options["maximumCount"].get_int64(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UniValue results(UniValue::VARR); |
|
|
|
|
std::vector<COutput> vecOutputs; |
|
|
|
|
assert(pwallet != NULL); |
|
|
|
|
LOCK2(cs_main, pwallet->cs_wallet); |
|
|
|
|
pwallet->AvailableCoins(vecOutputs, !include_unsafe, NULL, true); |
|
|
|
|
BOOST_FOREACH(const COutput& out, vecOutputs) { |
|
|
|
|
if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
pwallet->AvailableCoins(vecOutputs, !include_unsafe, NULL, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount, nMinDepth, nMaxDepth); |
|
|
|
|
BOOST_FOREACH(const COutput& out, vecOutputs) { |
|
|
|
|
CTxDestination address; |
|
|
|
|
const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey; |
|
|
|
|
bool fValidAddress = ExtractDestination(scriptPubKey, address); |
|
|
|
@ -2936,7 +2964,7 @@ static const CRPCCommand commands[] =
@@ -2936,7 +2964,7 @@ static const CRPCCommand commands[] =
|
|
|
|
|
{ "wallet", "listreceivedbyaddress", &listreceivedbyaddress, false, {"minconf","include_empty","include_watchonly"} }, |
|
|
|
|
{ "wallet", "listsinceblock", &listsinceblock, false, {"blockhash","target_confirmations","include_watchonly"} }, |
|
|
|
|
{ "wallet", "listtransactions", &listtransactions, false, {"account","count","skip","include_watchonly"} }, |
|
|
|
|
{ "wallet", "listunspent", &listunspent, false, {"minconf","maxconf","addresses","include_unsafe"} }, |
|
|
|
|
{ "wallet", "listunspent", &listunspent, false, {"minconf","maxconf","addresses","include_unsafe","query_options"} }, |
|
|
|
|
{ "wallet", "lockunspent", &lockunspent, true, {"unlock","transactions"} }, |
|
|
|
|
{ "wallet", "move", &movecmd, false, {"fromaccount","toaccount","amount","minconf","comment"} }, |
|
|
|
|
{ "wallet", "sendfrom", &sendfrom, false, {"fromaccount","toaddress","amount","minconf","comment","comment_to"} }, |
|
|
|
|