Skip to content

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

Merged
laanwj merged 4 commits into
bitcoin:masterfrom
luke-jr:listunspent_ancestorinfo
Sep 20, 2021
Merged

RPC: Add ancestor{count,size,fees} to listunspent output#12677
laanwj merged 4 commits into
bitcoin:masterfrom
luke-jr:listunspent_ancestorinfo

Conversation

@luke-jr

@luke-jr luke-jr commented Mar 12, 2018

Copy link
Copy Markdown
Member

Requested by a user

@promag promag left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could add tests for new fields. Also, help message could state when these are in the response.

Comment thread src/wallet/rpcwallet.cpp Outdated
Comment thread src/wallet/rpcwallet.cpp Outdated
@pacamoto

Copy link
Copy Markdown

Thank you Luke for taking it into consideration and adding it !

@meshcollider

Copy link
Copy Markdown
Contributor

Concept ACK, perhaps it'd be cleaner to sub-object them like you put in the title of the PR

@sipa

sipa commented Mar 17, 2018

Copy link
Copy Markdown
Member

Concept ACK

@luke-jr luke-jr force-pushed the listunspent_ancestorinfo branch from 3815e1b to daeb431 Compare March 31, 2018 07:29
@promag

promag commented May 3, 2018

Copy link
Copy Markdown
Contributor

@luke-jr is this still relevant? There are a couple of suggestions above and it's missing test(s) update.

@achow101

achow101 commented Jul 9, 2018

Copy link
Copy Markdown
Member

utACK daeb431

@maflcko

maflcko commented Jul 10, 2018

Copy link
Copy Markdown
Member

@promag Indeed, needs a trivial test where they are all different from 0

@DrahtBot

DrahtBot commented Oct 20, 2018

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #22798 (doc: Fix RPC result documentation by MarcoFalke)
  • #22689 (rpc: deprecate top-level fee fields in getmempool RPCs by josibake)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@luke-jr

luke-jr commented Feb 12, 2019

Copy link
Copy Markdown
Member Author

Rebased and added tests

@luke-jr

luke-jr commented Apr 6, 2019

Copy link
Copy Markdown
Member Author

Rebased again

@luke-jr luke-jr force-pushed the listunspent_ancestorinfo branch from 18922f8 to 305ab80 Compare April 6, 2019 16:29
@DrahtBot

Copy link
Copy Markdown
Contributor
There hasn't been much activity lately and the patch still needs rebase, so I am closing this for now. Please let me know when you want to continue working on this, so the pull request can be re-opened.

@sipa

sipa commented Oct 18, 2019

Copy link
Copy Markdown
Member

Concept ACK

Comment thread src/wallet/rpcwallet.cpp Outdated

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 7c0b6d6

$ bitcoin-cli -rpcwallet=W1 listunspent 0

[
  {
    "txid": "f3c7ab973f3f1857135ae9e9b10da8e85f6482a2a5d45d22d3aa20609e408ef7",
    "vout": 1,
    "address": "tb1qea2wjf035dm55zmvpwzaagfjvhhg44dycj4dvh",
    "label": "",
    "scriptPubKey": "0014cf54e925f1a3774a0b6c0b85dea13265ee8ad5a4",
    "amount": 0.00100000,
    "confirmations": 0,
    "ancestorcount": 2,
    "ancestorsize": 349,
    "ancestorfees": 350,
    "spendable": true,
    "solvable": true,
    "desc": "wpkh([6e03b4ba/0'/0'/4']02d24349d6b5a4eb456d623c998ca3af8f9f60277373e6e59bb7292188c681dc35)#kgxt3tcu",
    "safe": false
  }
]
    "ancestorcount": 2,
    "ancestorsize": 349,
    "ancestorfees": 350,

@luke-jr luke-jr force-pushed the listunspent_ancestorinfo branch from 7c0b6d6 to 6cb60f3 Compare September 16, 2021 20:36
@luke-jr

luke-jr commented Sep 16, 2021

Copy link
Copy Markdown
Member Author

Addressed various nits, needs re-ACKs

@laanwj

laanwj commented Sep 16, 2021

Copy link
Copy Markdown
Member

@achow101 achow101 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review ACK 6cb60f3

@naumenkogs naumenkogs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 6cb60f3

@ghost

ghost commented Sep 17, 2021

Copy link
Copy Markdown

reACK 6cb60f3

