Commit 7a42c3aa authored by Pavel Vasin's avatar Pavel Vasin

allow zero in burn rpc

parent 8aa6f07c
......@@ -82,10 +82,12 @@ void RPCTypeCheck(const Object& o,
}
}
int64_t AmountFromValue(const Value& value)
int64_t AmountFromValue(const Value& value, bool allowZero)
{
double dAmount = value.get_real();
if (dAmount <= 0.0 || dAmount > MAX_MONEY)
if (dAmount < 0.0 || dAmount > MAX_MONEY)
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
if (dAmount == 0 && !allowZero)
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
int64_t nAmount = roundint64(dAmount * COIN);
if (!MoneyRange(nAmount))
......
......@@ -77,7 +77,7 @@ extern void InitRPCMining();
extern void ShutdownRPCMining();
extern int64_t nWalletUnlockTime;
extern int64_t AmountFromValue(const json_spirit::Value& value);
extern int64_t AmountFromValue(const json_spirit::Value& value, bool allowZero = false);
extern json_spirit::Value ValueFromAmount(int64_t amount);
extern double GetDifficulty(const CBlockIndex* blockindex = NULL);
......
......@@ -314,7 +314,7 @@ Value burn(const Array& params, bool fHelp)
}
// Amount
int64_t nAmount = AmountFromValue(params[0]);
int64_t nAmount = AmountFromValue(params[0], true);
if (pwalletMain->IsLocked())
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment