Skip to content

Commit

Permalink
[RPC] use json object as output of mintzerocoin
Browse files Browse the repository at this point in the history
txid and time fields can be grouped outside of the mints list as it is
the same transaction.
Github-Pull: #1218
Rebased-From: f80b5e9
  • Loading branch information
random-zebra authored and Fuzzbawls committed Jan 11, 2020
1 parent 5539b01 commit ae841ed
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/wallet/rpcwallet.cpp
Expand Up @@ -3354,17 +3354,20 @@ UniValue mintzerocoin(const UniValue& params, bool fHelp)
" ]\n"

"\nResult:\n"
"[\n"
" {\n"
" \"txid\": \"xxx\", (string) Transaction ID.\n"
" \"value\": amount, (numeric) Minted amount.\n"
" \"pubcoin\": \"xxx\", (string) Pubcoin in hex format.\n"
" \"randomness\": \"xxx\", (string) Hex encoded randomness.\n"
" \"serial\": \"xxx\", (string) Serial in hex format.\n"
" \"time\": nnn (numeric) Time to mint this transaction.\n"
" }\n"
" ,...\n"
"]\n"
"{\n"
" \"txid\": \"xxx\", (string) Transaction ID.\n"
" \"time\": nnn (numeric) Time to mint this transaction.\n"
" \"mints\":\n"
" [\n"
" {\n"
" \"denomination\": nnn, (numeric) Minted denomination.\n"
" \"pubcoin\": \"xxx\", (string) Pubcoin in hex format.\n"
" \"randomness\": \"xxx\", (string) Hex encoded randomness.\n"
" \"serial\": \"xxx\", (string) Serial in hex format.\n"
" },\n"
" ...\n"
" ]\n"
"}\n"

"\nExamples:\n"
"\nMint 50 from anywhere\n" +
Expand Down Expand Up @@ -3432,20 +3435,22 @@ UniValue mintzerocoin(const UniValue& params, bool fHelp)
if (strError != "")
throw JSONRPCError(RPC_WALLET_ERROR, strError);

UniValue retObj(UniValue::VOBJ);
retObj.push_back(Pair("txid", wtx.GetHash().ToString()));
retObj.push_back(Pair("time", GetTimeMillis() - nTime));
UniValue arrMints(UniValue::VARR);
for (CDeterministicMint dMint : vDMints) {
UniValue m(UniValue::VOBJ);
m.push_back(Pair("txid", wtx.GetHash().ToString()));
m.push_back(Pair("value", ValueFromAmount(libzerocoin::ZerocoinDenominationToAmount(dMint.GetDenomination()))));
m.push_back(Pair("denomination", ValueFromAmount(libzerocoin::ZerocoinDenominationToAmount(dMint.GetDenomination()))));
m.push_back(Pair("pubcoinhash", dMint.GetPubcoinHash().GetHex()));
m.push_back(Pair("serialhash", dMint.GetSerialHash().GetHex()));
m.push_back(Pair("seedhash", dMint.GetSeedHash().GetHex()));
m.push_back(Pair("count", (int64_t)dMint.GetCount()));
m.push_back(Pair("time", GetTimeMillis() - nTime));
arrMints.push_back(m);
}
retObj.push_back(Pair("mints", arrMints));

return arrMints;
return retObj;
}

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

0 comments on commit ae841ed

Please sign in to comment.