Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/util.cpp
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | if (fStrict) { | ||||
std::string err = strprintf("Unexpected key %s", k); | std::string err = strprintf("Unexpected key %s", k); | ||||
throw JSONRPCError(RPC_TYPE_ERROR, err); | throw JSONRPCError(RPC_TYPE_ERROR, err); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
Amount AmountFromValue(const UniValue &value) { | Amount AmountFromValue(const UniValue &value) { | ||||
const auto currency = Currency::get(); | |||||
if (!value.isNum() && !value.isStr()) { | if (!value.isNum() && !value.isStr()) { | ||||
throw JSONRPCError(RPC_TYPE_ERROR, "Amount is not a number or string"); | throw JSONRPCError(RPC_TYPE_ERROR, "Amount is not a number or string"); | ||||
} | } | ||||
int64_t n; | int64_t n; | ||||
if (!ParseFixedPoint(value.getValStr(), 8, &n)) { | if (!ParseFixedPoint(value.getValStr(), currency.decimals(), &n)) { | ||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount"); | throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount"); | ||||
} | } | ||||
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"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 809 Lines • Show Last 20 Lines |