@@ -193,117 +193,6 @@ Value getrawtransaction(const Array& params, bool fHelp)
193
193
return result;
194
194
}
195
195
196
- #ifdef ENABLE_WALLET
197
- Value listunspent (const Array& params, bool fHelp )
198
- {
199
- if (fHelp || params.size () > 3 )
200
- throw runtime_error (
201
- " listunspent ( minconf maxconf [\" address\" ,...] )\n "
202
- " \n Returns array of unspent transaction outputs\n "
203
- " with between minconf and maxconf (inclusive) confirmations.\n "
204
- " Optionally filter to only include txouts paid to specified addresses.\n "
205
- " Results are an array of Objects, each of which has:\n "
206
- " {txid, vout, scriptPubKey, amount, confirmations}\n "
207
- " \n Arguments:\n "
208
- " 1. minconf (numeric, optional, default=1) The minimum confirmations to filter\n "
209
- " 2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n "
210
- " 3. \" addresses\" (string) A json array of bitcoin addresses to filter\n "
211
- " [\n "
212
- " \" address\" (string) bitcoin address\n "
213
- " ,...\n "
214
- " ]\n "
215
- " \n Result\n "
216
- " [ (array of json object)\n "
217
- " {\n "
218
- " \" txid\" : \" txid\" , (string) the transaction id \n "
219
- " \" vout\" : n, (numeric) the vout value\n "
220
- " \" address\" : \" address\" , (string) the bitcoin address\n "
221
- " \" account\" : \" account\" , (string) DEPRECATED. The associated account, or \"\" for the default account\n "
222
- " \" scriptPubKey\" : \" key\" , (string) the script key\n "
223
- " \" amount\" : x.xxx, (numeric) the transaction amount in btc\n "
224
- " \" confirmations\" : n (numeric) The number of confirmations\n "
225
- " }\n "
226
- " ,...\n "
227
- " ]\n "
228
-
229
- " \n Examples\n "
230
- + HelpExampleCli (" listunspent" , " " )
231
- + HelpExampleCli (" listunspent" , " 6 9999999 \" [\\\" 1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\" ,\\\" 1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\" ]\" " )
232
- + HelpExampleRpc (" listunspent" , " 6, 9999999 \" [\\\" 1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\" ,\\\" 1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\" ]\" " )
233
- );
234
-
235
- RPCTypeCheck (params, boost::assign::list_of (int_type)(int_type)(array_type));
236
-
237
- int nMinDepth = 1 ;
238
- if (params.size () > 0 )
239
- nMinDepth = params[0 ].get_int ();
240
-
241
- int nMaxDepth = 9999999 ;
242
- if (params.size () > 1 )
243
- nMaxDepth = params[1 ].get_int ();
244
-
245
- set<CBitcoinAddress> setAddress;
246
- if (params.size () > 2 ) {
247
- Array inputs = params[2 ].get_array ();
248
- BOOST_FOREACH (Value& input, inputs) {
249
- CBitcoinAddress address (input.get_str ());
250
- if (!address.IsValid ())
251
- throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, string (" Invalid Bitcoin address: " )+input.get_str ());
252
- if (setAddress.count (address))
253
- throw JSONRPCError (RPC_INVALID_PARAMETER, string (" Invalid parameter, duplicated address: " )+input.get_str ());
254
- setAddress.insert (address);
255
- }
256
- }
257
-
258
- Array results;
259
- vector<COutput> vecOutputs;
260
- assert (pwalletMain != NULL );
261
- LOCK2 (cs_main, pwalletMain->cs_wallet );
262
- pwalletMain->AvailableCoins (vecOutputs, false );
263
- BOOST_FOREACH (const COutput& out, vecOutputs) {
264
- if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth)
265
- continue ;
266
-
267
- if (setAddress.size ()) {
268
- CTxDestination address;
269
- if (!ExtractDestination (out.tx ->vout [out.i ].scriptPubKey , address))
270
- continue ;
271
-
272
- if (!setAddress.count (address))
273
- continue ;
274
- }
275
-
276
- CAmount nValue = out.tx ->vout [out.i ].nValue ;
277
- const CScript& pk = out.tx ->vout [out.i ].scriptPubKey ;
278
- Object entry;
279
- entry.push_back (Pair (" txid" , out.tx ->GetHash ().GetHex ()));
280
- entry.push_back (Pair (" vout" , out.i ));
281
- CTxDestination address;
282
- if (ExtractDestination (out.tx ->vout [out.i ].scriptPubKey , address)) {
283
- entry.push_back (Pair (" address" , CBitcoinAddress (address).ToString ()));
284
- if (pwalletMain->mapAddressBook .count (address))
285
- entry.push_back (Pair (" account" , pwalletMain->mapAddressBook [address].name ));
286
- }
287
- entry.push_back (Pair (" scriptPubKey" , HexStr (pk.begin (), pk.end ())));
288
- if (pk.IsPayToScriptHash ()) {
289
- CTxDestination address;
290
- if (ExtractDestination (pk, address)) {
291
- const CScriptID& hash = boost::get<const CScriptID&>(address);
292
- CScript redeemScript;
293
- if (pwalletMain->GetCScript (hash, redeemScript))
294
- entry.push_back (Pair (" redeemScript" , HexStr (redeemScript.begin (), redeemScript.end ())));
295
- }
296
- }
297
- entry.push_back (Pair (" amount" ,ValueFromAmount (nValue)));
298
- entry.push_back (Pair (" confirmations" ,out.nDepth ));
299
- entry.push_back (Pair (" spendable" , out.fSpendable ));
300
- results.push_back (entry);
301
- }
302
-
303
- return results;
304
- }
305
- #endif
306
-
307
196
Value createrawtransaction (const Array& params, bool fHelp )
308
197
{
309
198
if (fHelp || params.size () != 2 )
0 commit comments