Wallet refuses to create mints with zero reward. 64/head
authorfsb4000 <fsb4000@yandex.ru>
Mon, 24 Nov 2014 07:07:09 +0000 (13:07 +0600)
committerfsb4000 <fsb4000@yandex.ru>
Mon, 24 Nov 2014 07:07:09 +0000 (13:07 +0600)
Запрещает кошельку создавать PoS блоки с отрицательной или нулевой наградой.
Аналогично https://github.com/ppcoin/ppcoin/pull/66/

src/wallet.cpp

index a78a76b..96dbdeb 100644 (file)
@@ -2043,7 +2043,13 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
         CTxDB txdb("r");
         if (!txNew.GetCoinAge(txdb, nCoinAge))
             return error("CreateCoinStake : failed to calculate coin age");
-        nCredit += GetProofOfStakeReward(nCoinAge, nBits, txNew.nTime);
+        
+        int64 nReward = GetProofOfStakeReward(nCoinAge, nBits, txNew.nTime);
+        // Refuse to create mint that has zero or negative reward
+        if(nReward <= 0)
+            return false;
+    
+        nCredit += nReward;
     }
 
     int64 nMinFee = 0;
@@ -2798,4 +2804,4 @@ void CWallet::ClearOrphans()
 
     for(list<uint256>::const_iterator it = orphans.begin(); it != orphans.end(); ++it)
         EraseFromWallet(*it);
-}
\ No newline at end of file
+}