Skip to content

Commit 86bf3ae

Browse files
committed
Merge #20202: wallet: Make BDB support optional
d52f502 Fix mock SQLiteDatabases (Andrew Chow) 99309ab Allow disabling BDB in configure with --without-bdb (Andrew Chow) ee47f11 GUI: Force descriptor wallets when BDB is not compiled (Andrew Chow) 71e40b3 RPC: Require descriptors=True for createwallet when BDB is not compiled (Andrew Chow) 6ebc41b Enforce salvage is only for BDB wallets (Andrew Chow) a58b719 Do not compile BDB things when USE_BDB is defined (Andrew Chow) b33af48 Include wallet/bdb.h where it is actually being used (Andrew Chow) Pull request description: Adds a `--without-bdb` option to `configure` which disables the compilation of the BDB stuff. Legacy wallets will not be created when BDB is not compiled. A legacy-sqlite wallet can be loaded, but we will not create them. Based on #20156 to resolve the situation where both `--without-sqlite` and `--without-bdb` are provided. In that case, the wallet is disabled and `--disable-wallet` is effectively set. ACKs for top commit: laanwj: Code review ACK d52f502 Tree-SHA512: 5a92ba7a542acc2e27003e9d4e5940e0d02d5c1f110db06cdcab831372bfd83e8d89c269caff31dd5bff062c1cf5f04683becff12bd23a33be731676f346553d
2 parents 1b75f25 + d52f502 commit 86bf3ae

21 files changed

+128
-22
lines changed

build-aux/m4/bitcoin_find_bdb48.m4

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[
66
AC_ARG_VAR(BDB_CFLAGS, [C compiler flags for BerkeleyDB, bypasses autodetection])
77
AC_ARG_VAR(BDB_LIBS, [Linker flags for BerkeleyDB, bypasses autodetection])
88
9-
if test "x$BDB_CFLAGS" = "x"; then
9+
if test "x$use_bdb" = "xno"; then
10+
use_bdb=no
11+
elif test "x$BDB_CFLAGS" = "x"; then
1012
AC_MSG_CHECKING([for Berkeley DB C++ headers])
1113
BDB_CPPFLAGS=
1214
bdbpath=X
@@ -44,25 +46,30 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[
4446
],[])
4547
done
4648
if test "x$bdbpath" = "xX"; then
49+
use_bdb=no
4750
AC_MSG_RESULT([no])
48-
AC_MSG_ERROR([libdb_cxx headers missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
51+
AC_MSG_ERROR([libdb_cxx headers missing, ]AC_PACKAGE_NAME[ requires this library for BDB wallet support (--without-bdb to disable BDB wallet support)])
4952
elif test "x$bdb48path" = "xX"; then
5053
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
5154
AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 4.8])],[
52-
AC_MSG_WARN([Found Berkeley DB other than 4.8; wallets opened by this build will not be portable!])
55+
AC_MSG_WARN([Found Berkeley DB other than 4.8; BDB wallets opened by this build will not be portable!])
5356
],[
54-
AC_MSG_ERROR([Found Berkeley DB other than 4.8, required for portable wallets (--with-incompatible-bdb to ignore or --disable-wallet to disable wallet functionality)])
57+
AC_MSG_ERROR([Found Berkeley DB other than 4.8, required for portable BDB wallets (--with-incompatible-bdb to ignore or --without-bdb to disable BDB wallet support)])
5558
])
59+
use_bdb=yes
5660
else
5761
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb48path}],db_cxx)
5862
bdbpath="${bdb48path}"
63+
use_bdb=yes
5964
fi
6065
else
6166
BDB_CPPFLAGS=${BDB_CFLAGS}
6267
fi
6368
AC_SUBST(BDB_CPPFLAGS)
6469
65-
if test "x$BDB_LIBS" = "x"; then
70+
if test "x$use_bdb" = "xno"; then
71+
use_bdb=no
72+
elif test "x$BDB_LIBS" = "x"; then
6673
# TODO: Ideally this could find the library version and make sure it matches the headers being used
6774
for searchlib in db_cxx-4.8 db_cxx db4_cxx; do
6875
AC_CHECK_LIB([$searchlib],[main],[
@@ -71,8 +78,12 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[
7178
])
7279
done
7380
if test "x$BDB_LIBS" = "x"; then
74-
AC_MSG_ERROR([libdb_cxx missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)])
81+
AC_MSG_ERROR([libdb_cxx missing, ]AC_PACKAGE_NAME[ requires this library for BDB wallet support (--without-bdb to disable BDB wallet support)])
7582
fi
7683
fi
77-
AC_SUBST(BDB_LIBS)
84+
if test "x$use_bdb" != "xno"; then
85+
AC_SUBST(BDB_LIBS)
86+
AC_DEFINE([USE_BDB], [1], [Define if BDB support should be compiled in])
87+
use_bdb=yes
88+
fi
7889
])

