Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14864453
D17953.id53568.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D17953.id53568.diff
View Options
diff --git a/src/rpc/protocol.h b/src/rpc/protocol.h
--- a/src/rpc/protocol.h
+++ b/src/rpc/protocol.h
@@ -109,6 +109,8 @@
RPC_WALLET_NOT_FOUND = -18,
//! No wallet specified (error when there are multiple wallets loaded)
RPC_WALLET_NOT_SPECIFIED = -19,
+ //! This same wallet is already loaded
+ RPC_WALLET_ALREADY_LOADED = -35,
//! Backwards compatible aliases
RPC_WALLET_INVALID_ACCOUNT_NAME = RPC_WALLET_INVALID_LABEL_NAME,
diff --git a/src/wallet/rpc/util.cpp b/src/wallet/rpc/util.cpp
--- a/src/wallet/rpc/util.cpp
+++ b/src/wallet/rpc/util.cpp
@@ -149,10 +149,19 @@
// Map bad format to not found, since bad format is returned
// when the wallet directory exists, but doesn't contain a data
// file.
- RPCErrorCode code = status == DatabaseStatus::FAILED_NOT_FOUND ||
- status == DatabaseStatus::FAILED_BAD_FORMAT
- ? RPC_WALLET_NOT_FOUND
- : RPC_WALLET_ERROR;
+ RPCErrorCode code = RPC_WALLET_ERROR;
+ switch (status) {
+ case DatabaseStatus::FAILED_NOT_FOUND:
+ case DatabaseStatus::FAILED_BAD_FORMAT:
+ code = RPC_WALLET_NOT_FOUND;
+ break;
+ case DatabaseStatus::FAILED_ALREADY_LOADED:
+ code = RPC_WALLET_ALREADY_LOADED;
+ break;
+ default:
+ // RPC_WALLET_ERROR is returned for all other cases.
+ break;
+ }
throw JSONRPCError(code, error.original);
}
diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py
--- a/test/functional/wallet_multiwallet.py
+++ b/test/functional/wallet_multiwallet.py
@@ -448,7 +448,7 @@
"wallet.dat",
)
assert_raises_rpc_error(
- -4,
+ -35,
"Wallet file verification failed. Refusing to load database. "
f"Data file '{path}' is already loaded.",
self.nodes[0].loadwallet,
@@ -466,7 +466,7 @@
"wallet.dat",
)
assert_raises_rpc_error(
- -4,
+ -35,
"Wallet file verification failed. Refusing to load database. "
f"Data file '{path}' is already loaded.",
self.nodes[0].loadwallet,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 20, 19:50 (8 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5865816
Default Alt Text
D17953.id53568.diff (2 KB)
Attached To
D17953: rpc: Add specific error code for "wallet already loaded"
Event Timeline
Log In to Comment