Merge #19200: rpc: remove deprecated getaddressinfo fields

bc01f7ae05 doc: release note for rpc getaddressinfo removals (Jon Atack)
90e989390e rpc: getaddressinfo RPCResult fixup (Jon Atack)
a8507c99da rpc: remove deprecated getaddressinfo `labels: purpose` (Jon Atack)
645a8653c8 rpc: remove deprecated getaddressinfo `label` field (Jon Atack)

Pull request description:

  These were deprecated in #17578 and #17585, with expected 0.21 removal notified in the 0.20 release notes.
  ```
  - The `getaddressinfo` RPC has had its `label` field deprecated
    (re-enable for this release using the configuration parameter
    `-deprecatedrpc=label`).  The `labels` field is altered from returning
    JSON objects to returning a JSON array of label names (re-enable
    previous behavior for this release using the configuration parameter
    `-deprecatedrpc=labelspurpose`).  Backwards compatibility using the
    deprecated configuration parameters is expected to be dropped in the
    0.21 release.  (#17585, #17578)
  ```

ACKs for top commit:
  Sjors:
    utACK bc01f7a
  adamjonas:
    utACK bc01f7a
  meshcollider:
    utACK bc01f7ae05

Tree-SHA512: ae1af381e32c4c3bde8b061a56382838513a9a82c88767843cdeae3a2ab8aa7d8c2e66e106d2b31ea07d74bb80c191a2f842c9aaecc7c5438ad9a9bc66d1b251
This commit is contained in:
Samuel Dobson 2020-06-21 20:56:15 +12:00
commit 02b26ba1c1
No known key found for this signature in database
GPG key ID: D300116E1C875A3D
5 changed files with 12 additions and 118 deletions

View file

@ -0,0 +1,7 @@
## Wallet
- Backwards compatibility has been dropped for two `getaddressinfo` RPC
deprecations, as notified in the 0.20 release notes. The deprecated `label`
field has been removed as well as the deprecated `labels` behavior of
returning a JSON object containing `name` and `purpose` key-value pairs. Since
0.20, the `labels` field returns a JSON array of label names. (#19200)

View file

@ -3631,12 +3631,10 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
{RPCResult::Type::STR_HEX, "pubkey", /* optional */ true, "The hex value of the raw public key for single-key addresses (possibly embedded in P2SH or P2WSH)."}, {RPCResult::Type::STR_HEX, "pubkey", /* optional */ true, "The hex value of the raw public key for single-key addresses (possibly embedded in P2SH or P2WSH)."},
{RPCResult::Type::OBJ, "embedded", /* optional */ true, "Information about the address embedded in P2SH or P2WSH, if relevant and known.", {RPCResult::Type::OBJ, "embedded", /* optional */ true, "Information about the address embedded in P2SH or P2WSH, if relevant and known.",
{ {
{RPCResult::Type::ELISION, "", "Includes all\n" {RPCResult::Type::ELISION, "", "Includes all getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath, hdseedid)\n"
" getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath,\n" "and relation to the wallet (ismine, iswatchonly)."},
"hdseedid) and relation to the wallet (ismine, iswatchonly)."},
}}, }},
{RPCResult::Type::BOOL, "iscompressed", /* optional */ true, "If the pubkey is compressed."}, {RPCResult::Type::BOOL, "iscompressed", /* optional */ true, "If the pubkey is compressed."},
{RPCResult::Type::STR, "label", "DEPRECATED. The label associated with the address. Defaults to \"\". Replaced by the labels array below."},
{RPCResult::Type::NUM_TIME, "timestamp", /* optional */ true, "The creation time of the key, if available, expressed in " + UNIX_EPOCH_TIME + "."}, {RPCResult::Type::NUM_TIME, "timestamp", /* optional */ true, "The creation time of the key, if available, expressed in " + UNIX_EPOCH_TIME + "."},
{RPCResult::Type::STR, "hdkeypath", /* optional */ true, "The HD keypath, if the key is HD and available."}, {RPCResult::Type::STR, "hdkeypath", /* optional */ true, "The HD keypath, if the key is HD and available."},
{RPCResult::Type::STR_HEX, "hdseedid", /* optional */ true, "The Hash160 of the HD seed."}, {RPCResult::Type::STR_HEX, "hdseedid", /* optional */ true, "The Hash160 of the HD seed."},
@ -3644,12 +3642,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
{RPCResult::Type::ARR, "labels", "Array of labels associated with the address. Currently limited to one label but returned\n" {RPCResult::Type::ARR, "labels", "Array of labels associated with the address. Currently limited to one label but returned\n"
"as an array to keep the API stable if multiple labels are enabled in the future.", "as an array to keep the API stable if multiple labels are enabled in the future.",
{ {
{RPCResult::Type::STR, "label name", "The label name. Defaults to \"\"."}, {RPCResult::Type::STR, "label name", "Label name (defaults to \"\")."},
{RPCResult::Type::OBJ, "", "label data, DEPRECATED, will be removed in 0.21. To re-enable, launch bitcoind with `-deprecatedrpc=labelspurpose`",
{
{RPCResult::Type::STR, "name", "The label name. Defaults to \"\"."},
{RPCResult::Type::STR, "purpose", "The purpose of the associated address (send or receive)."},
}},
}}, }},
} }
}, },
@ -3695,14 +3688,6 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
UniValue detail = DescribeWalletAddress(pwallet, dest); UniValue detail = DescribeWalletAddress(pwallet, dest);
ret.pushKVs(detail); ret.pushKVs(detail);
// DEPRECATED: Return label field if existing. Currently only one label can
// be associated with an address, so the label should be equivalent to the
// value of the name key/value pair in the labels array below.
const auto* address_book_entry = pwallet->FindAddressBookEntry(dest);
if (pwallet->chain().rpcEnableDeprecated("label") && address_book_entry) {
ret.pushKV("label", address_book_entry->GetLabel());
}
ret.pushKV("ischange", pwallet->IsChange(scriptPubKey)); ret.pushKV("ischange", pwallet->IsChange(scriptPubKey));
ScriptPubKeyMan* spk_man = pwallet->GetScriptPubKeyMan(scriptPubKey); ScriptPubKeyMan* spk_man = pwallet->GetScriptPubKeyMan(scriptPubKey);
@ -3723,14 +3708,9 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
// stable if we allow multiple labels to be associated with an address in // stable if we allow multiple labels to be associated with an address in
// the future. // the future.
UniValue labels(UniValue::VARR); UniValue labels(UniValue::VARR);
const auto* address_book_entry = pwallet->FindAddressBookEntry(dest);
if (address_book_entry) { if (address_book_entry) {
// DEPRECATED: The previous behavior of returning an array containing a labels.push_back(address_book_entry->GetLabel());
// JSON object of `name` and `purpose` key/value pairs is deprecated.
if (pwallet->chain().rpcEnableDeprecated("labelspurpose")) {
labels.push_back(AddressBookDataToJSON(*address_book_entry, true));
} else {
labels.push_back(address_book_entry->GetLabel());
}
} }
ret.pushKV("labels", std::move(labels)); ret.pushKV("labels", std::move(labels));

