Skip to content

Commit

Permalink
[RPC] Enable v2 spending on regtest with spendrawzerocoin
Browse files Browse the repository at this point in the history
Github-Pull: #1218
Rebased-From: ddf18d9
  • Loading branch information
random-zebra authored and Fuzzbawls committed Jan 11, 2020
1 parent 5a3951a commit fc7069a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4325,9 +4325,9 @@ UniValue createautomintaddress(const UniValue& params, bool fHelp)

UniValue spendrawzerocoin(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 4 || params.size() > 6)
if (fHelp || params.size() < 4 || params.size() > 7)
throw std::runtime_error(
"spendrawzerocoin \"serialHex\" denom \"randomnessHex\" ( \"address\" \"mintTxId\" fRelay)\n"
"spendrawzerocoin \"serialHex\" denom \"randomnessHex\" \"priv key\" ( \"address\" \"mintTxId\" isPublicSpend)\n"
"\nCreate and broadcast a TX spending the provided zericoin.\n"

"\nArguments:\n"
Expand All @@ -4339,6 +4339,8 @@ UniValue spendrawzerocoin(const UniValue& params, bool fHelp)
" or empty string, spend to change address.\n"
"6. \"mintTxId\" (string, optional) txid of the transaction containing the mint. If not"
" specified, or empty string, the blockchain will be scanned (could take a while)"
"7. isPublicSpend (boolean, optional, default=true) create a public zc spend."
" If false, instead create spend version 2 (only for regression tests)"

"\nResult:\n"
"\"txid\" (string) The transaction txid in hex\n"
Expand All @@ -4347,6 +4349,10 @@ UniValue spendrawzerocoin(const UniValue& params, bool fHelp)
HelpExampleCli("spendrawzerocoin", "\"f80892e78c30a393ef4ab4d5a9d5a2989de6ebc7b976b241948c7f489ad716a2\" \"a4fd4d7248e6a51f1d877ddd2a4965996154acc6b8de5aa6c83d4775b283b600\" 100 \"xxx\"") +
HelpExampleRpc("spendrawzerocoin", "\"f80892e78c30a393ef4ab4d5a9d5a2989de6ebc7b976b241948c7f489ad716a2\", \"a4fd4d7248e6a51f1d877ddd2a4965996154acc6b8de5aa6c83d4775b283b600\", 100, \"xxx\""));

const bool isPublicSpend = (params.size() > 6 ? params[6].get_bool() : true);
if (Params().NetworkID() != CBaseChainParams::REGTEST && !isPublicSpend)
throw JSONRPCError(RPC_WALLET_ERROR, "zPIV old spend only available in regtest for tests purposes");

LOCK2(cs_main, pwalletMain->cs_wallet);

if (sporkManager.IsSporkActive(SPORK_16_ZEROCOIN_MAINTENANCE_MODE))
Expand Down Expand Up @@ -4417,7 +4423,7 @@ UniValue spendrawzerocoin(const UniValue& params, bool fHelp)
}

std::vector<CZerocoinMint> vMintsSelected = {mint};
return DoZpivSpend(mint.GetDenominationAsAmount(), false, true, vMintsSelected, address_str);
return DoZpivSpend(mint.GetDenominationAsAmount(), false, true, vMintsSelected, address_str, isPublicSpend);
}

UniValue clearspendcache(const UniValue& params, bool fHelp)
Expand Down

0 comments on commit fc7069a

Please sign in to comment.