From 50e647210d513dab8f40ded61fe439ecaa9a67c3 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Fri, 8 Feb 2019 15:29:45 -0500 Subject: Move ParseConfirmTarget from rpc/mining to rpc/util Util is a better home since it's called both by wallet and mining code. Suggested https://github.com/bitcoin/bitcoin/pull/15288#discussion_r254449444 --- src/rpc/util.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/rpc/util.cpp') diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 4275cc09a..aa5076cd8 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -4,10 +4,12 @@ #include #include +#include #include #include #include #include +#include InitInterfaces* g_rpc_interfaces = nullptr; @@ -129,6 +131,16 @@ UniValue DescribeAddress(const CTxDestination& dest) return boost::apply_visitor(DescribeAddressVisitor(), dest); } +unsigned int ParseConfirmTarget(const UniValue& value) +{ + int target = value.get_int(); + unsigned int max_target = ::feeEstimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE); + if (target < 1 || (unsigned int)target > max_target) { + throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid conf_target, must be between %u - %u", 1, max_target)); + } + return (unsigned int)target; +} + struct Section { Section(const std::string& left, const std::string& right) : m_left{left}, m_right{right} {} -- cgit v1.2.3