From b914da3dea8a66aa835014cf40926d9214f53c12 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 5 Jul 2024 14:41:06 +0700 Subject: [PATCH] fix: createwallet to require 'load_on_startup' for descriptor wallets createwallet has changed list of arguments: createwallet "wallet_name" ( disable_private_keys blank "passphrase" avoid_reuse descriptors load_on_startup ) load_on_startup used to be an argument 5 but now has a number 6. Both arguments 5 and 6 are boolean and it can confuse an user. To prevent confusion if user is not aware about this breaking changes, the RPC createwallet throws an exception if user trying to create descriptor wallet but has not mentioned load_on_startup. This requirement can be removed when major amount of users updated to v21 --- src/wallet/rpcwallet.cpp | 3 +++ test/functional/test_framework/test_node.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2a7b557b311d95..a787ab66373b3d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3032,6 +3032,9 @@ static RPCHelpMan createwallet() #ifndef USE_SQLITE throw JSONRPCError(RPC_WALLET_ERROR, "Compiled without sqlite support (required for descriptor wallets)"); #endif + if (request.params[6].isNull()) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "RPC createwallet would not accept creating descriptor wallets without specifying 'load_on_startup' flag. It is required explicitly in v21 due to breaking changes in createwallet RPC"); + } flags |= WALLET_FLAG_DESCRIPTORS; warnings.emplace_back(Untranslated("Wallet is an experimental descriptor wallet")); } diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index b1d6f70bfa8322..d92b5bc4a364c6 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -704,6 +704,8 @@ def __getattr__(self, name): def createwallet(self, wallet_name, disable_private_keys=None, blank=None, passphrase='', avoid_reuse=None, descriptors=None, load_on_startup=None): if descriptors is None: descriptors = self.descriptors + if descriptors is not None and load_on_startup is None: + load_on_startup = False return self.__getattr__('createwallet')(wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors, load_on_startup) def importprivkey(self, privkey, label=None, rescan=None):