rpc: Add load_wallet argument to migratewallet RPC
What changed, and why it matters
This commit adds a new optional 'load_wallet' argument to the 'migratewallet' RPC command in Bitcoin Core. It lets users choose whether the wallet should be automatically loaded after migration, defaulting to true to preserve existing behavior. There is no direct evidence in the commit that this fixes a security vulnerability; it appears to be a usability or workflow improvement.
No immediate security action required. Review the downstream MigrateLegacyToDescriptor implementation to confirm the load_wallet flag is handled safely, but the change itself is a low-risk feature addition.
Security signals we found
No security-relevant keywords in commit title or message
No input validation, parsing, or memory-safety changes observed
New boolean argument defaults to true, preserving prior behavior
No references to CVE, security advisory, bug bounty, or researcher attribution in commit materials
Evidence from the diff
The change registers a new boolean RPC parameter ‘load_wallet’ at position 2 for migratewallet and passes it through to MigrateLegacyToDescriptor(). The default is true, so existing callers are unaffected. It allows migration workflows where the migrated wallet is not immediately loaded into memory. The commit does not describe any security bug, boundary issue, or vulnerability being fixed.
Changed components
src/rpc/client.cppsrc/wallet/rpc/wallet.cppmigratewallet RPCMigrateLegacyToDescriptor wallet migration pathInspect captured patch +5 / −1
diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp
index a28543fb..4741df8a 100644
--- a/src/rpc/client.cpp
+++ b/src/rpc/client.cpp
@@ -388,6 +388,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "loadtxoutset", 0, "path", ParamFormat::STRING },
{ "migratewallet", 0, "wallet_name", ParamFormat::STRING },
{ "migratewallet", 1, "passphrase", ParamFormat::STRING },
+ { "migratewallet", 2, "load_wallet"},
{ "setlabel", 1, "label", ParamFormat::STRING },
{ "signmessage", 1, "message", ParamFormat::STRING },
{ "signmessagewithprivkey", 1, "message", ParamFormat::STRING },
diff --git a/src/wallet/rpc/wallet.cpp b/src/wallet/rpc/wallet.cpp
index df40e51e..1dd668c0 100644
--- a/src/wallet/rpc/wallet.cpp
+++ b/src/wallet/rpc/wallet.cpp
@@ -593,6 +593,7 @@ static RPCMethod migratewallet()
{
{"wallet_name", RPCArg::Type::STR, RPCArg::DefaultHint{"the wallet name from the RPC endpoint"}, "The name of the wallet to migrate. If provided both here and in the RPC endpoint, the two must be identical."},
{"passphrase", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "The wallet passphrase"},
+ {"load_wallet", RPCArg::Type::BOOL, RPCArg::Default{true}, "Load the wallet after migration."},
},
RPCResult{
RPCResult::Type::OBJ, "", "",
@@ -617,8 +618,10 @@ static RPCMethod migratewallet()
wallet_pass = std::string_view{request.params[1].get_str()};
}
+ const bool loadwallet = self.Arg<bool>("load_wallet");
+
WalletContext& context = EnsureWalletContext(request.context);
- util::Result<MigrationResult> res = MigrateLegacyToDescriptor(wallet_name, wallet_pass, context);
+ util::Result<MigrationResult> res = MigrateLegacyToDescriptor(wallet_name, wallet_pass, context, loadwallet);
if (!res) {
throw JSONRPCError(RPC_WALLET_ERROR, util::ErrorString(res).original);
}
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.