Merge bitcoin/bitcoin#12677: RPC: Add ancestor{count,size,fees} to listunspent output

6cb60f3e6d doc/release-notes: Add new listunspent fields (Luke Dashjr)
0be2f17ef5 QA: Add tests for listunspent ancestor{count,size,fees} to mempool_packages (Luke Dashjr)
6966e80f45 RPC: Add ancestor{count,size,fees} to listunspent output (Luke Dashjr)
3f77dfdaf0 Expose ancestorsize and ancestorfees via getTransactionAncestry (Luke Dashjr)

Pull request description:

  Requested by a user

ACKs for top commit:
  prayank23:
    reACK 6cb60f3e6d
  fjahr:
    Code review re-ACK 6cb60f3e6d
  kiminuo:
    ACK [6cb60f3](6cb60f3e6d)
  achow101:
    Code Review ACK 6cb60f3e6d
  naumenkogs:
    ACK 6cb60f3e6d
  darosior:
    utACK 6cb60f3e6d

Tree-SHA512: 5d16e5799558691e5853ab7ea2cc85514cb45da3ce69134d855c71845beef32ec6af5ab28d4462683e9800c8ea126f162773a9d3d5660edac08fd8edbfeda173
This commit is contained in:
W. J. van der Laan
2021-09-20 19:19:10 +02:00
7 changed files with 47 additions and 8 deletions

View File

@@ -1174,12 +1174,14 @@ uint64_t CTxMemPool::CalculateDescendantMaximum(txiter entry) const {
return maximum;
}
void CTxMemPool::GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) const {
void CTxMemPool::GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* const ancestorsize, CAmount* const ancestorfees) const {
LOCK(cs);
auto it = mapTx.find(txid);
ancestors = descendants = 0;
if (it != mapTx.end()) {
ancestors = it->GetCountWithAncestors();
if (ancestorsize) *ancestorsize = it->GetSizeWithAncestors();
if (ancestorfees) *ancestorfees = it->GetModFeesWithAncestors();
descendants = CalculateDescendantMaximum(it);
}
}