Skip to content

Commit

Permalink
Fix Amount
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Ziegler authored and Oliver Ziegler committed Jan 23, 2019
1 parent ca0c7de commit 0fccc50
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/bitcoin-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,9 @@ static CAmount AmountFromValue(const UniValue& value)
{
if (!value.isNum() && !value.isStr())
throw runtime_error("Amount is not a number or string");
CAmount amount;
CAmount amount = roundint64(amount * COIN);
if (!ParseFixedPoint(value.getValStr(), 8, &amount))
throw runtime_error("Invalid amount");
amount = roundint64(amount * COIN);
if (!MoneyRange(amount))
throw runtime_error("Amount out of range");
return amount;
Expand Down
3 changes: 1 addition & 2 deletions src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,9 @@ CAmount AmountFromValue(const UniValue& value)
{
if (!value.isNum() && !value.isStr())
throw JSONRPCError(RPC_TYPE_ERROR, "Amount is not a number or string");
CAmount amount;
CAmount amount = roundint64(amount * COIN);
if (!ParseFixedPoint(value.getValStr(), 8, &amount))
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
amount = roundint64(amount * COIN);
if (!MoneyRange(amount))
throw JSONRPCError(RPC_TYPE_ERROR, "Amount out of range");
return amount;
Expand Down

0 comments on commit 0fccc50

Please sign in to comment.