-
Notifications
You must be signed in to change notification settings - Fork 38.8k
rpc: getreceivedbylabel, return early if no addresses were found in the address book #25122
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: getreceivedbylabel, return early if no addresses were found in the address book #25122
Conversation
theStack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
Thanks for following up!
As expressed in #23662 (comment), I think users should be notified with an error if a label is passed that doesn't exist in the wallet address book. Not sure yet if it's worth the effort, but one could even go one step further and throw two different error messages for the cases
- there is no such label in the address book (i.e.
wallet.GetLabelAddressesreturns an empty set) - there is a label, but it doesn't apply to any address that is ours (i.e. after
IsMinefiltering,output_scriptsis empty)
As of the current state of the PR, I think the simplest (minimal-diff) solution would be to move that part
if (output_scripts.empty()) {
throw JSONRPCError(RPC_WALLET_ERROR, "Address/es not found in wallet");
}
to the end of the if (by_label) { ... } block. Then you could also be more specific with the message and say, e.g. "Label not found in wallet" (as you outlined in #23662 (comment)). Note also that the CI indicates that the functional test wallet_listreceivedby.py needs to be adapted.
a208ddf to
6482941
Compare
|
yep pushed. Tests passing now. Will rebase it once your PR gets merged. |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
6482941 to
73aea8c
Compare
|
ACK 73aea8c65e4810f3e41c8351f80ae43e276fc1d5 |
|
This needs release notes, as API is changed for cases when specified label does not exist in wallet. |
pushed 👍🏼. |
|
re-ACK 77915c1c21b7041c8e8ab76760bfd7e85e18fbab |
theStack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-review ACK 77915c1c21b7041c8e8ab76760bfd7e85e18fbab
77915c1 to
8a72297
Compare
pushed 👍🏼. |
theStack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK 8a722974b2b9e54fcc0139dd795023a0f8ef3f6c
jonatack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach ACK
src/wallet/rpc/coins.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought, and not necessarily in this PR, but by moving this line back to the top the entire section touched here can be bracket-scoped or extracted out to a function that returns std::set<CScript> output_scripts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, I structured it do some further decoupling but didn't find a good reason to add it here.
8a72297 to
a13b8a0
Compare
… no destinations were found for the input label. If wallet.GetLabelAddresses() returns an empty vector (the wallet does not have addresses with that label in the addressbook) or if none of the returned destinations are from the wallet, we can return the function right away.
a13b8a0 to
da8be10
Compare
|
Updated per feedback 👍🏼.
|
|
ACK da8be104cdaa2bef955bfea2909ce75af9992a2b |
|
Squash commits into one? |
doc/release-notes.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, just saw the release note might be in the wrong section
--- a/doc/release-notes.md
+++ b/doc/release-notes.md
@@ -57,9 +57,6 @@ Updated RPCs
Changes to wallet related RPCs can be found in the Wallet section below.
-- RPC `getreceivedbylabel` now returns an error, "Label not found
- in wallet" (-4), if the label is not in the address book. (#25122)
-
New RPCs
--------
@@ -81,6 +78,9 @@ Tools and Utilities
Wallet
------
+- RPC `getreceivedbylabel` now returns an error, "Label not found
+ in wallet" (-4), if the label is not in the address book. (#25122)
+
GUI changes
-----------There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushed
…if the label is not in the address book.
da8be10 to
baa3ddc
Compare
theStack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK baa3ddc
w0xlt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK baa3ddc
|
ACK baa3ddc |
|
Posthumous ACK |
…esses were found in the address book baa3ddc doc: add release notes about `getreceivedbylabel` returning an error if the label is not in the address book. (furszy) 8897a21 rpc: getreceivedbylabel, don't loop over the entire wallet txs map if no destinations were found for the input label. (furszy) Pull request description: Built on top of bitcoin#23662, coming from comment bitcoin#23662 (review). If `wallet.GetLabelAddresses()` returns an empty vector (the wallet does not have stored destinations with that label in the addressbook) or if none of the returned destinations are from the wallet, we can return the function right away. Otherwise, we are walking through all the wallet txs + outputs for no reason (`output_scripts` is empty). ACKs for top commit: achow101: ACK baa3ddc theStack: re-ACK baa3ddc w0xlt: ACK bitcoin@baa3ddc Tree-SHA512: 00e10365b179bf008da2f3ef8fbb3ee04a330426374020e3f2d0151b16991baba4ef2b944e4659452f3e4d6cb20f128d0918ddf0453933a25a4d9fd8414a1911
Built on top of #23662, coming from comment #23662 (review).
If
wallet.GetLabelAddresses()returns an empty vector (the wallet does not have stored destinations with that label in the addressbook) or if none of the returned destinations are from the wallet, we can return the function right away.Otherwise, we are walking through all the wallet txs + outputs for no reason (
output_scriptsis empty).