20 #include <validation.h>
33 "local time transaction entered pool in seconds since 1 Jan "
36 "block height when transaction entered pool"},
42 "transaction fee in " + ticker},
44 "transaction fee with fee deltas used for "
45 "mining priority in " +
51 "unconfirmed transactions used as inputs for this transaction",
53 "parent transaction id"}}},
57 "unconfirmed transactions spending outputs from this transaction",
59 "child transaction id"}}},
61 "Whether this transaction is currently unbroadcast (initial "
62 "broadcast not yet acknowledged by any peers)"},
72 fees.
pushKV(
"base", e->GetFee());
73 fees.
pushKV(
"modified", e->GetModifiedFee());
74 info.pushKV(
"fees", fees);
76 info.pushKV(
"size", (
int)e->GetTxSize());
78 info.pushKV(
"height", (
int)e->GetHeight());
80 std::set<std::string> setDepends;
88 for (
const std::string &dep : setDepends) {
92 info.pushKV(
"depends", depends);
95 for (
const auto &child : e->GetMemPoolChildrenConst()) {
96 spent.
push_back(child.get()->GetTx().GetId().ToString());
99 info.pushKV(
"spentby", spent);
100 info.pushKV(
"unbroadcast", pool.IsUnbroadcastTx(tx.
GetId()));
104 bool include_mempool_sequence) {
106 if (include_mempool_sequence) {
109 "Verbose results cannot contain mempool sequence values.");
114 const TxId &txid = e->GetTx().GetId();
124 uint64_t mempool_sequence;
125 std::vector<TxId> vtxids;
132 for (
const TxId &txid : vtxids) {
136 if (!include_mempool_sequence) {
141 o.
pushKV(
"mempool_sequence", mempool_sequence);
150 "Returns all transaction ids in memory pool as a json array of "
151 "string transaction ids.\n"
152 "\nHint: use getmempoolentry to fetch a specific transaction from the "
156 "True for a json object, false for array of transaction ids"},
158 "If verbose=false, returns a json object with transaction list "
159 "and mempool sequence number attached."},
178 "for verbose = false and mempool_sequence = true",
190 "The mempool sequence value."},
197 bool fVerbose =
false;
198 if (!request.params[0].isNull()) {
199 fVerbose = request.params[0].
get_bool();
202 bool include_mempool_sequence =
false;
203 if (!request.params[1].isNull()) {
204 include_mempool_sequence = request.params[1].get_bool();
208 include_mempool_sequence);
215 "getmempoolancestors",
216 "If txid is in the mempool, returns all in-mempool ancestors.\n",
219 "The transaction id (must be in mempool)"},
221 "True for a json object, false for array of transaction ids"},
225 "for verbose = false",
230 "The transaction id of an in-mempool ancestor transaction"}}},
244 bool fVerbose =
false;
245 if (!request.params[1].isNull()) {
246 fVerbose = request.params[1].
get_bool();
255 if (it == mempool.mapTx.end()) {
257 "Transaction not in mempool");
266 o.
push_back((*ancestorIt)->GetTx().GetId().ToString());
273 const TxId &_txid = e->GetTx().GetId();
286 "getmempooldescendants",
287 "If txid is in the mempool, returns all in-mempool descendants.\n",
290 "The transaction id (must be in mempool)"},
292 "True for a json object, false for array of transaction ids"},
300 "The transaction id of an in-mempool descendant "
315 bool fVerbose =
false;
316 if (!request.params[1].isNull()) {
317 fVerbose = request.params[1].
get_bool();
326 if (it == mempool.mapTx.end()) {
328 "Transaction not in mempool");
334 setDescendants.erase(it);
339 o.
push_back((*descendantIt)->GetTx().GetId().ToString());
347 const TxId &_txid = e->GetTx().GetId();
361 "Returns mempool data for given transaction\n",
364 "The transaction id (must be in mempool)"},
377 if (it == mempool.mapTx.end()) {
379 "Transaction not in mempool");
411 "Returns details on the active state of the TX memory pool.\n",
419 "True if the mempool is fully loaded"},
423 "Total memory usage for the mempool"},
425 "Maximum memory usage for the mempool"},
427 "Total fees for the mempool in " + ticker +
428 ", ignoring modified fees through prioritizetransaction"},
430 "Minimum fee rate in " + ticker +
431 "/kB for tx to be accepted. Is the maximum of "
432 "minrelaytxfee and minimum mempool fee"},
434 "Current minimum relay fee for transactions"},
436 "Current number of transactions that haven't passed initial "
451 "Dumps the mempool to disk. It will fail until the previous dump is "
459 "the directory and file where the mempool was saved"},
470 "The mempool was not loaded yet");
477 "Unable to dump mempool to disk");
499 for (
const auto &c : commands) {
Amount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
const TxId & GetTxId() const
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
The basic transaction that is broadcasted on the network and contained in blocks.
const std::vector< CTxIn > vin
An input of a transaction.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
std::set< txiter, CompareIteratorById > setEntries
bool GetLoadTried() const
CFeeRate GetMinFee() const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
Amount GetTotalFee() const EXCLUSIVE_LOCKS_REQUIRED(cs)
const int64_t m_max_size_bytes
void getAllTxIds(std::vector< TxId > &vtxid) const
size_t DynamicMemoryUsage() const
const CFeeRate m_min_relay_feerate
uint64_t GetSequence() const EXCLUSIVE_LOCKS_REQUIRED(cs)
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
bool CalculateMemPoolAncestors(const CTxMemPoolEntryRef &entry, setEntries &setAncestors, bool fSearchForParents=true) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Try to calculate all in-mempool ancestors of entry.
std::set< TxId > GetUnbroadcastTxs() const
Returns transactions in unbroadcast set.
void CalculateDescendants(txiter it, setEntries &setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Populate setDescendants with all in-mempool descendants of hash.
unsigned long size() const
uint64_t GetTotalTxSize() const EXCLUSIVE_LOCKS_REQUIRED(cs)
void __pushKV(const std::string &key, const UniValue &val)
bool push_back(const UniValue &val)
bool pushKV(const std::string &key, const UniValue &val)
std::string ToString() const
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
std::string u8string() const
static std::vector< RPCResult > MempoolEntryDescription()
RPCHelpMan getmempoolinfo()
void RegisterMempoolRPCCommands(CRPCTable &t)
Register mempool RPC commands.
UniValue MempoolInfoToJSON(const CTxMemPool &pool)
Mempool information to JSON.
RPCHelpMan getmempooldescendants()
UniValue MempoolToJSON(const CTxMemPool &pool, bool verbose, bool include_mempool_sequence)
Mempool to JSON.
static void entryToJSON(const CTxMemPool &pool, UniValue &info, const CTxMemPoolEntryRef &e) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
RPCHelpMan getmempoolancestors()
RPCHelpMan getmempoolentry()
RPCHelpMan getrawmempool()
bool DumpMempool(const CTxMemPool &pool, const fs::path &dump_path, FopenFn mockable_fopen_function, bool skip_file_commit)
fs::path MempoolPath(const ArgsManager &argsman)
bool ShouldPersistMempool(const ArgsManager &argsman)
UniValue JSONRPCError(int code, const std::string &message)
@ RPC_MISC_ERROR
General application defined errors std::exception thrown in command handling.
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded values (throws error if not hex).
ArgsManager & EnsureAnyArgsman(const std::any &context)
CTxMemPool & EnsureAnyMemPool(const std::any &context)
static const Currency & get()
@ STR_HEX
Special type that is a STR with only hex chars.
@ NUM_TIME
Special numeric to denote unix epoch time.
@ OBJ_DYN
Special dictionary with keys that are not literals.
@ STR_HEX
Special string with only hex chars.
@ STR_AMOUNT
Special string to represent a floating point amount.
A TxId is the identifier of a transaction.
NodeContext struct containing references to chain state and connection state.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
constexpr int64_t count_seconds(std::chrono::seconds t)