aboutsummaryrefslogtreecommitdiff
path: root/src/rpcmining.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2014-06-06 18:50:32 +0200
committerWladimir J. van der Laan <[email protected]>2014-06-06 18:51:00 +0200
commit95d68c48d7ae45cb2a7303152816e9391cfbd0c9 (patch)
tree0a25f1f328ca66177c79afcf4422ea99d221f981 /src/rpcmining.cpp
parentMerge pull request #4297 (diff)
parentestimatefee / estimatepriority RPC methods (diff)
downloaddiscoin-95d68c48d7ae45cb2a7303152816e9391cfbd0c9.tar.xz
discoin-95d68c48d7ae45cb2a7303152816e9391cfbd0c9.zip
Merge pull request #3959
171ca77 estimatefee / estimatepriority RPC methods (Gavin Andresen) 0193fb8 Allow multiple regression tests to run at once (Gavin Andresen) c6cb21d Type-safe CFeeRate class (Gavin Andresen)
Diffstat (limited to 'src/rpcmining.cpp')
-rw-r--r--src/rpcmining.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index 23876c603..dd148c6af 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -15,6 +15,7 @@
#endif
#include <stdint.h>
+#include <boost/assign/list_of.hpp>
#include "json/json_spirit_utils.h"
#include "json/json_spirit_value.h"
@@ -626,3 +627,63 @@ Value submitblock(const Array& params, bool fHelp)
return Value::null;
}
+
+Value estimatefee(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() != 1)
+ throw runtime_error(
+ "estimatefee nblocks\n"
+ "\nEstimates the approximate fee per kilobyte\n"
+ "needed for a transaction to get confirmed\n"
+ "within nblocks blocks.\n"
+ "\nArguments:\n"
+ "1. nblocks (numeric)\n"
+ "\nResult:\n"
+ "n : (numeric) estimated fee-per-kilobyte\n"
+ "\n"
+ "-1.0 is returned if not enough transactions and\n"
+ "blocks have been observed to make an estimate.\n"
+ "\nExample:\n"
+ + HelpExampleCli("estimatefee", "6")
+ );
+
+ RPCTypeCheck(params, boost::assign::list_of(int_type));
+
+ int nBlocks = params[0].get_int();
+ if (nBlocks < 1)
+ nBlocks = 1;
+
+ CFeeRate feeRate = mempool.estimateFee(nBlocks);
+ if (feeRate == CFeeRate(0))
+ return -1.0;
+
+ return ValueFromAmount(feeRate.GetFeePerK());
+}
+
+Value estimatepriority(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() != 1)
+ throw runtime_error(
+ "estimatepriority nblocks\n"
+ "\nEstimates the approximate priority\n"
+ "a zero-fee transaction needs to get confirmed\n"
+ "within nblocks blocks.\n"
+ "\nArguments:\n"
+ "1. nblocks (numeric)\n"
+ "\nResult:\n"
+ "n : (numeric) estimated priority\n"
+ "\n"
+ "-1.0 is returned if not enough transactions and\n"
+ "blocks have been observed to make an estimate.\n"
+ "\nExample:\n"
+ + HelpExampleCli("estimatepriority", "6")
+ );
+
+ RPCTypeCheck(params, boost::assign::list_of(int_type));
+
+ int nBlocks = params[0].get_int();
+ if (nBlocks < 1)
+ nBlocks = 1;
+
+ return mempool.estimatePriority(nBlocks);
+}