Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/server.cpp
Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | Amount AmountFromValue(const UniValue &value) { | ||||
Amount amt = n * SATOSHI; | Amount amt = n * SATOSHI; | ||||
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) { | |||||
bool sign = amount < Amount::zero(); | |||||
Amount n_abs(sign ? -amount : amount); | |||||
int64_t quotient = n_abs / COIN; | |||||
int64_t remainder = (n_abs % COIN) / SATOSHI; | |||||
return UniValue(UniValue::VNUM, strprintf("%s%d.%08d", sign ? "-" : "", | |||||
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(); | ||||
} | } | ||||
// Note: IsHex("") is false | // Note: IsHex("") is false | ||||
if (!IsHex(strHex)) { | if (!IsHex(strHex)) { | ||||
▲ Show 20 Lines • Show All 427 Lines • Show Last 20 Lines |