@@ -2239,82 +2239,82 @@ Value listunspent(const Array& params, bool fHelp)
2239
2239
return Value::null;
2240
2240
2241
2241
if (fHelp || params.size () > 3 )
2242
- throw runtime_error (
2243
- " listunspent ( minconf maxconf [\" address\" ,...] )\n "
2244
- " \n Returns array of unspent transaction outputs\n "
2245
- " with between minconf and maxconf (inclusive) confirmations.\n "
2246
- " Optionally filter to only include txouts paid to specified addresses.\n "
2247
- " Results are an array of Objects, each of which has:\n "
2248
- " {txid, vout, scriptPubKey, amount, confirmations}\n "
2249
- " \n Arguments:\n "
2250
- " 1. minconf (numeric, optional, default=1) The minimum confirmations to filter\n "
2251
- " 2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n "
2252
- " 3. \" addresses\" (string) A json array of bitcoin addresses to filter\n "
2253
- " [\n "
2254
- " \" address\" (string) bitcoin address\n "
2255
- " ,...\n "
2256
- " ]\n "
2257
- " \n Result\n "
2258
- " [ (array of json object)\n "
2259
- " {\n "
2260
- " \" txid\" : \" txid\" , (string) the transaction id \n "
2261
- " \" vout\" : n, (numeric) the vout value\n "
2262
- " \" address\" : \" address\" , (string) the bitcoin address\n "
2263
- " \" account\" : \" account\" , (string) DEPRECATED. The associated account, or \"\" for the default account\n "
2264
- " \" scriptPubKey\" : \" key\" , (string) the script key\n "
2265
- " \" amount\" : x.xxx, (numeric) the transaction amount in btc\n "
2266
- " \" confirmations\" : n (numeric) The number of confirmations\n "
2267
- " }\n "
2268
- " ,...\n "
2269
- " ]\n "
2270
-
2271
- " \n Examples\n "
2272
- + HelpExampleCli (" listunspent" , " " )
2273
- + HelpExampleCli (" listunspent" , " 6 9999999 \" [\\\" 1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\" ,\\\" 1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\" ]\" " )
2274
- + HelpExampleRpc (" listunspent" , " 6, 9999999 \" [\\\" 1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\" ,\\\" 1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\" ]\" " )
2275
- );
2276
-
2242
+ throw runtime_error (
2243
+ " listunspent ( minconf maxconf [\" address\" ,...] )\n "
2244
+ " \n Returns array of unspent transaction outputs\n "
2245
+ " with between minconf and maxconf (inclusive) confirmations.\n "
2246
+ " Optionally filter to only include txouts paid to specified addresses.\n "
2247
+ " Results are an array of Objects, each of which has:\n "
2248
+ " {txid, vout, scriptPubKey, amount, confirmations}\n "
2249
+ " \n Arguments:\n "
2250
+ " 1. minconf (numeric, optional, default=1) The minimum confirmations to filter\n "
2251
+ " 2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n "
2252
+ " 3. \" addresses\" (string) A json array of bitcoin addresses to filter\n "
2253
+ " [\n "
2254
+ " \" address\" (string) bitcoin address\n "
2255
+ " ,...\n "
2256
+ " ]\n "
2257
+ " \n Result\n "
2258
+ " [ (array of json object)\n "
2259
+ " {\n "
2260
+ " \" txid\" : \" txid\" , (string) the transaction id \n "
2261
+ " \" vout\" : n, (numeric) the vout value\n "
2262
+ " \" address\" : \" address\" , (string) the bitcoin address\n "
2263
+ " \" account\" : \" account\" , (string) DEPRECATED. The associated account, or \"\" for the default account\n "
2264
+ " \" scriptPubKey\" : \" key\" , (string) the script key\n "
2265
+ " \" amount\" : x.xxx, (numeric) the transaction amount in btc\n "
2266
+ " \" confirmations\" : n (numeric) The number of confirmations\n "
2267
+ " }\n "
2268
+ " ,...\n "
2269
+ " ]\n "
2270
+
2271
+ " \n Examples\n "
2272
+ + HelpExampleCli (" listunspent" , " " )
2273
+ + HelpExampleCli (" listunspent" , " 6 9999999 \" [\\\" 1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\" ,\\\" 1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\" ]\" " )
2274
+ + HelpExampleRpc (" listunspent" , " 6, 9999999 \" [\\\" 1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\" ,\\\" 1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\" ]\" " )
2275
+ );
2276
+
2277
2277
RPCTypeCheck (params, boost::assign::list_of (int_type)(int_type)(array_type));
2278
-
2278
+
2279
2279
int nMinDepth = 1 ;
2280
2280
if (params.size () > 0 )
2281
- nMinDepth = params[0 ].get_int ();
2282
-
2281
+ nMinDepth = params[0 ].get_int ();
2282
+
2283
2283
int nMaxDepth = 9999999 ;
2284
2284
if (params.size () > 1 )
2285
- nMaxDepth = params[1 ].get_int ();
2286
-
2285
+ nMaxDepth = params[1 ].get_int ();
2286
+
2287
2287
set<CBitcoinAddress> setAddress;
2288
2288
if (params.size () > 2 ) {
2289
2289
Array inputs = params[2 ].get_array ();
2290
2290
BOOST_FOREACH (Value& input, inputs) {
2291
2291
CBitcoinAddress address (input.get_str ());
2292
2292
if (!address.IsValid ())
2293
- throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, string (" Invalid Bitcoin address: " )+input.get_str ());
2293
+ throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, string (" Invalid Bitcoin address: " )+input.get_str ());
2294
2294
if (setAddress.count (address))
2295
- throw JSONRPCError (RPC_INVALID_PARAMETER, string (" Invalid parameter, duplicated address: " )+input.get_str ());
2296
- setAddress.insert (address);
2295
+ throw JSONRPCError (RPC_INVALID_PARAMETER, string (" Invalid parameter, duplicated address: " )+input.get_str ());
2296
+ setAddress.insert (address);
2297
2297
}
2298
2298
}
2299
-
2299
+
2300
2300
Array results;
2301
2301
vector<COutput> vecOutputs;
2302
2302
assert (pwalletMain != NULL );
2303
2303
LOCK2 (cs_main, pwalletMain->cs_wallet );
2304
2304
pwalletMain->AvailableCoins (vecOutputs, false );
2305
2305
BOOST_FOREACH (const COutput& out, vecOutputs) {
2306
2306
if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth)
2307
- continue ;
2308
-
2307
+ continue ;
2308
+
2309
2309
if (setAddress.size ()) {
2310
2310
CTxDestination address;
2311
2311
if (!ExtractDestination (out.tx ->vout [out.i ].scriptPubKey , address))
2312
- continue ;
2313
-
2312
+ continue ;
2313
+
2314
2314
if (!setAddress.count (address))
2315
- continue ;
2315
+ continue ;
2316
2316
}
2317
-
2317
+
2318
2318
CAmount nValue = out.tx ->vout [out.i ].nValue ;
2319
2319
const CScript& pk = out.tx ->vout [out.i ].scriptPubKey ;
2320
2320
Object entry;
@@ -2324,7 +2324,7 @@ Value listunspent(const Array& params, bool fHelp)
2324
2324
if (ExtractDestination (out.tx ->vout [out.i ].scriptPubKey , address)) {
2325
2325
entry.push_back (Pair (" address" , CBitcoinAddress (address).ToString ()));
2326
2326
if (pwalletMain->mapAddressBook .count (address))
2327
- entry.push_back (Pair (" account" , pwalletMain->mapAddressBook [address].name ));
2327
+ entry.push_back (Pair (" account" , pwalletMain->mapAddressBook [address].name ));
2328
2328
}
2329
2329
entry.push_back (Pair (" scriptPubKey" , HexStr (pk.begin (), pk.end ())));
2330
2330
if (pk.IsPayToScriptHash ()) {
@@ -2333,14 +2333,14 @@ Value listunspent(const Array& params, bool fHelp)
2333
2333
const CScriptID& hash = boost::get<const CScriptID&>(address);
2334
2334
CScript redeemScript;
2335
2335
if (pwalletMain->GetCScript (hash, redeemScript))
2336
- entry.push_back (Pair (" redeemScript" , HexStr (redeemScript.begin (), redeemScript.end ())));
2336
+ entry.push_back (Pair (" redeemScript" , HexStr (redeemScript.begin (), redeemScript.end ())));
2337
2337
}
2338
2338
}
2339
2339
entry.push_back (Pair (" amount" ,ValueFromAmount (nValue)));
2340
2340
entry.push_back (Pair (" confirmations" ,out.nDepth ));
2341
2341
entry.push_back (Pair (" spendable" , out.fSpendable ));
2342
2342
results.push_back (entry);
2343
2343
}
2344
-
2344
+
2345
2345
return results;
2346
2346
}
0 commit comments