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

wallet, rpc: add label to listsinceblock #25934

Merged
merged 4 commits into from Dec 7, 2022

Conversation

brunoerg
Copy link
Contributor

@brunoerg brunoerg commented Aug 25, 2022

This PR adds label parameter to listsinceblock to be able to fetch all incoming transactions having the specified label since a specific block.

It's possible to use it in listtransactions, however, it's only possible to set the number of transactions to return, not a specific block to fetch from. getreceivedbylabel only returns the total amount received, not the txs info. listreceivedbylabel doesn't list all the informations about the transactions and it's not possible to fetch since a block.

@brunoerg brunoerg marked this pull request as ready for review August 26, 2022 12:28
@brunoerg brunoerg force-pushed the 2022-08-add-label-listsinceblock branch from bfb8464 to cf00489 Compare August 27, 2022 00:31
Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

ACK cf00489

CI error is not related

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 23, 2022

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK w0xlt, aureleoules, achow101
Stale ACK jonatack

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #26238 (clang-tidy: fixup named argument comments by fanquake)
  • #25979 ([WIP] wallet: standardize change output detection process by furszy)

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.

Copy link
Member

@aureleoules aureleoules left a comment

Choose a reason for hiding this comment

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

Concept ACK
I think this change can be useful for accountability.

src/wallet/rpc/transactions.cpp Outdated Show resolved Hide resolved
src/wallet/rpc/transactions.cpp Outdated Show resolved Hide resolved
test/functional/wallet_listsinceblock.py Outdated Show resolved Hide resolved
@brunoerg brunoerg force-pushed the 2022-08-add-label-listsinceblock branch 3 times, most recently from 2097d20 to cd444f4 Compare September 26, 2022 22:46
src/wallet/rpc/transactions.cpp Outdated Show resolved Hide resolved
test/functional/wallet_listsinceblock.py Outdated Show resolved Hide resolved
@brunoerg brunoerg force-pushed the 2022-08-add-label-listsinceblock branch from 1c373dd to 2ddf967 Compare September 27, 2022 14:51
@brunoerg brunoerg force-pushed the 2022-08-add-label-listsinceblock branch from 2ddf967 to ee284ff Compare September 27, 2022 16:16
Copy link
Member

@aureleoules aureleoules left a comment

Choose a reason for hiding this comment

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

ACK ee284ff

src/wallet/rpc/transactions.cpp Outdated Show resolved Hide resolved
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.

Concept ACK. If I understand correctly, it looks like the PR title and description should describe this functionality as filtering the results by those having the label.