View file

@ -1,43 +0,0 @@
#!/usr/bin/env python3
# Copyright (c) 2020-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""
Test deprecation of the RPC getaddressinfo `label` field. It has been
superseded by the `labels` field.
"""
from test_framework.test_framework import BitcoinTestFramework
class GetAddressInfoLabelDeprecationTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
self.setup_clean_chain = False
# Start node[0] with -deprecatedrpc=label, and node[1] without.
self.extra_args = [["-deprecatedrpc=label"], []]
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
def test_label_with_deprecatedrpc_flag(self):
self.log.info("Test getaddressinfo label with -deprecatedrpc flag")
node = self.nodes[0]
address = node.getnewaddress()
info = node.getaddressinfo(address)
assert "label" in info
def test_label_without_deprecatedrpc_flag(self):
self.log.info("Test getaddressinfo label without -deprecatedrpc flag")
node = self.nodes[1]
address = node.getnewaddress()
info = node.getaddressinfo(address)
assert "label" not in info
def run_test(self):
"""Test getaddressinfo label with and without -deprecatedrpc flag."""
self.test_label_with_deprecatedrpc_flag()
self.test_label_without_deprecatedrpc_flag()
if __name__ == '__main__':
GetAddressInfoLabelDeprecationTest().main()

View file

@ -1,48 +0,0 @@
#!/usr/bin/env python3
# Copyright (c) 2020 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""
Test deprecation of RPC getaddressinfo `labels` returning an array
containing a JSON object of `name` and purpose` key-value pairs. It now
returns an array containing only the label name.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
LABELS_TO_TEST = frozenset({"" , "New 𝅘𝅥𝅯 $<#>&!рыба Label"})
class GetAddressInfoLabelsPurposeDeprecationTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
self.setup_clean_chain = False
# Start node[0] with -deprecatedrpc=labelspurpose and node[1] without.
self.extra_args = [["-deprecatedrpc=labelspurpose"], []]
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
def test_labels(self, node_num, label_name, expected_value):
node = self.nodes[node_num]
address = node.getnewaddress()
if label_name != "":
node.setlabel(address, label_name)
self.log.info(" set label to {}".format(label_name))
labels = node.getaddressinfo(address)["labels"]
self.log.info(" labels = {}".format(labels))
assert_equal(labels, expected_value)
def run_test(self):
"""Test getaddressinfo labels with and without -deprecatedrpc flag."""
self.log.info("Test getaddressinfo labels with -deprecatedrpc flag")
for label in LABELS_TO_TEST:
self.test_labels(node_num=0, label_name=label, expected_value=[{"name": label, "purpose": "receive"}])
self.log.info("Test getaddressinfo labels without -deprecatedrpc flag")
for label in LABELS_TO_TEST:
self.test_labels(node_num=1, label_name=label, expected_value=[label])
if __name__ == '__main__':
GetAddressInfoLabelsPurposeDeprecationTest().main()

View file

@ -242,8 +242,6 @@ BASE_SCRIPTS = [
'p2p_permissions.py', 'p2p_permissions.py',
'feature_blocksdir.py', 'feature_blocksdir.py',
'feature_config_args.py', 'feature_config_args.py',
'rpc_getaddressinfo_labels_purpose_deprecation.py',
'rpc_getaddressinfo_label_deprecation.py',
'rpc_getdescriptorinfo.py', 'rpc_getdescriptorinfo.py',
'rpc_help.py', 'rpc_help.py',
'feature_help.py', 'feature_help.py',