HomePhabricator

RPC: Add child transactions to getrawmempool verbose output

Description

RPC: Add child transactions to getrawmempool verbose output

Summary:

bitcoin-cli getrawmempool true only lists a transaction's parents in the
depends field. This change adds a spentby field to the json response,
which lists the transaction's children in the mempool.

Currently the only way to find child transactions is to use
getrawmempool or make another call to getmempooldescendants and search
the response for transactions that list the parent_txid in the depends
list, which is inefficient.

This change allows direct lookup of children.

Example Output

  "9a9b5733c0d89f207908cfa3fe17809bee71f629aa095c9f8754524e29e98ba4": {
    ...other geterawmempool data...
    "wtxid":
"9a9b5733c0d89f207908cfa3fe17809bee71f629aa095c9f8754524e29e98ba4",
    "depends": [
      "bdd92851d5766a42aeb62af667bb422a116cab4e032bba5e3dd6efe5b4b40aa0"
    ],
    "spentby": [
      "dc5d3ec388a9121421208738a041ac30a22163bc2e17758f2275b6c51a15ba7b"
    ]
  },

Backport of core PR12479
https://github.com/bitcoin/bitcoin/pull/12479/files

Test Plan:

./test/functional/test_runner.py interface_rest mempool_packages

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D3520

Details

Provenance
Conor Scott <conor.r.scott.88@gmail.com>Authored on Feb 18 2018, 15:51
FabienCommitted on Jul 3 2019, 15:06
FabienPushed on Jul 3 2019, 15:06
Reviewer
Restricted Project
Differential Revision
D3520: RPC: Add child transactions to getrawmempool verbose output
Parents
rABCfacbb283229e: [LINTER] Fix the python format string when dealing with arrays
Branches
Unknown
Tags
Unknown