Add RPC to get mempool txs spending outputs

We add an RPC to fetch the mempool transactions spending given outpoints.
Without this RPC, application developers would need to first call
`getrawmempool` which returns a long list of `txid`, then fetch each of
these txs individually to check whether they spend the given outpoint(s).

This RPC can later be enriched to also find confirmed transactions instead
of being restricted to mempool transactions.
This commit is contained in:
t-bast
2022-04-25 10:29:25 +02:00
parent 1ad5d5088d
commit 4185570340
7 changed files with 200 additions and 0 deletions

View File

@@ -100,6 +100,12 @@ class MempoolPackagesTest(BitcoinTestFramework):
entry = self.nodes[0].getmempoolentry(x)
assert_equal(entry, mempool[x])
# Check that gettxspendingprevout is consistent with getrawmempool
witnesstx = self.nodes[0].gettransaction(txid=x, verbose=True)['decoded']
for tx_in in witnesstx["vin"]:
spending_result = self.nodes[0].gettxspendingprevout([ {'txid' : tx_in["txid"], 'vout' : tx_in["vout"]} ])
assert_equal(spending_result, [ {'txid' : tx_in["txid"], 'vout' : tx_in["vout"], 'spendingtxid' : x} ])
# Check that the descendant calculations are correct
assert_equal(entry['descendantcount'], descendant_count)
descendant_fees += entry['fees']['base']