From 5d5af91e5d19fdb9f6f00da74934e105d02fa41e Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 6 Jan 2019 14:00:09 -0800 Subject: [PATCH] Add dpowconfs to z_listreceivedbyaddress --- src/wallet/rpcwallet.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5c4e21bfe..74231a58b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3796,13 +3796,30 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) if (boost::get(&zaddr) != nullptr) { for (CSproutNotePlaintextEntry & entry : sproutEntries) { UniValue obj(UniValue::VOBJ); + int nHeight = 0; + CTransaction tx; + uint256 hashBlock; + + if (GetTransaction(entry.jsop.hash, tx, hashBlock, true)) { + BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); + if (it != mapBlockIndex.end()) { + nHeight = it->second->GetHeight(); + fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); + } else { + fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); + } + } else { + fprintf(stderr,"tx hash %s does not exist!\n", entry.jsop.hash.ToString().c_str() ); + } + obj.push_back(Pair("txid", entry.jsop.hash.ToString())); obj.push_back(Pair("amount", ValueFromAmount(CAmount(entry.plaintext.value())))); std::string data(entry.plaintext.memo().begin(), entry.plaintext.memo().end()); obj.push_back(Pair("memo", HexStr(data))); obj.push_back(Pair("jsindex", entry.jsop.js)); obj.push_back(Pair("jsoutindex", entry.jsop.n)); - obj.push_back(Pair("confirmations", entry.confirmations)); + obj.push_back(Pair("rawconfirmations", entry.confirmations)); + obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); if (hasSpendingKey) { obj.push_back(Pair("change", pwalletMain->IsNoteSproutChange(nullifierSet, entry.address, entry.jsop))); } @@ -3811,11 +3828,27 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) } else if (boost::get(&zaddr) != nullptr) { for (SaplingNoteEntry & entry : saplingEntries) { UniValue obj(UniValue::VOBJ); + int nHeight = 0; + CTransaction tx; + uint256 hashBlock; + + if (GetTransaction(entry.op.hash, tx, hashBlock, true)) { + BlockMap::const_iterator it = mapBlockIndex.find(hashBlock); + if (it != mapBlockIndex.end()) { + nHeight = it->second->GetHeight(); + fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight); + } else { + fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() ); + } + } else { + fprintf(stderr,"tx hash %s does not exist!\n", entry.op.hash.ToString().c_str() ); + } obj.push_back(Pair("txid", entry.op.hash.ToString())); obj.push_back(Pair("amount", ValueFromAmount(CAmount(entry.note.value())))); obj.push_back(Pair("memo", HexStr(entry.memo))); obj.push_back(Pair("outindex", (int)entry.op.n)); - obj.push_back(Pair("confirmations", entry.confirmations)); + obj.push_back(Pair("rawconfirmations", entry.confirmations)); + obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations))); if (hasSpendingKey) { obj.push_back(Pair("change", pwalletMain->IsNoteSaplingChange(nullifierSet, entry.address, entry.op))); }