@fjahr

fjahr commented Sep 18, 2021

Copy link
Copy Markdown
Contributor

Code review re-ACK 6cb60f3

Comment thread src/wallet/rpcwallet.cpp
{RPCResult::Type::NUM, "confirmations", "The number of confirmations"},
{RPCResult::Type::NUM, "ancestorcount", /* optional */ true, "The number of in-mempool ancestor transactions, including this one (if transaction is in the mempool)"},
{RPCResult::Type::NUM, "ancestorsize", /* optional */ true, "The virtual transaction size of in-mempool ancestors, including this one (if transaction is in the mempool)"},
{RPCResult::Type::STR_AMOUNT, "ancestorfees", /* optional */ true, "The total fees of in-mempool ancestors (including this one) with fee deltas used for mining priority in " + CURRENCY_ATOM + " (if transaction is in the mempool)"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing this, I can see "ancestorfees": 164 in my output. Is it correct to mark the result type as RPCResult::Type::STR_AMOUNT here? I would probably expect RPCResult::Type::NUM given that the amount is in satoshis.

More complete output on my machine:

[
  {
    "txid": "<txid>",
    "vout": 1,
    "address": "<address>",
    "label": "",
    "scriptPubKey": "<spk>",
    "amount": 0.00100000,
    "confirmations": 0,
    "ancestorcount": 1,
    "ancestorsize": 164,
    "ancestorfees": 164,
    "spendable": true,
    "solvable": true,
    "desc": "<desc>",
    "safe": false
  }
]

Comment thread src/wallet/rpcwallet.cpp
{RPCResult::Type::STR, "scriptPubKey", "the script key"},
{RPCResult::Type::STR_AMOUNT, "amount", "the transaction output amount in " + CURRENCY_UNIT},
{RPCResult::Type::NUM, "confirmations", "The number of confirmations"},
{RPCResult::Type::NUM, "ancestorcount", /* optional */ true, "The number of in-mempool ancestor transactions, including this one (if transaction is in the mempool)"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#22903 makes me wonder whether one should change:

/* optional */ true -> /* optional= */ true

@kiminuo

kiminuo commented Sep 19, 2021

Copy link
Copy Markdown
Contributor

ACK 6cb60f3

@darosior darosior left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 6cb60f3

@laanwj laanwj merged commit 488e745 into bitcoin:master Sep 20, 2021
@sipa

sipa commented Sep 20, 2021

Copy link
Copy Markdown
Member

Shouldn't "ancestorfees" use ValueFromAmount here?

@jonatack jonatack left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few quick comments for a follow-up.

------------

- `listunspent` now includes `ancestorcount`, `ancestorsize`, and
`ancestorfees` for each transaction output that is still in the mempool.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing PR number at the end: s/mempool./mempool. (#12677)

Comment thread src/node/interfaces.cpp
return TransactionError::OK == err;
}
void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) override
void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize, CAmount* ancestorfees) override

@jonatack jonatack Sep 20, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function params naming: s/ancestorsize/ancestor_size/, idem for ancestorfees

Comment thread src/wallet/rpcwallet.cpp
if (ancestor_count) {
entry.pushKV("ancestorcount", uint64_t(ancestor_count));
entry.pushKV("ancestorsize", uint64_t(ancestor_size));
entry.pushKV("ancestorfees", uint64_t(ancestor_fees));

@jonatack jonatack Sep 20, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three new fields should be snakecase, e.g. s/ancestorcount/ancestor_count/.

Should they use UniValue ValueFromAmount() for the amount to print? in which case the units would need to be listed in the help as BTC instead of sat.

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 21, 2021
…t output

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

Pull request description:

  Requested by a user

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

Tree-SHA512: 5d16e5799558691e5853ab7ea2cc85514cb45da3ce69134d855c71845beef32ec6af5ab28d4462683e9800c8ea126f162773a9d3d5660edac08fd8edbfeda173
@ryanofsky ryanofsky mentioned this pull request Oct 6, 2021
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 5, 2022
Summary:
Expose ancestorsize and ancestorfees via getTransactionAncestry
Add ancestor{count,size,fees} to listunspent output

Add tests and release notes.

Note that fees returned by listunspent are in XEC in Bitcoin ABC, not satoshis.

Backport of [[bitcoin/bitcoin#12677 | core#12677]]

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D12151
@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.