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 (that would be a follow-up pull).
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. (in contrast to accounts.)
- Labels have no balance
- No
getreceivedbylabel
- No balances in
listlabels
listreceivedbylabel
can show received transactions to addresses with a label, not use the account tally (currently it is removed, but according to discussion that goes too far as this doesn’t inherently have to do with balance)listlabels
has no minconf or watchonly argument- Remove
move
- No
- 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 calldeletelabel
which assigns all address to the default label may make sense. - These calls stay the same, with
account
argument renamed tolabel
:importaddress
importprivkey
importpubkey
API
Short description of every RPC call: for detailed information check RPC help. The general idea is to offer the same functionality as the GUI label system. Labels are simply a name for an address, or a group of addresses.
Do not use the deprecated account system and the label system with the same wallet at the same time. These APIs use the same underlying data in the database for (slightly) different purposes, using them interchangeably will give unexpected results. (Just like using the GUI labels and account system at the same time. Using the GUI labels and the label API at the same time, however, is no problem)
getlabel
: returns the label (and other address book data) associated with an address- This exposes the fields in the CAddressBookData structure, which is currently the ‘purpose’ (sending address, receiving address) and ‘destdata’ (used for storing payment requests IIRC)
getaddressesbylabel
: get addresses labelled with one labellistlabels
: list all labels (or labels with a certain purpose, such as receive/send)setlabel
: assign a label to an addressgetlabeladdress
: get the ’label address’ for the specified label. This gets an unused address with the label, creating one if necessary should be removed according to discussion
These calls have a deprecated account parameter, which can be turned into a label-parameter as is:
listtransactions
Open questions
- Should there be such a thing as a ’label address’? My initial feeling about this was ’no’, labels are just a name for one or more addresses, intuitively there is no “default address”, and it also isn’t a GUI feature (->no)