mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 11:32:46 +01:00
984aae497d
d3bc18408146e91b3836f72360ff6fa2420b6887 doc: update release notes with getaddressinfo label deprecation (Jon Atack) 72af93f36479dc12d795f1d05fa3d8fbd9b293bd test: getaddressinfo label deprecation test (Jon Atack) d48875fa20d0b71b978cb3d1f85dd9ec14e664cc rpc: deprecate getaddressinfo label field (Jon Atack) dc0cabeda49a7edbfa71df22846721b6f6224aea test: remove getaddressinfo label tests (Jon Atack) c7654af6f830577a54df12b5d65df93532db0dc2 doc: address pr17578 review feedback (Jon Atack) Pull request description: This PR builds on #17578 (now merged) and deprecates the rpc getaddressinfo `label` field. The deprecated behavior can be re-enabled by starting bitcoind with `-deprecatedrpc=label`. See http://www.erisian.com.au/bitcoin-core-dev/log-2019-11-22.html#l-622 and https://github.com/bitcoin/bitcoin/pull/17283#issuecomment-554458001 for more context. Reviewers: This PR may be tested manually by building, then running bitcoind with and without the `-deprecatedrpc=label` flag while verifying the rpc getaddressinfo output and help text. Next step: add support for multiple labels. ACKs for top commit: jnewbery: ACK d3bc18408146e91b3836f72360ff6fa2420b6887 laanwj: ACK d3bc18408146e91b3836f72360ff6fa2420b6887 meshcollider: utACK d3bc18408146e91b3836f72360ff6fa2420b6887 Tree-SHA512: f954402884ec54977def332c8160fd892f289b0d2aee1e91fed9ac3220f7e5b1f7fc6421b84cc7a5c824a0582eca4e6fc194e4e33ddd378c733c8941ac45f56d
122 lines
4.4 KiB
Python
Executable File
122 lines
4.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2018-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 the behavior of RPC importprivkey on set and unset labels of
|
|
addresses.
|
|
|
|
It tests different cases in which an address is imported with importaddress
|
|
with or without a label and then its private key is imported with importprivkey
|
|
with and without a label.
|
|
"""
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.wallet_util import test_address
|
|
|
|
|
|
class ImportWithLabel(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.num_nodes = 2
|
|
self.setup_clean_chain = True
|
|
|
|
def skip_test_if_missing_module(self):
|
|
self.skip_if_no_wallet()
|
|
|
|
def run_test(self):
|
|
"""Main test logic"""
|
|
|
|
self.log.info(
|
|
"Test importaddress with label and importprivkey without label."
|
|
)
|
|
self.log.info("Import a watch-only address with a label.")
|
|
address = self.nodes[0].getnewaddress()
|
|
label = "Test Label"
|
|
self.nodes[1].importaddress(address, label)
|
|
test_address(self.nodes[1],
|
|
address,
|
|
iswatchonly=True,
|
|
ismine=False,
|
|
labels=[label])
|
|
|
|
self.log.info(
|
|
"Import the watch-only address's private key without a "
|
|
"label and the address should keep its label."
|
|
)
|
|
priv_key = self.nodes[0].dumpprivkey(address)
|
|
self.nodes[1].importprivkey(priv_key)
|
|
test_address(self.nodes[1], address, labels=[label])
|
|
|
|
self.log.info(
|
|
"Test importaddress without label and importprivkey with label."
|
|
)
|
|
self.log.info("Import a watch-only address without a label.")
|
|
address2 = self.nodes[0].getnewaddress()
|
|
self.nodes[1].importaddress(address2)
|
|
test_address(self.nodes[1],
|
|
address2,
|
|
iswatchonly=True,
|
|
ismine=False,
|
|
labels=[""])
|
|
|
|
self.log.info(
|
|
"Import the watch-only address's private key with a "
|
|
"label and the address should have its label updated."
|
|
)
|
|
priv_key2 = self.nodes[0].dumpprivkey(address2)
|
|
label2 = "Test Label 2"
|
|
self.nodes[1].importprivkey(priv_key2, label2)
|
|
|
|
test_address(self.nodes[1], address2, labels=[label2])
|
|
|
|
self.log.info("Test importaddress with label and importprivkey with label.")
|
|
self.log.info("Import a watch-only address with a label.")
|
|
address3 = self.nodes[0].getnewaddress()
|
|
label3_addr = "Test Label 3 for importaddress"
|
|
self.nodes[1].importaddress(address3, label3_addr)
|
|
test_address(self.nodes[1],
|
|
address3,
|
|
iswatchonly=True,
|
|
ismine=False,
|
|
labels=[label3_addr])
|
|
|
|
self.log.info(
|
|
"Import the watch-only address's private key with a "
|
|
"label and the address should have its label updated."
|
|
)
|
|
priv_key3 = self.nodes[0].dumpprivkey(address3)
|
|
label3_priv = "Test Label 3 for importprivkey"
|
|
self.nodes[1].importprivkey(priv_key3, label3_priv)
|
|
|
|
test_address(self.nodes[1], address3, labels=[label3_priv])
|
|
|
|
self.log.info(
|
|
"Test importprivkey won't label new dests with the same "
|
|
"label as others labeled dests for the same key."
|
|
)
|
|
self.log.info("Import a watch-only legacy address with a label.")
|
|
address4 = self.nodes[0].getnewaddress()
|
|
label4_addr = "Test Label 4 for importaddress"
|
|
self.nodes[1].importaddress(address4, label4_addr)
|
|
test_address(self.nodes[1],
|
|
address4,
|
|
iswatchonly=True,
|
|
ismine=False,
|
|
labels=[label4_addr])
|
|
|
|
self.log.info(
|
|
"Import the watch-only address's private key without a "
|
|
"label and new destinations for the key should have an "
|
|
"empty label while the 'old' destination should keep "
|
|
"its label."
|
|
)
|
|
priv_key4 = self.nodes[0].dumpprivkey(address4)
|
|
self.nodes[1].importprivkey(priv_key4)
|
|
|
|
test_address(self.nodes[1], address4, labels=[label4_addr])
|
|
|
|
self.stop_nodes()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
ImportWithLabel().main()
|