aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2019-02-08 15:29:45 -0500
committerRussell Yanofsky <russ@yanofsky.org>2019-02-08 15:29:45 -0500
commit50e647210d513dab8f40ded61fe439ecaa9a67c3 (patch)
tree35ff7860a0fc640c6ead14dcb1aca9d05c9da556 /src/rpc
parent2945492424934fa360f86b116184ee8e34f19d0a (diff)
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
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/mining.cpp10
-rw-r--r--src/rpc/mining.h3
-rw-r--r--src/rpc/util.cpp12
-rw-r--r--src/rpc/util.h3
4 files changed, 15 insertions, 13 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 200dfa107b..35f55b0141 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -31,16 +31,6 @@
#include <memory>
#include <stdint.h>
-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<CReserveScript> 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 4275cc09a8..aa5076cd8e 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -4,10 +4,12 @@
#include <key_io.h>
#include <keystore.h>
+#include <policy/fees.h>
#include <rpc/protocol.h>
#include <rpc/util.h>
#include <tinyformat.h>
#include <util/strencodings.h>
+#include <validation.h>
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} {}
diff --git a/src/rpc/util.h b/src/rpc/util.h
index 4a9d4be787..d34c9cfdbb 100644
--- a/src/rpc/util.h
+++ b/src/rpc/util.h
@@ -28,6 +28,9 @@ CScript CreateMultisigRedeemscript(const int required, const std::vector<CPubKey
UniValue DescribeAddress(const CTxDestination& dest);
+//! Parse a confirm target option and raise an RPC error if it is invalid.
+unsigned int ParseConfirmTarget(const UniValue& value);
+
struct RPCArg {
enum class Type {
OBJ,