Output formatting for: bitcoin-cli help getrawmempool #19579

issue stylesuxx opened this issue on July 24, 2020
  1. stylesuxx commented at 12:00 PM on July 24, 2020: contributor

    When invoking the help command bitcoin-cli help getrawmempool for getrawmempool the output is as follows:

    getrawmempool ( verbose )
    
    Returns all transaction ids in memory pool as a json array of string transaction ids.
    
    Hint: use getmempoolentry to fetch a specific transaction from the mempool.
    
    Arguments:
    1. verbose    (boolean, optional, default=false) True for a json object, false for array of transaction ids
    
    Result (for verbose = false):
    [           (json array)
      "hex",    (string) The transaction id
      ...
    ]
    
    Result (for verbose = true):
    {                                         (json object)
      "transactionid" : {                     (json object)
        "vsize" : n,                          (numeric) virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.
        "weight" : n,                         (numeric) transaction weight as defined in BIP 141.
        "fee" : n,                            (numeric) transaction fee in BTC (DEPRECATED)
        "modifiedfee" : n,                    (numeric) transaction fee with fee deltas used for mining priority (DEPRECATED)
        "time" : xxx,                         (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT
        "height" : n,                         (numeric) block height when transaction entered pool
        "descendantcount" : n,                (numeric) number of in-mempool descendant transactions (including this one)
        "descendantsize" : n,                 (numeric) virtual transaction size of in-mempool descendants (including this one)
        "descendantfees" : n,                 (numeric) modified fees (see above) of in-mempool descendants (including this one) (DEPRECATED)
        "ancestorcount" : n,                  (numeric) number of in-mempool ancestor transactions (including this one)
        "ancestorsize" : n,                   (numeric) virtual transaction size of in-mempool ancestors (including this one)
        "ancestorfees" : n,                   (numeric) modified fees (see above) of in-mempool ancestors (including this one) (DEPRECATED)
        "wtxid" : "hex",                      (string) hash of serialized transaction, including witness data
        "fees" : {                            (json object)
          "base" : n,                         (numeric) transaction fee in BTC
          "modified" : n,                     (numeric) transaction fee with fee deltas used for mining priority in BTC
          "ancestor" : n,                     (numeric) modified fees (see above) of in-mempool ancestors (including this one) in BTC
          "descendant" : n                    (numeric) modified fees (see above) of in-mempool descendants (including this one) in BTC
        },
        "depends" : [                         (json array) unconfirmed transactions used as inputs for this transaction
          "hex",                              (string) parent transaction id
          ...
        ],
        "spentby" : [                         (json array) unconfirmed transactions spending outputs from this transaction
          "hex",                              (string) child transaction id
          ...
        ],
        "bip125-replaceable" : true|false,    (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)
        "unbroadcast" : true|false,           (boolean) Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)
        ...
      }
    }
    
    Examples:
    > bitcoin-cli getrawmempool true
    > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getrawmempool", "params": [true]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
    

    The "transactionid" block for the verbose output has ... as the last entry, I think the elipsis should be in the next line (after the end of the object), indicating that there might be more objects of the same form instead of indicating that the transactionid object might have more, not documented values.

    Thus the output should be like this:

    getrawmempool ( verbose )
    
    Returns all transaction ids in memory pool as a json array of string transaction ids.
    
    Hint: use getmempoolentry to fetch a specific transaction from the mempool.
    
    Arguments:
    1. verbose    (boolean, optional, default=false) True for a json object, false for array of transaction ids
    
    Result (for verbose = false):
    [           (json array)
      "hex",    (string) The transaction id
      ...
    ]
    
    Result (for verbose = true):
    {                                         (json object)
      "transactionid" : {                     (json object)
        "vsize" : n,                          (numeric) virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.
        "weight" : n,                         (numeric) transaction weight as defined in BIP 141.
        "fee" : n,                            (numeric) transaction fee in BTC (DEPRECATED)
        "modifiedfee" : n,                    (numeric) transaction fee with fee deltas used for mining priority (DEPRECATED)
        "time" : xxx,                         (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT
        "height" : n,                         (numeric) block height when transaction entered pool
        "descendantcount" : n,                (numeric) number of in-mempool descendant transactions (including this one)
        "descendantsize" : n,                 (numeric) virtual transaction size of in-mempool descendants (including this one)
        "descendantfees" : n,                 (numeric) modified fees (see above) of in-mempool descendants (including this one) (DEPRECATED)
        "ancestorcount" : n,                  (numeric) number of in-mempool ancestor transactions (including this one)
        "ancestorsize" : n,                   (numeric) virtual transaction size of in-mempool ancestors (including this one)
        "ancestorfees" : n,                   (numeric) modified fees (see above) of in-mempool ancestors (including this one) (DEPRECATED)
        "wtxid" : "hex",                      (string) hash of serialized transaction, including witness data
        "fees" : {                            (json object)
          "base" : n,                         (numeric) transaction fee in BTC
          "modified" : n,                     (numeric) transaction fee with fee deltas used for mining priority in BTC
          "ancestor" : n,                     (numeric) modified fees (see above) of in-mempool ancestors (including this one) in BTC
          "descendant" : n                    (numeric) modified fees (see above) of in-mempool descendants (including this one) in BTC
        },
        "depends" : [                         (json array) unconfirmed transactions used as inputs for this transaction
          "hex",                              (string) parent transaction id
          ...
        ],
        "spentby" : [                         (json array) unconfirmed transactions spending outputs from this transaction
          "hex",                              (string) child transaction id
          ...
        ],
        "bip125-replaceable" : true|false,    (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)
        "unbroadcast" : true|false            (boolean) Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)
      },
      ...
    }
    
    Examples:
    > bitcoin-cli getrawmempool true
    > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getrawmempool", "params": [true]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
    

    Happy to submit a PR.

  2. MarcoFalke commented at 12:56 PM on July 24, 2020: member

    Haven't tested, but a potential fix would be:

    diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
    index 2afc9a3d4a..f27373b57c 100644
    --- a/src/rpc/blockchain.cpp
    +++ b/src/rpc/blockchain.cpp
    @@ -525,9 +525,9 @@ static UniValue getrawmempool(const JSONRPCRequest& request)
                                 {RPCResult::Type::STR_HEX, "", "The transaction id"},
                             }},
                         RPCResult{"for verbose = true",
    -                        RPCResult::Type::OBJ, "", "",
    +                        RPCResult::Type::OBJ_DYN, "", "",
                             {
    -                            {RPCResult::Type::OBJ_DYN, "transactionid", "", MempoolEntryDescription()},
    +                            {RPCResult::Type::OBJ, "transactionid", "", MempoolEntryDescription()},
                             }},
                     },
                     RPCExamples{
    @@ -556,7 +556,7 @@ static UniValue getmempoolancestors(const JSONRPCRequest& request)
                             RPCResult::Type::ARR, "", "",
                             {{RPCResult::Type::STR_HEX, "", "The transaction id of an in-mempool ancestor transaction"}}},
                         RPCResult{"for verbose = true",
    -                        RPCResult::Type::OBJ_DYN, "transactionid", "", MempoolEntryDescription()},
    +                        RPCResult::Type::OBJ, "transactionid", "", MempoolEntryDescription()},
                     },
                     RPCExamples{
                         HelpExampleCli("getmempoolancestors", "\"mytxid\"")
    @@ -616,9 +616,9 @@ static UniValue getmempooldescendants(const JSONRPCRequest& request)
                             RPCResult::Type::ARR, "", "",
                             {{RPCResult::Type::STR_HEX, "", "The transaction id of an in-mempool descendant transaction"}}},
                         RPCResult{"for verbose = true",
    -                        RPCResult::Type::OBJ, "", "",
    +                        RPCResult::Type::OBJ_DYN, "", "",
                             {
    -                            {RPCResult::Type::OBJ_DYN, "transactionid", "", MempoolEntryDescription()},
    +                            {RPCResult::Type::OBJ, "transactionid", "", MempoolEntryDescription()},
                             }},
                     },
                     RPCExamples{
    @@ -674,7 +674,7 @@ static UniValue getmempoolentry(const JSONRPCRequest& request)
                         {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id (must be in mempool)"},
                     },
                     RPCResult{
    -                    RPCResult::Type::OBJ_DYN, "", "", MempoolEntryDescription()},
    +                    RPCResult::Type::OBJ, "", "", MempoolEntryDescription()},
                     RPCExamples{
                         HelpExampleCli("getmempoolentry", "\"mytxid\"")
                 + HelpExampleRpc("getmempoolentry", "\"mytxid\"")
    
  3. MarcoFalke closed this on Jul 31, 2020

  4. MarcoFalke referenced this in commit a63a26f042 on Jul 31, 2020
  5. sidhujag referenced this in commit 9299f18d4b on Jul 31, 2020
  6. Warchant referenced this in commit 8ccc08784d on Aug 6, 2020
  7. MarcoFalke locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me