|
|
|
|
@@ -183,6 +183,60 @@ UniValue getdifficulty(const UniValue& params, bool fHelp)
|
|
|
|
|
return GetDifficulty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string EntryDescriptionString()
|
|
|
|
|
{
|
|
|
|
|
return " \"size\" : n, (numeric) transaction size in bytes\n"
|
|
|
|
|
" \"fee\" : n, (numeric) transaction fee in " + CURRENCY_UNIT + "\n"
|
|
|
|
|
" \"modifiedfee\" : n, (numeric) transaction fee with fee deltas used for mining priority\n"
|
|
|
|
|
" \"time\" : n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT\n"
|
|
|
|
|
" \"height\" : n, (numeric) block height when transaction entered pool\n"
|
|
|
|
|
" \"startingpriority\" : n, (numeric) priority when transaction entered pool\n"
|
|
|
|
|
" \"currentpriority\" : n, (numeric) transaction priority now\n"
|
|
|
|
|
" \"descendantcount\" : n, (numeric) number of in-mempool descendant transactions (including this one)\n"
|
|
|
|
|
" \"descendantsize\" : n, (numeric) size of in-mempool descendants (including this one)\n"
|
|
|
|
|
" \"descendantfees\" : n, (numeric) modified fees (see above) of in-mempool descendants (including this one)\n"
|
|
|
|
|
" \"ancestorcount\" : n, (numeric) number of in-mempool ancestor transactions (including this one)\n"
|
|
|
|
|
" \"ancestorsize\" : n, (numeric) size of in-mempool ancestors (including this one)\n"
|
|
|
|
|
" \"ancestorfees\" : n, (numeric) modified fees (see above) of in-mempool ancestors (including this one)\n"
|
|
|
|
|
" \"depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n"
|
|
|
|
|
" \"transactionid\", (string) parent transaction id\n"
|
|
|
|
|
" ... ]\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
|
|
|
|
|
{
|
|
|
|
|
AssertLockHeld(mempool.cs);
|
|
|
|
|
|
|
|
|
|
info.push_back(Pair("size", (int)e.GetTxSize()));
|
|
|
|
|
info.push_back(Pair("fee", ValueFromAmount(e.GetFee())));
|
|
|
|
|
info.push_back(Pair("modifiedfee", ValueFromAmount(e.GetModifiedFee())));
|
|
|
|
|
info.push_back(Pair("time", e.GetTime()));
|
|
|
|
|
info.push_back(Pair("height", (int)e.GetHeight()));
|
|
|
|
|
info.push_back(Pair("startingpriority", e.GetPriority(e.GetHeight())));
|
|
|
|
|
info.push_back(Pair("currentpriority", e.GetPriority(chainActive.Height())));
|
|
|
|
|
info.push_back(Pair("descendantcount", e.GetCountWithDescendants()));
|
|
|
|
|
info.push_back(Pair("descendantsize", e.GetSizeWithDescendants()));
|
|
|
|
|
info.push_back(Pair("descendantfees", e.GetModFeesWithDescendants()));
|
|
|
|
|
info.push_back(Pair("ancestorcount", e.GetCountWithAncestors()));
|
|
|
|
|
info.push_back(Pair("ancestorsize", e.GetSizeWithAncestors()));
|
|
|
|
|
info.push_back(Pair("ancestorfees", e.GetModFeesWithAncestors()));
|
|
|
|
|
const CTransaction& tx = e.GetTx();
|
|
|
|
|
set<string> setDepends;
|
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
|
|
|
|
{
|
|
|
|
|
if (mempool.exists(txin.prevout.hash))
|
|
|
|
|
setDepends.insert(txin.prevout.hash.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UniValue depends(UniValue::VARR);
|
|
|
|
|
BOOST_FOREACH(const string& dep, setDepends)
|
|
|
|
|
{
|
|
|
|
|
depends.push_back(dep);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info.push_back(Pair("depends", depends));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UniValue mempoolToJSON(bool fVerbose = false)
|
|
|
|
|
{
|
|
|
|
|
if (fVerbose)
|
|
|
|
|
@@ -193,31 +247,7 @@ UniValue mempoolToJSON(bool fVerbose = false)
|
|
|
|
|
{
|
|
|
|
|
const uint256& hash = e.GetTx().GetHash();
|
|
|
|
|
UniValue info(UniValue::VOBJ);
|
|
|
|
|
info.push_back(Pair("size", (int)e.GetTxSize()));
|
|
|
|
|
info.push_back(Pair("fee", ValueFromAmount(e.GetFee())));
|
|
|
|
|
info.push_back(Pair("modifiedfee", ValueFromAmount(e.GetModifiedFee())));
|
|
|
|
|
info.push_back(Pair("time", e.GetTime()));
|
|
|
|
|
info.push_back(Pair("height", (int)e.GetHeight()));
|
|
|
|
|
info.push_back(Pair("startingpriority", e.GetPriority(e.GetHeight())));
|
|
|
|
|
info.push_back(Pair("currentpriority", e.GetPriority(chainActive.Height())));
|
|
|
|
|
info.push_back(Pair("descendantcount", e.GetCountWithDescendants()));
|
|
|
|
|
info.push_back(Pair("descendantsize", e.GetSizeWithDescendants()));
|
|
|
|
|
info.push_back(Pair("descendantfees", e.GetModFeesWithDescendants()));
|
|
|
|
|
const CTransaction& tx = e.GetTx();
|
|
|
|
|
set<string> setDepends;
|
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
|
|
|
|
{
|
|
|
|
|
if (mempool.exists(txin.prevout.hash))
|
|
|
|
|
setDepends.insert(txin.prevout.hash.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UniValue depends(UniValue::VARR);
|
|
|
|
|
BOOST_FOREACH(const string& dep, setDepends)
|
|
|
|
|
{
|
|
|
|
|
depends.push_back(dep);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info.push_back(Pair("depends", depends));
|
|
|
|
|
entryToJSON(info, e);
|
|
|
|
|
o.push_back(Pair(hash.ToString(), info));
|
|
|
|
|
}
|
|
|
|
|
return o;
|
|
|
|
|
@@ -251,20 +281,8 @@ UniValue getrawmempool(const UniValue& params, bool fHelp)
|
|
|
|
|
"\nResult: (for verbose = true):\n"
|
|
|
|
|
"{ (json object)\n"
|
|
|
|
|
" \"transactionid\" : { (json object)\n"
|
|
|
|
|
" \"size\" : n, (numeric) transaction size in bytes\n"
|
|
|
|
|
" \"fee\" : n, (numeric) transaction fee in " + CURRENCY_UNIT + "\n"
|
|
|
|
|
" \"modifiedfee\" : n, (numeric) transaction fee with fee deltas used for mining priority\n"
|
|
|
|
|
" \"time\" : n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT\n"
|
|
|
|
|
" \"height\" : n, (numeric) block height when transaction entered pool\n"
|
|
|
|
|
" \"startingpriority\" : n, (numeric) priority when transaction entered pool\n"
|
|
|
|
|
" \"currentpriority\" : n, (numeric) transaction priority now\n"
|
|
|
|
|
" \"descendantcount\" : n, (numeric) number of in-mempool descendant transactions (including this one)\n"
|
|
|
|
|
" \"descendantsize\" : n, (numeric) size of in-mempool descendants (including this one)\n"
|
|
|
|
|
" \"descendantfees\" : n, (numeric) modified fees (see above) of in-mempool descendants (including this one)\n"
|
|
|
|
|
" \"depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n"
|
|
|
|
|
" \"transactionid\", (string) parent transaction id\n"
|
|
|
|
|
" ... ]\n"
|
|
|
|
|
" }, ...\n"
|
|
|
|
|
+ EntryDescriptionString()
|
|
|
|
|
+ " }, ...\n"
|
|
|
|
|
"}\n"
|
|
|
|
|
"\nExamples\n"
|
|
|
|
|
+ HelpExampleCli("getrawmempool", "true")
|
|
|
|
|
@@ -280,6 +298,167 @@ UniValue getrawmempool(const UniValue& params, bool fHelp)
|
|
|
|
|
return mempoolToJSON(fVerbose);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UniValue getmempoolancestors(const UniValue& params, bool fHelp)
|
|
|
|
|
{
|
|
|
|
|
if (fHelp || params.size() < 1 || params.size() > 2) {
|
|
|
|
|
throw runtime_error(
|
|
|
|
|
"getmempoolancestors txid (verbose)\n"
|
|
|
|
|
"\nIf txid is in the mempool, returns all in-mempool ancestors.\n"
|
|
|
|
|
"\nArguments:\n"
|
|
|
|
|
"1. \"txid\" (string, required) The transaction id (must be in mempool)\n"
|
|
|
|
|
"2. verbose (boolean, optional, default=false) true for a json object, false for array of transaction ids\n"
|
|
|
|
|
"\nResult (for verbose=false):\n"
|
|
|
|
|
"[ (json array of strings)\n"
|
|
|
|
|
" \"transactionid\" (string) The transaction id of an in-mempool ancestor transaction\n"
|
|
|
|
|
" ,...\n"
|
|
|
|
|
"]\n"
|
|
|
|
|
"\nResult (for verbose=true):\n"
|
|
|
|
|
"{ (json object)\n"
|
|
|
|
|
" \"transactionid\" : { (json object)\n"
|
|
|
|
|
+ EntryDescriptionString()
|
|
|
|
|
+ " }, ...\n"
|
|
|
|
|
"}\n"
|
|
|
|
|
"\nExamples\n"
|
|
|
|
|
+ HelpExampleCli("getmempoolancestors", "\"mytxid\"")
|
|
|
|
|
+ HelpExampleRpc("getmempoolancestors", "\"mytxid\"")
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool fVerbose = false;
|
|
|
|
|
if (params.size() > 1)
|
|
|
|
|
fVerbose = params[1].get_bool();
|
|
|
|
|
|
|
|
|
|
uint256 hash = ParseHashV(params[0], "parameter 1");
|
|
|
|
|
|
|
|
|
|
LOCK(mempool.cs);
|
|
|
|
|
|
|
|
|
|
CTxMemPool::txiter it = mempool.mapTx.find(hash);
|
|
|
|
|
if (it == mempool.mapTx.end()) {
|
|
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CTxMemPool::setEntries setAncestors;
|
|
|
|
|
uint64_t noLimit = std::numeric_limits<uint64_t>::max();
|
|
|
|
|
std::string dummy;
|
|
|
|
|
mempool.CalculateMemPoolAncestors(*it, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false);
|
|
|
|
|
|
|
|
|
|
if (!fVerbose) {
|
|
|
|
|
UniValue o(UniValue::VARR);
|
|
|
|
|
BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) {
|
|
|
|
|
o.push_back(ancestorIt->GetTx().GetHash().ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
} else {
|
|
|
|
|
UniValue o(UniValue::VOBJ);
|
|
|
|
|
BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) {
|
|
|
|
|
const CTxMemPoolEntry &e = *ancestorIt;
|
|
|
|
|
const uint256& hash = e.GetTx().GetHash();
|
|
|
|
|
UniValue info(UniValue::VOBJ);
|
|
|
|
|
entryToJSON(info, e);
|
|
|
|
|
o.push_back(Pair(hash.ToString(), info));
|
|
|
|
|
}
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UniValue getmempooldescendants(const UniValue& params, bool fHelp)
|
|
|
|
|
{
|
|
|
|
|
if (fHelp || params.size() < 1 || params.size() > 2) {
|
|
|
|
|
throw runtime_error(
|
|
|
|
|
"getmempooldescendants txid (verbose)\n"
|
|
|
|
|
"\nIf txid is in the mempool, returns all in-mempool descendants.\n"
|
|
|
|
|
"\nArguments:\n"
|
|
|
|
|
"1. \"txid\" (string, required) The transaction id (must be in mempool)\n"
|
|
|
|
|
"2. verbose (boolean, optional, default=false) true for a json object, false for array of transaction ids\n"
|
|
|
|
|
"\nResult (for verbose=false):\n"
|
|
|
|
|
"[ (json array of strings)\n"
|
|
|
|
|
" \"transactionid\" (string) The transaction id of an in-mempool descendant transaction\n"
|
|
|
|
|
" ,...\n"
|
|
|
|
|
"]\n"
|
|
|
|
|
"\nResult (for verbose=true):\n"
|
|
|
|
|
"{ (json object)\n"
|
|
|
|
|
" \"transactionid\" : { (json object)\n"
|
|
|
|
|
+ EntryDescriptionString()
|
|
|
|
|
+ " }, ...\n"
|
|
|
|
|
"}\n"
|
|
|
|
|
"\nExamples\n"
|
|
|
|
|
+ HelpExampleCli("getmempooldescendants", "\"mytxid\"")
|
|
|
|
|
+ HelpExampleRpc("getmempooldescendants", "\"mytxid\"")
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool fVerbose = false;
|
|
|
|
|
if (params.size() > 1)
|
|
|
|
|
fVerbose = params[1].get_bool();
|
|
|
|
|
|
|
|
|
|
uint256 hash = ParseHashV(params[0], "parameter 1");
|
|
|
|
|
|
|
|
|
|
LOCK(mempool.cs);
|
|
|
|
|
|
|
|
|
|
CTxMemPool::txiter it = mempool.mapTx.find(hash);
|
|
|
|
|
if (it == mempool.mapTx.end()) {
|
|
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CTxMemPool::setEntries setDescendants;
|
|
|
|
|
mempool.CalculateDescendants(it, setDescendants);
|
|
|
|
|
// CTxMemPool::CalculateDescendants will include the given tx
|
|
|
|
|
setDescendants.erase(it);
|
|
|
|
|
|
|
|
|
|
if (!fVerbose) {
|
|
|
|
|
UniValue o(UniValue::VARR);
|
|
|
|
|
BOOST_FOREACH(CTxMemPool::txiter descendantIt, setDescendants) {
|
|
|
|
|
o.push_back(descendantIt->GetTx().GetHash().ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
} else {
|
|
|
|
|
UniValue o(UniValue::VOBJ);
|
|
|
|
|
BOOST_FOREACH(CTxMemPool::txiter descendantIt, setDescendants) {
|
|
|
|
|
const CTxMemPoolEntry &e = *descendantIt;
|
|
|
|
|
const uint256& hash = e.GetTx().GetHash();
|
|
|
|
|
UniValue info(UniValue::VOBJ);
|
|
|
|
|
entryToJSON(info, e);
|
|
|
|
|
o.push_back(Pair(hash.ToString(), info));
|
|
|
|
|
}
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UniValue getmempoolentry(const UniValue& params, bool fHelp)
|
|
|
|
|
{
|
|
|
|
|
if (fHelp || params.size() != 1) {
|
|
|
|
|
throw runtime_error(
|
|
|
|
|
"getmempoolentry txid\n"
|
|
|
|
|
"\nReturns mempool data for given transaction\n"
|
|
|
|
|
"\nArguments:\n"
|
|
|
|
|
"1. \"txid\" (string, required) The transaction id (must be in mempool)\n"
|
|
|
|
|
"\nResult:\n"
|
|
|
|
|
"{ (json object)\n"
|
|
|
|
|
+ EntryDescriptionString()
|
|
|
|
|
+ "}\n"
|
|
|
|
|
"\nExamples\n"
|
|
|
|
|
+ HelpExampleCli("getmempoolentry", "\"mytxid\"")
|
|
|
|
|
+ HelpExampleRpc("getmempoolentry", "\"mytxid\"")
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint256 hash = ParseHashV(params[0], "parameter 1");
|
|
|
|
|
|
|
|
|
|
LOCK(mempool.cs);
|
|
|
|
|
|
|
|
|
|
CTxMemPool::txiter it = mempool.mapTx.find(hash);
|
|
|
|
|
if (it == mempool.mapTx.end()) {
|
|
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CTxMemPoolEntry &e = *it;
|
|
|
|
|
UniValue info(UniValue::VOBJ);
|
|
|
|
|
entryToJSON(info, e);
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UniValue getblockhash(const UniValue& params, bool fHelp)
|
|
|
|
|
{
|
|
|
|
|
if (fHelp || params.size() != 1)
|
|
|
|
|
@@ -1004,6 +1183,9 @@ static const CRPCCommand commands[] =
|
|
|
|
|
{ "blockchain", "getblockheader", &getblockheader, true },
|
|
|
|
|
{ "blockchain", "getchaintips", &getchaintips, true },
|
|
|
|
|
{ "blockchain", "getdifficulty", &getdifficulty, true },
|
|
|
|
|
{ "blockchain", "getmempoolancestors", &getmempoolancestors, true },
|
|
|
|
|
{ "blockchain", "getmempooldescendants", &getmempooldescendants, true },
|
|
|
|
|
{ "blockchain", "getmempoolentry", &getmempoolentry, true },
|
|
|
|
|
{ "blockchain", "getmempoolinfo", &getmempoolinfo, true },
|
|
|
|
|
{ "blockchain", "getrawmempool", &getrawmempool, true },
|
|
|
|
|
{ "blockchain", "gettxout", &gettxout, true },
|
|
|
|
|
|