Coins metadata load fixes
[novacoin.git] / src / wallet.h
index 3d07f57..195a6ce 100644 (file)
@@ -80,6 +80,9 @@ private:
     // the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded
     int nWalletMaxVersion;
 
+    // selected coins metadata
+    map<uint256, pair<pair<CTxIndex, pair<const CWalletTx*,unsigned int> >, pair<CBlock, uint64> > > mapMeta;
+
 public:
     mutable CCriticalSection cs_wallet;
 
@@ -200,6 +203,7 @@ public:
     bool GetStakeWeight(const CKeyStore& keystore, uint64& nMinWeight, uint64& nMaxWeight, uint64& nWeight);
     void GetStakeWeightFromValue(const int64& nTime, const int64& nValue, uint64& nWeight);
     bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64 nSearchInterval, CTransaction& txNew, CKey& key);
+    bool MergeCoins(const int64& nAmount, const int64& nMaxValue, const int64& nOutputValue, list<uint256>& listMerged);
 
     std::string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);
     std::string SendMoneyToDestination(const CTxDestination &address, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);
@@ -460,6 +464,8 @@ public:
         fWatchCreditCached = false;
         fAvailableCreditCached = false;
         fAvailableWatchCreditCached = false;
+        fImmatureCreditCached = false;
+        fImmatureWatchCreditCached = false;
         fChangeCached = false;
         nDebitCached = 0;
         nWatchDebitCached = 0;
@@ -467,6 +473,8 @@ public:
         nWatchCreditCached = 0;
         nAvailableCreditCached = 0;
         nAvailableWatchCreditCached = 0;
+        nImmatureCreditCached = 0;
+        nImmatureWatchCreditCached = 0;
         nChangeCached = 0;
         nOrderPos = -1;
     }
@@ -648,7 +656,7 @@ public:
 
     int64 GetImmatureCredit(bool fUseCache=true) const
     {
-        if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0 && IsInMainChain())
+        if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain())
         {
             if (fUseCache && fImmatureCreditCached)
                 return nImmatureCreditCached;
@@ -662,7 +670,7 @@ public:
 
     int64 GetImmatureWatchOnlyCredit(bool fUseCache=true) const
     {
-        if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0 && IsInMainChain())
+        if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain())
         {
             if (fUseCache && fImmatureWatchCreditCached)
                 return nImmatureWatchCreditCached;