Skip to content

Commit

Permalink
Merge f3727fd into merged_master (Bitcoin PR #20156)
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Dec 1, 2020
2 parents 8c3388f + f3727fd commit f3afbf3
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 5 deletions.
30 changes: 29 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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)])],
Expand Down Expand Up @@ -1249,7 +1255,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)
Expand Down Expand Up @@ -1603,6 +1626,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])
Expand Down Expand Up @@ -1669,6 +1693,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)
Expand Down Expand Up @@ -1745,6 +1770,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"
Expand Down
2 changes: 1 addition & 1 deletion doc/build-unix.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion doc/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 5 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,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 = \
assetsdir.cpp \
Expand All @@ -390,7 +390,6 @@ 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 \
Expand All @@ -401,6 +400,10 @@ libbitcoin_wallet_a_SOURCES = \
$(libbitcoin_server_a_SOURCES) \
$(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 = \
Expand Down
6 changes: 6 additions & 0 deletions src/qt/createwalletdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2904,6 +2904,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"));
}
Expand Down
8 changes: 8 additions & 0 deletions src/wallet/walletdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -1099,6 +1101,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()));
Expand All @@ -1107,6 +1110,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;
Expand Down Expand Up @@ -1135,9 +1139,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);
}
Expand Down
4 changes: 4 additions & 0 deletions src/wallet/walletutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit f3afbf3

Please sign in to comment.