Skip to content

Commit 77d5bb7

Browse files
committed
wallet: Remove path checking code from createwallet RPC
This commit does not change behavior except for error messages which now include more complete information.
1 parent a987438 commit 77d5bb7

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,6 +2647,7 @@ static UniValue createwallet(const JSONRPCRequest& request)
26472647

26482648
DatabaseOptions options;
26492649
DatabaseStatus status;
2650+
options.require_create = true;
26502651
options.create_flags = flags;
26512652
options.create_passphrase = passphrase;
26522653
bilingual_str error;

src/wallet/wallet.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,6 @@ std::shared_ptr<CWallet> CreateWallet(interfaces::Chain& chain, const std::strin
253253
wallet_creation_flags |= WALLET_FLAG_BLANK_WALLET;
254254
}
255255

256-
// Check the wallet file location
257-
if (fs::symlink_status(fs::absolute(name.empty() ? "wallet.dat" : name, GetWalletDir())).type() != fs::file_not_found) {
258-
error = strprintf(Untranslated("Wallet %s already exists."), name);
259-
status = DatabaseStatus::FAILED_CREATE;
260-
return nullptr;
261-
}
262-
263256
// Wallet::Verify will check if we're trying to create a wallet with a duplicate name.
264257
std::unique_ptr<WalletDatabase> database = MakeWalletDatabase(name, options, status, error);
265258
if (!database) {

test/functional/wallet_multiwallet.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ def wallet_file(name):
273273
self.log.info("Test dynamic wallet creation.")
274274

275275
# Fail to create a wallet if it already exists.
276-
assert_raises_rpc_error(-4, "Wallet w2 already exists.", self.nodes[0].createwallet, 'w2')
276+
path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "w2")
277+
assert_raises_rpc_error(-4, "Failed to create database path '{}'. Database already exists.".format(path), self.nodes[0].createwallet, 'w2')
277278

278279
# Successfully create a wallet with a new name
279280
loadwallet_name = self.nodes[0].createwallet('w9')

0 commit comments

Comments
 (0)