Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0bc23ef
Update wallet_importprunedfunds to avoid dumpprivkey
achow101 Apr 3, 2020
90dfb1f
Use a separate watchonly wallet in rpc_fundrawtransaction.py
achow101 Apr 4, 2020
2a1619b
Make import tests in wallet_listtransactions.py legacy wallet only
achow101 Apr 6, 2020
f337bd8
Avoid dumpprivkey in wallet_listsinceblock.py
achow101 Apr 6, 2020
93a59c6
Use importdescriptors for descriptor wallets in wallet_bumpfee.py
achow101 Apr 6, 2020
6e0ad04
Move import and watchonly tests to be legacy wallet only in wallet_ba…
achow101 Apr 6, 2020
11ae325
Use separate watchonly wallet for multisig in feature_nulldummy.py
achow101 Apr 6, 2020
f27138a
Add descriptor wallet output to tool_wallet.py
achow101 Apr 6, 2020
6b98833
Add script equivalent of functions in address.py
achow101 Apr 7, 2020
de5ec3f
Avoid dumpprivkey and watchonly behavior in rpc_signrawtransaction.py
achow101 Apr 7, 2020
1d54a4a
Use importdescriptors when in descriptor wallet mode in wallet_create…
achow101 Apr 7, 2020
9ece42a
Do addmultisigaddress tests in legacy wallet mode in wallet_address_t…
achow101 Apr 7, 2020
e83a076
Make raw multisig tests legacy wallet only in rpc_rawtransaction.py
achow101 Apr 8, 2020
e4c9e4c
Ensure a legacy wallet for BDB format check
achow101 Oct 21, 2020
39ec320
tests: Add a --legacy-wallet that is mutually exclusive with --descri…
achow101 Apr 27, 2020
e8e49d4
Update wallet_labels.py to not require descriptors=False
achow101 Oct 26, 2020
1b49997
Disable some tests for tool_wallet when descriptors
achow101 Oct 27, 2020
57b3bfb
Update feature_backwards_compatibility for descriptor wallets
achow101 Oct 27, 2020
20676bf
Avoid creating legacy wallets in wallet_importdescriptors.py
achow101 Oct 27, 2020
f0d058d
Allow direct sqlite db
achow101 Oct 27, 2020
26c3376
Add wallet_util functions for checking file magic
achow101 Oct 28, 2020
154c46d
tests: have wallet_multiwallet.py actually make the correct wallet types
achow101 Oct 27, 2020
b118f2d
Update feature_backwards_compatibility.py to handle single sqlite files
achow101 Oct 28, 2020
80bd5e6
Use a helper function to get wallet file paths
achow101 Oct 28, 2020
4b48854
Change sqlite wallets to not use wallet directories
achow101 Oct 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/wallet/bdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool WalletDatabaseFileId::operator==(const WalletDatabaseFileId& rhs) const
std::shared_ptr<BerkeleyEnvironment> GetWalletEnv(const fs::path& wallet_path, std::string& database_filename)
{
fs::path env_directory;
SplitWalletPath(wallet_path, env_directory, database_filename);
SplitWalletPath(wallet_path, env_directory, database_filename, "wallet.dat");
LOCK(cs_db);
auto inserted = g_dbenvs.emplace(env_directory.string(), std::weak_ptr<BerkeleyEnvironment>());
if (inserted.second) {
Expand Down Expand Up @@ -812,7 +812,7 @@ bool ExistsBerkeleyDatabase(const fs::path& path)
{
fs::path env_directory;
std::string data_filename;
SplitWalletPath(path, env_directory, data_filename);
SplitWalletPath(path, env_directory, data_filename, "wallet.dat");
return IsBDBFile(env_directory / data_filename);
}

Expand Down
9 changes: 5 additions & 4 deletions src/wallet/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

#include <string>

void SplitWalletPath(const fs::path& wallet_path, fs::path& env_directory, std::string& database_filename)
void SplitWalletPath(const fs::path& wallet_path, fs::path& env_directory, std::string& database_filename, const std::string& default_filename, bool default_dir)
{
if (fs::is_regular_file(wallet_path)) {
// Special case for backwards compatibility: if wallet path points to an
if (fs::is_regular_file(wallet_path) || (!fs::exists(wallet_path) && !default_dir)) {
// For newly created SQLite wallets (!exists && !default_dir): Always make a file at wallet_path
// For BDB Special case for backwards compatibility: if wallet path points to an
// existing file, treat it as the path to a BDB data file in a parent
// directory that also contains BDB log files.
env_directory = wallet_path.parent_path();
Expand All @@ -20,6 +21,6 @@ void SplitWalletPath(const fs::path& wallet_path, fs::path& env_directory, std::
// Normal case: Interpret wallet path as a directory path containing
// data and log files.
env_directory = wallet_path;
database_filename = "wallet.dat";
database_filename = default_filename;
}
}
2 changes: 1 addition & 1 deletion src/wallet/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

struct bilingual_str;

void SplitWalletPath(const fs::path& wallet_path, fs::path& env_directory, std::string& database_filename);
void SplitWalletPath(const fs::path& wallet_path, fs::path& env_directory, std::string& database_filename, const std::string& default_filename, bool default_dir=true);

/** RAII class that provides access to a WalletDatabase */
class DatabaseBatch
Expand Down
12 changes: 9 additions & 3 deletions src/wallet/sqlite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,15 +568,21 @@ bool SQLiteBatch::TxnAbort()

bool ExistsSQLiteDatabase(const fs::path& path)
{
const fs::path file = path / DATABASE_FILENAME;
fs::path dir;
std::string filename;
SplitWalletPath(path, dir, filename, DATABASE_FILENAME, false);
const fs::path file = dir / filename;
return fs::symlink_status(file).type() == fs::regular_file && IsSQLiteFile(file);
}

std::unique_ptr<SQLiteDatabase> MakeSQLiteDatabase(const fs::path& path, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error)
{
const fs::path file = path / DATABASE_FILENAME;
fs::path dir;
std::string filename;
SplitWalletPath(path, dir, filename, DATABASE_FILENAME, false);
const fs::path file = dir / filename;
try {
auto db = MakeUnique<SQLiteDatabase>(path, file);
auto db = MakeUnique<SQLiteDatabase>(dir, file);
if (options.verify && !db->Verify(error)) {
status = DatabaseStatus::FAILED_VERIFY;
return nullptr;
Expand Down
4 changes: 3 additions & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <util/translation.h>
#include <wallet/coincontrol.h>
#include <wallet/fees.h>
#include <wallet/sqlite.h>

#include <univalue.h>

Expand Down Expand Up @@ -3795,7 +3796,8 @@ std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, cons
fs::file_type path_type = fs::symlink_status(wallet_path).type();
if (!(path_type == fs::file_not_found || path_type == fs::directory_file ||
(path_type == fs::symlink_file && fs::is_directory(wallet_path)) ||
(path_type == fs::regular_file && fs::path(name).filename() == name))) {
(path_type == fs::regular_file && fs::path(name).filename() == name) ||
(path_type == fs::regular_file && ExistsSQLiteDatabase(wallet_path)))) {
error_string = Untranslated(strprintf(
"Invalid -wallet path '%s'. -wallet path should point to a directory where wallet.dat and "
"database/log.?????????? files can be stored, a location where such a directory could be created, "
Expand Down
17 changes: 14 additions & 3 deletions src/wallet/walletutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
bool ExistsBerkeleyDatabase(const fs::path& path);
bool ExistsSQLiteDatabase(const fs::path& path);

static bool ExistsDatabase(const fs::path& path)
{
return ExistsBerkeleyDatabase(path) || ExistsSQLiteDatabase(path);
}

fs::path GetWalletDir()
{
fs::path path;
Expand Down Expand Up @@ -49,11 +54,10 @@ std::vector<fs::path> ListWalletDir()
// This can be replaced by boost::filesystem::lexically_relative once boost is bumped to 1.60.
const fs::path path = it->path().string().substr(offset);

if (it->status().type() == fs::directory_file &&
(ExistsBerkeleyDatabase(it->path()) || ExistsSQLiteDatabase(it->path()))) {
if (it->status().type() == fs::directory_file && ExistsDatabase(it->path())) {
// Found a directory which contains wallet.dat btree file, add it as a wallet.
paths.emplace_back(path);
} else if (it.level() == 0 && it->symlink_status().type() == fs::regular_file && ExistsBerkeleyDatabase(it->path())) {
} else if (it.level() == 0 && it->symlink_status().type() == fs::regular_file && ExistsDatabase(it->path())) {
if (it->path().filename() == "wallet.dat") {
// Found top-level wallet.dat btree file, add top level directory ""
// as a wallet.
Expand All @@ -65,6 +69,13 @@ std::vector<fs::path> ListWalletDir()
// Add it to the list of available wallets.
paths.emplace_back(path);
}
} else if (it->symlink_status().type() == fs::regular_file && ExistsSQLiteDatabase(it->path())) {
// Only SQLite wallets will be created nested inside of directories
if (it->path().filename() == "wallet.dat") {
// SQLite wallets can also be in the traditional wallet dir structure, so if see one that is like that, ignore it here
continue;
}
paths.emplace_back(path);
}
}

Expand Down
Loading