Skip to content

Commit ddf18d9

Browse files
committed
[RPC] Enable v2 spending on regtest with spendrawzerocoin
1 parent b3af5bd commit ddf18d9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4313,9 +4313,9 @@ UniValue createautomintaddress(const UniValue& params, bool fHelp)
43134313

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

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

43314333
"\nResult:\n"
43324334
"\"txid\" (string) The transaction txid in hex\n"
@@ -4335,6 +4337,10 @@ UniValue spendrawzerocoin(const UniValue& params, bool fHelp)
43354337
HelpExampleCli("spendrawzerocoin", "\"f80892e78c30a393ef4ab4d5a9d5a2989de6ebc7b976b241948c7f489ad716a2\" \"a4fd4d7248e6a51f1d877ddd2a4965996154acc6b8de5aa6c83d4775b283b600\" 100 \"xxx\"") +
43364338
HelpExampleRpc("spendrawzerocoin", "\"f80892e78c30a393ef4ab4d5a9d5a2989de6ebc7b976b241948c7f489ad716a2\", \"a4fd4d7248e6a51f1d877ddd2a4965996154acc6b8de5aa6c83d4775b283b600\", 100, \"xxx\""));
43374339

4340+
const bool isPublicSpend = (params.size() > 6 ? params[6].get_bool() : true);
4341+
if (Params().NetworkID() != CBaseChainParams::REGTEST && !isPublicSpend)
4342+
throw JSONRPCError(RPC_WALLET_ERROR, "zPIV old spend only available in regtest for tests purposes");
4343+
43384344
LOCK2(cs_main, pwalletMain->cs_wallet);
43394345

43404346
if (sporkManager.IsSporkActive(SPORK_16_ZEROCOIN_MAINTENANCE_MODE))
@@ -4405,7 +4411,7 @@ UniValue spendrawzerocoin(const UniValue& params, bool fHelp)
44054411
}
44064412

44074413
std::vector<CZerocoinMint> vMintsSelected = {mint};
4408-
return DoZpivSpend(mint.GetDenominationAsAmount(), false, true, vMintsSelected, address_str);
4414+
return DoZpivSpend(mint.GetDenominationAsAmount(), false, true, vMintsSelected, address_str, isPublicSpend);
44094415
}
44104416

44114417
UniValue clearspendcache(const UniValue& params, bool fHelp)

0 commit comments

Comments
 (0)