mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
rpc: Add ParseFeeRate helper
This commit is contained in:
parent
fa0ff66109
commit
fade94d11a
2 changed files with 12 additions and 0 deletions
|
@ -75,6 +75,13 @@ CAmount AmountFromValue(const UniValue& value, int decimals)
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CFeeRate ParseFeeRate(const UniValue& json)
|
||||||
|
{
|
||||||
|
CAmount val{AmountFromValue(json)};
|
||||||
|
if (val >= COIN) throw JSONRPCError(RPC_INVALID_PARAMETER, "Fee rates larger than or equal to 1BTC/kvB are not accepted");
|
||||||
|
return CFeeRate{val};
|
||||||
|
}
|
||||||
|
|
||||||
uint256 ParseHashV(const UniValue& v, std::string_view name)
|
uint256 ParseHashV(const UniValue& v, std::string_view name)
|
||||||
{
|
{
|
||||||
const std::string& strHex(v.get_str());
|
const std::string& strHex(v.get_str());
|
||||||
|
|
|
@ -103,6 +103,11 @@ std::vector<unsigned char> ParseHexO(const UniValue& o, std::string_view strKey)
|
||||||
* @returns a CAmount if the various checks pass.
|
* @returns a CAmount if the various checks pass.
|
||||||
*/
|
*/
|
||||||
CAmount AmountFromValue(const UniValue& value, int decimals = 8);
|
CAmount AmountFromValue(const UniValue& value, int decimals = 8);
|
||||||
|
/**
|
||||||
|
* Parse a json number or string, denoting BTC/kvB, into a CFeeRate (sat/kvB).
|
||||||
|
* Reject negative values or rates larger than 1BTC/kvB.
|
||||||
|
*/
|
||||||
|
CFeeRate ParseFeeRate(const UniValue& json);
|
||||||
|
|
||||||
using RPCArgList = std::vector<std::pair<std::string, UniValue>>;
|
using RPCArgList = std::vector<std::pair<std::string, UniValue>>;
|
||||||
std::string HelpExampleCli(const std::string& methodname, const std::string& args);
|
std::string HelpExampleCli(const std::string& methodname, const std::string& args);
|
||||||
|
|
Loading…
Reference in a new issue