build_msvc/bitcoin_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
/* Define to 1 to enable wallet functions */
3636
#define ENABLE_WALLET 1
3737

38+
/* Define to 1 to enable BDB wallet */
39+
#define USE_BDB 1
40+
41+
/* Define to 1 to enable SQLite wallet */
42+
#define USE_SQLITE 1
43+
3844
/* Define to 1 to enable ZMQ functions */
3945
#define ENABLE_ZMQ 1
4046

build_msvc/bitcoind/bitcoind.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
Replace="@EXEEXT@" By=".exe"></ReplaceInFile>
6363
<ReplaceInFile FilePath="$(ConfigIniOut)"
6464
Replace="@ENABLE_WALLET_TRUE@" By=""></ReplaceInFile>
65+
<ReplaceInFile FilePath="$(ConfigIniOut)"
66+
Replace="@USE_BDB_TRUE@" By=""></ReplaceInFile>
67+
<ReplaceInFile FilePath="$(ConfigIniOut)"
68+
Replace="@USE_SQLITE_TRUE@" By=""></ReplaceInFile>
6569
<ReplaceInFile FilePath="$(ConfigIniOut)"
6670
Replace="@BUILD_BITCOIN_CLI_TRUE@" By=""></ReplaceInFile>
6771
<ReplaceInFile FilePath="$(ConfigIniOut)"

build_msvc/libbitcoin_wallet/libbitcoin_wallet.vcxproj.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<ConfigurationType>StaticLibrary</ConfigurationType>
99
</PropertyGroup>
1010
<ItemGroup>
11+
<ClCompile Include="..\..\src\wallet\bdb.cpp" />
12+
<ClCompile Include="..\..\src\wallet\salvage.cpp" />
13+
<ClCompile Include="..\..\src\wallet\sqlite.cpp" />
1114
@SOURCE_FILES@
1215
</ItemGroup>
1316
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

configure.ac

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,20 @@ AC_ARG_ENABLE([wallet],
115115
[AS_HELP_STRING([--disable-wallet],
116116
[disable wallet (enabled by default)])],
117117
[enable_wallet=$enableval],
118-
[enable_wallet=yes])
118+
[enable_wallet=auto])
119119

120120
AC_ARG_WITH([sqlite],
121121
[AS_HELP_STRING([--with-sqlite=yes|no|auto],
122122
[enable sqlite wallet support (default: auto, i.e., enabled if wallet is enabled and sqlite is found)])],
123123
[use_sqlite=$withval],
124124
[use_sqlite=auto])
125125

126+
AC_ARG_WITH([bdb],
127+
[AS_HELP_STRING([--without-bdb],
128+
[disable bdb wallet support (default is enabled if wallet is enabled)])],
129+
[use_bdb=$withval],
130+
[use_bdb=auto])
131+
126132
AC_ARG_WITH([miniupnpc],
127133
[AS_HELP_STRING([--with-miniupnpc],
128134
[enable UPNP (default is yes if libminiupnpc is found)])],
@@ -1237,6 +1243,14 @@ if test x$enable_wallet != xno; then
12371243
fi
12381244
fi
12391245
AC_MSG_RESULT([$use_sqlite])
1246+
1247+
dnl Disable wallet if both --without-bdb and --without-sqlite
1248+
if test "x$use_bdb$use_sqlite" = "xnono"; then
1249+
if test "x$enable_wallet" = "xyes"; then
1250+
AC_MSG_ERROR([wallet functionality requested but no BDB or SQLite support available.])
1251+
fi
1252+
enable_wallet=no
1253+
fi
12401254
fi
12411255

12421256
dnl Check for libminiupnpc (optional)
@@ -1492,6 +1506,7 @@ AC_MSG_CHECKING([if wallet should be enabled])
14921506
if test x$enable_wallet != xno; then
14931507
AC_MSG_RESULT(yes)
14941508
AC_DEFINE_UNQUOTED([ENABLE_WALLET],[1],[Define to 1 to enable wallet functions])
1509+
enable_wallet=yes
14951510

14961511
else
14971512
AC_MSG_RESULT(no)
@@ -1591,6 +1606,7 @@ AM_CONDITIONAL([TARGET_LINUX], [test x$TARGET_OS = xlinux])
15911606
AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows])
15921607
AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes])
15931608
AM_CONDITIONAL([USE_SQLITE], [test "x$use_sqlite" = "xyes"])
1609+
AM_CONDITIONAL([USE_BDB], [test "x$use_bdb" = "xyes"])
15941610
AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
15951611
AM_CONDITIONAL([ENABLE_FUZZ],[test x$enable_fuzz = xyes])
15961612
AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes])
@@ -1655,6 +1671,7 @@ AC_SUBST(SHANI_CXXFLAGS)
16551671
AC_SUBST(ARM_CRC_CXXFLAGS)
16561672
AC_SUBST(LIBTOOL_APP_LDFLAGS)
16571673
AC_SUBST(USE_SQLITE)
1674+
AC_SUBST(USE_BDB)
16581675
AC_SUBST(USE_UPNP)
16591676
AC_SUBST(USE_QRCODE)
16601677
AC_SUBST(BOOST_LIBS)
@@ -1732,6 +1749,7 @@ echo " multiprocess = $build_multiprocess"
17321749
echo " with wallet = $enable_wallet"
17331750
if test "x$enable_wallet" != "xno"; then
17341751
echo " with sqlite = $use_sqlite"
1752+
echo " with bdb = $use_bdb"
17351753
fi
17361754
echo " with gui / qt = $bitcoin_enable_qt"
17371755
if test x$bitcoin_enable_qt != xno; then

