Use global mempool nullifier count, not local wallet nullifier count
This commit is contained in:
@@ -481,6 +481,7 @@ extern UniValue z_exportviewingkey(const UniValue& params, bool fHelp, const CPu
|
|||||||
extern UniValue z_importviewingkey(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdump.cpp
|
extern UniValue z_importviewingkey(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdump.cpp
|
||||||
extern UniValue z_getnewaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
extern UniValue z_getnewaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
||||||
extern UniValue z_listaddresses(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
extern UniValue z_listaddresses(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
||||||
|
extern UniValue z_listnullifiers(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
||||||
extern UniValue z_exportwallet(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdump.cpp
|
extern UniValue z_exportwallet(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdump.cpp
|
||||||
extern UniValue z_importwallet(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdump.cpp
|
extern UniValue z_importwallet(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdump.cpp
|
||||||
extern UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
extern UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||||
|
// Copyright (c) 2019-2020 The Hush developers
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|||||||
@@ -888,6 +888,10 @@ bool CTxMemPool::IsFullyNotified() {
|
|||||||
return nRecentlyAddedSequence == nNotifiedSequence;
|
return nRecentlyAddedSequence == nNotifiedSequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<uint256, const CTransaction*> CTxMemPool::getNullifiers() {
|
||||||
|
return mapSaplingNullifiers;
|
||||||
|
}
|
||||||
|
|
||||||
CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { }
|
CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { }
|
||||||
|
|
||||||
bool CCoinsViewMemPool::GetNullifier(const uint256 &nf, ShieldedType type) const
|
bool CCoinsViewMemPool::GetNullifier(const uint256 &nf, ShieldedType type) const
|
||||||
|
|||||||
@@ -201,6 +201,7 @@ public:
|
|||||||
* all inputs are in the mapNextTx array). If sanity-checking is turned off,
|
* all inputs are in the mapNextTx array). If sanity-checking is turned off,
|
||||||
* check does nothing.
|
* check does nothing.
|
||||||
*/
|
*/
|
||||||
|
std::map<uint256, const CTransaction*> getNullifiers();
|
||||||
void check(const CCoinsViewCache *pcoins) const;
|
void check(const CCoinsViewCache *pcoins) const;
|
||||||
void setSanityCheck(double dFrequency = 1.0) { nCheckFrequency = static_cast<uint32_t>(dFrequency * 4294967295.0); }
|
void setSanityCheck(double dFrequency = 1.0) { nCheckFrequency = static_cast<uint32_t>(dFrequency * 4294967295.0); }
|
||||||
|
|
||||||
|
|||||||
@@ -3748,27 +3748,25 @@ UniValue z_listnullifiers(const UniValue& params, bool fHelp, const CPubKey& myp
|
|||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() > 1)
|
if (fHelp || params.size() > 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"z_listaddresses ( includeWatchonly )\n"
|
"z_listnullifiers\n"
|
||||||
"\nReturns the list of Sprout and Sapling shielded addresses belonging to the wallet.\n"
|
"\nReturns the list of Sapling nullifiers.\n"
|
||||||
"\nArguments:\n"
|
|
||||||
"1. includeWatchonly (bool, optional, default=false) Also include watchonly addresses (see 'z_importviewingkey')\n"
|
|
||||||
"\nResult:\n"
|
"\nResult:\n"
|
||||||
"[ (json array of string)\n"
|
"[ (json array of string)\n"
|
||||||
" \"zaddr\" (string) a zaddr belonging to the wallet\n"
|
" \"nullifier\" (string) a Sapling nullifer\n"
|
||||||
" ,...\n"
|
" ,...\n"
|
||||||
"]\n"
|
"]\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
+ HelpExampleCli("z_listaddresses", "")
|
+ HelpExampleCli("z_listnullifiers", "")
|
||||||
+ HelpExampleRpc("z_listaddresses", "")
|
+ HelpExampleRpc("z_listnullifiers", "")
|
||||||
);
|
);
|
||||||
|
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
UniValue ret(UniValue::VARR);
|
UniValue ret(UniValue::VARR);
|
||||||
for (auto nullifier: Nullifiers){
|
//for (auto nullifier: mempool.getNullifiers()) {
|
||||||
ret.push_back(EncodePaymentAddress(addr));
|
// ret.push_back(nullifier.GetHex());
|
||||||
}
|
//}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -613,15 +613,6 @@ std::set<std::pair<libzcash::PaymentAddress, uint256>> CWallet::GetNullifiersFor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const auto & txPair : mapWallet) {
|
for (const auto & txPair : mapWallet) {
|
||||||
// Sprout
|
|
||||||
for (const auto & noteDataPair : txPair.second.mapSproutNoteData) {
|
|
||||||
auto & noteData = noteDataPair.second;
|
|
||||||
auto & nullifier = noteData.nullifier;
|
|
||||||
auto & address = noteData.address;
|
|
||||||
if (nullifier && addresses.count(address)) {
|
|
||||||
nullifierSet.insert(std::make_pair(address, nullifier.get()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Sapling
|
// Sapling
|
||||||
for (const auto & noteDataPair : txPair.second.mapSaplingNoteData) {
|
for (const auto & noteDataPair : txPair.second.mapSaplingNoteData) {
|
||||||
auto & noteData = noteDataPair.second;
|
auto & noteData = noteDataPair.second;
|
||||||
@@ -960,12 +951,29 @@ void CWallet::AddToSpends(const uint256& wtxid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<uint256> CWallet::GetNullifiers()
|
||||||
|
{
|
||||||
|
std::set<uint256> nullifierSet;
|
||||||
|
for (const auto & txPair : mapWallet) {
|
||||||
|
// Sapling
|
||||||
|
for (const auto & noteDataPair : txPair.second.mapSaplingNoteData) {
|
||||||
|
auto & noteData = noteDataPair.second;
|
||||||
|
auto & nullifier = noteData.nullifier;
|
||||||
|
if (nullifier) {
|
||||||
|
nullifierSet.insert(nullifier.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullifierSet;
|
||||||
|
}
|
||||||
|
|
||||||
int64_t CWallet::NullifierCount()
|
int64_t CWallet::NullifierCount()
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
return mapTxSaplingNullifiers.size();
|
return mempool.getNullifiers().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CWallet::ClearNoteWitnessCache()
|
void CWallet::ClearNoteWitnessCache()
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
|
|||||||
@@ -797,6 +797,7 @@ public:
|
|||||||
void ClearNoteWitnessCache();
|
void ClearNoteWitnessCache();
|
||||||
|
|
||||||
int64_t NullifierCount();
|
int64_t NullifierCount();
|
||||||
|
std::set<uint256> GetNullifiers();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user