From: Scott Nadal Date: Fri, 3 Aug 2012 14:41:08 +0000 (+0100) Subject: PPCoin: Enforce minimum output amount 1 cent X-Git-Tag: v0.4.0-unstable~112 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=8bb29178006eafab89b9c2106bdcd0dd75f21b94 PPCoin: Enforce minimum output amount 1 cent --- diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 17d1b31..2ea5415 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -569,6 +569,8 @@ Value sendtoaddress(const Array& params, bool fHelp) // Amount int64 nAmount = AmountFromValue(params[1]); + if (nAmount < MIN_TXOUT_AMOUNT) + throw JSONRPCError(-101, "Send amount too small"); // Wallet comments CWalletTx wtx; @@ -891,6 +893,8 @@ Value sendfrom(const Array& params, bool fHelp) if (!address.IsValid()) throw JSONRPCError(-5, "Invalid ppcoin address"); int64 nAmount = AmountFromValue(params[2]); + if (nAmount < MIN_TXOUT_AMOUNT) + throw JSONRPCError(-101, "Send amount too small"); int nMinDepth = 1; if (params.size() > 3) nMinDepth = params[3].get_int(); @@ -959,6 +963,8 @@ Value sendmany(const Array& params, bool fHelp) CScript scriptPubKey; scriptPubKey.SetBitcoinAddress(address); int64 nAmount = AmountFromValue(s.value_); + if (nAmount < MIN_TXOUT_AMOUNT) + throw JSONRPCError(-101, "Send amount too small"); totalAmount += nAmount; vecSend.push_back(make_pair(scriptPubKey, nAmount)); diff --git a/src/main.cpp b/src/main.cpp index c90565d..835f60c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -455,8 +455,9 @@ bool CTransaction::CheckTransaction() const const CTxOut& txout = vout[i]; if (txout.IsEmpty() && (!IsCoinBase()) && (!IsCoinStake())) return DoS(100, error("CTransaction::CheckTransaction() : txout empty for user transaction")); - if (txout.nValue < 0) - return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue negative")); + // ppcoin: enforce minimum output amount + if ((!txout.IsEmpty()) && txout.nValue < MIN_TXOUT_AMOUNT) + return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue below minimum")); if (txout.nValue > MAX_MONEY) return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue too high")); nValueOut += txout.nValue; diff --git a/src/main.h b/src/main.h index 9a893b4..92bfd77 100644 --- a/src/main.h +++ b/src/main.h @@ -36,6 +36,7 @@ static const int64 MIN_TX_FEE = 10000; static const int64 MIN_RELAY_TX_FEE = 10000; static const int64 MAX_MONEY = 2000000000 * COIN; static const int64 MAX_MINT_PROOF_OF_WORK = 9999 * COIN; +static const int64 MIN_TXOUT_AMOUNT = MIN_TX_FEE; inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } static const int COINBASE_MATURITY = 100; // Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.