add blockheight, blockindex and blocktime to z_listreceivedbyaddress
This commit is contained in:
parent
de47393848
commit
7e946d7ccb
|
@ -49,6 +49,9 @@ class ListReceivedTest (BitcoinTestFramework):
|
|||
assert_equal(1, r[0]['amount'])
|
||||
assert_false(r[0]['change'], "Note should not be change")
|
||||
assert_equal(my_memo, r[0]['memo'])
|
||||
assert_equal(0, r[0]['confirmations'])
|
||||
assert_equal(-1, r[0]['blockindex'])
|
||||
assert_equal(0, r[0]['blockheight'])
|
||||
|
||||
# Confirm transaction (1 ZEC from taddr to zaddr1)
|
||||
self.generate_and_sync(height+3)
|
||||
|
@ -56,6 +59,12 @@ class ListReceivedTest (BitcoinTestFramework):
|
|||
# adjust previous result because now there is one more confirmation
|
||||
r[0]['confirmations'] += 1
|
||||
|
||||
# adjust blockindex as now there are 2 transactions confirmed in the block
|
||||
r[0]['blockindex'] = 1
|
||||
|
||||
# adjust height as we generated blocks
|
||||
r[0]['blockheight'] = height + 3
|
||||
|
||||
# Require one confirmation, note should be present
|
||||
assert_equal(r, self.nodes[1].z_listreceivedbyaddress(zaddr1))
|
||||
|
||||
|
|
|
@ -3303,6 +3303,23 @@ CAmount getBalanceZaddr(std::string address, int minDepth = 1, bool ignoreUnspen
|
|||
return balance;
|
||||
}
|
||||
|
||||
struct trxblock
|
||||
{
|
||||
int blockheight = 0;
|
||||
int blockindex = -1;
|
||||
int64_t blocktime = 0;
|
||||
|
||||
trxblock(uint256 hash)
|
||||
{
|
||||
if(pwalletMain->mapWallet.count(hash)) {
|
||||
const CWalletTx& wtx = pwalletMain->mapWallet[hash];
|
||||
if(!wtx.hashBlock.IsNull())
|
||||
blockheight = mapBlockIndex[wtx.hashBlock]->nHeight;
|
||||
blockindex = wtx.nIndex;
|
||||
blocktime = wtx.GetTxTime();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp)
|
||||
{
|
||||
|
@ -3322,6 +3339,9 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp)
|
|||
" \"amount\": xxxxx, (numeric) the amount of value in the note\n"
|
||||
" \"memo\": xxxxx, (string) hexadecimal string representation of memo field\n"
|
||||
" \"confirmations\" : n, (numeric) the number of confirmations\n"
|
||||
" \"blockheight\": n, (numeric) The block height containing the transaction\n"
|
||||
" \"blockindex\": n, (numeric) The block index containing the transaction.\n"
|
||||
" \"time\": xxx, (numeric) The transaction time in seconds since epoch (midnight Jan 1 1970 GMT).\n"
|
||||
" \"jsindex\" (sprout) : n, (numeric) the joinsplit index\n"
|
||||
" \"jsoutindex\" (sprout) : n, (numeric) the output index of the joinsplit\n"
|
||||
" \"outindex\" (sapling) : n, (numeric) the output index\n"
|
||||
|
@ -3376,6 +3396,12 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp)
|
|||
obj.push_back(Pair("jsindex", entry.jsop.js));
|
||||
obj.push_back(Pair("jsoutindex", entry.jsop.n));
|
||||
obj.push_back(Pair("confirmations", entry.confirmations));
|
||||
|
||||
trxblock additional(entry.jsop.hash);
|
||||
obj.push_back(Pair("blockheight", additional.blockheight));
|
||||
obj.push_back(Pair("blockindex", additional.blockindex));
|
||||
obj.push_back(Pair("blocktime", additional.blocktime));
|
||||
|
||||
if (hasSpendingKey) {
|
||||
obj.push_back(Pair("change", pwalletMain->IsNoteSproutChange(nullifierSet, entry.address, entry.jsop)));
|
||||
}
|
||||
|
@ -3389,6 +3415,12 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp)
|
|||
obj.push_back(Pair("memo", HexStr(entry.memo)));
|
||||
obj.push_back(Pair("outindex", (int)entry.op.n));
|
||||
obj.push_back(Pair("confirmations", entry.confirmations));
|
||||
|
||||
trxblock additional(entry.op.hash);
|
||||
obj.push_back(Pair("blockheight", additional.blockheight));
|
||||
obj.push_back(Pair("blockindex", additional.blockindex));
|
||||
obj.push_back(Pair("blocktime", additional.blocktime));
|
||||
|
||||
if (hasSpendingKey) {
|
||||
obj.push_back(Pair("change", pwalletMain->IsNoteSaplingChange(nullifierSet, entry.address, entry.op)));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue