Add vjoinsplit to JSON output of RPC call gettransaction
This commit is contained in:
@@ -225,13 +225,17 @@ class WalletTest (BitcoinTestFramework):
|
|||||||
|
|
||||||
# send from node 0 to node 2 taddr
|
# send from node 0 to node 2 taddr
|
||||||
mytaddr = self.nodes[2].getnewaddress();
|
mytaddr = self.nodes[2].getnewaddress();
|
||||||
self.nodes[0].sendtoaddress(mytaddr, 10.0);
|
mytxid = self.nodes[0].sendtoaddress(mytaddr, 10.0);
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
mybalance = self.nodes[2].z_getbalance(mytaddr)
|
mybalance = self.nodes[2].z_getbalance(mytaddr)
|
||||||
assert_equal(self.nodes[2].z_getbalance(mytaddr), Decimal('10.0'));
|
assert_equal(self.nodes[2].z_getbalance(mytaddr), Decimal('10.0'));
|
||||||
|
|
||||||
|
mytxdetails = self.nodes[2].gettransaction(mytxid)
|
||||||
|
myvjoinsplits = mytxdetails["vjoinsplit"]
|
||||||
|
assert_equal(0, len(myvjoinsplits))
|
||||||
|
|
||||||
# add zaddr to node 2
|
# add zaddr to node 2
|
||||||
myzaddr = self.nodes[2].z_getnewaddress()
|
myzaddr = self.nodes[2].z_getnewaddress()
|
||||||
|
|
||||||
@@ -251,6 +255,7 @@ class WalletTest (BitcoinTestFramework):
|
|||||||
sleep(1)
|
sleep(1)
|
||||||
else:
|
else:
|
||||||
status = results[0]["status"]
|
status = results[0]["status"]
|
||||||
|
mytxid = results[0]["result"]["txid"]
|
||||||
break
|
break
|
||||||
|
|
||||||
assert_equal("success", status)
|
assert_equal("success", status)
|
||||||
@@ -274,6 +279,10 @@ class WalletTest (BitcoinTestFramework):
|
|||||||
assert_equal(Decimal(resp["private"]), zsendmanynotevalue)
|
assert_equal(Decimal(resp["private"]), zsendmanynotevalue)
|
||||||
assert_equal(Decimal(resp["total"]), node2utxobalance + zsendmanynotevalue)
|
assert_equal(Decimal(resp["total"]), node2utxobalance + zsendmanynotevalue)
|
||||||
|
|
||||||
|
# there should be at least one joinsplit
|
||||||
|
mytxdetails = self.nodes[2].gettransaction(mytxid)
|
||||||
|
myvjoinsplits = mytxdetails["vjoinsplit"]
|
||||||
|
assert_greater_than(len(myvjoinsplits), 0)
|
||||||
|
|
||||||
# send from private note to node 0 and node 2
|
# send from private note to node 0 and node 2
|
||||||
node0balance = self.nodes[0].getbalance() # 25.99794745
|
node0balance = self.nodes[0].getbalance() # 25.99794745
|
||||||
|
|||||||
@@ -55,41 +55,8 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeH
|
|||||||
out.push_back(Pair("addresses", a));
|
out.push_back(Pair("addresses", a));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
|
|
||||||
{
|
|
||||||
entry.push_back(Pair("txid", tx.GetHash().GetHex()));
|
|
||||||
entry.push_back(Pair("version", tx.nVersion));
|
|
||||||
entry.push_back(Pair("locktime", (int64_t)tx.nLockTime));
|
|
||||||
Array vin;
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
|
||||||
Object in;
|
|
||||||
if (tx.IsCoinBase())
|
|
||||||
in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
|
|
||||||
else {
|
|
||||||
in.push_back(Pair("txid", txin.prevout.hash.GetHex()));
|
|
||||||
in.push_back(Pair("vout", (int64_t)txin.prevout.n));
|
|
||||||
Object o;
|
|
||||||
o.push_back(Pair("asm", txin.scriptSig.ToString()));
|
|
||||||
o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
|
|
||||||
in.push_back(Pair("scriptSig", o));
|
|
||||||
}
|
|
||||||
in.push_back(Pair("sequence", (int64_t)txin.nSequence));
|
|
||||||
vin.push_back(in);
|
|
||||||
}
|
|
||||||
entry.push_back(Pair("vin", vin));
|
|
||||||
Array vout;
|
|
||||||
for (unsigned int i = 0; i < tx.vout.size(); i++) {
|
|
||||||
const CTxOut& txout = tx.vout[i];
|
|
||||||
Object out;
|
|
||||||
out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
|
|
||||||
out.push_back(Pair("n", (int64_t)i));
|
|
||||||
Object o;
|
|
||||||
ScriptPubKeyToJSON(txout.scriptPubKey, o, true);
|
|
||||||
out.push_back(Pair("scriptPubKey", o));
|
|
||||||
vout.push_back(out);
|
|
||||||
}
|
|
||||||
entry.push_back(Pair("vout", vout));
|
|
||||||
|
|
||||||
|
Array TxJoinSplitToJSON(const CTransaction& tx) {
|
||||||
Array vjoinsplit;
|
Array vjoinsplit;
|
||||||
for (unsigned int i = 0; i < tx.vjoinsplit.size(); i++) {
|
for (unsigned int i = 0; i < tx.vjoinsplit.size(); i++) {
|
||||||
const JSDescription& jsdescription = tx.vjoinsplit[i];
|
const JSDescription& jsdescription = tx.vjoinsplit[i];
|
||||||
@@ -126,7 +93,45 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
|
|||||||
|
|
||||||
vjoinsplit.push_back(joinsplit);
|
vjoinsplit.push_back(joinsplit);
|
||||||
}
|
}
|
||||||
|
return vjoinsplit;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
|
||||||
|
{
|
||||||
|
entry.push_back(Pair("txid", tx.GetHash().GetHex()));
|
||||||
|
entry.push_back(Pair("version", tx.nVersion));
|
||||||
|
entry.push_back(Pair("locktime", (int64_t)tx.nLockTime));
|
||||||
|
Array vin;
|
||||||
|
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
||||||
|
Object in;
|
||||||
|
if (tx.IsCoinBase())
|
||||||
|
in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
|
||||||
|
else {
|
||||||
|
in.push_back(Pair("txid", txin.prevout.hash.GetHex()));
|
||||||
|
in.push_back(Pair("vout", (int64_t)txin.prevout.n));
|
||||||
|
Object o;
|
||||||
|
o.push_back(Pair("asm", txin.scriptSig.ToString()));
|
||||||
|
o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
|
||||||
|
in.push_back(Pair("scriptSig", o));
|
||||||
|
}
|
||||||
|
in.push_back(Pair("sequence", (int64_t)txin.nSequence));
|
||||||
|
vin.push_back(in);
|
||||||
|
}
|
||||||
|
entry.push_back(Pair("vin", vin));
|
||||||
|
Array vout;
|
||||||
|
for (unsigned int i = 0; i < tx.vout.size(); i++) {
|
||||||
|
const CTxOut& txout = tx.vout[i];
|
||||||
|
Object out;
|
||||||
|
out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
|
||||||
|
out.push_back(Pair("n", (int64_t)i));
|
||||||
|
Object o;
|
||||||
|
ScriptPubKeyToJSON(txout.scriptPubKey, o, true);
|
||||||
|
out.push_back(Pair("scriptPubKey", o));
|
||||||
|
vout.push_back(out);
|
||||||
|
}
|
||||||
|
entry.push_back(Pair("vout", vout));
|
||||||
|
|
||||||
|
Array vjoinsplit = TxJoinSplitToJSON(tx);
|
||||||
entry.push_back(Pair("vjoinsplit", vjoinsplit));
|
entry.push_back(Pair("vjoinsplit", vjoinsplit));
|
||||||
|
|
||||||
if (!hashBlock.IsNull()) {
|
if (!hashBlock.IsNull()) {
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ using namespace json_spirit;
|
|||||||
|
|
||||||
using namespace libzcash;
|
using namespace libzcash;
|
||||||
|
|
||||||
|
extern Array TxJoinSplitToJSON(const CTransaction& tx);
|
||||||
|
|
||||||
int64_t nWalletUnlockTime;
|
int64_t nWalletUnlockTime;
|
||||||
static CCriticalSection cs_nWalletUnlockTime;
|
static CCriticalSection cs_nWalletUnlockTime;
|
||||||
|
|
||||||
@@ -92,6 +94,8 @@ void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
|
|||||||
entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived));
|
entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived));
|
||||||
BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue)
|
BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue)
|
||||||
entry.push_back(Pair(item.first, item.second));
|
entry.push_back(Pair(item.first, item.second));
|
||||||
|
|
||||||
|
entry.push_back(Pair("vjoinsplit", TxJoinSplitToJSON(wtx)));
|
||||||
}
|
}
|
||||||
|
|
||||||
string AccountFromValue(const Value& value)
|
string AccountFromValue(const Value& value)
|
||||||
@@ -1702,6 +1706,17 @@ Value gettransaction(const Array& params, bool fHelp)
|
|||||||
" }\n"
|
" }\n"
|
||||||
" ,...\n"
|
" ,...\n"
|
||||||
" ],\n"
|
" ],\n"
|
||||||
|
" \"vjoinsplit\" : [\n"
|
||||||
|
" {\n"
|
||||||
|
" \"anchor\" : \"treestateref\", (string) Merkle root of note commitment tree\n"
|
||||||
|
" \"nullifiers\" : [ string, ... ] (string) Nullifiers of input notes\n"
|
||||||
|
" \"commitments\" : [ string, ... ] (string) Note commitments for note outputs\n"
|
||||||
|
" \"macs\" : [ string, ... ] (string) Message authentication tags\n"
|
||||||
|
" \"vpub_old\" : x.xxx (numeric) The amount removed from the transparent value pool\n"
|
||||||
|
" \"vpub_new\" : x.xxx, (numeric) The amount added to the transparent value pool\n"
|
||||||
|
" }\n"
|
||||||
|
" ,...\n"
|
||||||
|
" ],\n"
|
||||||
" \"hex\" : \"data\" (string) Raw data for transaction\n"
|
" \"hex\" : \"data\" (string) Raw data for transaction\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user