From cdfd1d75e789cab577096187aec15a9fe4a4cebf Mon Sep 17 00:00:00 2001 From: Sunny King Date: Tue, 2 Oct 2012 16:20:06 +0100 Subject: [PATCH 1/1] PPCoin: Fix coinstake generation with lots of small coins in wallet --- src/wallet.cpp | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/src/wallet.cpp b/src/wallet.cpp index c585590..e955965 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -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) -- 1.7.1