mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-01 17:29:22 +02:00
Merge bitcoin/bitcoin#31250: wallet: Disable creating and loading legacy wallets
17bb63f9f9wallet: Disallow loading legacy wallets (Ava Chow)9f04e02ffawallet: Disallow creating legacy wallets (Ava Chow)6b247279b7wallet: Disallow legacy wallet creation from the wallet tool (Ava Chow)5e93b1fd6cbench: Remove WalletLoadingLegacy benchmark (Ava Chow)56f959d829wallet: Remove wallettool salvage (Ava Chow)7a41c939f0wallet: Remove -format and bdb from wallet tool's createfromdump (Ava Chow)c847dee148test: remove legacy wallet functional tests (Ava Chow)20a9173717test: Remove legacy wallet tests from wallet_reindex.py (Ava Chow)446d480cb2test: Remove legacy wallet tests from wallet_backwards_compatibility.py (Ava Chow)aff80298d0test: wallet_signer.py bdb will be removed (Ava Chow)f94f9399actest: Remove legacy wallet unit tests (Ava Chow)d9ac9dbd8etests, gui: Use descriptors watchonly wallet for watchonly test (Ava Chow) Pull request description: To prepare for the deletion of legacy wallet code, disable creating or loading new legacy wallets. Tests for the legacy wallet specifically are deleted. Split from https://github.com/bitcoin/bitcoin/pull/28710 ACKs for top commit: Sjors: re-ACK17bb63f9f9pablomartin4btc: re-ACK17bb63f9f9laanwj: re-ACK17bb63f9f9Tree-SHA512: d7a86df1f71f12451b335f22f7c3f0394166ac3f8f5b81f6bbf0321026e2e8ed621576656c371d70e202df1be4410b2b1c1acb5d5f0c341e7b67aaa0ac792e7c
This commit is contained in:
@@ -151,7 +151,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
self.supports_cli = True
|
||||
self.bind_to_localhost_only = True
|
||||
self.parse_args(test_file)
|
||||
self.default_wallet_name = "default_wallet" if self.options.descriptors else ""
|
||||
self.default_wallet_name = "default_wallet"
|
||||
self.wallet_data_filename = "wallet.dat"
|
||||
# Optional list of wallet names that can be set in set_test_params to
|
||||
# create and import keys to. If unset, default is len(nodes) *
|
||||
@@ -160,8 +160,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
# are not imported.
|
||||
self.wallet_names = None
|
||||
# By default the wallet is not required. Set to true by skip_if_no_wallet().
|
||||
# When False, we ignore wallet_names regardless of what it is.
|
||||
self._requires_wallet = False
|
||||
# Can also be set to None to indicate that the wallet will be used if available.
|
||||
# When False or None, we ignore wallet_names regardless of what it is.
|
||||
self.uses_wallet = False
|
||||
# Disable ThreadOpenConnections by default, so that adding entries to
|
||||
# addrman will not result in automatic connections to them.
|
||||
self.disable_autoconnect = True
|
||||
@@ -271,20 +272,6 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
if self.options.v1transport:
|
||||
self.options.v2transport=False
|
||||
|
||||
if "descriptors" not in self.options:
|
||||
# Wallet is not required by the test at all and the value of self.options.descriptors won't matter.
|
||||
# It still needs to exist and be None in order for tests to work however.
|
||||
# So set it to None to force -disablewallet, because the wallet is not needed.
|
||||
self.options.descriptors = None
|
||||
elif self.options.descriptors is None:
|
||||
if self.is_wallet_compiled():
|
||||
self.options.descriptors = True
|
||||
else:
|
||||
# Tests requiring a wallet will be skipped and the value of self.options.descriptors won't matter
|
||||
# It still needs to exist and be None in order for tests to work however.
|
||||
# So set it to None, which will also set -disablewallet.
|
||||
self.options.descriptors = None
|
||||
|
||||
PortSeed.n = self.options.port_seed
|
||||
|
||||
def get_binary_paths(self):
|
||||
@@ -472,7 +459,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
"""Override this method to customize test node setup"""
|
||||
self.add_nodes(self.num_nodes, self.extra_args)
|
||||
self.start_nodes()
|
||||
if self._requires_wallet:
|
||||
if self.uses_wallet:
|
||||
self.import_deterministic_coinbase_privkeys()
|
||||
if not self.setup_clean_chain:
|
||||
for n in self.nodes:
|
||||
@@ -497,7 +484,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
if wallet_name is not False:
|
||||
n = self.nodes[node]
|
||||
if wallet_name is not None:
|
||||
n.createwallet(wallet_name=wallet_name, descriptors=self.options.descriptors, load_on_startup=True)
|
||||
n.createwallet(wallet_name=wallet_name, load_on_startup=True)
|
||||
n.importprivkey(privkey=n.get_deterministic_priv_key().key, label='coinbase', rescan=True)
|
||||
|
||||
# Only enables wallet support when the module is available
|
||||
@@ -510,21 +497,6 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
|
||||
# Public helper methods. These can be accessed by the subclass test scripts.
|
||||
|
||||
def add_wallet_options(self, parser, *, descriptors=True, legacy=True):
|
||||
kwargs = {}
|
||||
if descriptors + legacy == 1:
|
||||
# If only one type can be chosen, set it as default
|
||||
kwargs["default"] = descriptors
|
||||
group = parser.add_mutually_exclusive_group(
|
||||
# If only one type is allowed, require it to be set in test_runner.py
|
||||
required=os.getenv("REQUIRE_WALLET_TYPE_SET") == "1" and "default" in kwargs)
|
||||
if descriptors:
|
||||
group.add_argument("--descriptors", action='store_const', const=True, **kwargs,
|
||||
help="Run test using a descriptor wallet", dest='descriptors')
|
||||
if legacy:
|
||||
group.add_argument("--legacy-wallet", action='store_const', const=False, **kwargs,
|
||||
help="Run test using legacy wallets", dest='descriptors')
|
||||
|
||||
def add_nodes(self, num_nodes: int, extra_args=None, *, rpchost=None, versions=None):
|
||||
"""Instantiate TestNode objects.
|
||||
|
||||
@@ -598,8 +570,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
use_cli=self.options.usecli,
|
||||
start_perf=self.options.perf,
|
||||
use_valgrind=self.options.valgrind,
|
||||
descriptors=self.options.descriptors,
|
||||
v2transport=self.options.v2transport,
|
||||
uses_wallet=self.uses_wallet,
|
||||
)
|
||||
self.nodes.append(test_node_i)
|
||||
if not test_node_i.version_is_at_least(170000):
|
||||
@@ -903,7 +875,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
binaries=self.get_binaries(),
|
||||
coverage_dir=None,
|
||||
cwd=self.options.tmpdir,
|
||||
descriptors=self.options.descriptors,
|
||||
uses_wallet=self.uses_wallet,
|
||||
))
|
||||
self.start_node(CACHE_NODE_ID)
|
||||
cache_node = self.nodes[CACHE_NODE_ID]
|
||||
@@ -1006,11 +978,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
|
||||
def skip_if_no_wallet(self):
|
||||
"""Skip the running test if wallet has not been compiled."""
|
||||
self._requires_wallet = True
|
||||
self.uses_wallet = True
|
||||
if not self.is_wallet_compiled():
|
||||
raise SkipTest("wallet has not been compiled.")
|
||||
if not self.options.descriptors:
|
||||
self.skip_if_no_bdb()
|
||||
|
||||
def skip_if_no_bdb(self):
|
||||
"""Skip the running test if BDB has not been compiled."""
|
||||
@@ -1067,14 +1037,6 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
"""Checks whether the wallet module was compiled."""
|
||||
return self.config["components"].getboolean("ENABLE_WALLET")
|
||||
|
||||
def is_specified_wallet_compiled(self):
|
||||
"""Checks whether wallet support for the specified type
|
||||
(legacy or descriptor wallet) was compiled."""
|
||||
if self.options.descriptors:
|
||||
return self.is_wallet_compiled()
|
||||
else:
|
||||
return self.is_bdb_compiled()
|
||||
|
||||
def is_wallet_tool_compiled(self):
|
||||
"""Checks whether bitcoin-wallet was compiled."""
|
||||
return self.config["components"].getboolean("ENABLE_WALLET_TOOL")
|
||||
|
||||
@@ -77,7 +77,7 @@ class TestNode():
|
||||
To make things easier for the test writer, any unrecognised messages will
|
||||
be dispatched to the RPC connection."""
|
||||
|
||||
def __init__(self, i, datadir_path, *, chain, rpchost, timewait, timeout_factor, binaries, coverage_dir, cwd, extra_conf=None, extra_args=None, use_cli=False, start_perf=False, use_valgrind=False, version=None, descriptors=False, v2transport=False):
|
||||
def __init__(self, i, datadir_path, *, chain, rpchost, timewait, timeout_factor, binaries, coverage_dir, cwd, extra_conf=None, extra_args=None, use_cli=False, start_perf=False, use_valgrind=False, version=None, v2transport=False, uses_wallet=False):
|
||||
"""
|
||||
Kwargs:
|
||||
start_perf (bool): If True, begin profiling the node with `perf` as soon as
|
||||
@@ -96,7 +96,6 @@ class TestNode():
|
||||
self.binaries = binaries
|
||||
self.coverage_dir = coverage_dir
|
||||
self.cwd = cwd
|
||||
self.descriptors = descriptors
|
||||
self.has_explicit_bind = False
|
||||
if extra_conf is not None:
|
||||
append_config(self.datadir_path, extra_conf)
|
||||
@@ -119,7 +118,7 @@ class TestNode():
|
||||
"-debugexclude=rand",
|
||||
"-uacomment=testnode%d" % i, # required for subversion uniqueness across peers
|
||||
]
|
||||
if self.descriptors is None:
|
||||
if uses_wallet is not None and not uses_wallet:
|
||||
self.args.append("-disablewallet")
|
||||
|
||||
# Use valgrind, expect for previous release binaries
|
||||
@@ -210,10 +209,10 @@ class TestNode():
|
||||
def __getattr__(self, name):
|
||||
"""Dispatches any unrecognised messages to the RPC connection or a CLI instance."""
|
||||
if self.use_cli:
|
||||
return getattr(RPCOverloadWrapper(self.cli, True, self.descriptors), name)
|
||||
return getattr(RPCOverloadWrapper(self.cli, True), name)
|
||||
else:
|
||||
assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
|
||||
return getattr(RPCOverloadWrapper(self.rpc, descriptors=self.descriptors), name)
|
||||
return getattr(RPCOverloadWrapper(self.rpc), name)
|
||||
|
||||
def start(self, extra_args=None, *, cwd=None, stdout=None, stderr=None, env=None, **kwargs):
|
||||
"""Start the node."""
|
||||
@@ -375,11 +374,11 @@ class TestNode():
|
||||
|
||||
def get_wallet_rpc(self, wallet_name):
|
||||
if self.use_cli:
|
||||
return RPCOverloadWrapper(self.cli("-rpcwallet={}".format(wallet_name)), True, self.descriptors)
|
||||
return RPCOverloadWrapper(self.cli("-rpcwallet={}".format(wallet_name)), True)
|
||||
else:
|
||||
assert self.rpc_connected and self.rpc, self._node_msg("RPC not connected")
|
||||
wallet_path = "wallet/{}".format(urllib.parse.quote(wallet_name))
|
||||
return RPCOverloadWrapper(self.rpc / wallet_path, descriptors=self.descriptors)
|
||||
return RPCOverloadWrapper(self.rpc / wallet_path)
|
||||
|
||||
def version_is_at_least(self, ver):
|
||||
return self.version is None or self.version >= ver
|
||||
@@ -926,10 +925,9 @@ class TestNodeCLI():
|
||||
return cli_stdout.rstrip("\n")
|
||||
|
||||
class RPCOverloadWrapper():
|
||||
def __init__(self, rpc, cli=False, descriptors=False):
|
||||
def __init__(self, rpc, cli=False):
|
||||
self.rpc = rpc
|
||||
self.is_cli = cli
|
||||
self.descriptors = descriptors
|
||||
|
||||
def __getattr__(self, name):
|
||||
return getattr(self.rpc, name)
|
||||
@@ -937,11 +935,6 @@ class RPCOverloadWrapper():
|
||||
def createwallet_passthrough(self, *args, **kwargs):
|
||||
return self.__getattr__("createwallet")(*args, **kwargs)
|
||||
|
||||
def createwallet(self, wallet_name, disable_private_keys=None, blank=None, passphrase='', avoid_reuse=None, descriptors=None, load_on_startup=None, external_signer=None):
|
||||
if descriptors is None:
|
||||
descriptors = self.descriptors
|
||||
return self.__getattr__('createwallet')(wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors, load_on_startup, external_signer)
|
||||
|
||||
def importprivkey(self, privkey, label=None, rescan=None):
|
||||
wallet_info = self.getwalletinfo()
|
||||
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
|
||||
|
||||
@@ -18,11 +18,8 @@ class TestShell:
|
||||
start a single TestShell at a time."""
|
||||
|
||||
class __TestShell(BitcoinTestFramework):
|
||||
def add_options(self, parser):
|
||||
self.add_wallet_options(parser)
|
||||
|
||||
def set_test_params(self):
|
||||
pass
|
||||
self.uses_wallet = None
|
||||
|
||||
def run_test(self):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user