Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/server.cpp
Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | CAmount AmountFromValue(const UniValue &value) { | ||||
if (!MoneyRange(amount)) | if (!MoneyRange(amount)) | ||||
throw JSONRPCError(RPC_TYPE_ERROR, "Amount out of range"); | throw JSONRPCError(RPC_TYPE_ERROR, "Amount out of range"); | ||||
return amount; | return amount; | ||||
} | } | ||||
UniValue ValueFromAmount(const CAmount &amount) { | UniValue ValueFromAmount(const CAmount &amount) { | ||||
bool sign = amount < 0; | bool sign = amount < 0; | ||||
int64_t n_abs = (sign ? -amount : amount); | int64_t n_abs = (sign ? -amount : amount); | ||||
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()) strHex = v.get_str(); | if (v.isStr()) strHex = v.get_str(); | ||||
// Note: IsHex("") is false | // Note: IsHex("") is false | ||||
▲ Show 20 Lines • Show All 384 Lines • Show Last 20 Lines |