From 5e65a216d1fd00c447757736d4f2899d235e731a Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Tue, 29 Nov 2022 16:05:51 -0500 Subject: [PATCH] wallet: Explicitly say migratewallet on encrypted wallets is unsupported --- src/wallet/rpc/wallet.cpp | 4 +++- test/functional/wallet_migration.py | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpc/wallet.cpp b/src/wallet/rpc/wallet.cpp index 675c4a759d0..971814e9cda 100644 --- a/src/wallet/rpc/wallet.cpp +++ b/src/wallet/rpc/wallet.cpp @@ -730,7 +730,9 @@ static RPCHelpMan migratewallet() std::shared_ptr wallet = GetWalletForJSONRPCRequest(request); if (!wallet) return NullUniValue; - EnsureWalletIsUnlocked(*wallet); + if (wallet->IsCrypted()) { + throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: migratewallet on encrypted wallets is currently unsupported."); + } WalletContext& context = EnsureWalletContext(request.context); diff --git a/test/functional/wallet_migration.py b/test/functional/wallet_migration.py index 355046c9af8..4f060f99606 100755 --- a/test/functional/wallet_migration.py +++ b/test/functional/wallet_migration.py @@ -399,8 +399,7 @@ class WalletMigrationTest(BitcoinTestFramework): wallet.encryptwallet("pass") - wallet.walletpassphrase("pass", 10) - assert_raises_rpc_error(-4, "Error: Unable to produce descriptors for this legacy wallet. Make sure the wallet is unlocked first", wallet.migratewallet) + assert_raises_rpc_error(-15, "Error: migratewallet on encrypted wallets is currently unsupported.", wallet.migratewallet) # TODO: Fix migratewallet so that we can actually migrate encrypted wallets def run_test(self):