Skip to content

Commit 623e5c8

Browse files
presstabFuzzbawls
authored andcommitted
dzpivstate RPC call. Displays state of deterministic zpiv wallet.
1 parent 0de37d9 commit 623e5c8

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

src/rpcserver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ static const CRPCCommand vRPCCommands[] =
448448
{"zerocoin", "getzpivseed", &getzpivseed, false, false, true},
449449
{"zerocoin", "setzpivseed", &setzpivseed, false, false, true},
450450
{"zerocoin", "generatemintlist", &generatemintlist, false, false, true},
451-
{"zerocoin", "searchdzpiv", &searchdzpiv, false, false, true}
451+
{"zerocoin", "searchdzpiv", &searchdzpiv, false, false, true},
452+
{"zerocoin", "dzpivstate", &dzpivstate, false, false, true}
452453

453454
#endif // ENABLE_WALLET
454455
};

src/rpcserver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ extern UniValue setzpivseed(const UniValue& params, bool fHelp);
262262
extern UniValue getzpivseed(const UniValue& params, bool fHelp);
263263
extern UniValue generatemintlist(const UniValue& params, bool fHelp);
264264
extern UniValue searchdzpiv(const UniValue& params, bool fHelp);
265+
extern UniValue dzpivstate(const UniValue& params, bool fHelp);
265266

266267
extern UniValue getrawtransaction(const UniValue& params, bool fHelp); // in rcprawtransaction.cpp
267268
extern UniValue listunspent(const UniValue& params, bool fHelp);

src/rpcwallet.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3392,6 +3392,26 @@ UniValue generatemintlist(const UniValue& params, bool fHelp)
33923392
return arrRet;
33933393
}
33943394

3395+
UniValue dzpivstate(const UniValue& params, bool fHelp) {
3396+
if (fHelp || params.size() != 0)
3397+
throw runtime_error(
3398+
"dzpivstate\n"
3399+
"\nThe current state of the mintpool of the deterministic zPIV wallet.\n" +
3400+
HelpRequiringPassphrase() + "\n"
3401+
3402+
"\nExamples\n" +
3403+
HelpExampleCli("mintpoolstatus", "") + HelpExampleRpc("mintpoolstatus", ""));
3404+
3405+
CzPIVWallet* zwallet = pwalletMain->zwalletMain;
3406+
UniValue obj(UniValue::VOBJ);
3407+
int nCount, nCountLastUsed;
3408+
zwallet->GetState(nCount, nCountLastUsed);
3409+
obj.push_back(Pair("dzpiv_count", nCount));
3410+
obj.push_back(Pair("mintpool_count", nCountLastUsed));
3411+
3412+
return obj;
3413+
}
3414+
33953415
UniValue searchdzpiv(const UniValue& params, bool fHelp)
33963416
{
33973417
if(fHelp || params.size() != 2)

src/zpivwallet.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ void CzPIVWallet::RemoveMintsFromPool(const std::vector<uint256>& vPubcoinHashes
164164
mintPool.Remove(hash);
165165
}
166166

167+
void CzPIVWallet::GetState(int& nCount, int& nLastGenerated)
168+
{
169+
nCount = this->nCountLastUsed + 1;
170+
nLastGenerated = mintPool.CountOfLastGenerated();
171+
}
172+
167173
//Catch the counter up with the chain
168174
map<uint256, uint32_t> mapMissingMints;
169175
void CzPIVWallet::SyncWithChain(bool fGenerateMintPool)

src/zpivwallet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class CzPIVWallet
2828
void SyncWithChain(bool fGenerateMintPool = true);
2929
void GenerateDeterministicZPIV(libzerocoin::CoinDenomination denom, libzerocoin::PrivateCoin& coin, CDeterministicMint& dMint, bool fGenerateOnly = false);
3030
void GenerateMint(const uint32_t& nCount, const libzerocoin::CoinDenomination denom, libzerocoin::PrivateCoin& coin, CDeterministicMint& dMint);
31+
void GetState(int& nCount, int& nLastGenerated);
3132
bool RegenerateMint(const CDeterministicMint& dMint, CZerocoinMint& mint);
3233
void GenerateMintPool(uint32_t nCountStart = 0, uint32_t nCountEnd = 0);
3334
bool LoadMintPoolFromDB();

0 commit comments

Comments
 (0)