rpc: remove deprecated getaddressinfo label field

This commit is contained in:
Jon Atack 2020-06-06 20:30:50 +02:00
parent b1b1739944
commit 645a8653c8
No known key found for this signature in database
GPG key ID: 4F5721B3D0E3921D
3 changed files with 1 additions and 53 deletions

View file

@ -3746,7 +3746,6 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
"hdseedid) and relation to the wallet (ismine, iswatchonly)."},
}},
{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::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."},
@ -3801,14 +3800,6 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
UniValue detail = DescribeWalletAddress(pwallet, dest);
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));
ScriptPubKeyMan* spk_man = pwallet->GetScriptPubKeyMan(scriptPubKey);
@ -3829,6 +3820,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
// stable if we allow multiple labels to be associated with an address in
// the future.
UniValue labels(UniValue::VARR);
const auto* address_book_entry = pwallet->FindAddressBookEntry(dest);
if (address_book_entry) {
// DEPRECATED: The previous behavior of returning an array containing a
// JSON object of `name` and `purpose` key/value pairs is deprecated.

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

@ -241,7 +241,6 @@ BASE_SCRIPTS = [
'feature_blocksdir.py',
'feature_config_args.py',
'rpc_getaddressinfo_labels_purpose_deprecation.py',
'rpc_getaddressinfo_label_deprecation.py',
'rpc_getdescriptorinfo.py',
'rpc_help.py',
'feature_help.py',