PPCoin: Fix coinstake generation with lots of small coins in wallet
authorSunny King <sunnyking9999@gmail.com>
Tue, 2 Oct 2012 15:20:06 +0000 (16:20 +0100)
committerSunny King <sunnyking9999@gmail.com>
Tue, 2 Oct 2012 15:20:06 +0000 (16:20 +0100)
src/wallet.cpp

index c585590..e955965 100644 (file)
@@ -1322,6 +1322,9 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
         if (txNew.vout.size() == 2 && ((pcoin.first->vout[pcoin.second].scriptPubKey == scriptPubKeyKernel || pcoin.first->vout[pcoin.second].scriptPubKey == txNew.vout[1].scriptPubKey))
             && pcoin.first->GetHash() != txNew.vin[0].prevout.hash)
         {
+            // Stop adding more inputs if already too many inputs
+            if (txNew.vin.size() >= 100)
+                break;
             // Stop adding more inputs if value is already pretty significant
             if (nCredit > nCombineThreshold)
                 break;
@@ -1368,7 +1371,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
         // Limit size
         unsigned int nBytes = ::GetSerializeSize(txNew, SER_NETWORK, PROTOCOL_VERSION);
         if (nBytes >= MAX_BLOCK_SIZE_GEN/5)
-            return false;
+            return error("CreateCoinStake : exceeded coinstake size limit");
 
         // Check enough fee is paid
         if (nMinFee < txNew.GetMinFee() - MIN_TX_FEE)