src/wallet/rpc/transactions.cpp Show resolved Hide resolved
doc/release-notes-25934.md Outdated Show resolved Hide resolved
doc/release-notes-25934.md Outdated Show resolved Hide resolved
@@ -552,6 +552,8 @@ RPCHelpMan listsinceblock()
{"include_removed", RPCArg::Type::BOOL, RPCArg::Default{true}, "Show transactions that were removed due to a reorg in the \"removed\" array\n"
"(not guaranteed to work on pruned nodes)"},
{"include_change", RPCArg::Type::BOOL, RPCArg::Default{false}, "Also add entries for change outputs.\n"},
{"label", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "If set, should be a valid label name to return only incoming transactions\n"
Copy link
Contributor

@jonatack jonatack Sep 28, 2022

Choose a reason for hiding this comment

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

Seems this can be shorter and on one line

Suggested change
{"label", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "If set, should be a valid label name to return only incoming transactions\n"
{"label", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "Return only incoming transactions\n"

and s/with/having/

Unlike listtransactions, I wasn't able to get an invalid label error with listsinceblock. Maybe test for that like the one in test/functional/wallet_listtransactions.py::L282, if the label can be invalid in listsinceblock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perfect, you're right. Gonna update it.

Copy link
Member

Choose a reason for hiding this comment

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

I'm working on this in #26186.
I didn't think it would fit the scope of this PR.

Copy link
Contributor

@jonatack jonatack Sep 30, 2022

Choose a reason for hiding this comment

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

That PR doesn't seem to touch/fix the invalidity check for listsinceblock. Should it be done here while adding the arg, or do you plan to update that pull after this one?

Copy link
Member

Choose a reason for hiding this comment

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

I've refactored LabelFromValue in #26186, and it's marked for the 24.0 milestone so maybe this PR should be rebased on top of #26186 and the check should be added here as well?
I also don't mind updating my pull if this one gets merged first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unlike listtransactions, I wasn't able to get an invalid label error with listsinceblock

I think in listtransactions label parameter is the first one, so you pass a value like "*" or a real name and if you try it with an empty label it throws an error. In this case, label is the last parameter, you can pass a label or leave it empty to fetch all, there is no need to adopt the same pattern as listtransactions.

src/wallet/rpc/transactions.cpp Outdated Show resolved Hide resolved
test/functional/wallet_listsinceblock.py Outdated Show resolved Hide resolved
@brunoerg brunoerg force-pushed the 2022-08-add-label-listsinceblock branch from ee284ff to 2a86921 Compare September 28, 2022 21:58
Copy link
Member

@aureleoules aureleoules left a comment

Choose a reason for hiding this comment

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

re-ACK 2a86921 - minor changes and documentation improvements since my last review.

src/wallet/rpc/transactions.cpp Outdated Show resolved Hide resolved
doc/release-notes-25934.md Outdated Show resolved Hide resolved
src/wallet/rpc/transactions.cpp Outdated Show resolved Hide resolved
src/wallet/rpc/transactions.cpp Outdated Show resolved Hide resolved
@@ -552,6 +552,8 @@ RPCHelpMan listsinceblock()
{"include_removed", RPCArg::Type::BOOL, RPCArg::Default{true}, "Show transactions that were removed due to a reorg in the \"removed\" array\n"
"(not guaranteed to work on pruned nodes)"},
{"include_change", RPCArg::Type::BOOL, RPCArg::Default{false}, "Also add entries for change outputs.\n"},
{"label", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "If set, should be a valid label name to return only incoming transactions\n"
Copy link
Contributor

@jonatack jonatack Sep 30, 2022

Choose a reason for hiding this comment

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

That PR doesn't seem to touch/fix the invalidity check for listsinceblock. Should it be done here while adding the arg, or do you plan to update that pull after this one?

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.

Not sure, but should the PR title and description describe this functionality as filtering the results by those having the label?

@brunoerg brunoerg force-pushed the 2022-08-add-label-listsinceblock branch 2 times, most recently from c15c9b5 to 0ff870f Compare October 24, 2022 14:30
@brunoerg
Copy link
Contributor Author

Not sure, but should the PR title and description describe this functionality as filtering the results by those having the label?

Just updated the description.

@brunoerg
Copy link
Contributor Author

Force-pushed addressing @jonatack's review.

Obs: CI failed for Win64 native due an intermittent issue (See: #26330)

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.

ACK 0ff870f

test/functional/wallet_listsinceblock.py Outdated Show resolved Hide resolved
Copy link
Member

@aureleoules aureleoules left a comment

Choose a reason for hiding this comment

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

reACK 0ff870f - minor changes and documentation improvements since my last review.

@brunoerg brunoerg force-pushed the 2022-08-add-label-listsinceblock branch 2 times, most recently from 219b7f0 to c9b60d3 Compare October 27, 2022 20:22
@brunoerg
Copy link
Contributor Author

Force-pushed rebasing and addressing @jonatack's suggestion for the test.

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.

ACK c9b60d3

@jonatack
Copy link
Contributor

@brunoerg it might be good to un-resolve the discussion from #25934 (comment) as it needs to be addressed (if I'm not confused).

Copy link
Member

@aureleoules aureleoules left a comment

Choose a reason for hiding this comment

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

reACK c9b60d3

@brunoerg brunoerg force-pushed the 2022-08-add-label-listsinceblock branch from c9b60d3 to 4e362c2 Compare December 6, 2022 19:05
@brunoerg
Copy link
Contributor Author

brunoerg commented Dec 6, 2022

Force-pushed rebasing.

Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

ACK 4e362c2

Copy link
Member

@aureleoules aureleoules left a comment

Choose a reason for hiding this comment

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

ACK 4e362c2

@achow101
Copy link
Member

achow101 commented Dec 7, 2022

ACK 4e362c2

@achow101 achow101 merged commit a653f4b into bitcoin:master Dec 7, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 8, 2022
4e362c2 doc: add release note for 25934 (brunoerg)
fe488b4 test: add coverage for `label` in `listsinceblock` (brunoerg)
722e9a4 wallet, rpc: add `label` to `listsinceblock` (brunoerg)
852891f refactor, wallet: use optional for `label` in `ListTransactions` (brunoerg)

Pull request description:

  This PR adds `label` parameter to `listsinceblock` to be able to fetch all incoming transactions having the specified label since a specific block.

  It's possible to use it in `listtransactions`, however, it's only possible to set the number of transactions to return, not a specific block to fetch from. `getreceivedbylabel` only returns the total amount received, not the txs info. `listreceivedbylabel` doesn't list all the informations about the transactions and it's not possible to fetch since a block.

ACKs for top commit:
  achow101:
    ACK 4e362c2
  w0xlt:
    ACK bitcoin@4e362c2
  aureleoules:
    ACK 4e362c2

Tree-SHA512: fbde5db8cebf7a27804154fa61997b5155ad512e978cebb78c17acab9efcb624ea5f39d649899d12e5e675f80d4d0064cae8132b864de0d93a8d1e6fbcb9a737
@bitcoin bitcoin locked and limited conversation to collaborators Dec 7, 2023
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

9 participants