LCOV - code coverage report
Current view: top level - src/rpc - mempool.cpp (source / functions) Coverage Total Hit
Test: total_coverage.info Lines: 97.4 % 782 762
Test Date: 2025-08-04 05:03:43 Functions: 100.0 % 32 32
Branches: 51.6 % 2684 1384

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2010 Satoshi Nakamoto
       2                 :             : // Copyright (c) 2009-2022 The Bitcoin Core developers
       3                 :             : // Distributed under the MIT software license, see the accompanying
       4                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5                 :             : 
       6                 :             : #include <rpc/blockchain.h>
       7                 :             : 
       8                 :             : #include <node/mempool_persist.h>
       9                 :             : 
      10                 :             : #include <chainparams.h>
      11                 :             : #include <consensus/validation.h>
      12                 :             : #include <core_io.h>
      13                 :             : #include <kernel/mempool_entry.h>
      14                 :             : #include <net_processing.h>
      15                 :             : #include <node/mempool_persist_args.h>
      16                 :             : #include <node/types.h>
      17                 :             : #include <policy/rbf.h>
      18                 :             : #include <policy/settings.h>
      19                 :             : #include <primitives/transaction.h>
      20                 :             : #include <rpc/server.h>
      21                 :             : #include <rpc/server_util.h>
      22                 :             : #include <rpc/util.h>
      23                 :             : #include <txmempool.h>
      24                 :             : #include <univalue.h>
      25                 :             : #include <util/fs.h>
      26                 :             : #include <util/moneystr.h>
      27                 :             : #include <util/strencodings.h>
      28                 :             : #include <util/time.h>
      29                 :             : #include <util/vector.h>
      30                 :             : 
      31                 :             : #include <utility>
      32                 :             : 
      33                 :             : using node::DumpMempool;
      34                 :             : 
      35                 :             : using node::DEFAULT_MAX_BURN_AMOUNT;
      36                 :             : using node::DEFAULT_MAX_RAW_TX_FEE_RATE;
      37                 :             : using node::MempoolPath;
      38                 :             : using node::NodeContext;
      39                 :             : using node::TransactionError;
      40                 :             : using util::ToString;
      41                 :             : 
      42                 :       24883 : static RPCHelpMan sendrawtransaction()
      43                 :             : {
      44                 :       24883 :     return RPCHelpMan{
      45                 :       24883 :         "sendrawtransaction",
      46         [ +  - ]:       49766 :         "Submit a raw transaction (serialized, hex-encoded) to local node and network.\n"
      47                 :             :         "\nThe transaction will be sent unconditionally to all peers, so using sendrawtransaction\n"
      48                 :             :         "for manual rebroadcast may degrade privacy by leaking the transaction's origin, as\n"
      49                 :             :         "nodes will normally not rebroadcast non-wallet transactions already in their mempool.\n"
      50                 :             :         "\nA specific exception, RPC_TRANSACTION_ALREADY_IN_UTXO_SET, may throw if the transaction cannot be added to the mempool.\n"
      51                 :             :         "\nRelated RPCs: createrawtransaction, signrawtransactionwithkey\n",
      52                 :             :         {
      53   [ +  -  +  - ]:       49766 :             {"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex string of the raw transaction"},
      54   [ +  -  +  -  :       49766 :             {"maxfeerate", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK())},
                   +  - ]
      55         [ +  - ]:       49766 :              "Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT +
      56                 :       24883 :                  "/kvB.\nFee rates larger than 1BTC/kvB are rejected.\nSet to 0 to accept any fee rate."},
      57   [ +  -  +  -  :       49766 :             {"maxburnamount", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_BURN_AMOUNT)},
                   +  - ]
      58         [ +  - ]:       49766 :              "Reject transactions with provably unspendable outputs (e.g. 'datacarrier' outputs that use the OP_RETURN opcode) greater than the specified value, expressed in " + CURRENCY_UNIT + ".\n"
      59                 :             :              "If burning funds through unspendable outputs is desired, increase this value.\n"
      60                 :       24883 :              "This check is based on heuristics and does not guarantee spendability of outputs.\n"},
      61                 :             :         },
      62         [ +  - ]:       49766 :         RPCResult{
      63   [ +  -  +  - ]:       49766 :             RPCResult::Type::STR_HEX, "", "The transaction hash in hex"
      64         [ +  - ]:       49766 :         },
      65                 :       24883 :         RPCExamples{
      66                 :             :             "\nCreate a transaction\n"
      67   [ +  -  +  -  :       49766 :             + HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"") +
             +  -  +  - ]
      68                 :       24883 :             "Sign the transaction, and get back the hex\n"
      69   [ +  -  +  -  :       99532 :             + HelpExampleCli("signrawtransactionwithwallet", "\"myhex\"") +
             +  -  +  - ]
      70                 :       24883 :             "\nSend the transaction (signed hex)\n"
      71   [ +  -  +  -  :       99532 :             + HelpExampleCli("sendrawtransaction", "\"signedhex\"") +
             +  -  +  - ]
      72                 :       24883 :             "\nAs a JSON-RPC call\n"
      73   [ +  -  +  -  :       99532 :             + HelpExampleRpc("sendrawtransaction", "\"signedhex\"")
             +  -  +  - ]
      74         [ +  - ]:       24883 :                 },
      75                 :       24883 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
      76                 :             :         {
      77         [ +  + ]:       22658 :             const CAmount max_burn_amount = request.params[2].isNull() ? 0 : AmountFromValue(request.params[2]);
      78                 :             : 
      79                 :       22658 :             CMutableTransaction mtx;
      80   [ +  -  +  -  :       22658 :             if (!DecodeHexTx(mtx, request.params[0].get_str())) {
             +  -  +  + ]
      81   [ +  -  +  - ]:           4 :                 throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
      82                 :             :             }
      83                 :             : 
      84         [ +  + ]:       85443 :             for (const auto& out : mtx.vout) {
      85   [ +  +  +  -  :       62791 :                 if((out.scriptPubKey.IsUnspendable() || !out.scriptPubKey.HasValidOps()) && out.nValue > max_burn_amount) {
             +  +  +  + ]
      86   [ +  -  +  - ]:           8 :                     throw JSONRPCTransactionError(TransactionError::MAX_BURN_EXCEEDED);
      87                 :             :                 }
      88                 :             :             }
      89                 :             : 
      90         [ +  - ]:       22652 :             CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
      91                 :             : 
      92   [ +  -  +  - ]:       22652 :             const CFeeRate max_raw_tx_fee_rate{ParseFeeRate(self.Arg<UniValue>("maxfeerate"))};
      93                 :             : 
      94         [ +  - ]:       22652 :             int64_t virtual_size = GetVirtualTransactionSize(*tx);
      95         [ +  - ]:       22652 :             CAmount max_raw_tx_fee = max_raw_tx_fee_rate.GetFee(virtual_size);
      96                 :             : 
      97         [ +  - ]:       22652 :             std::string err_string;
      98                 :       22652 :             AssertLockNotHeld(cs_main);
      99         [ +  - ]:       22652 :             NodeContext& node = EnsureAnyNodeContext(request.context);
     100   [ +  -  +  -  :       45304 :             const TransactionError err = BroadcastTransaction(node, tx, err_string, max_raw_tx_fee, /*relay=*/true, /*wait_callback=*/true);
                   +  - ]
     101         [ +  + ]:       22652 :             if (TransactionError::OK != err) {
     102         [ +  - ]:        4260 :                 throw JSONRPCTransactionError(err, err_string);
     103                 :             :             }
     104                 :             : 
     105   [ +  -  +  - ]:       36784 :             return tx->GetHash().GetHex();
     106         [ +  - ]:       63696 :         },
     107   [ +  -  +  -  :      174181 :     };
             +  +  -  - ]
     108   [ +  -  +  -  :      149298 : }
             +  -  -  - ]
     109                 :             : 
     110                 :        3734 : static RPCHelpMan testmempoolaccept()
     111                 :             : {
     112                 :        3734 :     return RPCHelpMan{
     113                 :        3734 :         "testmempoolaccept",
     114                 :             :         "Returns result of mempool acceptance tests indicating if raw transaction(s) (serialized, hex-encoded) would be accepted by mempool.\n"
     115                 :             :         "\nIf multiple transactions are passed in, parents must come before children and package policies apply: the transactions cannot conflict with any mempool transactions or each other.\n"
     116                 :             :         "\nIf one transaction fails, other transactions may not be fully validated (the 'allowed' key will be blank).\n"
     117   [ +  -  +  - ]:        7468 :         "\nThe maximum number of transactions allowed is " + ToString(MAX_PACKAGE_COUNT) + ".\n"
     118                 :             :         "\nThis checks if transactions violate the consensus or policy rules.\n"
     119                 :        3734 :         "\nSee sendrawtransaction call.\n",
     120                 :             :         {
     121   [ +  -  +  - ]:        7468 :             {"rawtxs", RPCArg::Type::ARR, RPCArg::Optional::NO, "An array of hex strings of raw transactions.",
     122                 :             :                 {
     123   [ +  -  +  - ]:        7468 :                     {"rawtx", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, ""},
     124                 :             :                 },
     125                 :             :             },
     126   [ +  -  +  -  :        7468 :             {"maxfeerate", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK())},
                   +  - ]
     127         [ +  - ]:        7468 :              "Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT +
     128                 :        3734 :                  "/kvB.\nFee rates larger than 1BTC/kvB are rejected.\nSet to 0 to accept any fee rate."},
     129                 :             :         },
     130         [ +  - ]:        7468 :         RPCResult{
     131   [ +  -  +  - ]:        7468 :             RPCResult::Type::ARR, "", "The result of the mempool acceptance test for each raw transaction in the input array.\n"
     132                 :             :                                       "Returns results for each transaction in the same order they were passed in.\n"
     133                 :             :                                       "Transactions that cannot be fully validated due to failures in other transactions will not contain an 'allowed' result.\n",
     134                 :             :             {
     135   [ +  -  +  - ]:        7468 :                 {RPCResult::Type::OBJ, "", "",
     136                 :             :                 {
     137   [ +  -  +  - ]:        7468 :                     {RPCResult::Type::STR_HEX, "txid", "The transaction hash in hex"},
     138   [ +  -  +  - ]:        7468 :                     {RPCResult::Type::STR_HEX, "wtxid", "The transaction witness hash in hex"},
     139   [ +  -  +  - ]:        7468 :                     {RPCResult::Type::STR, "package-error", /*optional=*/true, "Package validation error, if any (only possible if rawtxs had more than 1 transaction)."},
     140   [ +  -  +  - ]:        7468 :                     {RPCResult::Type::BOOL, "allowed", /*optional=*/true, "Whether this tx would be accepted to the mempool and pass client-specified maxfeerate. "
     141                 :             :                                                        "If not present, the tx was not fully validated due to a failure in another tx in the list."},
     142   [ +  -  +  - ]:        7468 :                     {RPCResult::Type::NUM, "vsize", /*optional=*/true, "Virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted (only present when 'allowed' is true)"},
     143   [ +  -  +  - ]:        7468 :                     {RPCResult::Type::OBJ, "fees", /*optional=*/true, "Transaction fees (only present if 'allowed' is true)",
     144                 :             :                     {
     145   [ +  -  +  - ]:        7468 :                         {RPCResult::Type::STR_AMOUNT, "base", "transaction fee in " + CURRENCY_UNIT},
     146   [ +  -  +  - ]:        7468 :                         {RPCResult::Type::STR_AMOUNT, "effective-feerate", /*optional=*/false, "the effective feerate in " + CURRENCY_UNIT + " per KvB. May differ from the base feerate if, for example, there are modified fees from prioritisetransaction or a package feerate was used."},
     147   [ +  -  +  - ]:        7468 :                         {RPCResult::Type::ARR, "effective-includes", /*optional=*/false, "transactions whose fees and vsizes are included in effective-feerate.",
     148   [ +  -  +  - ]:        7468 :                             {RPCResult{RPCResult::Type::STR_HEX, "", "transaction wtxid in hex"},
     149                 :             :                         }},
     150                 :             :                     }},
     151   [ +  -  +  - ]:        7468 :                     {RPCResult::Type::STR, "reject-reason", /*optional=*/true, "Rejection reason (only present when 'allowed' is false)"},
     152   [ +  -  +  - ]:        7468 :                     {RPCResult::Type::STR, "reject-details", /*optional=*/true, "Rejection details (only present when 'allowed' is false and rejection details exist)"},
     153                 :             :                 }},
     154                 :             :             }
     155   [ +  -  +  -  :      100818 :         },
          +  -  +  -  +  
          -  +  +  +  +  
          +  +  +  +  -  
          -  -  -  -  -  
                   -  - ]
     156                 :        3734 :         RPCExamples{
     157                 :             :             "\nCreate a transaction\n"
     158   [ +  -  +  -  :        7468 :             + HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"") +
             +  -  +  - ]
     159                 :        3734 :             "Sign the transaction, and get back the hex\n"
     160   [ +  -  +  -  :       14936 :             + HelpExampleCli("signrawtransactionwithwallet", "\"myhex\"") +
             +  -  +  - ]
     161                 :        3734 :             "\nTest acceptance of the transaction (signed hex)\n"
     162   [ +  -  +  -  :       14936 :             + HelpExampleCli("testmempoolaccept", R"('["signedhex"]')") +
             +  -  +  - ]
     163                 :        3734 :             "\nAs a JSON-RPC call\n"
     164   [ +  -  +  -  :       14936 :             + HelpExampleRpc("testmempoolaccept", "[\"signedhex\"]")
             +  -  +  - ]
     165         [ +  - ]:        3734 :                 },
     166                 :        3734 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
     167                 :             :         {
     168                 :        1509 :             const UniValue raw_transactions = request.params[0].get_array();
     169   [ -  +  +  +  :        1509 :             if (raw_transactions.size() < 1 || raw_transactions.size() > MAX_PACKAGE_COUNT) {
                   +  + ]
     170                 :           2 :                 throw JSONRPCError(RPC_INVALID_PARAMETER,
     171   [ +  -  +  -  :           6 :                                    "Array must contain between 1 and " + ToString(MAX_PACKAGE_COUNT) + " transactions.");
                   +  - ]
     172                 :             :             }
     173                 :             : 
     174   [ +  -  +  + ]:        1507 :             const CFeeRate max_raw_tx_fee_rate{ParseFeeRate(self.Arg<UniValue>("maxfeerate"))};
     175                 :             : 
     176                 :        1505 :             std::vector<CTransactionRef> txns;
     177   [ -  +  +  - ]:        1505 :             txns.reserve(raw_transactions.size());
     178   [ +  -  +  + ]:        3613 :             for (const auto& rawtx : raw_transactions.getValues()) {
     179         [ +  - ]:        2109 :                 CMutableTransaction mtx;
     180   [ +  -  +  -  :        2109 :                 if (!DecodeHexTx(mtx, rawtx.get_str())) {
                   +  + ]
     181                 :           1 :                     throw JSONRPCError(RPC_DESERIALIZATION_ERROR,
     182   [ +  -  +  -  :           3 :                                        "TX decode failed: " + rawtx.get_str() + " Make sure the tx has at least one input.");
                   +  - ]
     183                 :             :                 }
     184   [ +  -  +  - ]:        6324 :                 txns.emplace_back(MakeTransactionRef(std::move(mtx)));
     185                 :        2109 :             }
     186                 :             : 
     187         [ +  - ]:        1504 :             NodeContext& node = EnsureAnyNodeContext(request.context);
     188         [ +  - ]:        1504 :             CTxMemPool& mempool = EnsureMemPool(node);
     189         [ +  - ]:        1504 :             ChainstateManager& chainman = EnsureChainman(node);
     190         [ +  - ]:        1504 :             Chainstate& chainstate = chainman.ActiveChainstate();
     191                 :        3008 :             const PackageMempoolAcceptResult package_result = [&] {
     192                 :        1504 :                 LOCK(::cs_main);
     193   [ -  +  +  +  :        1504 :                 if (txns.size() > 1) return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/true, /*client_maxfeerate=*/{});
                   +  - ]
     194         [ +  - ]:        1419 :                 return PackageMempoolAcceptResult(txns[0]->GetWitnessHash(),
     195   [ +  -  +  - ]:        1419 :                                                   chainman.ProcessTransaction(txns[0], /*test_accept=*/true));
     196         [ +  - ]:        3008 :             }();
     197                 :             : 
     198                 :        1504 :             UniValue rpc_result(UniValue::VARR);
     199                 :             :             // We will check transaction fees while we iterate through txns in order. If any transaction fee
     200                 :             :             // exceeds maxfeerate, we will leave the rest of the validation results blank, because it
     201                 :             :             // doesn't make sense to return a validation result for a transaction if its ancestor(s) would
     202                 :             :             // not be submitted.
     203                 :        1504 :             bool exit_early{false};
     204         [ +  + ]:        3612 :             for (const auto& tx : txns) {
     205                 :        2108 :                 UniValue result_inner(UniValue::VOBJ);
     206   [ +  -  +  -  :        4216 :                 result_inner.pushKV("txid", tx->GetHash().GetHex());
             +  -  +  - ]
     207   [ +  -  +  -  :        4216 :                 result_inner.pushKV("wtxid", tx->GetWitnessHash().GetHex());
             +  -  +  - ]
     208         [ +  + ]:        2108 :                 if (package_result.m_state.GetResult() == PackageValidationResult::PCKG_POLICY) {
     209   [ +  -  +  -  :         224 :                     result_inner.pushKV("package-error", package_result.m_state.ToString());
             +  -  +  - ]
     210                 :             :                 }
     211                 :        2108 :                 auto it = package_result.m_tx_results.find(tx->GetWitnessHash());
     212   [ +  +  +  + ]:        2108 :                 if (exit_early || it == package_result.m_tx_results.end()) {
     213                 :             :                     // Validation unfinished. Just return the txid and wtxid.
     214         [ +  - ]:         150 :                     rpc_result.push_back(std::move(result_inner));
     215                 :         150 :                     continue;
     216                 :             :                 }
     217         [ +  - ]:        1958 :                 const auto& tx_result = it->second;
     218                 :             :                 // Package testmempoolaccept doesn't allow transactions to already be in the mempool.
     219         [ +  - ]:        1958 :                 CHECK_NONFATAL(tx_result.m_result_type != MempoolAcceptResult::ResultType::MEMPOOL_ENTRY);
     220         [ +  + ]:        1958 :                 if (tx_result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
     221         [ +  - ]:        1709 :                     const CAmount fee = tx_result.m_base_fees.value();
     222                 :             :                     // Check that fee does not exceed maximum fee
     223         [ +  - ]:        1709 :                     const int64_t virtual_size = tx_result.m_vsize.value();
     224         [ +  - ]:        1709 :                     const CAmount max_raw_tx_fee = max_raw_tx_fee_rate.GetFee(virtual_size);
     225         [ +  + ]:        1709 :                     if (max_raw_tx_fee && fee > max_raw_tx_fee) {
     226   [ +  -  +  -  :           8 :                         result_inner.pushKV("allowed", false);
                   +  - ]
     227   [ +  -  +  -  :           4 :                         result_inner.pushKV("reject-reason", "max-fee-exceeded");
                   +  - ]
     228                 :           4 :                         exit_early = true;
     229                 :             :                     } else {
     230                 :             :                         // Only return the fee and vsize if the transaction would pass ATMP.
     231                 :             :                         // These can be used to calculate the feerate.
     232   [ +  -  +  -  :        3410 :                         result_inner.pushKV("allowed", true);
                   +  - ]
     233   [ +  -  +  -  :        3410 :                         result_inner.pushKV("vsize", virtual_size);
                   +  - ]
     234                 :        1705 :                         UniValue fees(UniValue::VOBJ);
     235   [ +  -  +  -  :        3410 :                         fees.pushKV("base", ValueFromAmount(fee));
                   +  - ]
     236   [ +  -  +  -  :        3410 :                         fees.pushKV("effective-feerate", ValueFromAmount(tx_result.m_effective_feerate.value().GetFeePerK()));
             +  -  +  - ]
     237                 :        1705 :                         UniValue effective_includes_res(UniValue::VARR);
     238   [ +  -  +  + ]:        3410 :                         for (const auto& wtxid : tx_result.m_wtxids_fee_calculations.value()) {
     239   [ +  -  +  -  :        1705 :                             effective_includes_res.push_back(wtxid.ToString());
                   +  - ]
     240                 :             :                         }
     241   [ +  -  +  - ]:        3410 :                         fees.pushKV("effective-includes", std::move(effective_includes_res));
     242   [ +  -  +  - ]:        3410 :                         result_inner.pushKV("fees", std::move(fees));
     243                 :        1705 :                     }
     244                 :             :                 } else {
     245   [ +  -  +  -  :         498 :                     result_inner.pushKV("allowed", false);
                   +  - ]
     246         [ +  - ]:         249 :                     const TxValidationState state = tx_result.m_state;
     247         [ +  + ]:         249 :                     if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS) {
     248   [ +  -  +  -  :         232 :                         result_inner.pushKV("reject-reason", "missing-inputs");
                   +  - ]
     249                 :             :                     } else {
     250   [ -  +  +  -  :         399 :                         result_inner.pushKV("reject-reason", state.GetRejectReason());
             +  -  +  - ]
     251   [ +  -  +  -  :         266 :                         result_inner.pushKV("reject-details", state.ToString());
             +  -  +  - ]
     252                 :             :                     }
     253                 :         249 :                 }
     254         [ +  - ]:        1958 :                 rpc_result.push_back(std::move(result_inner));
     255                 :        2108 :             }
     256                 :        1504 :             return rpc_result;
     257                 :        1510 :         },
     258   [ +  -  +  -  :       33606 :     };
          +  -  +  +  +  
             +  -  -  -  
                      - ]
     259   [ +  -  +  -  :       70946 : }
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  -  -  
             -  -  -  - ]
     260                 :             : 
     261                 :       16188 : static std::vector<RPCResult> MempoolEntryDescription()
     262                 :             : {
     263                 :       16188 :     return {
     264   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::NUM, "vsize", "virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted."},
     265   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::NUM, "weight", "transaction weight as defined in BIP 141."},
     266   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::NUM_TIME, "time", "local time transaction entered pool in seconds since 1 Jan 1970 GMT"},
     267   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::NUM, "height", "block height when transaction entered pool"},
     268   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::NUM, "descendantcount", "number of in-mempool descendant transactions (including this one)"},
     269   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::NUM, "descendantsize", "virtual transaction size of in-mempool descendants (including this one)"},
     270   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::NUM, "ancestorcount", "number of in-mempool ancestor transactions (including this one)"},
     271   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::NUM, "ancestorsize", "virtual transaction size of in-mempool ancestors (including this one)"},
     272   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::STR_HEX, "wtxid", "hash of serialized transaction, including witness data"},
     273   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::OBJ, "fees", "",
     274                 :             :             {
     275   [ +  -  +  - ]:       32376 :                 RPCResult{RPCResult::Type::STR_AMOUNT, "base", "transaction fee, denominated in " + CURRENCY_UNIT},
     276   [ +  -  +  - ]:       32376 :                 RPCResult{RPCResult::Type::STR_AMOUNT, "modified", "transaction fee with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT},
     277   [ +  -  +  - ]:       32376 :                 RPCResult{RPCResult::Type::STR_AMOUNT, "ancestor", "transaction fees of in-mempool ancestors (including this one) with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT},
     278   [ +  -  +  - ]:       32376 :                 RPCResult{RPCResult::Type::STR_AMOUNT, "descendant", "transaction fees of in-mempool descendants (including this one) with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT},
     279   [ +  -  +  +  :       97128 :             }},
                   -  - ]
     280   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::ARR, "depends", "unconfirmed transactions used as inputs for this transaction",
     281   [ +  -  +  -  :       64752 :             {RPCResult{RPCResult::Type::STR_HEX, "transactionid", "parent transaction id"}}},
          +  -  +  +  -  
                      - ]
     282   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::ARR, "spentby", "unconfirmed transactions spending outputs from this transaction",
     283   [ +  -  +  -  :       64752 :             {RPCResult{RPCResult::Type::STR_HEX, "transactionid", "child transaction id"}}},
          +  -  +  +  -  
                      - ]
     284   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::BOOL, "bip125-replaceable", "Whether this transaction signals BIP125 replaceability or has an unconfirmed ancestor signaling BIP125 replaceability. (DEPRECATED)\n"},
     285   [ +  -  +  - ]:       32376 :         RPCResult{RPCResult::Type::BOOL, "unbroadcast", "Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)"},
     286   [ +  -  +  +  :      275196 :     };
                   -  - ]
     287   [ +  -  +  -  :      323760 : }
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  -  -  -  
                      - ]
     288                 :             : 
     289                 :        4579 : static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPoolEntry& e) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
     290                 :             : {
     291                 :        4579 :     AssertLockHeld(pool.cs);
     292                 :             : 
     293   [ +  -  +  - ]:        9158 :     info.pushKV("vsize", (int)e.GetTxSize());
     294   [ +  -  +  - ]:        9158 :     info.pushKV("weight", (int)e.GetTxWeight());
     295   [ +  -  +  - ]:        9158 :     info.pushKV("time", count_seconds(e.GetTime()));
     296   [ +  -  +  - ]:        9158 :     info.pushKV("height", (int)e.GetHeight());
     297   [ +  -  +  - ]:        9158 :     info.pushKV("descendantcount", e.GetCountWithDescendants());
     298   [ +  -  +  - ]:        9158 :     info.pushKV("descendantsize", e.GetSizeWithDescendants());
     299   [ +  -  +  - ]:        9158 :     info.pushKV("ancestorcount", e.GetCountWithAncestors());
     300   [ +  -  +  - ]:        9158 :     info.pushKV("ancestorsize", e.GetSizeWithAncestors());
     301   [ +  -  +  -  :        9158 :     info.pushKV("wtxid", e.GetTx().GetWitnessHash().ToString());
                   +  - ]
     302                 :             : 
     303                 :        4579 :     UniValue fees(UniValue::VOBJ);
     304   [ +  -  +  -  :        9158 :     fees.pushKV("base", ValueFromAmount(e.GetFee()));
                   +  - ]
     305   [ +  -  +  -  :        9158 :     fees.pushKV("modified", ValueFromAmount(e.GetModifiedFee()));
                   +  - ]
     306   [ +  -  +  -  :        9158 :     fees.pushKV("ancestor", ValueFromAmount(e.GetModFeesWithAncestors()));
                   +  - ]
     307   [ +  -  +  -  :        9158 :     fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants()));
                   +  - ]
     308   [ +  -  +  - ]:        9158 :     info.pushKV("fees", std::move(fees));
     309                 :             : 
     310                 :        4579 :     const CTransaction& tx = e.GetTx();
     311                 :        4579 :     std::set<std::string> setDepends;
     312         [ +  + ]:       14836 :     for (const CTxIn& txin : tx.vin)
     313                 :             :     {
     314   [ +  -  +  + ]:       10257 :         if (pool.exists(txin.prevout.hash))
     315   [ +  -  +  - ]:       12952 :             setDepends.insert(txin.prevout.hash.ToString());
     316                 :             :     }
     317                 :             : 
     318                 :        4579 :     UniValue depends(UniValue::VARR);
     319         [ +  + ]:       11055 :     for (const std::string& dep : setDepends)
     320                 :             :     {
     321   [ +  -  +  - ]:        6476 :         depends.push_back(dep);
     322                 :             :     }
     323                 :             : 
     324   [ +  -  +  - ]:        9158 :     info.pushKV("depends", std::move(depends));
     325                 :             : 
     326                 :        4579 :     UniValue spent(UniValue::VARR);
     327   [ +  -  +  + ]:       10871 :     for (const CTxMemPoolEntry& child : e.GetMemPoolChildrenConst()) {
     328   [ +  -  +  -  :        6292 :         spent.push_back(child.GetTx().GetHash().ToString());
                   +  - ]
     329                 :             :     }
     330                 :             : 
     331   [ +  -  +  - ]:        9158 :     info.pushKV("spentby", std::move(spent));
     332                 :             : 
     333                 :             :     // Add opt-in RBF status
     334                 :        4579 :     bool rbfStatus = false;
     335         [ +  - ]:        4579 :     RBFTransactionState rbfState = IsRBFOptIn(tx, pool);
     336         [ -  + ]:        4579 :     if (rbfState == RBFTransactionState::UNKNOWN) {
     337   [ #  #  #  # ]:           0 :         throw JSONRPCError(RPC_MISC_ERROR, "Transaction is not in mempool");
     338         [ +  + ]:        4579 :     } else if (rbfState == RBFTransactionState::REPLACEABLE_BIP125) {
     339                 :        3891 :         rbfStatus = true;
     340                 :             :     }
     341                 :             : 
     342   [ +  -  +  -  :        9158 :     info.pushKV("bip125-replaceable", rbfStatus);
                   +  - ]
     343   [ +  -  +  -  :        9158 :     info.pushKV("unbroadcast", pool.IsUnbroadcastTx(tx.GetHash()));
                   +  - ]
     344                 :        4579 : }
     345                 :             : 
     346                 :        6346 : UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose, bool include_mempool_sequence)
     347                 :             : {
     348         [ +  + ]:        6346 :     if (verbose) {
     349         [ +  + ]:        1038 :         if (include_mempool_sequence) {
     350   [ +  -  +  - ]:           2 :             throw JSONRPCError(RPC_INVALID_PARAMETER, "Verbose results cannot contain mempool sequence values.");
     351                 :             :         }
     352                 :        1037 :         LOCK(pool.cs);
     353                 :        1037 :         UniValue o(UniValue::VOBJ);
     354   [ +  -  +  + ]:        4126 :         for (const CTxMemPoolEntry& e : pool.entryAll()) {
     355                 :        3089 :             UniValue info(UniValue::VOBJ);
     356         [ +  - ]:        3089 :             entryToJSON(pool, info, e);
     357                 :             :             // Mempool has unique entries so there is no advantage in using
     358                 :             :             // UniValue::pushKV, which checks if the key already exists in O(N).
     359                 :             :             // UniValue::pushKVEnd is used instead which currently is O(1).
     360   [ +  -  +  - ]:        6178 :             o.pushKVEnd(e.GetTx().GetHash().ToString(), std::move(info));
     361                 :        3089 :         }
     362         [ +  - ]:        1037 :         return o;
     363                 :        1037 :     } else {
     364                 :        5308 :         UniValue a(UniValue::VARR);
     365                 :        5308 :         uint64_t mempool_sequence;
     366                 :        5308 :         {
     367         [ +  - ]:        5308 :             LOCK(pool.cs);
     368   [ +  -  +  -  :      287115 :             for (const CTxMemPoolEntry& e : pool.entryAll()) {
                   +  + ]
     369   [ +  -  +  -  :      281807 :                 a.push_back(e.GetTx().GetHash().ToString());
                   +  - ]
     370                 :             :             }
     371         [ +  - ]:        5308 :             mempool_sequence = pool.GetSequence();
     372                 :           0 :         }
     373         [ +  + ]:        5308 :         if (!include_mempool_sequence) {
     374                 :        5291 :             return a;
     375                 :             :         } else {
     376                 :          17 :             UniValue o(UniValue::VOBJ);
     377   [ +  -  +  - ]:          34 :             o.pushKV("txids", std::move(a));
     378   [ +  -  +  -  :          34 :             o.pushKV("mempool_sequence", mempool_sequence);
                   +  - ]
     379                 :          17 :             return o;
     380                 :          17 :         }
     381                 :        5308 :     }
     382                 :             : }
     383                 :             : 
     384                 :        8566 : static RPCHelpMan getrawmempool()
     385                 :             : {
     386                 :        8566 :     return RPCHelpMan{
     387                 :        8566 :         "getrawmempool",
     388         [ +  - ]:       17132 :         "Returns all transaction ids in memory pool as a json array of string transaction ids.\n"
     389                 :             :         "\nHint: use getmempoolentry to fetch a specific transaction from the mempool.\n",
     390                 :             :         {
     391   [ +  -  +  -  :       25698 :             {"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "True for a json object, false for array of transaction ids"},
                   +  - ]
     392   [ +  -  +  -  :       25698 :             {"mempool_sequence", RPCArg::Type::BOOL, RPCArg::Default{false}, "If verbose=false, returns a json object with transaction list and mempool sequence number attached."},
                   +  - ]
     393                 :             :         },
     394                 :             :         {
     395         [ +  - ]:        8566 :             RPCResult{"for verbose = false",
     396   [ +  -  +  - ]:       17132 :                 RPCResult::Type::ARR, "", "",
     397                 :             :                 {
     398   [ +  -  +  - ]:       17132 :                     {RPCResult::Type::STR_HEX, "", "The transaction id"},
     399   [ +  -  +  +  :       25698 :                 }},
                   -  - ]
     400         [ +  - ]:       17132 :             RPCResult{"for verbose = true",
     401   [ +  -  +  - ]:       17132 :                 RPCResult::Type::OBJ_DYN, "", "",
     402                 :             :                 {
     403   [ +  -  +  -  :       17132 :                     {RPCResult::Type::OBJ, "transactionid", "", MempoolEntryDescription()},
                   +  - ]
     404   [ +  -  +  +  :       25698 :                 }},
                   -  - ]
     405         [ +  - ]:       17132 :             RPCResult{"for verbose = false and mempool_sequence = true",
     406   [ +  -  +  - ]:       17132 :                 RPCResult::Type::OBJ, "", "",
     407                 :             :                 {
     408   [ +  -  +  - ]:       17132 :                     {RPCResult::Type::ARR, "txids", "",
     409                 :             :                     {
     410   [ +  -  +  - ]:       17132 :                         {RPCResult::Type::STR_HEX, "", "The transaction id"},
     411                 :             :                     }},
     412   [ +  -  +  - ]:       17132 :                     {RPCResult::Type::NUM, "mempool_sequence", "The mempool sequence value."},
     413   [ +  -  +  -  :       59962 :                 }},
          +  +  +  +  -  
                -  -  - ]
     414                 :             :         },
     415                 :        8566 :         RPCExamples{
     416   [ +  -  +  -  :       17132 :             HelpExampleCli("getrawmempool", "true")
                   +  - ]
     417   [ +  -  +  -  :       34264 :             + HelpExampleRpc("getrawmempool", "true")
                   +  - ]
     418         [ +  - ]:        8566 :         },
     419                 :        8566 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
     420                 :             : {
     421                 :        6342 :     bool fVerbose = false;
     422         [ +  + ]:        6342 :     if (!request.params[0].isNull())
     423                 :        1096 :         fVerbose = request.params[0].get_bool();
     424                 :             : 
     425                 :        6342 :     bool include_mempool_sequence = false;
     426         [ +  + ]:        6342 :     if (!request.params[1].isNull()) {
     427                 :          18 :         include_mempool_sequence = request.params[1].get_bool();
     428                 :             :     }
     429                 :             : 
     430                 :        6342 :     return MempoolToJSON(EnsureAnyMemPool(request.context), fVerbose, include_mempool_sequence);
     431                 :             : },
     432   [ +  -  +  -  :      102792 :     };
          +  -  +  -  +  
          +  +  +  -  -  
                   -  - ]
     433   [ +  -  +  -  :      102792 : }
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  -  -  -  -  
                   -  - ]
     434                 :             : 
     435                 :        2275 : static RPCHelpMan getmempoolancestors()
     436                 :             : {
     437                 :        2275 :     return RPCHelpMan{
     438                 :        2275 :         "getmempoolancestors",
     439         [ +  - ]:        4550 :         "If txid is in the mempool, returns all in-mempool ancestors.\n",
     440                 :             :         {
     441   [ +  -  +  - ]:        4550 :             {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id (must be in mempool)"},
     442   [ +  -  +  -  :        6825 :             {"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "True for a json object, false for array of transaction ids"},
                   +  - ]
     443                 :             :         },
     444                 :             :         {
     445         [ +  - ]:        2275 :             RPCResult{"for verbose = false",
     446   [ +  -  +  - ]:        4550 :                 RPCResult::Type::ARR, "", "",
     447   [ +  -  +  -  :        9100 :                 {{RPCResult::Type::STR_HEX, "", "The transaction id of an in-mempool ancestor transaction"}}},
          +  -  +  +  -  
                      - ]
     448         [ +  - ]:        4550 :             RPCResult{"for verbose = true",
     449   [ +  -  +  - ]:        4550 :                 RPCResult::Type::OBJ_DYN, "", "",
     450                 :             :                 {
     451   [ +  -  +  -  :        4550 :                     {RPCResult::Type::OBJ, "transactionid", "", MempoolEntryDescription()},
                   +  - ]
     452   [ +  -  +  +  :        6825 :                 }},
                   -  - ]
     453                 :             :         },
     454                 :        2275 :         RPCExamples{
     455   [ +  -  +  -  :        4550 :             HelpExampleCli("getmempoolancestors", "\"mytxid\"")
                   +  - ]
     456   [ +  -  +  -  :        9100 :             + HelpExampleRpc("getmempoolancestors", "\"mytxid\"")
                   +  - ]
     457         [ +  - ]:        2275 :         },
     458                 :        2275 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
     459                 :             : {
     460                 :          51 :     bool fVerbose = false;
     461         [ +  + ]:          51 :     if (!request.params[1].isNull())
     462                 :          26 :         fVerbose = request.params[1].get_bool();
     463                 :             : 
     464                 :          51 :     uint256 hash = ParseHashV(request.params[0], "parameter 1");
     465                 :             : 
     466                 :          51 :     const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
     467                 :          51 :     LOCK(mempool.cs);
     468                 :             : 
     469         [ +  - ]:          51 :     const auto entry{mempool.GetEntry(Txid::FromUint256(hash))};
     470         [ -  + ]:          51 :     if (entry == nullptr) {
     471   [ #  #  #  # ]:           0 :         throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
     472                 :             :     }
     473                 :             : 
     474   [ -  +  +  - ]:          51 :     auto ancestors{mempool.AssumeCalculateMemPoolAncestors(self.m_name, *entry, CTxMemPool::Limits::NoLimits(), /*fSearchForParents=*/false)};
     475                 :             : 
     476         [ +  + ]:          51 :     if (!fVerbose) {
     477                 :          25 :         UniValue o(UniValue::VARR);
     478         [ +  + ]:         325 :         for (CTxMemPool::txiter ancestorIt : ancestors) {
     479   [ +  -  +  -  :         300 :             o.push_back(ancestorIt->GetTx().GetHash().ToString());
                   +  - ]
     480                 :             :         }
     481                 :             :         return o;
     482                 :           0 :     } else {
     483                 :          26 :         UniValue o(UniValue::VOBJ);
     484         [ +  + ]:         350 :         for (CTxMemPool::txiter ancestorIt : ancestors) {
     485                 :         324 :             const CTxMemPoolEntry &e = *ancestorIt;
     486                 :         324 :             const uint256& _hash = e.GetTx().GetHash();
     487                 :         324 :             UniValue info(UniValue::VOBJ);
     488         [ +  - ]:         324 :             entryToJSON(mempool, info, e);
     489   [ +  -  +  - ]:         648 :             o.pushKV(_hash.ToString(), std::move(info));
     490                 :         324 :         }
     491                 :          26 :         return o;
     492                 :          26 :     }
     493         [ +  - ]:         102 : },
     494   [ +  -  +  -  :       25025 :     };
          +  -  +  -  +  
          +  +  +  -  -  
                   -  - ]
     495   [ +  -  +  -  :       18200 : }
          +  -  +  -  +  
          -  +  -  -  -  
                   -  - ]
     496                 :             : 
     497                 :        2275 : static RPCHelpMan getmempooldescendants()
     498                 :             : {
     499                 :        2275 :     return RPCHelpMan{
     500                 :        2275 :         "getmempooldescendants",
     501         [ +  - ]:        4550 :         "If txid is in the mempool, returns all in-mempool descendants.\n",
     502                 :             :         {
     503   [ +  -  +  - ]:        4550 :             {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id (must be in mempool)"},
     504   [ +  -  +  -  :        6825 :             {"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "True for a json object, false for array of transaction ids"},
                   +  - ]
     505                 :             :         },
     506                 :             :         {
     507         [ +  - ]:        2275 :             RPCResult{"for verbose = false",
     508   [ +  -  +  - ]:        4550 :                 RPCResult::Type::ARR, "", "",
     509   [ +  -  +  -  :        9100 :                 {{RPCResult::Type::STR_HEX, "", "The transaction id of an in-mempool descendant transaction"}}},
          +  -  +  +  -  
                      - ]
     510         [ +  - ]:        4550 :             RPCResult{"for verbose = true",
     511   [ +  -  +  - ]:        4550 :                 RPCResult::Type::OBJ_DYN, "", "",
     512                 :             :                 {
     513   [ +  -  +  -  :        4550 :                     {RPCResult::Type::OBJ, "transactionid", "", MempoolEntryDescription()},
                   +  - ]
     514   [ +  -  +  +  :        6825 :                 }},
                   -  - ]
     515                 :             :         },
     516                 :        2275 :         RPCExamples{
     517   [ +  -  +  -  :        4550 :             HelpExampleCli("getmempooldescendants", "\"mytxid\"")
                   +  - ]
     518   [ +  -  +  -  :        9100 :             + HelpExampleRpc("getmempooldescendants", "\"mytxid\"")
                   +  - ]
     519         [ +  - ]:        2275 :         },
     520                 :        2275 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
     521                 :             : {
     522                 :          51 :     bool fVerbose = false;
     523         [ +  + ]:          51 :     if (!request.params[1].isNull())
     524                 :          26 :         fVerbose = request.params[1].get_bool();
     525                 :             : 
     526                 :          51 :     Txid txid{Txid::FromUint256(ParseHashV(request.params[0], "parameter 1"))};
     527                 :             : 
     528                 :          51 :     const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
     529                 :          51 :     LOCK(mempool.cs);
     530                 :             : 
     531         [ +  - ]:          51 :     const auto it{mempool.GetIter(txid)};
     532         [ -  + ]:          51 :     if (!it) {
     533   [ #  #  #  # ]:           0 :         throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
     534                 :             :     }
     535                 :             : 
     536         [ +  - ]:          51 :     CTxMemPool::setEntries setDescendants;
     537         [ +  - ]:          51 :     mempool.CalculateDescendants(*it, setDescendants);
     538                 :             :     // CTxMemPool::CalculateDescendants will include the given tx
     539                 :          51 :     setDescendants.erase(*it);
     540                 :             : 
     541         [ +  + ]:          51 :     if (!fVerbose) {
     542                 :          25 :         UniValue o(UniValue::VARR);
     543         [ +  + ]:         325 :         for (CTxMemPool::txiter descendantIt : setDescendants) {
     544   [ +  -  +  -  :         300 :             o.push_back(descendantIt->GetTx().GetHash().ToString());
                   +  - ]
     545                 :             :         }
     546                 :             : 
     547                 :             :         return o;
     548                 :           0 :     } else {
     549                 :          26 :         UniValue o(UniValue::VOBJ);
     550         [ +  + ]:         350 :         for (CTxMemPool::txiter descendantIt : setDescendants) {
     551                 :         324 :             const CTxMemPoolEntry &e = *descendantIt;
     552                 :         324 :             const uint256& _hash = e.GetTx().GetHash();
     553                 :         324 :             UniValue info(UniValue::VOBJ);
     554         [ +  - ]:         324 :             entryToJSON(mempool, info, e);
     555   [ +  -  +  - ]:         648 :             o.pushKV(_hash.ToString(), std::move(info));
     556                 :         324 :         }
     557                 :          26 :         return o;
     558                 :          26 :     }
     559         [ +  - ]:         102 : },
     560   [ +  -  +  -  :       25025 :     };
          +  -  +  -  +  
          +  +  +  -  -  
                   -  - ]
     561   [ +  -  +  -  :       18200 : }
          +  -  +  -  +  
          -  +  -  -  -  
                   -  - ]
     562                 :             : 
     563                 :        3072 : static RPCHelpMan getmempoolentry()
     564                 :             : {
     565                 :        3072 :     return RPCHelpMan{
     566                 :        3072 :         "getmempoolentry",
     567         [ +  - ]:        6144 :         "Returns mempool data for given transaction\n",
     568                 :             :         {
     569   [ +  -  +  - ]:        6144 :             {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id (must be in mempool)"},
     570                 :             :         },
     571         [ +  - ]:        6144 :         RPCResult{
     572   [ +  -  +  -  :        6144 :             RPCResult::Type::OBJ, "", "", MempoolEntryDescription()},
             +  -  +  - ]
     573                 :        3072 :         RPCExamples{
     574   [ +  -  +  -  :        6144 :             HelpExampleCli("getmempoolentry", "\"mytxid\"")
                   +  - ]
     575   [ +  -  +  -  :       12288 :             + HelpExampleRpc("getmempoolentry", "\"mytxid\"")
             +  -  +  - ]
     576         [ +  - ]:        3072 :         },
     577                 :        3072 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
     578                 :             : {
     579                 :         848 :     uint256 hash = ParseHashV(request.params[0], "parameter 1");
     580                 :             : 
     581                 :         848 :     const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
     582                 :         848 :     LOCK(mempool.cs);
     583                 :             : 
     584         [ +  - ]:         848 :     const auto entry{mempool.GetEntry(Txid::FromUint256(hash))};
     585         [ +  + ]:         848 :     if (entry == nullptr) {
     586   [ +  -  +  - ]:          12 :         throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
     587                 :             :     }
     588                 :             : 
     589                 :         842 :     UniValue info(UniValue::VOBJ);
     590         [ +  - ]:         842 :     entryToJSON(mempool, info, *entry);
     591         [ +  - ]:         842 :     return info;
     592                 :         842 : },
     593   [ +  -  +  -  :       15360 :     };
             +  +  -  - ]
     594         [ +  - ]:        6144 : }
     595                 :             : 
     596                 :        2260 : static RPCHelpMan gettxspendingprevout()
     597                 :             : {
     598                 :        2260 :     return RPCHelpMan{"gettxspendingprevout",
     599         [ +  - ]:        4520 :         "Scans the mempool to find transactions spending any of the given outputs",
     600                 :             :         {
     601   [ +  -  +  - ]:        4520 :             {"outputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "The transaction outputs that we want to check, and within each, the txid (string) vout (numeric).",
     602                 :             :                 {
     603   [ +  -  +  - ]:        4520 :                     {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
     604                 :             :                         {
     605   [ +  -  +  - ]:        4520 :                             {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"},
     606   [ +  -  +  - ]:        4520 :                             {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"},
     607                 :             :                         },
     608                 :             :                     },
     609                 :             :                 },
     610                 :             :             },
     611                 :             :         },
     612         [ +  - ]:        4520 :         RPCResult{
     613   [ +  -  +  - ]:        4520 :             RPCResult::Type::ARR, "", "",
     614                 :             :             {
     615   [ +  -  +  - ]:        4520 :                 {RPCResult::Type::OBJ, "", "",
     616                 :             :                 {
     617   [ +  -  +  - ]:        4520 :                     {RPCResult::Type::STR_HEX, "txid", "the transaction id of the checked output"},
     618   [ +  -  +  - ]:        4520 :                     {RPCResult::Type::NUM, "vout", "the vout value of the checked output"},
     619   [ +  -  +  - ]:        4520 :                     {RPCResult::Type::STR_HEX, "spendingtxid", /*optional=*/true, "the transaction id of the mempool transaction spending this output (omitted if unspent)"},
     620                 :             :                 }},
     621                 :             :             }
     622   [ +  -  +  -  :       20340 :         },
          +  -  +  +  +  
             +  -  -  -  
                      - ]
     623                 :        2260 :         RPCExamples{
     624   [ +  -  +  -  :        4520 :             HelpExampleCli("gettxspendingprevout", "\"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":3}]\"")
                   +  - ]
     625   [ +  -  +  -  :        9040 :             + HelpExampleRpc("gettxspendingprevout", "\"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":3}]\"")
             +  -  +  - ]
     626         [ +  - ]:        2260 :         },
     627                 :        2260 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
     628                 :             :         {
     629                 :          36 :             const UniValue& output_params = request.params[0].get_array();
     630   [ -  +  +  + ]:          36 :             if (output_params.empty()) {
     631   [ +  -  +  - ]:           2 :                 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, outputs are missing");
     632                 :             :             }
     633                 :             : 
     634                 :          35 :             std::vector<COutPoint> prevouts;
     635         [ +  - ]:          35 :             prevouts.reserve(output_params.size());
     636                 :             : 
     637   [ -  +  +  + ]:          68 :             for (unsigned int idx = 0; idx < output_params.size(); idx++) {
     638   [ +  -  +  - ]:          38 :                 const UniValue& o = output_params[idx].get_obj();
     639                 :             : 
     640   [ +  +  +  +  :         156 :                 RPCTypeCheckObj(o,
                   +  + ]
     641                 :             :                                 {
     642         [ +  - ]:          38 :                                     {"txid", UniValueType(UniValue::VSTR)},
     643         [ +  - ]:          38 :                                     {"vout", UniValueType(UniValue::VNUM)},
     644                 :             :                                 }, /*fAllowNull=*/false, /*fStrict=*/true);
     645                 :             : 
     646         [ +  - ]:          34 :                 const Txid txid = Txid::FromUint256(ParseHashO(o, "txid"));
     647   [ +  -  +  - ]:          34 :                 const int nOutput{o.find_value("vout").getInt<int>()};
     648         [ +  + ]:          34 :                 if (nOutput < 0) {
     649   [ +  -  +  - ]:           2 :                     throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout cannot be negative");
     650                 :             :                 }
     651                 :             : 
     652         [ +  - ]:          33 :                 prevouts.emplace_back(txid, nOutput);
     653                 :             :             }
     654                 :             : 
     655         [ +  - ]:          30 :             const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
     656         [ +  - ]:          30 :             LOCK(mempool.cs);
     657                 :             : 
     658                 :          30 :             UniValue result{UniValue::VARR};
     659                 :             : 
     660         [ +  + ]:          63 :             for (const COutPoint& prevout : prevouts) {
     661                 :          33 :                 UniValue o(UniValue::VOBJ);
     662   [ +  -  +  -  :          66 :                 o.pushKV("txid", prevout.hash.ToString());
             +  -  +  - ]
     663   [ +  -  +  -  :          66 :                 o.pushKV("vout", (uint64_t)prevout.n);
                   +  - ]
     664                 :             : 
     665         [ +  - ]:          33 :                 const CTransaction* spendingTx = mempool.GetConflictTx(prevout);
     666         [ +  + ]:          33 :                 if (spendingTx != nullptr) {
     667   [ +  -  +  -  :          60 :                     o.pushKV("spendingtxid", spendingTx->GetHash().ToString());
             +  -  +  - ]
     668                 :             :                 }
     669                 :             : 
     670         [ +  - ]:          33 :                 result.push_back(std::move(o));
     671                 :          33 :             }
     672                 :             : 
     673         [ +  - ]:          30 :             return result;
     674   [ +  -  +  -  :          72 :         },
             +  -  -  + ]
     675   [ +  -  +  -  :       27120 :     };
          +  -  +  -  +  
          +  +  +  +  +  
          -  -  -  -  -  
                      - ]
     676   [ +  -  +  -  :       27120 : }
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  -  -  -  
                      - ]
     677                 :             : 
     678                 :        1198 : UniValue MempoolInfoToJSON(const CTxMemPool& pool)
     679                 :             : {
     680                 :             :     // Make sure this call is atomic in the pool.
     681                 :        1198 :     LOCK(pool.cs);
     682                 :        1198 :     UniValue ret(UniValue::VOBJ);
     683   [ +  -  +  -  :        2396 :     ret.pushKV("loaded", pool.GetLoadTried());
             +  -  +  - ]
     684   [ +  -  +  -  :        2396 :     ret.pushKV("size", (int64_t)pool.size());
             +  -  +  - ]
     685   [ +  -  +  -  :        2396 :     ret.pushKV("bytes", (int64_t)pool.GetTotalTxSize());
                   +  - ]
     686   [ +  -  +  -  :        2396 :     ret.pushKV("usage", (int64_t)pool.DynamicMemoryUsage());
             +  -  +  - ]
     687   [ +  -  +  -  :        2396 :     ret.pushKV("total_fee", ValueFromAmount(pool.GetTotalFee()));
                   +  - ]
     688   [ +  -  +  -  :        2396 :     ret.pushKV("maxmempool", pool.m_opts.max_size_bytes);
                   +  - ]
     689   [ +  -  +  +  :        3517 :     ret.pushKV("mempoolminfee", ValueFromAmount(std::max(pool.GetMinFee(), pool.m_opts.min_relay_feerate).GetFeePerK()));
          +  -  +  -  +  
                      - ]
     690   [ +  -  +  -  :        2396 :     ret.pushKV("minrelaytxfee", ValueFromAmount(pool.m_opts.min_relay_feerate.GetFeePerK()));
                   +  - ]
     691   [ +  -  +  -  :        2396 :     ret.pushKV("incrementalrelayfee", ValueFromAmount(pool.m_opts.incremental_relay_feerate.GetFeePerK()));
                   +  - ]
     692   [ +  -  +  -  :        2396 :     ret.pushKV("unbroadcastcount", uint64_t{pool.GetUnbroadcastTxs().size()});
             +  -  +  - ]
     693   [ +  -  +  -  :        2396 :     ret.pushKV("fullrbf", true);
                   +  - ]
     694   [ +  -  +  -  :        2396 :     ret.pushKV("permitbaremultisig", pool.m_opts.permit_bare_multisig);
                   +  - ]
     695   [ +  +  +  -  :        3592 :     ret.pushKV("maxdatacarriersize", pool.m_opts.max_datacarrier_bytes.value_or(0));
             +  -  +  - ]
     696         [ +  - ]:        1198 :     return ret;
     697                 :        1198 : }
     698                 :             : 
     699                 :        3421 : static RPCHelpMan getmempoolinfo()
     700                 :             : {
     701                 :        3421 :     return RPCHelpMan{"getmempoolinfo",
     702         [ +  - ]:        6842 :         "Returns details on the active state of the TX memory pool.",
     703                 :             :         {},
     704         [ +  - ]:        6842 :         RPCResult{
     705         [ +  - ]:        6842 :             RPCResult::Type::OBJ, "", "",
     706                 :             :             {
     707   [ +  -  +  - ]:        6842 :                 {RPCResult::Type::BOOL, "loaded", "True if the initial load attempt of the persisted mempool finished"},
     708   [ +  -  +  - ]:        6842 :                 {RPCResult::Type::NUM, "size", "Current tx count"},
     709   [ +  -  +  - ]:        6842 :                 {RPCResult::Type::NUM, "bytes", "Sum of all virtual transaction sizes as defined in BIP 141. Differs from actual serialized size because witness data is discounted"},
     710   [ +  -  +  - ]:        6842 :                 {RPCResult::Type::NUM, "usage", "Total memory usage for the mempool"},
     711   [ +  -  +  - ]:        6842 :                 {RPCResult::Type::STR_AMOUNT, "total_fee", "Total fees for the mempool in " + CURRENCY_UNIT + ", ignoring modified fees through prioritisetransaction"},
     712   [ +  -  +  - ]:        6842 :                 {RPCResult::Type::NUM, "maxmempool", "Maximum memory usage for the mempool"},
     713   [ +  -  +  - ]:        6842 :                 {RPCResult::Type::STR_AMOUNT, "mempoolminfee", "Minimum fee rate in " + CURRENCY_UNIT + "/kvB for tx to be accepted. Is the maximum of minrelaytxfee and minimum mempool fee"},
     714   [ +  -  +  - ]:        6842 :                 {RPCResult::Type::STR_AMOUNT, "minrelaytxfee", "Current minimum relay fee for transactions"},
     715   [ +  -  +  - ]:        6842 :                 {RPCResult::Type::NUM, "incrementalrelayfee", "minimum fee rate increment for mempool limiting or replacement in " + CURRENCY_UNIT + "/kvB"},
     716   [ +  -  +  - ]:        6842 :                 {RPCResult::Type::NUM, "unbroadcastcount", "Current number of transactions that haven't passed initial broadcast yet"},
     717   [ +  -  +  - ]:        6842 :                 {RPCResult::Type::BOOL, "fullrbf", "True if the mempool accepts RBF without replaceability signaling inspection (DEPRECATED)"},
     718   [ +  -  +  - ]:        6842 :                 {RPCResult::Type::BOOL, "permitbaremultisig", "True if the mempool accepts transactions with bare multisig outputs"},
     719   [ +  -  +  - ]:        6842 :                 {RPCResult::Type::NUM, "maxdatacarriersize", "Maximum number of bytes that can be used by OP_RETURN outputs in the mempool"},
     720   [ +  -  +  -  :       92367 :             }},
             +  +  -  - ]
     721                 :        3421 :         RPCExamples{
     722   [ +  -  +  -  :        6842 :             HelpExampleCli("getmempoolinfo", "")
                   +  - ]
     723   [ +  -  +  -  :       13684 :             + HelpExampleRpc("getmempoolinfo", "")
             +  -  +  - ]
     724         [ +  - ]:        3421 :         },
     725                 :        3421 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
     726                 :             : {
     727                 :        1197 :     return MempoolInfoToJSON(EnsureAnyMemPool(request.context));
     728                 :             : },
     729   [ +  -  +  - ]:       13684 :     };
     730   [ +  -  +  -  :       44473 : }
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  -  - ]
     731                 :             : 
     732                 :        2227 : static RPCHelpMan importmempool()
     733                 :             : {
     734                 :        2227 :     return RPCHelpMan{
     735                 :        2227 :         "importmempool",
     736         [ +  - ]:        4454 :         "Import a mempool.dat file and attempt to add its contents to the mempool.\n"
     737                 :             :         "Warning: Importing untrusted files is dangerous, especially if metadata from the file is taken over.",
     738                 :             :         {
     739   [ +  -  +  - ]:        4454 :             {"filepath", RPCArg::Type::STR, RPCArg::Optional::NO, "The mempool file"},
     740         [ +  - ]:        4454 :             {"options",
     741                 :             :              RPCArg::Type::OBJ_NAMED_PARAMS,
     742                 :        2227 :              RPCArg::Optional::OMITTED,
     743         [ +  - ]:        4454 :              "",
     744                 :             :              {
     745   [ +  -  +  - ]:        4454 :                  {"use_current_time", RPCArg::Type::BOOL, RPCArg::Default{true},
     746         [ +  - ]:        4454 :                   "Whether to use the current system time or use the entry time metadata from the mempool file.\n"
     747                 :             :                   "Warning: Importing untrusted metadata may lead to unexpected issues and undesirable behavior."},
     748   [ +  -  +  - ]:        4454 :                  {"apply_fee_delta_priority", RPCArg::Type::BOOL, RPCArg::Default{false},
     749         [ +  - ]:        4454 :                   "Whether to apply the fee delta metadata from the mempool file.\n"
     750                 :             :                   "It will be added to any existing fee deltas.\n"
     751                 :             :                   "The fee delta can be set by the prioritisetransaction RPC.\n"
     752                 :             :                   "Warning: Importing untrusted metadata may lead to unexpected issues and undesirable behavior.\n"
     753                 :             :                   "Only set this bool if you understand what it does."},
     754   [ +  -  +  - ]:        4454 :                  {"apply_unbroadcast_set", RPCArg::Type::BOOL, RPCArg::Default{false},
     755         [ +  - ]:        4454 :                   "Whether to apply the unbroadcast set metadata from the mempool file.\n"
     756                 :             :                   "Warning: Importing untrusted metadata may lead to unexpected issues and undesirable behavior."},
     757                 :             :              },
     758         [ +  - ]:        2227 :              RPCArgOptions{.oneline_description = "options"}},
     759                 :             :         },
     760   [ +  -  +  -  :        4454 :         RPCResult{RPCResult::Type::OBJ, "", "", std::vector<RPCResult>{}},
             +  -  +  - ]
     761   [ +  -  +  -  :        6681 :         RPCExamples{HelpExampleCli("importmempool", "/path/to/mempool.dat") + HelpExampleRpc("importmempool", "/path/to/mempool.dat")},
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     762                 :        2227 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
     763                 :           3 :             const NodeContext& node{EnsureAnyNodeContext(request.context)};
     764                 :             : 
     765                 :           3 :             CTxMemPool& mempool{EnsureMemPool(node)};
     766                 :           3 :             ChainstateManager& chainman = EnsureChainman(node);
     767                 :           3 :             Chainstate& chainstate = chainman.ActiveChainstate();
     768                 :             : 
     769         [ -  + ]:           3 :             if (chainman.IsInitialBlockDownload()) {
     770   [ #  #  #  # ]:           0 :                 throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Can only import the mempool after the block download and sync is done.");
     771                 :             :             }
     772                 :             : 
     773                 :           3 :             const fs::path load_path{fs::u8path(request.params[0].get_str())};
     774   [ +  -  +  -  :           3 :             const UniValue& use_current_time{request.params[1]["use_current_time"]};
                   +  - ]
     775   [ +  -  +  -  :           3 :             const UniValue& apply_fee_delta{request.params[1]["apply_fee_delta_priority"]};
                   +  - ]
     776   [ +  -  +  -  :           3 :             const UniValue& apply_unbroadcast{request.params[1]["apply_unbroadcast_set"]};
                   +  - ]
     777         [ -  + ]:           3 :             node::ImportMempoolOptions opts{
     778   [ -  +  -  - ]:           3 :                 .use_current_time = use_current_time.isNull() ? true : use_current_time.get_bool(),
     779   [ +  +  +  - ]:           3 :                 .apply_fee_delta_priority = apply_fee_delta.isNull() ? false : apply_fee_delta.get_bool(),
     780   [ +  +  +  - ]:           3 :                 .apply_unbroadcast_set = apply_unbroadcast.isNull() ? false : apply_unbroadcast.get_bool(),
     781   [ -  +  +  +  :           5 :             };
                   +  + ]
     782                 :             : 
     783   [ +  -  -  + ]:           3 :             if (!node::LoadMempool(mempool, load_path, chainstate, std::move(opts))) {
     784   [ #  #  #  # ]:           0 :                 throw JSONRPCError(RPC_MISC_ERROR, "Unable to import mempool file, see debug.log for details.");
     785                 :             :             }
     786                 :             : 
     787                 :           3 :             UniValue ret{UniValue::VOBJ};
     788                 :           3 :             return ret;
     789                 :           6 :         },
     790   [ +  -  +  -  :       24497 :     };
          +  -  +  +  +  
             +  -  -  -  
                      - ]
     791   [ +  -  +  -  :       20043 : }
          +  -  +  -  +  
             -  -  -  -  
                      - ]
     792                 :             : 
     793                 :        2228 : static RPCHelpMan savemempool()
     794                 :             : {
     795                 :        2228 :     return RPCHelpMan{
     796                 :        2228 :         "savemempool",
     797         [ +  - ]:        4456 :         "Dumps the mempool to disk. It will fail until the previous dump is fully loaded.\n",
     798                 :             :         {},
     799         [ +  - ]:        4456 :         RPCResult{
     800         [ +  - ]:        4456 :             RPCResult::Type::OBJ, "", "",
     801                 :             :             {
     802   [ +  -  +  - ]:        4456 :                 {RPCResult::Type::STR, "filename", "the directory and file where the mempool was saved"},
     803   [ +  -  +  -  :        6684 :             }},
             +  +  -  - ]
     804                 :        2228 :         RPCExamples{
     805   [ +  -  +  -  :        4456 :             HelpExampleCli("savemempool", "")
                   +  - ]
     806   [ +  -  +  -  :        8912 :             + HelpExampleRpc("savemempool", "")
             +  -  +  - ]
     807         [ +  - ]:        2228 :         },
     808                 :        2228 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
     809                 :             : {
     810                 :           4 :     const ArgsManager& args{EnsureAnyArgsman(request.context)};
     811                 :           4 :     const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
     812                 :             : 
     813         [ -  + ]:           4 :     if (!mempool.GetLoadTried()) {
     814   [ #  #  #  # ]:           0 :         throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet");
     815                 :             :     }
     816                 :             : 
     817                 :           4 :     const fs::path& dump_path = MempoolPath(args);
     818                 :             : 
     819   [ +  -  +  + ]:           4 :     if (!DumpMempool(mempool, dump_path)) {
     820   [ +  -  +  - ]:           2 :         throw JSONRPCError(RPC_MISC_ERROR, "Unable to dump mempool to disk");
     821                 :             :     }
     822                 :             : 
     823                 :           3 :     UniValue ret(UniValue::VOBJ);
     824   [ +  -  +  -  :           6 :     ret.pushKV("filename", dump_path.utf8string());
             +  -  +  - ]
     825                 :             : 
     826                 :           6 :     return ret;
     827                 :           0 : },
     828   [ +  -  +  - ]:        8912 :     };
     829         [ +  - ]:        2228 : }
     830                 :             : 
     831                 :        4868 : static std::vector<RPCResult> OrphanDescription()
     832                 :             : {
     833                 :        4868 :     return {
     834   [ +  -  +  - ]:        9736 :         RPCResult{RPCResult::Type::STR_HEX, "txid", "The transaction hash in hex"},
     835   [ +  -  +  - ]:        9736 :         RPCResult{RPCResult::Type::STR_HEX, "wtxid", "The transaction witness hash in hex"},
     836   [ +  -  +  - ]:        9736 :         RPCResult{RPCResult::Type::NUM, "bytes", "The serialized transaction size in bytes"},
     837   [ +  -  +  - ]:        9736 :         RPCResult{RPCResult::Type::NUM, "vsize", "The virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted."},
     838   [ +  -  +  - ]:        9736 :         RPCResult{RPCResult::Type::NUM, "weight", "The transaction weight as defined in BIP 141."},
     839   [ +  -  +  - ]:        9736 :         RPCResult{RPCResult::Type::ARR, "from", "",
     840                 :             :         {
     841   [ +  -  +  - ]:        9736 :             RPCResult{RPCResult::Type::NUM, "peer_id", "Peer ID"},
     842   [ +  -  +  +  :       14604 :         }},
                   -  - ]
     843   [ +  -  +  +  :       43812 :     };
                   -  - ]
     844   [ +  -  +  -  :       34076 : }
          +  -  +  -  +  
          -  +  -  +  -  
                   -  - ]
     845                 :             : 
     846                 :          43 : static UniValue OrphanToJSON(const node::TxOrphanage::OrphanTxBase& orphan)
     847                 :             : {
     848                 :          43 :     UniValue o(UniValue::VOBJ);
     849   [ +  -  +  -  :          86 :     o.pushKV("txid", orphan.tx->GetHash().ToString());
             +  -  +  - ]
     850   [ +  -  +  -  :          86 :     o.pushKV("wtxid", orphan.tx->GetWitnessHash().ToString());
             +  -  +  - ]
     851   [ +  -  +  -  :          86 :     o.pushKV("bytes", orphan.tx->GetTotalSize());
             +  -  +  - ]
     852   [ +  -  +  -  :          86 :     o.pushKV("vsize", GetVirtualTransactionSize(*orphan.tx));
             +  -  +  - ]
     853   [ +  -  +  -  :          86 :     o.pushKV("weight", GetTransactionWeight(*orphan.tx));
                   +  - ]
     854                 :          43 :     UniValue from(UniValue::VARR);
     855         [ +  + ]:          93 :     for (const auto fromPeer: orphan.announcers) {
     856   [ +  -  +  - ]:          50 :         from.push_back(fromPeer);
     857                 :             :     }
     858   [ +  -  +  -  :          86 :     o.pushKV("from", from);
                   +  - ]
     859                 :          43 :     return o;
     860                 :          43 : }
     861                 :             : 
     862                 :        2434 : static RPCHelpMan getorphantxs()
     863                 :             : {
     864                 :        2434 :     return RPCHelpMan{
     865                 :        2434 :         "getorphantxs",
     866         [ +  - ]:        4868 :         "Shows transactions in the tx orphanage.\n"
     867                 :             :         "\nEXPERIMENTAL warning: this call may be changed in future releases.\n",
     868                 :             :         {
     869   [ +  -  +  -  :        7302 :             {"verbosity", RPCArg::Type::NUM, RPCArg::Default{0}, "0 for an array of txids (may contain duplicates), 1 for an array of objects with tx details, and 2 for details from (1) and tx hex",
                   +  - ]
     870         [ +  - ]:        4868 :              RPCArgOptions{.skip_type_check = true}},
     871                 :             :         },
     872                 :             :         {
     873         [ +  - ]:        2434 :             RPCResult{"for verbose = 0",
     874   [ +  -  +  - ]:        4868 :                 RPCResult::Type::ARR, "", "",
     875                 :             :                 {
     876   [ +  -  +  - ]:        4868 :                     {RPCResult::Type::STR_HEX, "txid", "The transaction hash in hex"},
     877   [ +  -  +  +  :        7302 :                 }},
                   -  - ]
     878         [ +  - ]:        4868 :             RPCResult{"for verbose = 1",
     879   [ +  -  +  - ]:        4868 :                 RPCResult::Type::ARR, "", "",
     880                 :             :                 {
     881   [ +  -  +  -  :        4868 :                     {RPCResult::Type::OBJ, "", "", OrphanDescription()},
                   +  - ]
     882   [ +  -  +  +  :        7302 :                 }},
                   -  - ]
     883         [ +  - ]:        4868 :             RPCResult{"for verbose = 2",
     884   [ +  -  +  - ]:        4868 :                 RPCResult::Type::ARR, "", "",
     885                 :             :                 {
     886   [ +  -  +  - ]:        4868 :                     {RPCResult::Type::OBJ, "", "",
     887   [ +  -  +  -  :       12170 :                         Cat<std::vector<RPCResult>>(
             +  +  -  - ]
     888         [ +  - ]:        4868 :                             OrphanDescription(),
     889   [ +  -  +  - ]:        4868 :                             {{RPCResult::Type::STR_HEX, "hex", "The serialized, hex-encoded transaction data"}}
     890                 :             :                         )
     891                 :             :                     },
     892   [ +  -  +  +  :        7302 :                 }},
                   -  - ]
     893                 :             :         },
     894                 :        2434 :         RPCExamples{
     895   [ +  -  +  -  :        7302 :             HelpExampleCli("getorphantxs", "2")
                   +  - ]
     896   [ +  -  +  -  :        9736 :             + HelpExampleRpc("getorphantxs", "2")
                   +  - ]
     897         [ +  - ]:        2434 :         },
     898                 :        2434 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
     899                 :             :         {
     900                 :         218 :             const NodeContext& node = EnsureAnyNodeContext(request.context);
     901                 :         218 :             PeerManager& peerman = EnsurePeerman(node);
     902                 :         218 :             std::vector<node::TxOrphanage::OrphanTxBase> orphanage = peerman.GetOrphanTransactions();
     903                 :             : 
     904   [ +  -  +  + ]:         218 :             int verbosity{ParseVerbosity(request.params[0], /*default_verbosity=*/0, /*allow_bool*/false)};
     905                 :             : 
     906                 :         216 :             UniValue ret(UniValue::VARR);
     907                 :             : 
     908         [ +  + ]:         216 :             if (verbosity == 0) {
     909         [ +  + ]:       18479 :                 for (auto const& orphan : orphanage) {
     910   [ +  -  +  -  :       18298 :                     ret.push_back(orphan.tx->GetHash().ToString());
                   +  - ]
     911                 :             :                 }
     912         [ +  + ]:          35 :             } else if (verbosity == 1) {
     913         [ +  + ]:          55 :                 for (auto const& orphan : orphanage) {
     914   [ +  -  +  - ]:          32 :                     ret.push_back(OrphanToJSON(orphan));
     915                 :             :                 }
     916         [ +  + ]:          12 :             } else if (verbosity == 2) {
     917         [ +  + ]:          21 :                 for (auto const& orphan : orphanage) {
     918         [ +  - ]:          11 :                     UniValue o{OrphanToJSON(orphan)};
     919   [ +  -  +  -  :          22 :                     o.pushKV("hex", EncodeHexTx(*orphan.tx));
             +  -  +  - ]
     920   [ +  -  +  - ]:          11 :                     ret.push_back(o);
     921                 :          11 :                 }
     922                 :             :             } else {
     923   [ +  -  +  -  :           4 :                 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid verbosity value " + ToString(verbosity));
                   +  - ]
     924                 :             :             }
     925                 :             : 
     926                 :         214 :             return ret;
     927                 :         220 :         },
     928   [ +  -  +  -  :       26774 :     };
          +  -  +  -  +  
          +  +  +  -  -  
                   -  - ]
     929   [ +  -  +  -  :       19472 : }
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  -  - ]
     930                 :             : 
     931                 :        2315 : static RPCHelpMan submitpackage()
     932                 :             : {
     933                 :        2315 :     return RPCHelpMan{"submitpackage",
     934         [ +  - ]:        4630 :         "Submit a package of raw transactions (serialized, hex-encoded) to local node.\n"
     935                 :             :         "The package will be validated according to consensus and mempool policy rules. If any transaction passes, it will be accepted to mempool.\n"
     936                 :             :         "This RPC is experimental and the interface may be unstable. Refer to doc/policy/packages.md for documentation on package policies.\n"
     937                 :             :         "Warning: successful submission does not mean the transactions will propagate throughout the network.\n"
     938                 :             :         ,
     939                 :             :         {
     940   [ +  -  +  - ]:        4630 :             {"package", RPCArg::Type::ARR, RPCArg::Optional::NO, "An array of raw transactions.\n"
     941                 :             :                 "The package must solely consist of a child transaction and all of its unconfirmed parents, if any. None of the parents may depend on each other.\n"
     942                 :             :                 "The package must be topologically sorted, with the child being the last element in the array.",
     943                 :             :                 {
     944   [ +  -  +  - ]:        4630 :                     {"rawtx", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, ""},
     945                 :             :                 },
     946                 :             :             },
     947   [ +  -  +  -  :        4630 :             {"maxfeerate", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK())},
                   +  - ]
     948         [ +  - ]:        4630 :              "Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT +
     949                 :        2315 :                  "/kvB.\nFee rates larger than 1BTC/kvB are rejected.\nSet to 0 to accept any fee rate."},
     950   [ +  -  +  -  :        4630 :             {"maxburnamount", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_BURN_AMOUNT)},
                   +  - ]
     951         [ +  - ]:        4630 :              "Reject transactions with provably unspendable outputs (e.g. 'datacarrier' outputs that use the OP_RETURN opcode) greater than the specified value, expressed in " + CURRENCY_UNIT + ".\n"
     952                 :             :              "If burning funds through unspendable outputs is desired, increase this value.\n"
     953                 :        2315 :              "This check is based on heuristics and does not guarantee spendability of outputs.\n"
     954                 :             :             },
     955                 :             :         },
     956         [ +  - ]:        4630 :         RPCResult{
     957   [ +  -  +  - ]:        4630 :             RPCResult::Type::OBJ, "", "",
     958                 :             :             {
     959   [ +  -  +  - ]:        4630 :                 {RPCResult::Type::STR, "package_msg", "The transaction package result message. \"success\" indicates all transactions were accepted into or are already in the mempool."},
     960   [ +  -  +  - ]:        4630 :                 {RPCResult::Type::OBJ_DYN, "tx-results", "transaction results keyed by wtxid",
     961                 :             :                 {
     962   [ +  -  +  - ]:        4630 :                     {RPCResult::Type::OBJ, "wtxid", "transaction wtxid", {
     963   [ +  -  +  - ]:        4630 :                         {RPCResult::Type::STR_HEX, "txid", "The transaction hash in hex"},
     964   [ +  -  +  - ]:        4630 :                         {RPCResult::Type::STR_HEX, "other-wtxid", /*optional=*/true, "The wtxid of a different transaction with the same txid but different witness found in the mempool. This means the submitted transaction was ignored."},
     965   [ +  -  +  - ]:        4630 :                         {RPCResult::Type::NUM, "vsize", /*optional=*/true, "Sigops-adjusted virtual transaction size."},
     966   [ +  -  +  - ]:        4630 :                         {RPCResult::Type::OBJ, "fees", /*optional=*/true, "Transaction fees", {
     967   [ +  -  +  - ]:        4630 :                             {RPCResult::Type::STR_AMOUNT, "base", "transaction fee in " + CURRENCY_UNIT},
     968   [ +  -  +  - ]:        4630 :                             {RPCResult::Type::STR_AMOUNT, "effective-feerate", /*optional=*/true, "if the transaction was not already in the mempool, the effective feerate in " + CURRENCY_UNIT + " per KvB. For example, the package feerate and/or feerate with modified fees from prioritisetransaction."},
     969   [ +  -  +  - ]:        4630 :                             {RPCResult::Type::ARR, "effective-includes", /*optional=*/true, "if effective-feerate is provided, the wtxids of the transactions whose fees and vsizes are included in effective-feerate.",
     970   [ +  -  +  - ]:        4630 :                                 {{RPCResult::Type::STR_HEX, "", "transaction wtxid in hex"},
     971                 :             :                             }},
     972                 :             :                         }},
     973   [ +  -  +  - ]:        4630 :                         {RPCResult::Type::STR, "error", /*optional=*/true, "The transaction error string, if it was rejected by the mempool"},
     974                 :             :                     }}
     975                 :             :                 }},
     976   [ +  -  +  - ]:        4630 :                 {RPCResult::Type::ARR, "replaced-transactions", /*optional=*/true, "List of txids of replaced transactions",
     977                 :             :                 {
     978   [ +  -  +  - ]:        4630 :                     {RPCResult::Type::STR_HEX, "", "The transaction id"},
     979                 :             :                 }},
     980                 :             :             },
     981   [ +  -  +  -  :       67135 :         },
          +  -  +  -  +  
          -  +  -  +  -  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  -  -  -  
          -  -  -  -  -  
             -  -  -  - ]
     982                 :        2315 :         RPCExamples{
     983   [ +  -  +  -  :        4630 :             HelpExampleRpc("submitpackage", R"(["raw-parent-tx-1", "raw-parent-tx-2", "raw-child-tx"])") +
                   +  - ]
     984   [ +  -  +  -  :        6945 :             HelpExampleCli("submitpackage", R"('["raw-tx-without-unconfirmed-parents"]')")
             +  -  +  - ]
     985         [ +  - ]:        2315 :         },
     986                 :        2315 :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
     987                 :             :         {
     988                 :          91 :             const UniValue raw_transactions = request.params[0].get_array();
     989   [ -  +  +  +  :          91 :             if (raw_transactions.empty() || raw_transactions.size() > MAX_PACKAGE_COUNT) {
                   +  + ]
     990                 :           2 :                 throw JSONRPCError(RPC_INVALID_PARAMETER,
     991   [ +  -  +  -  :           6 :                                    "Array must contain between 1 and " + ToString(MAX_PACKAGE_COUNT) + " transactions.");
                   +  - ]
     992                 :             :             }
     993                 :             : 
     994                 :             :             // Fee check needs to be run with chainstate and package context
     995   [ +  -  +  - ]:          89 :             const CFeeRate max_raw_tx_fee_rate{ParseFeeRate(self.Arg<UniValue>("maxfeerate"))};
     996         [ +  + ]:          89 :             std::optional<CFeeRate> client_maxfeerate{max_raw_tx_fee_rate};
     997                 :             :             // 0-value is special; it's mapped to no sanity check
     998         [ +  + ]:          89 :             if (max_raw_tx_fee_rate == CFeeRate(0)) {
     999                 :           5 :                 client_maxfeerate = std::nullopt;
    1000                 :             :             }
    1001                 :             : 
    1002                 :             :             // Burn sanity check is run with no context
    1003   [ +  -  +  +  :          89 :             const CAmount max_burn_amount = request.params[2].isNull() ? 0 : AmountFromValue(request.params[2]);
             +  -  +  - ]
    1004                 :             : 
    1005                 :          89 :             std::vector<CTransactionRef> txns;
    1006   [ -  +  +  - ]:          89 :             txns.reserve(raw_transactions.size());
    1007   [ +  -  +  + ]:         414 :             for (const auto& rawtx : raw_transactions.getValues()) {
    1008         [ +  - ]:         327 :                 CMutableTransaction mtx;
    1009   [ +  -  +  -  :         327 :                 if (!DecodeHexTx(mtx, rawtx.get_str())) {
                   +  + ]
    1010                 :           1 :                     throw JSONRPCError(RPC_DESERIALIZATION_ERROR,
    1011   [ +  -  +  -  :           3 :                                        "TX decode failed: " + rawtx.get_str() + " Make sure the tx has at least one input.");
                   +  - ]
    1012                 :             :                 }
    1013                 :             : 
    1014         [ +  + ]:         786 :                 for (const auto& out : mtx.vout) {
    1015   [ +  +  +  -  :         461 :                     if((out.scriptPubKey.IsUnspendable() || !out.scriptPubKey.HasValidOps()) && out.nValue > max_burn_amount) {
             -  +  +  + ]
    1016   [ +  -  +  - ]:           2 :                         throw JSONRPCTransactionError(TransactionError::MAX_BURN_EXCEEDED);
    1017                 :             :                     }
    1018                 :             :                 }
    1019                 :             : 
    1020   [ +  -  +  - ]:         975 :                 txns.emplace_back(MakeTransactionRef(std::move(mtx)));
    1021                 :         327 :             }
    1022         [ +  - ]:          87 :             CHECK_NONFATAL(!txns.empty());
    1023   [ -  +  +  +  :          87 :             if (txns.size() > 1 && !IsChildWithParentsTree(txns)) {
             +  -  +  + ]
    1024   [ +  -  +  - ]:           4 :                 throw JSONRPCTransactionError(TransactionError::INVALID_PACKAGE, "package topology disallowed. not child-with-parents or parents depend on each other.");
    1025                 :             :             }
    1026                 :             : 
    1027         [ +  - ]:          85 :             NodeContext& node = EnsureAnyNodeContext(request.context);
    1028         [ +  - ]:          85 :             CTxMemPool& mempool = EnsureMemPool(node);
    1029   [ +  -  +  - ]:          85 :             Chainstate& chainstate = EnsureChainman(node).ActiveChainstate();
    1030   [ +  -  +  - ]:         255 :             const auto package_result = WITH_LOCK(::cs_main, return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/ false, client_maxfeerate));
    1031                 :             : 
    1032         [ +  - ]:          85 :             std::string package_msg = "success";
    1033                 :             : 
    1034                 :             :             // First catch package-wide errors, continue if we can
    1035   [ +  -  +  - ]:          85 :             switch(package_result.m_state.GetResult()) {
    1036                 :          40 :                 case PackageValidationResult::PCKG_RESULT_UNSET:
    1037                 :          40 :                 {
    1038                 :             :                     // Belt-and-suspenders check; everything should be successful here
    1039   [ -  +  +  - ]:          40 :                     CHECK_NONFATAL(package_result.m_tx_results.size() == txns.size());
    1040         [ +  + ]:         215 :                     for (const auto& tx : txns) {
    1041   [ +  -  +  - ]:         175 :                         CHECK_NONFATAL(mempool.exists(tx->GetHash()));
    1042                 :             :                     }
    1043                 :             :                     break;
    1044                 :             :                 }
    1045                 :           0 :                 case PackageValidationResult::PCKG_MEMPOOL_ERROR:
    1046                 :           0 :                 {
    1047                 :             :                     // This only happens with internal bug; user should stop and report
    1048                 :           0 :                     throw JSONRPCTransactionError(TransactionError::MEMPOOL_ERROR,
    1049   [ #  #  #  # ]:           0 :                         package_result.m_state.GetRejectReason());
    1050                 :             :                 }
    1051                 :          45 :                 case PackageValidationResult::PCKG_POLICY:
    1052                 :          45 :                 case PackageValidationResult::PCKG_TX:
    1053                 :          45 :                 {
    1054                 :             :                     // Package-wide error we want to return, but we also want to return individual responses
    1055         [ +  - ]:          45 :                     package_msg = package_result.m_state.ToString();
    1056   [ -  +  +  +  :          47 :                     CHECK_NONFATAL(package_result.m_tx_results.size() == txns.size() ||
             +  -  +  - ]
    1057                 :             :                             package_result.m_tx_results.empty());
    1058                 :             :                     break;
    1059                 :             :                 }
    1060                 :             :             }
    1061                 :             : 
    1062                 :          85 :             size_t num_broadcast{0};
    1063         [ +  + ]:         402 :             for (const auto& tx : txns) {
    1064                 :             :                 // We don't want to re-submit the txn for validation in BroadcastTransaction
    1065   [ +  -  +  + ]:         317 :                 if (!mempool.exists(tx->GetHash())) {
    1066                 :          84 :                     continue;
    1067                 :             :                 }
    1068                 :             : 
    1069                 :             :                 // We do not expect an error here; we are only broadcasting things already/still in mempool
    1070         [ +  - ]:         233 :                 std::string err_string;
    1071   [ +  -  +  -  :         466 :                 const auto err = BroadcastTransaction(node, tx, err_string, /*max_tx_fee=*/0, /*relay=*/true, /*wait_callback=*/true);
                   +  - ]
    1072         [ -  + ]:         233 :                 if (err != TransactionError::OK) {
    1073                 :           0 :                     throw JSONRPCTransactionError(err,
    1074         [ #  # ]:           0 :                         strprintf("transaction broadcast failed: %s (%d transactions were broadcast successfully)",
    1075         [ #  # ]:           0 :                             err_string, num_broadcast));
    1076                 :             :                 }
    1077                 :         233 :                 num_broadcast++;
    1078                 :         233 :             }
    1079                 :             : 
    1080                 :          85 :             UniValue rpc_result{UniValue::VOBJ};
    1081   [ +  -  +  -  :         170 :             rpc_result.pushKV("package_msg", package_msg);
                   +  - ]
    1082                 :         170 :             UniValue tx_result_map{UniValue::VOBJ};
    1083                 :         170 :             std::set<uint256> replaced_txids;
    1084         [ +  + ]:         402 :             for (const auto& tx : txns) {
    1085                 :         317 :                 UniValue result_inner{UniValue::VOBJ};
    1086   [ +  -  +  -  :         634 :                 result_inner.pushKV("txid", tx->GetHash().GetHex());
             +  -  +  - ]
    1087                 :         317 :                 auto it = package_result.m_tx_results.find(tx->GetWitnessHash());
    1088         [ +  + ]:         317 :                 if (it == package_result.m_tx_results.end()) {
    1089                 :             :                     // No results, report error and continue
    1090   [ +  -  +  -  :          12 :                     result_inner.pushKV("error", "unevaluated");
                   +  - ]
    1091                 :           6 :                     continue;
    1092                 :             :                 }
    1093   [ -  +  +  - ]:         311 :                 const auto& tx_result = it->second;
    1094   [ -  +  +  - ]:         311 :                 switch(it->second.m_result_type) {
    1095                 :           0 :                 case MempoolAcceptResult::ResultType::DIFFERENT_WITNESS:
    1096   [ #  #  #  #  :           0 :                     result_inner.pushKV("other-wtxid", it->second.m_other_wtxid.value().GetHex());
          #  #  #  #  #  
                      # ]
    1097                 :           0 :                     break;
    1098                 :          79 :                 case MempoolAcceptResult::ResultType::INVALID:
    1099   [ +  -  +  -  :         158 :                     result_inner.pushKV("error", it->second.m_state.ToString());
             +  -  +  - ]
    1100                 :          79 :                     break;
    1101                 :         232 :                 case MempoolAcceptResult::ResultType::VALID:
    1102                 :         232 :                 case MempoolAcceptResult::ResultType::MEMPOOL_ENTRY:
    1103   [ +  -  +  -  :         464 :                     result_inner.pushKV("vsize", int64_t{it->second.m_vsize.value()});
             +  -  +  - ]
    1104                 :         232 :                     UniValue fees(UniValue::VOBJ);
    1105   [ +  -  +  -  :         464 :                     fees.pushKV("base", ValueFromAmount(it->second.m_base_fees.value()));
             +  -  +  - ]
    1106         [ +  + ]:         232 :                     if (tx_result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
    1107                 :             :                         // Effective feerate is not provided for MEMPOOL_ENTRY transactions even
    1108                 :             :                         // though modified fees is known, because it is unknown whether package
    1109                 :             :                         // feerate was used when it was originally submitted.
    1110   [ +  -  +  -  :         298 :                         fees.pushKV("effective-feerate", ValueFromAmount(tx_result.m_effective_feerate.value().GetFeePerK()));
             +  -  +  - ]
    1111                 :         149 :                         UniValue effective_includes_res(UniValue::VARR);
    1112   [ +  -  +  + ]:         328 :                         for (const auto& wtxid : tx_result.m_wtxids_fee_calculations.value()) {
    1113   [ +  -  +  -  :         179 :                             effective_includes_res.push_back(wtxid.ToString());
                   +  - ]
    1114                 :             :                         }
    1115   [ +  -  +  - ]:         298 :                         fees.pushKV("effective-includes", std::move(effective_includes_res));
    1116                 :         149 :                     }
    1117   [ +  -  +  - ]:         464 :                     result_inner.pushKV("fees", std::move(fees));
    1118         [ +  + ]:         347 :                     for (const auto& ptx : it->second.m_replaced_transactions) {
    1119         [ +  - ]:         115 :                         replaced_txids.insert(ptx->GetHash());
    1120                 :             :                     }
    1121                 :         232 :                     break;
    1122                 :             :                 }
    1123   [ +  -  +  - ]:         622 :                 tx_result_map.pushKV(tx->GetWitnessHash().GetHex(), std::move(result_inner));
    1124                 :         317 :             }
    1125   [ +  -  +  - ]:         170 :             rpc_result.pushKV("tx-results", std::move(tx_result_map));
    1126                 :         170 :             UniValue replaced_list(UniValue::VARR);
    1127   [ +  -  +  -  :         200 :             for (const uint256& hash : replaced_txids) replaced_list.push_back(hash.ToString());
             +  -  +  + ]
    1128   [ +  -  +  - ]:         170 :             rpc_result.pushKV("replaced-transactions", std::move(replaced_list));
    1129                 :         170 :             return rpc_result;
    1130                 :          95 :         },
    1131   [ +  -  +  -  :       23150 :     };
          +  -  +  +  +  
             +  -  -  -  
                      - ]
    1132   [ +  -  +  -  :       50930 : }
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  -  -  -  
             -  -  -  -  
                      - ]
    1133                 :             : 
    1134                 :        1236 : void RegisterMempoolRPCCommands(CRPCTable& t)
    1135                 :             : {
    1136                 :        1236 :     static const CRPCCommand commands[]{
    1137         [ +  - ]:        2214 :         {"rawtransactions", &sendrawtransaction},
    1138         [ +  - ]:        2214 :         {"rawtransactions", &testmempoolaccept},
    1139         [ +  - ]:        2214 :         {"blockchain", &getmempoolancestors},
    1140         [ +  - ]:        2214 :         {"blockchain", &getmempooldescendants},
    1141         [ +  - ]:        2214 :         {"blockchain", &getmempoolentry},
    1142         [ +  - ]:        2214 :         {"blockchain", &gettxspendingprevout},
    1143         [ +  - ]:        2214 :         {"blockchain", &getmempoolinfo},
    1144         [ +  - ]:        2214 :         {"blockchain", &getrawmempool},
    1145         [ +  - ]:        2214 :         {"blockchain", &importmempool},
    1146         [ +  - ]:        2214 :         {"blockchain", &savemempool},
    1147         [ +  - ]:        2214 :         {"hidden", &getorphantxs},
    1148         [ +  - ]:        2214 :         {"rawtransactions", &submitpackage},
    1149   [ +  +  +  -  :       14520 :     };
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  -  
                      - ]
    1150         [ +  + ]:       16068 :     for (const auto& c : commands) {
    1151                 :       14832 :         t.appendCommand(c.name, &c);
    1152                 :             :     }
    1153                 :        1236 : }
        

Generated by: LCOV version 2.0-1