From 7e05caae39358b45ce21b1bb3cdf1adef4b14454 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 11 Feb 2019 08:34:10 -0500 Subject: [PATCH] Merge #15373: Move ParseConfirmTarget from rpc/mining to rpc/util 50e647210d Move ParseConfirmTarget from rpc/mining to rpc/util (Russell Yanofsky) Pull request description: 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 Tree-SHA512: 4320caf2a3f70d2885c421de04f2ec68ff3f6519258c5155fc46e245dc1765fd15c81f260af5096318f24ff9deb88fc3c5ef40eec8b7393f467f5b963d17215b --- src/rpc/mining.cpp | 10 ---------- src/rpc/mining.h | 3 --- src/rpc/util.cpp | 12 ++++++++++++ src/rpc/util.h | 3 +++ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index c54dd266df..dbb0892f0c 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -40,16 +40,6 @@ #include #include -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; -} - /** * Return average network hashes per second based on the last 'lookup' blocks, * or from the last difficulty change if 'lookup' is nonpositive. diff --git a/src/rpc/mining.h b/src/rpc/mining.h index 8d46273159..be9a973315 100644 --- a/src/rpc/mining.h +++ b/src/rpc/mining.h @@ -12,7 +12,4 @@ /** Generate blocks (mine) */ UniValue generateBlocks(std::shared_ptr coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript); -/** Check bounds on a command line confirm target */ -unsigned int ParseConfirmTarget(const UniValue& value); - #endif diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 149ca16eb6..66707c0fa8 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -4,10 +4,12 @@ #include #include +#include #include #include #include #include +#include // Converts a hex string to a public key if possible CPubKey HexToPubKey(const std::string& hex_in) @@ -92,6 +94,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; +} + std::string RPCHelpMan::ToString() const { std::string ret; diff --git a/src/rpc/util.h b/src/rpc/util.h index 90185391df..6d2995becb 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -25,6 +25,9 @@ CScript CreateMultisigRedeemscript(const int required, const std::vector