Skip to content
This repository has been archived by the owner on Dec 30, 2018. It is now read-only.

Commit

Permalink
Preventing move from getting a negative balance
Browse files Browse the repository at this point in the history
  • Loading branch information
Lohoris committed Dec 6, 2012
1 parent 0a4e67a commit 4442224
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,17 @@ Value movecmd(const Array& params, bool fHelp)
string strFrom = AccountFromValue(params[0]);
string strTo = AccountFromValue(params[1]);
int64 nAmount = AmountFromValue(params[2]);
int nMinDepth = 1;
if (params.size() > 3)
// unused parameter, used to be nMinDepth, keep type-checking it though
(void)params[3].get_int();
nMinDepth = params[3].get_int();
string strComment;
if (params.size() > 4)
strComment = params[4].get_str();


int64 nBalance = GetAccountBalance(strFrom, nMinDepth);
if (nBalance < nAmount)
throw JSONRPCError(-6, "Account has insufficient funds");

CWalletDB walletdb(pwalletMain->strWalletFile);
if (!walletdb.TxnBegin())
throw JSONRPCError(-20, "database error");
Expand Down

0 comments on commit 4442224

Please sign in to comment.