LCOV - code coverage report
Current view: top level - src/rpc - mempool.cpp (source / functions) Coverage Total Hit
Test: total_coverage.info Lines: 97.4 % 783 763
Test Date: 2025-10-25 05:06:34 Functions: 100.0 % 32 32
Branches: 51.5 % 2690 1386

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

Generated by: LCOV version 2.0-1