mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-22 20:58:09 +02:00
Merge #20156: build: Make sqlite support optional (compile-time)
bbb42a6896RPC: createwallet: Nicer error message if descriptor wallet requested and sqlite support not compiled in (Luke Dashjr)6608fec332GUI: Create Wallet: Nicely disable descriptor wallet checkbox if sqlite support not compiled in (Luke Dashjr)7b54d768e1Make sqlite support optional (compile-time) (Luke Dashjr) Pull request description: As a new requirement, sqlite support should be optional. This PR aims to be only minimum/blocker changes for 0.21. Potential follow-up PRs after this: * Make BDB support optional * Nicer error messages when user tries to load an unsupported wallet * Don't compile descriptor wallet code if sqlite disabled ACKs for top commit: jonasschnelli: Tested ACKbbb42a6896achow101: ACKbbb42a6896Sjors: re-utACKbbb42a6896hebasto: ACKbbb42a6896, tested on Linux Mint 20 (x86_64, Qt 5.12.8). Tree-SHA512: 500209dd1971310fab8ae51543343ce0ba91f088ccccff6109b4cc27547cd5532289dca6cb7dac2a7d7c59cdf3c8f5aacc31e9b0f912e38cea52ec26b97100bd
This commit is contained in:
@@ -356,7 +356,7 @@ endif
|
||||
|
||||
# wallet: shared between bitcoind and bitcoin-qt, but only linked
|
||||
# when wallet enabled
|
||||
libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
|
||||
libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(SQLITE_CFLAGS)
|
||||
libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
libbitcoin_wallet_a_SOURCES = \
|
||||
interfaces/wallet.cpp \
|
||||
@@ -372,13 +372,16 @@ libbitcoin_wallet_a_SOURCES = \
|
||||
wallet/rpcwallet.cpp \
|
||||
wallet/salvage.cpp \
|
||||
wallet/scriptpubkeyman.cpp \
|
||||
wallet/sqlite.cpp \
|
||||
wallet/wallet.cpp \
|
||||
wallet/walletdb.cpp \
|
||||
wallet/walletutil.cpp \
|
||||
wallet/coinselection.cpp \
|
||||
$(BITCOIN_CORE_H)
|
||||
|
||||
if USE_SQLITE
|
||||
libbitcoin_wallet_a_SOURCES += wallet/sqlite.cpp
|
||||
endif
|
||||
|
||||
libbitcoin_wallet_tool_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
|
||||
libbitcoin_wallet_tool_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
libbitcoin_wallet_tool_a_SOURCES = \
|
||||
|
||||
@@ -34,6 +34,12 @@ CreateWalletDialog::CreateWalletDialog(QWidget* parent) :
|
||||
ui->disable_privkeys_checkbox->setChecked(false);
|
||||
}
|
||||
});
|
||||
|
||||
#ifndef USE_SQLITE
|
||||
ui->descriptor_checkbox->setToolTip(tr("Compiled without sqlite support (required for descriptor wallets)"));
|
||||
ui->descriptor_checkbox->setEnabled(false);
|
||||
ui->descriptor_checkbox->setChecked(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
CreateWalletDialog::~CreateWalletDialog()
|
||||
|
||||
@@ -2742,6 +2742,9 @@ static RPCHelpMan createwallet()
|
||||
flags |= WALLET_FLAG_AVOID_REUSE;
|
||||
}
|
||||
if (!request.params[5].isNull() && request.params[5].get_bool()) {
|
||||
#ifndef USE_SQLITE
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Compiled without sqlite support (required for descriptor wallets)");
|
||||
#endif
|
||||
flags |= WALLET_FLAG_DESCRIPTORS;
|
||||
warnings.emplace_back(Untranslated("Wallet is an experimental descriptor wallet"));
|
||||
}
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
#include <util/time.h>
|
||||
#include <util/translation.h>
|
||||
#include <wallet/bdb.h>
|
||||
#ifdef USE_SQLITE
|
||||
#include <wallet/sqlite.h>
|
||||
#endif
|
||||
#include <wallet/wallet.h>
|
||||
|
||||
#include <atomic>
|
||||
@@ -1012,6 +1014,7 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas
|
||||
if (ExistsBerkeleyDatabase(path)) {
|
||||
format = DatabaseFormat::BERKELEY;
|
||||
}
|
||||
#ifdef USE_SQLITE
|
||||
if (ExistsSQLiteDatabase(path)) {
|
||||
if (format) {
|
||||
error = Untranslated(strprintf("Failed to load database path '%s'. Data is in ambiguous format.", path.string()));
|
||||
@@ -1020,6 +1023,7 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas
|
||||
}
|
||||
format = DatabaseFormat::SQLITE;
|
||||
}
|
||||
#endif
|
||||
} else if (options.require_existing) {
|
||||
error = Untranslated(strprintf("Failed to load database path '%s'. Path does not exist.", path.string()));
|
||||
status = DatabaseStatus::FAILED_NOT_FOUND;
|
||||
@@ -1048,9 +1052,13 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas
|
||||
// Format is not set when a db doesn't already exist, so use the format specified by the options if it is set.
|
||||
if (!format && options.require_format) format = options.require_format;
|
||||
|
||||
#ifdef USE_SQLITE
|
||||
if (format && format == DatabaseFormat::SQLITE) {
|
||||
return MakeSQLiteDatabase(path, options, status, error);
|
||||
}
|
||||
#else
|
||||
assert(format != DatabaseFormat::SQLITE);
|
||||
#endif
|
||||
|
||||
return MakeBerkeleyDatabase(path, options, status, error);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,11 @@
|
||||
#include <util/system.h>
|
||||
|
||||
bool ExistsBerkeleyDatabase(const fs::path& path);
|
||||
#ifdef USE_SQLITE
|
||||
bool ExistsSQLiteDatabase(const fs::path& path);
|
||||
#else
|
||||
# define ExistsSQLiteDatabase(path) (false)
|
||||
#endif
|
||||
|
||||
fs::path GetWalletDir()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user