Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/server.cpp
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | Amount AmountFromValue(const UniValue &value) { | ||||
if (!MoneyRange(amt)) { | if (!MoneyRange(amt)) { | ||||
throw JSONRPCError(RPC_TYPE_ERROR, "Amount out of range"); | throw JSONRPCError(RPC_TYPE_ERROR, "Amount out of range"); | ||||
} | } | ||||
return amt; | return amt; | ||||
} | } | ||||
UniValue ValueFromAmount(const Amount amount) { | UniValue ValueFromAmount(const Amount amount) { | ||||
int64_t amt = amount.GetSatoshis(); | bool sign = amount < Amount(0); | ||||
bool sign = amt < 0; | Amount n_abs(sign ? -amount : amount); | ||||
int64_t n_abs = (sign ? -amt : amt); | int64_t quotient = n_abs / COIN; | ||||
int64_t quotient = n_abs / COIN.GetSatoshis(); | int64_t remainder = n_abs % COIN; | ||||
int64_t remainder = n_abs % COIN.GetSatoshis(); | |||||
return UniValue(UniValue::VNUM, strprintf("%s%d.%08d", sign ? "-" : "", | return UniValue(UniValue::VNUM, strprintf("%s%d.%08d", sign ? "-" : "", | ||||
quotient, remainder)); | quotient, remainder)); | ||||
} | } | ||||
uint256 ParseHashV(const UniValue &v, std::string strName) { | uint256 ParseHashV(const UniValue &v, std::string strName) { | ||||
std::string strHex; | std::string strHex; | ||||
if (v.isStr()) { | if (v.isStr()) { | ||||
strHex = v.get_str(); | strHex = v.get_str(); | ||||
▲ Show 20 Lines • Show All 456 Lines • Show Last 20 Lines |