aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/rpc/util.cpp
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2022-03-25 22:41:21 +0000
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2022-03-25 22:47:29 +0000
commitf59959e3818692c5b3c2dfa51c14e515085e940f (patch)
tree4a12506f5469cedbbc8c0cc825c8b1870ea7aa1e /src/wallet/rpc/util.cpp
parent2f0f056e08cd5a1435120592a9ecd212fcdb915b (diff)
downloadbitcoin-f59959e3818692c5b3c2dfa51c14e515085e940f.tar.xz
wallet: Prevent wallet unload on GetWalletForJSONRPCRequest
Don't extend shared ownership of all wallets to GetWalletForJSONRPCRequest scope.
Diffstat (limited to 'src/wallet/rpc/util.cpp')
-rw-r--r--src/wallet/rpc/util.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/wallet/rpc/util.cpp b/src/wallet/rpc/util.cpp
index 59683c5fd8..f788d0d2d3 100644
--- a/src/wallet/rpc/util.cpp
+++ b/src/wallet/rpc/util.cpp
@@ -64,12 +64,11 @@ std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& reques
return pwallet;
}
- std::vector<std::shared_ptr<CWallet>> wallets = GetWallets(context);
- if (wallets.size() == 1) {
- return wallets[0];
- }
+ size_t count{0};
+ auto wallet = GetDefaultWallet(context, count);
+ if (wallet) return wallet;
- if (wallets.empty()) {
+ if (count == 0) {
throw JSONRPCError(
RPC_WALLET_NOT_FOUND, "No wallet is loaded. Load a wallet using loadwallet or create a new one with createwallet. (Note: A default wallet is no longer automatically created)");
}