Skip to content

Conversation

jnewbery
Copy link
Contributor

@jnewbery jnewbery commented Apr 5, 2018

Add label API to wallet RPC.

This is one step towards #3816 ("Remove bolt-on account system") although it doesn't
actually remove anything yet.

These initially mirror the account functions, with the following differences:

  • These functions aren't DEPRECATED in the help
  • Help mentions 'label' instead of accounts. In the language used, labels are
    associated with addresses, instead of addresses associated with labels. (unlike
    with accounts.)
  • Labels have no balance
    • No balances in listlabels
    • listlabels has no minconf or watchonly argument
  • Like in the GUI, labels can be set on any address, not just receiving addreses
  • Unlike accounts, labels can be deleted.
    Being unable to delete them is a common annoyance (see XMLRPC: setaccount moves label to the other, unused address #1231).
    Currently only by reassigning all addresses using setlabel, but an explicit
    call deletelabel which assigns all address to the default label may make
    sense.

@jnewbery
Copy link
Contributor Author

jnewbery commented Apr 5, 2018

This is #7729 with the following changes:

@laanwj doesn't have time to maintain #7729. I'd like to try to get this merged before v0.17.

@jnewbery
Copy link
Contributor Author

jnewbery commented Apr 5, 2018

For full history of this PR, see #7729. Requesting review from reviewers of that PR: @Sjors , @MarcoFalke , @ryanofsky , @jonasschnelli , @instagibbs , @sipa , @luke-jr .

+ HelpExampleCli("setlabel", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"")
+ HelpExampleRpc("setlabel", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")
+ HelpExampleCli("setlabel", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\" \"tabby\"")
+ HelpExampleRpc("setlabel", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\", \"tabby\"")
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted

@jnewbery jnewbery added the Wallet label Apr 5, 2018
@jnewbery jnewbery added this to the 0.17.0 milestone Apr 5, 2018
throw std::runtime_error(
"getlabeladdress \"label\"\n"
"\nReturns the current Bitcoin address for receiving payments to this label.\n"
"\nReturns the current 'label address' for this label.\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this call gets even weirder, shouldn't we deprecate it in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aparently some miners require this functionality (#7729 (comment)).

I'd personally prefer to deprecate/remove this RPC method, but in the interest of making progress on this, let's maintain the current functionality and reconsider deprecation later.

+ HelpExampleRpc("getaddressesbylabel", "\"tabby\"")
);

LOCK2(cs_main, pwallet->cs_wallet);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove cs_main?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


// Find all addresses that have the given label
std::vector<std::pair<std::string, UniValue>> addresses;
for (const std::pair<CTxDestination, CAddressBookData>& item : pwallet->mapAddressBook) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Future improvements:

  • move this to wallet function?
  • index address by label with a multi map?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll leave this functionality here for now. Can be refactored later if required.

std::vector<std::pair<std::string, UniValue>> addresses;
for (const std::pair<CTxDestination, CAddressBookData>& item : pwallet->mapAddressBook) {
if (item.second.name == label) {
addresses.push_back(Pair(EncodeDestination(item.first), AddressBookDataToJSON(item.second, false)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Could push to ret and avoid addresses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, done.

+ HelpExampleRpc("listlabels", "receive")
);

LOCK2(cs_main, pwallet->cs_wallet);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove cs_main?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

LOCK2(cs_main, pwallet->cs_wallet);

std::string purpose;
if (request.params.size() > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

!params[0].isNull()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

std::list<std::string> label_list(label_set.begin(), label_set.end());
label_list.sort();
UniValue ret(UniValue::VARR);
for (const std::string &name : label_list) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit space after &.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -187,6 +187,11 @@ UniValue getnewaddress(const JSONRPCRequest& request)
return EncodeDestination(dest);
}

void DeleteLabel(CWallet& wallet, std::string label)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, move to CWallet::DeleteLabel(const std::string& label)? Or make it static for now?

Copy link
Contributor

@PierreRochard PierreRochard Apr 5, 2018

Choose a reason for hiding this comment

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

Agree, if left unchanged this would be the only direct CWalletDB call from rpcwallet. Seems as though it should go through CWallet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved into CWallet

@@ -205,14 +210,15 @@ UniValue getlabeladdress(const JSONRPCRequest& request)
return NullUniValue;
}

if (request.fHelp || request.params.size() != 1)
if (request.fHelp || request.params.size() > 2)
throw std::runtime_error(
"getlabeladdress \"label\"\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing ( force ).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -205,14 +210,15 @@ UniValue getlabeladdress(const JSONRPCRequest& request)
return NullUniValue;
}

if (request.fHelp || request.params.size() != 1)
if (request.fHelp || request.params.size() > 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing < 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -224,6 +230,20 @@ UniValue getlabeladdress(const JSONRPCRequest& request)

// Parse the label first so we don't generate a key if there's an error
std::string label = LabelFromValue(request.params[0]);
bool force = false;
if (!request.params[1].isNull())
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, add {}.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@jnewbery
Copy link
Contributor Author

jnewbery commented Apr 5, 2018

Thanks for the review @promag . Will address comments tomorrow.

@@ -308,22 +328,24 @@ UniValue setlabel(const JSONRPCRequest& request)
}

std::string label;
if (!request.params[1].isNull())
if (!request.params[1].isNull()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems odd to me that label is marked as a required argument for setlabel but if it's not provided then we default to an empty string instead of throwing an error. If we want to keep the behavior then label should be marked as optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the behaviour to match the help text: the rpc call will fail if no label is provided.

@jnewbery
Copy link
Contributor Author

jnewbery commented Apr 6, 2018

Addressed review comments from @promag and @PierreRochard . Are you able to re-review?

@PierreRochard
Copy link
Contributor

Yes, re-reviewing now

@PierreRochard
Copy link
Contributor

A behavior difference between the old getaccountaddress and the new aliased getlabeladdress is causing the wallet_basic.py to fail. I was able to fix it by adding force to the test, but I think it's the endpoint that should be changed if the goal is to not break the API with the aliasing.

rpc_listtransactions.py and wallet_listreceivedby.py are also failing, it may be due to the same root cause but I won't be able to confirm until tomorrow.

@PierreRochard
Copy link
Contributor

Fixing wallet_basic.py and rpc_listtransactions.py: If we want to continue supporting the behavior of the aliased getaccountaddress, force should default to true when that call is made, so something like bool force = request.strMethod == "getaccountaddress" ? true : false;

Fixing wallet_listreceivedby.py: line 143 should read self.nodes[1].getlabeladdress(label="mynewlabel", force=True)

@jnewbery
Copy link
Contributor Author

jnewbery commented Apr 7, 2018

Thanks for the fixes @PierreRochard! I've updated the tests as you suggested and force pushed.

@PierreRochard
Copy link
Contributor

Tested ACK 1f7f1dfd1c16cf0c9a700e2b262ffa8f6c6559cd

@laanwj
Copy link
Member

laanwj commented Apr 9, 2018

I'm still not convinced we really need getlabeladdress in the first place, but anyhow.
utACK 1f7f1df

@maflcko
Copy link
Member

maflcko commented Apr 9, 2018

Needs rebase

@jnewbery
Copy link
Contributor Author

jnewbery commented Apr 9, 2018

Rebased.

I'm still not convinced we really need getlabeladdress

ok, that's three concept NACKs for getlabeladdress (me, @jonasschnelli #12892 (comment) and @laanwj #12892 (comment)).

I kept this call because there was a comment in the previous PR (#7729 (comment)) that this functionality was important for some miners and I wanted to avoid controversy to get this PR merged. However, if there's overwhelming opposition to getlabeladdress, it makes sense to remove it. getlabeladdress doesn't make much sense to me, and blurs the distinction that "labels are associated with addresses, instead of addresses associated with labels".

Other reviewers of this and the previous PR (@promag, @PierreRochard, @Sjors, @MarcoFalke , @ryanofsky , @instagibbs , @sipa , @luke-jr) - please can you provide concept input into whether we should just remove getlabeladdress?

@PierreRochard
Copy link
Contributor

@jnewbery I agree that getlabeladdress should be removed, it has too much overlap with getnewaddress and miner-specific use cases are likely best implemented in the mining software (this suggestion seems reasonable: #7729 (comment))

@ryanofsky
Copy link
Contributor

ryanofsky commented Apr 9, 2018

Other reviewers of this and the previous PR (@promag, @PierreRochard, @Sjors, @MarcoFalke , @ryanofsky , @instagibbs , @sipa , @luke-jr) - please can you provide concept input into whether we should just remove getlabeladdress?

I think it would be better to keep this PR as focused as possible. The goal should just be to fill in the last missing bits of the label implementation, so it is easy to switch from accounts to labels and we can get rid of broken "account balance" code and code that tries to track what account a transaction is sent from. I don't think it makes sense to introduce additional differences between accounts and labels that will make migration more difficult than necessary.

The main problem I see with getlabeladdress is just the documentation which is completely self-referential:

Returns the current 'label address' for this label.

Instead of explanatory like:

Returns the default receiving address for this label. This will reset to a fresh address once there's a transaction that spends to it.

Maybe there are other problems with getlabeladdress, but I can't see where they have been mentioned.

Also, I think this PR needs release notes. Good documentation is probably the most important part of this change.

@jnewbery
Copy link
Contributor Author

jnewbery commented Apr 9, 2018

I don't think it makes sense to introduce additional differences between accounts and labels that will make migration more difficult than necessary.

ok, I can see the merit in that. Let's keep this PR focused and we can squabble over removing getlabeladdress later.

I've updated the help text for getlabeladdress and added release notes.

Re-review would be very much appreciated at this point 😃

@laanwj
Copy link
Member

laanwj commented Apr 10, 2018

My intent was not for the getlabeladdress discussion to block this PR. We need to make a decision about it before the 0.17 release, not necessarily now.

getlabeladdress doesn't make much sense to me, and blurs the distinction that "labels are associated with addresses, instead of addresses associated with labels".

Another problem with it is that it requires keeping this whole CAccount administration in place. Part of the reason for this account to label refactor is simplify the wallet mess and to get rid of that.

Will re-review.

re-utACK 86d3394de8e053c863b1e55b1c8c935d36884802

Copy link
Contributor

@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.

Will test. Some nits thou.

@@ -3643,6 +3643,12 @@ std::set<CTxDestination> CWallet::GetLabelAddresses(const std::string& label) co
return result;
}

void CWallet::DeleteLabel(std::string label)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, const std::string& label.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree that's better. Fixed.

{
UniValue ret(UniValue::VOBJ);
if (verbose) {
ret.push_back(Pair("name", data.name));
Copy link
Contributor

Choose a reason for hiding this comment

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

pushKV.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

if (verbose) {
ret.push_back(Pair("name", data.name));
}
ret.push_back(Pair("purpose", data.purpose));
Copy link
Contributor

Choose a reason for hiding this comment

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

pushKV.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

UniValue ret(UniValue::VOBJ);
for (const std::pair<CTxDestination, CAddressBookData>& item : pwallet->mapAddressBook) {
if (item.second.name == label) {
ret.push_back(Pair(EncodeDestination(item.first), AddressBookDataToJSON(item.second, false)));
Copy link
Contributor

Choose a reason for hiding this comment

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

pushKV.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

laanwj and others added 2 commits April 10, 2018 19:27
Add label API to wallet RPC.

This is one step towards bitcoin#3816 ("Remove bolt-on account system") although it doesn't
actually remove anything yet.

These initially mirror the account functions, with the following differences:

- These functions aren't DEPRECATED in the help
- Help mentions 'label' instead of accounts. In the language used, labels are
  associated with addresses, instead of addresses associated with labels. (unlike
  with accounts.)
- Labels have no balance
  - No balances in `listlabels`
  - `listlabels` has no minconf or watchonly argument
- Like in the GUI, labels can be set on any address, not just receiving addreses
- Unlike accounts, labels can be deleted.
  Being unable to delete them is a common annoyance (see bitcoin#1231).
  Currently only by reassigning all addresses using `setlabel`, but an explicit
  call `deletelabel` which assigns all address to the default label may make
  sense.

Thanks to Pierre Rochard for test fixes.
@jnewbery
Copy link
Contributor Author

Fixed comment. b00faff -> 41ba061

@promag
Copy link
Contributor

promag commented Apr 11, 2018

utACK 41ba061.

Copy link
Contributor

@kallewoof kallewoof left a comment

Choose a reason for hiding this comment

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

utACK 41ba061

@@ -226,6 +227,21 @@ UniValue getlabeladdress(const JSONRPCRequest& request)

// Parse the label first so we don't generate a key if there's an error
std::string label = LabelFromValue(request.params[0]);
bool force = request.strMethod == "getaccountaddress" ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: ? true : false is redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

duh. Will tidy up in follow-up PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let it go, will go away when accounts are removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, not worth a PR for just that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in #12953

@laanwj laanwj merged commit 41ba061 into bitcoin:master Apr 11, 2018
laanwj added a commit that referenced this pull request Apr 11, 2018
41ba061 [docs] Add release notes for wallet 'label' API. (John Newbery)
189e0ef [wallet] [rpc] introduce 'label' API for wallet (Wladimir J. van der Laan)

Pull request description:

  Add label API to wallet RPC.

  This is one step towards #3816 ("Remove bolt-on account system") although it doesn't
  actually remove anything yet.

  These initially mirror the account functions, with the following differences:

  - These functions aren't DEPRECATED in the help
  - Help mentions 'label' instead of accounts. In the language used, labels are
    associated with addresses, instead of addresses associated with labels. (unlike
    with accounts.)
  - Labels have no balance
    - No balances in `listlabels`
    - `listlabels` has no minconf or watchonly argument
  - Like in the GUI, labels can be set on any address, not just receiving addreses
  - Unlike accounts, labels can be deleted.
    Being unable to delete them is a common annoyance (see #1231).
    Currently only by reassigning all addresses using `setlabel`, but an explicit
    call `deletelabel` which assigns all address to the default label may make
    sense.

Tree-SHA512: 45cc313c68ad529ce3a15c02181d2ab0083a7e14fe824e2cde34972713fecce512e3d4b9aa46db5355f2baa857c44b234d4fe9709225bc23c7ebbc0e03febbf5
@jnewbery jnewbery mentioned this pull request Apr 11, 2018
6 tasks
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 8, 2019
Summary:
41ba061 [docs] Add release notes for wallet 'label' API. (John Newbery)
189e0ef [wallet] [rpc] introduce 'label' API for wallet (Wladimir J. van der Laan)

Pull request description:

  Add label API to wallet RPC.

  This is one step towards #3816 ("Remove bolt-on account system") although it doesn't
  actually remove anything yet.

  These initially mirror the account functions, with the following differences:

  - These functions aren't DEPRECATED in the help
  - Help mentions 'label' instead of accounts. In the language used, labels are
    associated with addresses, instead of addresses associated with labels. (unlike
    with accounts.)
  - Labels have no balance
    - No balances in `listlabels`
    - `listlabels` has no minconf or watchonly argument
  - Like in the GUI, labels can be set on any address, not just receiving addreses
  - Unlike accounts, labels can be deleted.
    Being unable to delete them is a common annoyance (see #1231).
    Currently only by reassigning all addresses using `setlabel`, but an explicit
    call `deletelabel` which assigns all address to the default label may make
    sense.

Tree-SHA512: 45cc313c68ad529ce3a15c02181d2ab0083a7e14fe824e2cde34972713fecce512e3d4b9aa46db5355f2baa857c44b234d4fe9709225bc23c7ebbc0e03febbf5

Backport of Core PR12892
bitcoin/bitcoin#12892

Depends on D3308

Test Plan:
  make check
  test_runner.py

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc, markblundeberg

Reviewed By: Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D3949
laanwj added a commit that referenced this pull request Nov 26, 2019
33f5fc3 test: add rpc getaddressinfo labels test coverage (Jon Atack)
0f3539a test: add listlabels test in wallet_labels.py (Jon Atack)
1388de8 rpc: add getaddressinfo code documentation (Jon Atack)
2ee0cb3 rpc: update getaddressinfo RPCExamples to bech32 (Jon Atack)
8d1ed0c rpc: clarify label vs labels in getaddressinfo RPCHelpman (Jon Atack)
5a0ed85 rpc: improve getaddressinfo RPCHelpman content (Jon Atack)
70cda34 rpc: improve getaddressinfo RPCHelpman formatting (Jon Atack)

Pull request description:

  This PR is a continuation of the work in #12892.

  Main motivations:
  - There is currently no test coverage for the getaddressinfo `labels` response. Coverage here is a prerequisite before deprecating the `label` response or adding multiple labels per address.
  - `bitcoin-cli help getaddressinfo` returns a few content errors, difficult-to-read formatting, and no explanation why it returns both `label` and `labels` and how they relate, which can be confusing for application developers.

  Changes by order of commits:
  - [x] improve/fix getaddressinfo RPCHelpman layout formatting
  - [x] improve/fix getaddressinfo RPCHelpman content
  - [x] clarify the `label` and `labels` fields in getaddressinfo RPCHelpman
  - [x] update getaddressinfo RPCExamples addresses to bech32
  - [x] add getaddressinfo code docs
  - [x] add a `listlabels` test assertion in wallet_labels.py
  - [x] add missing getaddressinfo `labels` test coverage and improve the existing `label` tests

  Here are gists of the CLI help output:
  [`bitcoin-cli help getaddressinfo` before this PR](https://gist.github.com/jonatack/022af5221a85c069780359a22643c810)
  [`bitcoin-cli help getaddressinfo` after this PR](https://gist.github.com/jonatack/4ee5f6abc62a3d99269570206a5f90ba)

  It seems we ought to begin a deprecation process for the getaddressinfo `label` field? If yes, I have a follow-up ready. _--> EDIT: Deprecation follow-ups #17578 and #17585 now build on this PR._

ACKs for top commit:
  fjahr:
    Re-ACK 33f5fc3
  jnewbery:
    ACK 33f5fc3.

Tree-SHA512: a001aa863090ec2566a31059477945b1c303ebeb430b33472f8b150e420fa5742fc33bca9d95571746395b607f43f6078dd5b53e238ac1f3fc648b51c8f79a07
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Nov 27, 2019
… code docs

33f5fc3 test: add rpc getaddressinfo labels test coverage (Jon Atack)
0f3539a test: add listlabels test in wallet_labels.py (Jon Atack)
1388de8 rpc: add getaddressinfo code documentation (Jon Atack)
2ee0cb3 rpc: update getaddressinfo RPCExamples to bech32 (Jon Atack)
8d1ed0c rpc: clarify label vs labels in getaddressinfo RPCHelpman (Jon Atack)
5a0ed85 rpc: improve getaddressinfo RPCHelpman content (Jon Atack)
70cda34 rpc: improve getaddressinfo RPCHelpman formatting (Jon Atack)

Pull request description:

  This PR is a continuation of the work in bitcoin#12892.

  Main motivations:
  - There is currently no test coverage for the getaddressinfo `labels` response. Coverage here is a prerequisite before deprecating the `label` response or adding multiple labels per address.
  - `bitcoin-cli help getaddressinfo` returns a few content errors, difficult-to-read formatting, and no explanation why it returns both `label` and `labels` and how they relate, which can be confusing for application developers.

  Changes by order of commits:
  - [x] improve/fix getaddressinfo RPCHelpman layout formatting
  - [x] improve/fix getaddressinfo RPCHelpman content
  - [x] clarify the `label` and `labels` fields in getaddressinfo RPCHelpman
  - [x] update getaddressinfo RPCExamples addresses to bech32
  - [x] add getaddressinfo code docs
  - [x] add a `listlabels` test assertion in wallet_labels.py
  - [x] add missing getaddressinfo `labels` test coverage and improve the existing `label` tests

  Here are gists of the CLI help output:
  [`bitcoin-cli help getaddressinfo` before this PR](https://gist.github.com/jonatack/022af5221a85c069780359a22643c810)
  [`bitcoin-cli help getaddressinfo` after this PR](https://gist.github.com/jonatack/4ee5f6abc62a3d99269570206a5f90ba)

  It seems we ought to begin a deprecation process for the getaddressinfo `label` field? If yes, I have a follow-up ready. _--> EDIT: Deprecation follow-ups bitcoin#17578 and bitcoin#17585 now build on this PR._

ACKs for top commit:
  fjahr:
    Re-ACK 33f5fc3
  jnewbery:
    ACK 33f5fc3.

Tree-SHA512: a001aa863090ec2566a31059477945b1c303ebeb430b33472f8b150e420fa5742fc33bca9d95571746395b607f43f6078dd5b53e238ac1f3fc648b51c8f79a07
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 1, 2020
…e docs

Summary:
33f5fc32e5bfbe1e89c4d20ce455bcc6dc194151 test: add rpc getaddressinfo labels test coverage (Jon Atack)
0f3539ac6d772fc646b5f184fa1efe77bf632f6a test: add listlabels test in wallet_labels.py (Jon Atack)
1388de83900eaced906d369fe9e8887ae74b2dcf rpc: add getaddressinfo code documentation (Jon Atack)
2ee0cb3330ccf70f0540cb42370796e32eff1569 rpc: update getaddressinfo RPCExamples to bech32 (Jon Atack)
8d1ed0c263f8cdff7189f02040b5d02238d93da0 rpc: clarify label vs labels in getaddressinfo RPCHelpman (Jon Atack)
5a0ed850700dfb19167d40b38f80313bd5e427ca rpc: improve getaddressinfo RPCHelpman content (Jon Atack)
70cda342cd20d0e0cd9f28405457544036968f2d rpc: improve getaddressinfo RPCHelpman formatting (Jon Atack)

Pull request description:

  This PR is a continuation of the work in bitcoin/bitcoin#12892.

  Main motivations:
  - There is currently no test coverage for the getaddressinfo `labels` response. Coverage here is a prerequisite before deprecating the `label` response or adding multiple labels per address.
  - `bitcoin-cli help getaddressinfo` returns a few content errors, difficult-to-read formatting, and no explanation why it returns both `label` and `labels` and how they relate, which can be confusing for application developers.

  Changes by order of commits:
  - [x] improve/fix getaddressinfo RPCHelpman layout formatting
  - [x] improve/fix getaddressinfo RPCHelpman content
  - [x] clarify the `label` and `labels` fields in getaddressinfo RPCHelpman
  - [x] update getaddressinfo RPCExamples addresses to bech32
  - [x] add getaddressinfo code docs
  - [x] add a `listlabels` test assertion in wallet_labels.py
  - [x] add missing getaddressinfo `labels` test coverage and improve the existing `label` tests

  Here are gists of the CLI help output:
  [`bitcoin-cli help getaddressinfo` before this PR](https://gist.github.com/jonatack/022af5221a85c069780359a22643c810)
  [`bitcoin-cli help getaddressinfo` after this PR](https://gist.github.com/jonatack/4ee5f6abc62a3d99269570206a5f90ba)

  It seems we ought to begin a deprecation process for the getaddressinfo `label` field? If yes, I have a follow-up ready. _--> EDIT: Deprecation follow-ups #17578 and #17585 now build on this PR._

---

Depends on D7716

Backport of Core [[bitcoin/bitcoin#17283 | PR17283]]

Test Plan:
  ninja all check check-functional

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7718
sidhujag pushed a commit to syscoin-core/syscoin that referenced this pull request Nov 10, 2020
… code docs

33f5fc3 test: add rpc getaddressinfo labels test coverage (Jon Atack)
0f3539a test: add listlabels test in wallet_labels.py (Jon Atack)
1388de8 rpc: add getaddressinfo code documentation (Jon Atack)
2ee0cb3 rpc: update getaddressinfo RPCExamples to bech32 (Jon Atack)
8d1ed0c rpc: clarify label vs labels in getaddressinfo RPCHelpman (Jon Atack)
5a0ed85 rpc: improve getaddressinfo RPCHelpman content (Jon Atack)
70cda34 rpc: improve getaddressinfo RPCHelpman formatting (Jon Atack)

Pull request description:

  This PR is a continuation of the work in bitcoin#12892.

  Main motivations:
  - There is currently no test coverage for the getaddressinfo `labels` response. Coverage here is a prerequisite before deprecating the `label` response or adding multiple labels per address.
  - `bitcoin-cli help getaddressinfo` returns a few content errors, difficult-to-read formatting, and no explanation why it returns both `label` and `labels` and how they relate, which can be confusing for application developers.

  Changes by order of commits:
  - [x] improve/fix getaddressinfo RPCHelpman layout formatting
  - [x] improve/fix getaddressinfo RPCHelpman content
  - [x] clarify the `label` and `labels` fields in getaddressinfo RPCHelpman
  - [x] update getaddressinfo RPCExamples addresses to bech32
  - [x] add getaddressinfo code docs
  - [x] add a `listlabels` test assertion in wallet_labels.py
  - [x] add missing getaddressinfo `labels` test coverage and improve the existing `label` tests

  Here are gists of the CLI help output:
  [`bitcoin-cli help getaddressinfo` before this PR](https://gist.github.com/jonatack/022af5221a85c069780359a22643c810)
  [`bitcoin-cli help getaddressinfo` after this PR](https://gist.github.com/jonatack/4ee5f6abc62a3d99269570206a5f90ba)

  It seems we ought to begin a deprecation process for the getaddressinfo `label` field? If yes, I have a follow-up ready. _--> EDIT: Deprecation follow-ups bitcoin#17578 and bitcoin#17585 now build on this PR._

ACKs for top commit:
  fjahr:
    Re-ACK 33f5fc3
  jnewbery:
    ACK 33f5fc3.

Tree-SHA512: a001aa863090ec2566a31059477945b1c303ebeb430b33472f8b150e420fa5742fc33bca9d95571746395b607f43f6078dd5b53e238ac1f3fc648b51c8f79a07
xdustinface pushed a commit to xdustinface/dash that referenced this pull request Dec 18, 2020
…llet

Add label API to wallet RPC.

This is one step towards dashpay#3816 ("Remove bolt-on account system") although it doesn't
actually remove anything yet.

These initially mirror the account functions, with the following differences:

- These functions aren't DEPRECATED in the help
- Help mentions 'label' instead of accounts. In the language used, labels are
  associated with addresses, instead of addresses associated with labels. (unlike
  with accounts.)
- Labels have no balance
  - No balances in `listlabels`
  - `listlabels` has no minconf or watchonly argument
- Like in the GUI, labels can be set on any address, not just receiving addreses
- Unlike accounts, labels can be deleted.
  Being unable to delete them is a common annoyance (see dashpay#1231).
  Currently only by reassigning all addresses using `setlabel`, but an explicit
  call `deletelabel` which assigns all address to the default label may make
  sense.

Thanks to Pierre Rochard for test fixes.
xdustinface pushed a commit to xdustinface/dash that referenced this pull request Dec 18, 2020
Add label API to wallet RPC.

This is one step towards dashpay#3816 ("Remove bolt-on account system") although it doesn't
actually remove anything yet.

These initially mirror the account functions, with the following differences:

- These functions aren't DEPRECATED in the help
- Help mentions 'label' instead of accounts. In the language used, labels are
  associated with addresses, instead of addresses associated with labels. (unlike
  with accounts.)
- Labels have no balance
  - No balances in `listlabels`
  - `listlabels` has no minconf or watchonly argument
- Like in the GUI, labels can be set on any address, not just receiving addreses
- Unlike accounts, labels can be deleted.
  Being unable to delete them is a common annoyance (see dashpay#1231).
  Currently only by reassigning all addresses using `setlabel`, but an explicit
  call `deletelabel` which assigns all address to the default label may make
  sense.

Thanks to Pierre Rochard for test fixes.
xdustinface pushed a commit to xdustinface/dash that referenced this pull request Dec 22, 2020
Add label API to wallet RPC.

This is one step towards dashpay#3816 ("Remove bolt-on account system") although it doesn't
actually remove anything yet.

These initially mirror the account functions, with the following differences:

- These functions aren't DEPRECATED in the help
- Help mentions 'label' instead of accounts. In the language used, labels are
  associated with addresses, instead of addresses associated with labels. (unlike
  with accounts.)
- Labels have no balance
  - No balances in `listlabels`
  - `listlabels` has no minconf or watchonly argument
- Like in the GUI, labels can be set on any address, not just receiving addreses
- Unlike accounts, labels can be deleted.
  Being unable to delete them is a common annoyance (see dashpay#1231).
  Currently only by reassigning all addresses using `setlabel`, but an explicit
  call `deletelabel` which assigns all address to the default label may make
  sense.

Thanks to Pierre Rochard for test fixes.
xdustinface pushed a commit to xdustinface/dash that referenced this pull request Dec 22, 2020
Add label API to wallet RPC.

This is one step towards dashpay#3816 ("Remove bolt-on account system") although it doesn't
actually remove anything yet.

These initially mirror the account functions, with the following differences:

- These functions aren't DEPRECATED in the help
- Help mentions 'label' instead of accounts. In the language used, labels are
  associated with addresses, instead of addresses associated with labels. (unlike
  with accounts.)
- Labels have no balance
  - No balances in `listlabels`
  - `listlabels` has no minconf or watchonly argument
- Like in the GUI, labels can be set on any address, not just receiving addreses
- Unlike accounts, labels can be deleted.
  Being unable to delete them is a common annoyance (see dashpay#1231).
  Currently only by reassigning all addresses using `setlabel`, but an explicit
  call `deletelabel` which assigns all address to the default label may make
  sense.

Thanks to Pierre Rochard for test fixes.
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Mar 12, 2022
Add label API to wallet RPC.

This is one step towards dashpay#3816 ("Remove bolt-on account system") although it doesn't
actually remove anything yet.

These initially mirror the account functions, with the following differences:

- These functions aren't DEPRECATED in the help
- Help mentions 'label' instead of accounts. In the language used, labels are
  associated with addresses, instead of addresses associated with labels. (unlike
  with accounts.)
- Labels have no balance
  - No balances in `listlabels`
  - `listlabels` has no minconf or watchonly argument
- Like in the GUI, labels can be set on any address, not just receiving addreses
- Unlike accounts, labels can be deleted.
  Being unable to delete them is a common annoyance (see dashpay#1231).
  Currently only by reassigning all addresses using `setlabel`, but an explicit
  call `deletelabel` which assigns all address to the default label may make
  sense.

Thanks to Pierre Rochard for test fixes.
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants