mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-13 16:20:20 +02:00
wallet: Allow MigrateLegacyToDescriptor to take a wallet name
An overload of MigrateLegacyToDescriptor is added which takes the wallet
name. The original that took a wallet pointer is still available, it
just gets the name, closes the wallet, and calls the new overload.
Github-Pull: #26595
Reabsed-From: dbfa345403
This commit is contained in:
@@ -727,16 +727,20 @@ static RPCHelpMan migratewallet()
|
||||
},
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
std::shared_ptr<CWallet> wallet = GetWalletForJSONRPCRequest(request);
|
||||
if (!wallet) return NullUniValue;
|
||||
std::string wallet_name;
|
||||
{
|
||||
std::shared_ptr<CWallet> wallet = GetWalletForJSONRPCRequest(request);
|
||||
if (!wallet) return NullUniValue;
|
||||
|
||||
if (wallet->IsCrypted()) {
|
||||
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: migratewallet on encrypted wallets is currently unsupported.");
|
||||
if (wallet->IsCrypted()) {
|
||||
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: migratewallet on encrypted wallets is currently unsupported.");
|
||||
}
|
||||
wallet_name = wallet->GetName();
|
||||
}
|
||||
|
||||
WalletContext& context = EnsureWalletContext(request.context);
|
||||
|
||||
util::Result<MigrationResult> res = MigrateLegacyToDescriptor(std::move(wallet), context);
|
||||
util::Result<MigrationResult> res = MigrateLegacyToDescriptor(wallet_name, context);
|
||||
if (!res) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, util::ErrorString(res).original);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user