@@ -26,7 +26,7 @@ CzPIVWallet::CzPIVWallet(std::string strWalletFile, bool fFirstRun)
2626 seed = CBigNum::randBignum (CBigNum (~uint256 (0 ))).getuint256 ();
2727
2828 SetMasterSeed (seed);
29- this ->mintPool = CMintPool (nCount );
29+ this ->mintPool = CMintPool (nCountLastUsed );
3030}
3131
3232bool CzPIVWallet::SetMasterSeed (const uint256& seedMaster, bool fResetCount )
@@ -37,11 +37,11 @@ bool CzPIVWallet::SetMasterSeed(const uint256& seedMaster, bool fResetCount)
3737 if (!walletdb.WriteZPIVSeed (seedMaster))
3838 return false ;
3939
40- nCount = 0 ;
40+ nCountLastUsed = 0 ;
4141 if (fResetCount )
42- walletdb.WriteZPIVCount (nCount );
43- else if (!walletdb.ReadZPIVCount (nCount ))
44- nCount = 0 ;
42+ walletdb.WriteZPIVCount (nCountLastUsed );
43+ else if (!walletdb.ReadZPIVCount (nCountLastUsed ))
44+ nCountLastUsed = 0 ;
4545
4646 // todo fix to sync with count above
4747 mintPool.Reset ();
@@ -52,7 +52,7 @@ bool CzPIVWallet::SetMasterSeed(const uint256& seedMaster, bool fResetCount)
5252// Add the next 10 mints to the mint pool
5353void CzPIVWallet::GenerateMintPool (int nCountStart, int nCountEnd)
5454{
55- int n = std::max (mintPool. CountOfLastGenerated () + 1 , nCount) ;
55+ int n = nCountLastUsed + 1 ;
5656 if (nCountStart > 0 )
5757 n = nCountStart;
5858
@@ -199,8 +199,8 @@ void CzPIVWallet::SyncWithChain(bool fGenerateMintPool)
199199
200200 SetMintSeen (bnValue, nHeight, txHash, denomination);
201201 nLastCountUsed = std::max (pMint.second , nLastCountUsed);
202- nCount = std::max (nLastCountUsed + 1 , nCount );
203- LogPrint (" zero" , " %s: updated count to %d\n " , __func__, nCount );
202+ nCountLastUsed = std::max (nLastCountUsed, nCountLastUsed );
203+ LogPrint (" zero" , " %s: updated count to %d\n " , __func__, nCountLastUsed );
204204 }
205205 }
206206 }
@@ -272,10 +272,10 @@ bool CzPIVWallet::SetMintSeen(const CBigNum& bnValue, const int& nHeight, const
272272 pwalletMain->zpivTracker ->Add (dMint, true );
273273
274274 // Update the count if it is less than the mint's count
275- if (nCount <= pMint.second ) {
275+ if (nCountLastUsed < pMint.second ) {
276276 CWalletDB walletdb (strWalletFile);
277- nCount = pMint.second + 1 ;
278- walletdb.WriteZPIVCount (nCount );
277+ nCountLastUsed = pMint.second ;
278+ walletdb.WriteZPIVCount (nCountLastUsed );
279279 }
280280
281281 // remove from the pool
@@ -341,7 +341,7 @@ void CzPIVWallet::SeedToZPIV(const uint512& seedZerocoin, CBigNum& bnSerial, CBi
341341
342342uint512 CzPIVWallet::GetNextZerocoinSeed ()
343343{
344- return GetZerocoinSeed (nCount );
344+ return GetZerocoinSeed (nCountLastUsed + 1 );
345345}
346346
347347uint512 CzPIVWallet::GetZerocoinSeed (uint32_t n)
@@ -354,14 +354,14 @@ uint512 CzPIVWallet::GetZerocoinSeed(uint32_t n)
354354
355355void CzPIVWallet::UpdateCount ()
356356{
357- nCount ++;
357+ nCountLastUsed ++;
358358 CWalletDB walletdb (strWalletFile);
359- walletdb.WriteZPIVCount (nCount );
359+ walletdb.WriteZPIVCount (nCountLastUsed );
360360}
361361
362362void CzPIVWallet::GenerateDeterministicZPIV (CoinDenomination denom, PrivateCoin& coin, CDeterministicMint& dMint, bool fGenerateOnly )
363363{
364- GenerateMint (nCount , denom, coin, dMint);
364+ GenerateMint (nCountLastUsed + 1 , denom, coin, dMint);
365365 if (fGenerateOnly )
366366 return ;
367367
0 commit comments