diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-10-29 12:03:31 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-10-29 12:03:36 +0100 |
commit | f3727fd73538b3a097559cc1005c08caa2bdf1dd (patch) | |
tree | 21e703c3f0b36318ac970316d1cf79fc1bd7739c | |
parent | 924a4ff7eb626185684a4524bb0acea7e2904db8 (diff) | |
parent | bbb42a68961a8ae1e4ef3221ffb1d5ff7272b075 (diff) |
Merge #20156: build: Make sqlite support optional (compile-time)
bbb42a68961a8ae1e4ef3221ffb1d5ff7272b075 RPC: createwallet: Nicer error message if descriptor wallet requested and sqlite support not compiled in (Luke Dashjr)
6608fec332eac4dfd91138bc4fe2e1b5c7bb758f GUI: Create Wallet: Nicely disable descriptor wallet checkbox if sqlite support not compiled in (Luke Dashjr)
7b54d768e1514b328e1ac108d3db2f1bac3ba7ff Make 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 ACK bbb42a68961a8ae1e4ef3221ffb1d5ff7272b075
achow101:
ACK bbb42a68961a8ae1e4ef3221ffb1d5ff7272b075
Sjors:
re-utACK bbb42a68961a8ae1e4ef3221ffb1d5ff7272b075
hebasto:
ACK bbb42a68961a8ae1e4ef3221ffb1d5ff7272b075, tested on Linux Mint 20 (x86_64, Qt 5.12.8).
Tree-SHA512: 500209dd1971310fab8ae51543343ce0ba91f088ccccff6109b4cc27547cd5532289dca6cb7dac2a7d7c59cdf3c8f5aacc31e9b0f912e38cea52ec26b97100bd
-rw-r--r-- | configure.ac | 30 | ||||
-rw-r--r-- | doc/build-unix.md | 2 | ||||
-rw-r--r-- | doc/dependencies.md | 2 | ||||
-rw-r--r-- | src/Makefile.am | 7 | ||||
-rw-r--r-- | src/qt/createwalletdialog.cpp | 6 | ||||
-rw-r--r-- | src/wallet/rpcwallet.cpp | 3 | ||||
-rw-r--r-- | src/wallet/walletdb.cpp | 8 | ||||
-rw-r--r-- | src/wallet/walletutil.cpp | 4 |
8 files changed, 57 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index ab40991ce4..9a16b7c880 100644 --- a/configure.ac +++ b/configure.ac @@ -128,6 +128,12 @@ AC_ARG_ENABLE([wallet], [enable_wallet=$enableval], [enable_wallet=yes]) +AC_ARG_WITH([sqlite], + [AS_HELP_STRING([--with-sqlite=yes|no|auto], + [enable sqlite wallet support (default: auto, i.e., enabled if wallet is enabled and sqlite is found)])], + [use_sqlite=$withval], + [use_sqlite=auto]) + AC_ARG_WITH([miniupnpc], [AS_HELP_STRING([--with-miniupnpc], [enable UPNP (default is yes if libminiupnpc is found)])], @@ -1224,7 +1230,24 @@ if test x$enable_wallet != xno; then fi dnl Check for sqlite3 - PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.7.17], , [AC_MSG_ERROR([sqlite3 not found.])]) + if test "x$use_sqlite" != "xno"; then + PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.7.17], [have_sqlite=yes], [have_sqlite=no]) + fi + AC_MSG_CHECKING([whether to build wallet with support for sqlite]) + if test "x$use_sqlite" = "xno"; then + use_sqlite=no + elif test "x$have_sqlite" = "xno"; then + if test "x$use_sqlite" = "xyes"; then + AC_MSG_ERROR([sqlite support requested but cannot be built. Use --without-sqlite]) + fi + use_sqlite=no + else + if test x$use_sqlite != xno; then + AC_DEFINE([USE_SQLITE],[1],[Define if sqlite support should be compiled in]) + use_sqlite=yes + fi + fi + AC_MSG_RESULT([$use_sqlite]) fi dnl Check for libminiupnpc (optional) @@ -1578,6 +1601,7 @@ AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin]) AM_CONDITIONAL([TARGET_LINUX], [test x$TARGET_OS = xlinux]) AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows]) AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes]) +AM_CONDITIONAL([USE_SQLITE], [test "x$use_sqlite" = "xyes"]) AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes]) AM_CONDITIONAL([ENABLE_FUZZ],[test x$enable_fuzz = xyes]) AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes]) @@ -1643,6 +1667,7 @@ AC_SUBST(AVX2_CXXFLAGS) AC_SUBST(SHANI_CXXFLAGS) AC_SUBST(ARM_CRC_CXXFLAGS) AC_SUBST(LIBTOOL_APP_LDFLAGS) +AC_SUBST(USE_SQLITE) AC_SUBST(USE_UPNP) AC_SUBST(USE_QRCODE) AC_SUBST(BOOST_LIBS) @@ -1718,6 +1743,9 @@ echo "Options used to compile and link:" echo " boost process = $ax_cv_boost_process" echo " multiprocess = $build_multiprocess" echo " with wallet = $enable_wallet" +if test "x$enable_wallet" != "xno"; then + echo " with sqlite = $use_sqlite" +fi echo " with gui / qt = $bitcoin_enable_qt" if test x$bitcoin_enable_qt != xno; then echo " with qr = $use_qr" diff --git a/doc/build-unix.md b/doc/build-unix.md index c076fb6fff..ab83ceff3d 100644 --- a/doc/build-unix.md +++ b/doc/build-unix.md @@ -46,7 +46,7 @@ Optional dependencies: libqrencode | QR codes in GUI | Optional for generating QR codes (only needed when GUI enabled) univalue | Utility | JSON parsing and encoding (bundled version will be used unless --with-system-univalue passed to configure) libzmq3 | ZMQ notification | Optional, allows generating ZMQ notifications (requires ZMQ version >= 4.0.0) - sqlite3 | SQLite DB | Wallet storage (only needed when wallet enabled) + sqlite3 | SQLite DB | Optional, wallet storage (only needed when wallet enabled) For the versions used, see [dependencies.md](dependencies.md) diff --git a/doc/dependencies.md b/doc/dependencies.md index ddd50ef296..d1bf4b3a87 100644 --- a/doc/dependencies.md +++ b/doc/dependencies.md @@ -34,7 +34,7 @@ Some dependencies are not needed in all configurations. The following are some f #### Options passed to `./configure` * MiniUPnPc is not needed with `--with-miniupnpc=no`. * Berkeley DB is not needed with `--disable-wallet`. -* SQLite is not needed with `--disable-wallet`. +* SQLite is not needed with `--disable-wallet` or `--without-sqlite`. * Qt is not needed with `--without-gui`. * If the qrencode dependency is absent, QR support won't be added. To force an error when that happens, pass `--with-qrencode`. * ZeroMQ is needed only with the `--with-zmq` option. diff --git a/src/Makefile.am b/src/Makefile.am index b0d36717ce..67fd402603 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 = \ diff --git a/src/qt/createwalletdialog.cpp b/src/qt/createwalletdialog.cpp index 5056e487fc..38c6bfe56a 100644 --- a/src/qt/createwalletdialog.cpp +++ b/src/qt/createwalletdialog.cpp @@ -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() diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 29b55ec130..086ffa1272 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -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")); } diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 0092a29cb4..aa3b3c10b0 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -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); } diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp index a2a55f9751..2f3e597b90 100644 --- a/src/wallet/walletutil.cpp +++ b/src/wallet/walletutil.cpp @@ -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() { |