mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
Use a typedef for monetary values
This commit is contained in:
committed by
Mark Friedenbach
parent
64cfaf891f
commit
a372168e77
@@ -88,18 +88,18 @@ static inline int64_t roundint64(double d)
|
||||
return (int64_t)(d > 0 ? d + 0.5 : d - 0.5);
|
||||
}
|
||||
|
||||
int64_t AmountFromValue(const Value& value)
|
||||
CAmount AmountFromValue(const Value& value)
|
||||
{
|
||||
double dAmount = value.get_real();
|
||||
if (dAmount <= 0.0 || dAmount > 21000000.0)
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
|
||||
int64_t nAmount = roundint64(dAmount * COIN);
|
||||
CAmount nAmount = roundint64(dAmount * COIN);
|
||||
if (!MoneyRange(nAmount))
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
|
||||
return nAmount;
|
||||
}
|
||||
|
||||
Value ValueFromAmount(int64_t amount)
|
||||
Value ValueFromAmount(const CAmount& amount)
|
||||
{
|
||||
return (double)amount / (double)COIN;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user