@@ -2481,16 +2481,31 @@ UniValue listspentzerocoins(const UniValue& params, bool fHelp)
2481
2481
2482
2482
UniValue mintzerocoin (const UniValue& params, bool fHelp )
2483
2483
{
2484
- if (fHelp || params.size () != 1 )
2484
+ if (fHelp || params.size () < 1 || params. size () > 2 )
2485
2485
throw runtime_error (
2486
- " mintzerocoin <amount>\n "
2487
- " Usage: Enter an amount of Piv to convert to zPiv"
2486
+ " mintzerocoin <amount> [UTXOs]\n "
2487
+ " amount: Enter an amount of Piv to convert to zPiv\n "
2488
+ " UTXOs: (string, optional) A json array of objects. Each object the txid (string) vout (numeric)\n "
2489
+ " [ (json array of json objects)\n "
2490
+ " {\n "
2491
+ " \" txid\" :\" id\" , (string) The transaction id\n "
2492
+ " \" vout\" : n (numeric) The output number\n "
2493
+ " }\n "
2494
+ " ,...\n "
2495
+ " ]\n "
2488
2496
+ HelpRequiringPassphrase ());
2489
2497
2490
2498
LOCK2 (cs_main, pwalletMain->cs_wallet );
2491
2499
2492
- int64_t nTime = GetTimeMillis ();
2500
+ if (params.size () == 1 )
2501
+ {
2502
+ RPCTypeCheck (params, boost::assign::list_of (UniValue::VNUM));
2503
+ } else
2504
+ {
2505
+ RPCTypeCheck (params, boost::assign::list_of (UniValue::VNUM)(UniValue::VARR));
2506
+ }
2493
2507
2508
+ int64_t nTime = GetTimeMillis ();
2494
2509
if (GetAdjustedTime () > GetSporkValue (SPORK_16_ZEROCOIN_MAINTENANCE_MODE))
2495
2510
throw JSONRPCError (RPC_WALLET_ERROR, " zPIV is currently disabled due to maintenance." );
2496
2511
@@ -2501,7 +2516,36 @@ UniValue mintzerocoin(const UniValue& params, bool fHelp)
2501
2516
2502
2517
CWalletTx wtx;
2503
2518
vector<CZerocoinMint> vMints;
2504
- string strError = pwalletMain->MintZerocoin (nAmount, wtx, vMints);
2519
+ string strError;
2520
+ vector<COutPoint> vOutpts;
2521
+
2522
+ if (params.size () == 2 )
2523
+ {
2524
+ UniValue outputs = params[1 ].get_array ();
2525
+ for (unsigned int idx = 0 ; idx < outputs.size (); idx++) {
2526
+ const UniValue& output = outputs[idx];
2527
+ if (!output.isObject ())
2528
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid parameter, expected object" );
2529
+ const UniValue& o = output.get_obj ();
2530
+
2531
+ RPCTypeCheckObj (o, boost::assign::map_list_of (" txid" , UniValue::VSTR)(" vout" , UniValue::VNUM));
2532
+
2533
+ string txid = find_value (o, " txid" ).get_str ();
2534
+ if (!IsHex (txid))
2535
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid parameter, expected hex txid" );
2536
+
2537
+ int nOutput = find_value (o, " vout" ).get_int ();
2538
+ if (nOutput < 0 )
2539
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid parameter, vout must be positive" );
2540
+
2541
+ COutPoint outpt (uint256 (txid), nOutput);
2542
+ vOutpts.push_back (outpt);
2543
+ }
2544
+ strError = pwalletMain->MintZerocoinFromOutPoint (nAmount, wtx, vMints, vOutpts);
2545
+ } else
2546
+ {
2547
+ strError = pwalletMain->MintZerocoin (nAmount, wtx, vMints);
2548
+ }
2505
2549
2506
2550
if (strError != " " )
2507
2551
throw JSONRPCError (RPC_WALLET_ERROR, strError);
0 commit comments