| 113 | } |
| 114 | |
| 115 | Value getrawmempool(const Array& params, bool fHelp) |
| 116 | { |
| 117 | if (fHelp || params.size() > 1) |
| 118 | throw runtime_error( |
| 119 | "getrawmempool ( verbose )\n" |
| 120 | "\nReturns all transaction ids in memory pool as a json or an array of string transaction ids.\n" |
| 121 | "\nArguments:\n" |
| 122 | "1. verbose (boolean, optional, default=false) true for a json object, false for array of " |
| 123 | "transaction ids\n" |
| 124 | "\nResult: (for verbose = false):\n" |
| 125 | "[ (json array of string)\n" |
| 126 | " \"txid\" (string) The transaction id\n" |
| 127 | " ,...\n" |
| 128 | "]\n" |
| 129 | "\nResult: (for verbose = true):\n" |
| 130 | "{ (json object)\n" |
| 131 | " \"txid\" : { (json object)\n" |
| 132 | " \"fee\" : n, (numeric) transaction fee in WICC coins\n" |
| 133 | " \"size\" : n, (numeric) transaction size in bytes\n" |
| 134 | " \"priority\" : n, (numeric) priority\n" |
| 135 | " \"time\" : n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 " |
| 136 | "GMT\n" |
| 137 | " \"height\" : n, (numeric) block height when transaction entered pool\n" |
| 138 | " }, ...\n" |
| 139 | "]\n" |
| 140 | "\nExamples\n" + |
| 141 | HelpExampleCli("getrawmempool", "true") + "\nAs json rpc\n" + HelpExampleRpc("getrawmempool", "true")); |
| 142 | |
| 143 | bool fVerbose = false; |
| 144 | if (params.size() > 0) |
| 145 | fVerbose = params[0].get_bool(); |
| 146 | |
| 147 | if (fVerbose) { |
| 148 | LOCK(mempool.cs); |
| 149 | Object obj; |
| 150 | for (const auto& entry : mempool.memPoolTxs) { |
| 151 | const uint256& hash = entry.first; |
| 152 | const CTxMemPoolEntry& mpe = entry.second; |
| 153 | Object info; |
| 154 | info.push_back(Pair("size", (int) mpe.GetTxSize())); |
| 155 | info.push_back(Pair("fees_type", std::get<0>(mpe.GetFees()))); |
| 156 | info.push_back(Pair("fees", JsonValueFromAmount(std::get<1>(mpe.GetFees())))); |
| 157 | info.push_back(Pair("time", mpe.GetTime())); |
| 158 | info.push_back(Pair("height", (int) mpe.GetHeight())); |
| 159 | info.push_back(Pair("priority", mpe.GetPriority())); |
| 160 | |
| 161 | obj.push_back(Pair(hash.ToString(), info)); |
| 162 | } |
| 163 | return obj; |
| 164 | } else { |
| 165 | vector<uint256> txids; |
| 166 | mempool.QueryHash(txids); |
| 167 | |
| 168 | Array arr; |
| 169 | for (const auto& hash : txids) { |
| 170 | arr.push_back(hash.ToString()); |
| 171 | } |
| 172 |
nothing calls this directly
no test coverage detected