Browse Source

Auto merge of #2054 - str4d:2030-decoderawtransaction-joinsplit-fields, r=bitcartel

Show all JoinSplit components in getrawtransaction and decoderawtransaction

Closes #2030.
pull/4/head
zkbot 7 years ago
parent
commit
d32511c72c
  1. 9
      qa/rpc-tests/wallet.py
  2. 73
      src/rpcrawtransaction.cpp

9
qa/rpc-tests/wallet.py

@ -339,6 +339,15 @@ class WalletTest (BitcoinTestFramework):
myvjoinsplits = mytxdetails["vjoinsplit"]
assert_greater_than(len(myvjoinsplits), 0)
# the first (probably only) joinsplit should take in all the public value
myjoinsplit = self.nodes[2].getrawtransaction(mytxid, 1)["vjoinsplit"][0]
assert_equal(myjoinsplit["vpub_old"], zsendmanynotevalue)
assert_equal(myjoinsplit["vpub_new"], 0)
assert("onetimePubKey" in myjoinsplit.keys())
assert("randomSeed" in myjoinsplit.keys())
assert("ciphertexts" in myjoinsplit.keys())
# send from private note to node 0 and node 2
node0balance = self.nodes[0].getbalance() # 25.99794745
node2balance = self.nodes[2].getbalance() # 16.99790000

73
src/rpcrawtransaction.cpp

@ -62,6 +62,9 @@ Array TxJoinSplitToJSON(const CTransaction& tx) {
const JSDescription& jsdescription = tx.vjoinsplit[i];
Object joinsplit;
joinsplit.push_back(Pair("vpub_old", ValueFromAmount(jsdescription.vpub_old)));
joinsplit.push_back(Pair("vpub_new", ValueFromAmount(jsdescription.vpub_new)));
joinsplit.push_back(Pair("anchor", jsdescription.anchor.GetHex()));
{
@ -80,6 +83,9 @@ Array TxJoinSplitToJSON(const CTransaction& tx) {
joinsplit.push_back(Pair("commitments", commitments));
}
joinsplit.push_back(Pair("onetimePubKey", jsdescription.ephemeralKey.GetHex()));
joinsplit.push_back(Pair("randomSeed", jsdescription.randomSeed.GetHex()));
{
Array macs;
BOOST_FOREACH(const uint256 mac, jsdescription.macs) {
@ -88,8 +94,17 @@ Array TxJoinSplitToJSON(const CTransaction& tx) {
joinsplit.push_back(Pair("macs", macs));
}
joinsplit.push_back(Pair("vpub_old", ValueFromAmount(jsdescription.vpub_old)));
joinsplit.push_back(Pair("vpub_new", ValueFromAmount(jsdescription.vpub_new)));
CDataStream ssProof(SER_NETWORK, PROTOCOL_VERSION);
ssProof << jsdescription.proof;
joinsplit.push_back(Pair("proof", HexStr(ssProof.begin(), ssProof.end())));
{
Array ciphertexts;
for (const ZCNoteEncryption::Ciphertext ct : jsdescription.ciphertexts) {
ciphertexts.push_back(HexStr(ct.begin(), ct.end()));
}
joinsplit.push_back(Pair("ciphertexts", ciphertexts));
}
vjoinsplit.push_back(joinsplit);
}
@ -204,6 +219,33 @@ Value getrawtransaction(const Array& params, bool fHelp)
" }\n"
" ,...\n"
" ],\n"
" \"vjoinsplit\" : [ (array of json objects, only for version >= 2)\n"
" {\n"
" \"vpub_old\" : x.xxx, (numeric) public input value in ZEC\n"
" \"vpub_new\" : x.xxx, (numeric) public output value in ZEC\n"
" \"anchor\" : \"hex\", (string) the anchor\n"
" \"nullifiers\" : [ (json array of string)\n"
" \"hex\" (string) input note nullifier\n"
" ,...\n"
" ],\n"
" \"commitments\" : [ (json array of string)\n"
" \"hex\" (string) output note commitment\n"
" ,...\n"
" ],\n"
" \"onetimePubKey\" : \"hex\", (string) the onetime public key used to encrypt the ciphertexts\n"
" \"randomSeed\" : \"hex\", (string) the random seed\n"
" \"macs\" : [ (json array of string)\n"
" \"hex\" (string) input note MAC\n"
" ,...\n"
" ],\n"
" \"proof\" : \"hex\", (string) the zero-knowledge proof\n"
" \"ciphertexts\" : [ (json array of string)\n"
" \"hex\" (string) output note ciphertext\n"
" ,...\n"
" ]\n"
" }\n"
" ,...\n"
" ],\n"
" \"blockhash\" : \"hash\", (string) the block hash\n"
" \"confirmations\" : n, (numeric) The confirmations\n"
" \"time\" : ttt, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT)\n"
@ -474,6 +516,33 @@ Value decoderawtransaction(const Array& params, bool fHelp)
" }\n"
" ,...\n"
" ],\n"
" \"vjoinsplit\" : [ (array of json objects, only for version >= 2)\n"
" {\n"
" \"vpub_old\" : x.xxx, (numeric) public input value in ZEC\n"
" \"vpub_new\" : x.xxx, (numeric) public output value in ZEC\n"
" \"anchor\" : \"hex\", (string) the anchor\n"
" \"nullifiers\" : [ (json array of string)\n"
" \"hex\" (string) input note nullifier\n"
" ,...\n"
" ],\n"
" \"commitments\" : [ (json array of string)\n"
" \"hex\" (string) output note commitment\n"
" ,...\n"
" ],\n"
" \"onetimePubKey\" : \"hex\", (string) the onetime public key used to encrypt the ciphertexts\n"
" \"randomSeed\" : \"hex\", (string) the random seed\n"
" \"macs\" : [ (json array of string)\n"
" \"hex\" (string) input note MAC\n"
" ,...\n"
" ],\n"
" \"proof\" : \"hex\", (string) the zero-knowledge proof\n"
" \"ciphertexts\" : [ (json array of string)\n"
" \"hex\" (string) output note ciphertext\n"
" ,...\n"
" ]\n"
" }\n"
" ,...\n"
" ],\n"
"}\n"
"\nExamples:\n"

Loading…
Cancel
Save