Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from Sep 20, 2021

Conversation

luke-jr
Copy link
Member

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

Requested by a user

Copy link
Member

@promag promag left a comment

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.

src/wallet/rpcwallet.cpp Outdated Show resolved Hide resolved
@pacamoto
Copy link

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

@meshcollider
Copy link
Contributor

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

@sipa
Copy link
Member

sipa commented Mar 17, 2018

Concept ACK

@promag
Copy link
Member

promag commented May 3, 2018

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

@achow101
Copy link
Member

achow101 commented Jul 9, 2018

utACK daeb431

@maflcko
Copy link
Member

maflcko commented Jul 10, 2018

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

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 20, 2018

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
Copy link
Member Author

luke-jr commented Feb 12, 2019

Rebased and added tests

@luke-jr
Copy link
Member Author

luke-jr commented Apr 6, 2019

Rebased again

@DrahtBot
Copy link
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
Copy link
Member

sipa commented Oct 18, 2019

Concept ACK

Copy link

@ghost ghost left a comment

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
Copy link
Member Author

luke-jr commented Sep 16, 2021

Addressed various nits, needs re-ACKs

@laanwj
Copy link
Member

laanwj commented Sep 16, 2021

Copy link
Member

@achow101 achow101 left a comment

Choose a reason for hiding this comment

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

Code Review ACK 6cb60f3

Copy link
Member

@naumenkogs naumenkogs left a comment

Choose a reason for hiding this comment

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

ACK 6cb60f3

@ghost
Copy link

ghost commented Sep 17, 2021

reACK 6cb60f3

@fjahr
Copy link
Contributor

fjahr commented Sep 18, 2021

Code review re-ACK 6cb60f3

@@ -2880,6 +2880,9 @@ static RPCHelpMan listunspent()
{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)"},
{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
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
  }
]

@@ -2880,6 +2880,9 @@ static RPCHelpMan listunspent()
{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
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
Copy link
Contributor

kiminuo commented Sep 19, 2021

ACK 6cb60f3

laanwj added a commit to laanwj/bitcoin that referenced this pull request Sep 20, 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
Copy link
Member

@darosior darosior left a comment

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
@laanwj laanwj removed this from Blockers in High-priority for review Sep 20, 2021
@sipa
Copy link
Member

sipa commented Sep 20, 2021

Shouldn't "ancestorfees" use ValueFromAmount here?

Copy link
Contributor

@jonatack jonatack left a comment

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
Contributor

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)

@@ -574,11 +574,11 @@ class ChainImpl : public Chain
// that Chain clients do not need to know about.
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
Copy link
Contributor

@jonatack jonatack Sep 20, 2021

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

if (ancestor_count) {
entry.pushKV("ancestorcount", uint64_t(ancestor_count));
entry.pushKV("ancestorsize", uint64_t(ancestor_size));
entry.pushKV("ancestorfees", uint64_t(ancestor_fees));
Copy link
Contributor

@jonatack jonatack Sep 20, 2021

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.

None yet