rpc: Add ParseFeeRate helper

This commit is contained in:
MarcoFalke committed 2024-02-15 10:55:47 +01:00
1 parent fa0ff66109
commit fade94d11a
2 files changed
+12

No files matched your search

+7
View File
@@ -75,6 +75,13 @@ CAmount AmountFromValue(const UniValue& value, int decimals)
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)
{
const std::string& strHex(v.get_str());
+5
View File
@@ -103,6 +103,11 @@ std::vector<unsigned char> ParseHexO(const UniValue& o, std::string_view strKey)
* @returns a CAmount if the various checks pass.
*/
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>>;
std::string HelpExampleCli(const std::string& methodname, const std::string& args);