doc/build-unix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Optional dependencies:
4141
Library | Purpose | Description
4242
------------|------------------|----------------------
4343
miniupnpc | UPnP Support | Firewall-jumping support
44-
libdb4.8 | Berkeley DB | Wallet storage (only needed when wallet enabled)
44+
libdb4.8 | Berkeley DB | Optional, wallet storage (only needed when wallet enabled)
4545
qt | GUI | GUI toolkit (only needed when GUI enabled)
4646
libqrencode | QR codes in GUI | Optional for generating QR codes (only needed when GUI enabled)
4747
univalue | Utility | JSON parsing and encoding (bundled version will be used unless --with-system-univalue passed to configure)

doc/dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Some dependencies are not needed in all configurations. The following are some f
3333

3434
#### Options passed to `./configure`
3535
* MiniUPnPc is not needed with `--with-miniupnpc=no`.
36-
* Berkeley DB is not needed with `--disable-wallet`.
36+
* Berkeley DB is not needed with `--disable-wallet` or `--without-bdb`.
3737
* SQLite is not needed with `--disable-wallet` or `--without-sqlite`.
3838
* Qt is not needed with `--without-gui`.
3939
* If the qrencode dependency is absent, QR support won't be added. To force an error when that happens, pass `--with-qrencode`.

src/Makefile.am

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(SQLITE_CFLAG
360360
libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
361361
libbitcoin_wallet_a_SOURCES = \
362362
interfaces/wallet.cpp \
363-
wallet/bdb.cpp \
364363
wallet/coincontrol.cpp \
365364
wallet/context.cpp \
366365
wallet/crypter.cpp \
@@ -370,7 +369,6 @@ libbitcoin_wallet_a_SOURCES = \
370369
wallet/load.cpp \
371370
wallet/rpcdump.cpp \
372371
wallet/rpcwallet.cpp \
373-
wallet/salvage.cpp \
374372
wallet/scriptpubkeyman.cpp \
375373
wallet/wallet.cpp \
376374
wallet/walletdb.cpp \
@@ -381,6 +379,9 @@ libbitcoin_wallet_a_SOURCES = \
381379
if USE_SQLITE
382380
libbitcoin_wallet_a_SOURCES += wallet/sqlite.cpp
383381
endif
382+
if USE_BDB
383+
libbitcoin_wallet_a_SOURCES += wallet/bdb.cpp wallet/salvage.cpp
384+
endif
384385

385386
libbitcoin_wallet_tool_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
386387
libbitcoin_wallet_tool_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)

src/Makefile.test.include

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ BITCOIN_TESTS =\
292292

293293
if ENABLE_WALLET
294294
BITCOIN_TESTS += \
295-
wallet/test/db_tests.cpp \
296295
wallet/test/psbt_wallet_tests.cpp \
297296
wallet/test/wallet_tests.cpp \
298297
wallet/test/walletdb_tests.cpp \
@@ -302,6 +301,10 @@ BITCOIN_TESTS += \
302301
wallet/test/ismine_tests.cpp \
303302
wallet/test/scriptpubkeyman_tests.cpp
304303

304+
if USE_BDB
305+
BITCOIN_TESTS += wallet/test/db_tests.cpp
306+
endif
307+
305308
BITCOIN_TEST_SUITE += \
306309
wallet/test/wallet_test_fixture.cpp \
307310
wallet/test/wallet_test_fixture.h \

src/qt/createwalletdialog.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,15 @@ CreateWalletDialog::CreateWalletDialog(QWidget* parent) :
5151
}
5252
});
5353

54-
#ifndef USE_SQLITE
54+
#ifndef USE_SQLITE
5555
ui->descriptor_checkbox->setToolTip(tr("Compiled without sqlite support (required for descriptor wallets)"));
5656
ui->descriptor_checkbox->setEnabled(false);
5757
ui->descriptor_checkbox->setChecked(false);
58-
#endif
59-
58+
#endif
59+
#ifndef USE_BDB
60+
ui->descriptor_checkbox->setEnabled(false);
61+
ui->descriptor_checkbox->setChecked(true);
62+
#endif
6063
}
6164

6265
CreateWalletDialog::~CreateWalletDialog()

0 commit comments

Comments
 (0)