@@ -2481,16 +2481,31 @@ UniValue listspentzerocoins(const UniValue& params, bool fHelp)
24812481
24822482UniValue mintzerocoin (const UniValue& params, bool fHelp )
24832483{
2484- if (fHelp || params.size () != 1 )
2484+ if (fHelp || params.size () < 1 || params. size () > 2 )
24852485 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 "
24882496 + HelpRequiringPassphrase ());
24892497
24902498 LOCK2 (cs_main, pwalletMain->cs_wallet );
24912499
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+ }
24932507
2508+ int64_t nTime = GetTimeMillis ();
24942509 if (GetAdjustedTime () > GetSporkValue (SPORK_16_ZEROCOIN_MAINTENANCE_MODE))
24952510 throw JSONRPCError (RPC_WALLET_ERROR, " zPIV is currently disabled due to maintenance." );
24962511
@@ -2501,7 +2516,36 @@ UniValue mintzerocoin(const UniValue& params, bool fHelp)
25012516
25022517 CWalletTx wtx;
25032518 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+ }
25052549
25062550 if (strError != " " )
25072551 throw JSONRPCError (RPC_WALLET_ERROR, strError);
0 commit comments