From: Sunny King Date: Tue, 2 Oct 2012 15:20:06 +0000 (+0100) Subject: PPCoin: Fix coinstake generation with lots of small coins in wallet X-Git-Tag: v0.4.0-unstable~60 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=cdfd1d75e789cab577096187aec15a9fe4a4cebf PPCoin: Fix coinstake generation with lots of small coins in wallet --- 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)