rpc: remove deprecated getaddressinfo `labels: purpose`

pull/19200/head
Jon Atack 5 years ago
parent 645a8653c8
commit a8507c99da
No known key found for this signature in database
GPG Key ID: 4F5721B3D0E3921D

@ -3753,12 +3753,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)."},
}},
}}, }},
} }
}, },
@ -3822,13 +3817,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
UniValue labels(UniValue::VARR); UniValue labels(UniValue::VARR);
const auto* address_book_entry = pwallet->FindAddressBookEntry(dest); 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));

@ -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()

@ -240,7 +240,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_getdescriptorinfo.py', 'rpc_getdescriptorinfo.py',
'rpc_help.py', 'rpc_help.py',
'feature_help.py', 'feature_help.py',

Loading…
Cancel
Save