Skip to content

Commit 1285f55

Browse files
committed
build: Require sqlite when --enable-wallet
Require sqlite is available in order to compile the wallet. Removes instances of USE_SQLITE since it is no longer possible to not have sqlite available.
1 parent 09d1410 commit 1285f55

28 files changed

+15
-94
lines changed

CMakeLists.txt

+1-4
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,13 @@ option(BUILD_UTIL_CHAINSTATE "Build experimental bitcoin-chainstate executable."
8888
option(BUILD_KERNEL_LIB "Build experimental bitcoinkernel library." ${BUILD_UTIL_CHAINSTATE})
8989

9090
option(ENABLE_WALLET "Enable wallet." ON)
91-
option(WITH_SQLITE "Enable SQLite wallet support." ${ENABLE_WALLET})
92-
if(WITH_SQLITE)
91+
if(ENABLE_WALLET)
9392
if(VCPKG_TARGET_TRIPLET)
9493
# Use of the `unofficial::` namespace is a vcpkg package manager convention.
9594
find_package(unofficial-sqlite3 CONFIG REQUIRED)
9695
else()
9796
find_package(SQLite3 3.7.17 REQUIRED)
9897
endif()
99-
set(USE_SQLITE ON)
10098
endif()
10199
option(WITH_BDB "Enable Berkeley DB (BDB) wallet support." OFF)
102100
cmake_dependent_option(WARN_INCOMPATIBLE_BDB "Warn when using a Berkeley DB (BDB) version other than 4.8." ON "WITH_BDB" OFF)
@@ -602,7 +600,6 @@ message(" libbitcoinkernel (experimental) ..... ${BUILD_KERNEL_LIB}")
602600
message("Optional features:")
603601
message(" wallet support ...................... ${ENABLE_WALLET}")
604602
if(ENABLE_WALLET)
605-
message(" - descriptor wallets (SQLite) ...... ${WITH_SQLITE}")
606603
message(" - legacy wallets (Berkeley DB) ..... ${WITH_BDB}")
607604
endif()
608605
message(" external signer ..................... ${ENABLE_EXTERNAL_SIGNER}")

cmake/bitcoin-build-config.h.in

-3
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,4 @@
144144
/* Define if QR support should be compiled in */
145145
#cmakedefine USE_QRCODE 1
146146

147-
/* Define if sqlite support should be compiled in */
148-
#cmakedefine USE_SQLITE 1
149-
150147
#endif //BITCOIN_CONFIG_H

doc/build-openbsd.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ There are many ways to configure Bitcoin Core, here are a few common examples:
103103
This enables descriptor wallet support and the GUI, assuming SQLite and Qt 5 are installed.
104104

105105
```bash
106-
cmake -B build -DWITH_SQLITE=ON -DBUILD_GUI=ON
106+
cmake -B build -DBUILD_GUI=ON
107107
```
108108

109109
Run `cmake -B build -LH` to see the full list of available options.

src/bench/wallet_create.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
44

55
#include <bench/bench.h>
6-
#include <bitcoin-build-config.h> // IWYU pragma: keep
76
#include <random.h>
87
#include <support/allocators/secure.h>
98
#include <test/util/setup_common.h>
@@ -61,9 +60,7 @@ static void WalletCreate(benchmark::Bench& bench, bool encrypted)
6160
static void WalletCreatePlain(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/false); }
6261
static void WalletCreateEncrypted(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/true); }
6362

64-
#ifdef USE_SQLITE
6563
BENCHMARK(WalletCreatePlain, benchmark::PriorityLevel::LOW);
6664
BENCHMARK(WalletCreateEncrypted, benchmark::PriorityLevel::LOW);
67-
#endif
6865

6966
} // namespace wallet

src/bench/wallet_ismine.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <addresstype.h>
66
#include <bench/bench.h>
7-
#include <bitcoin-build-config.h> // IWYU pragma: keep
87
#include <key.h>
98
#include <key_io.h>
109
#include <script/descriptor.h>
@@ -70,10 +69,8 @@ static void WalletIsMine(benchmark::Bench& bench, bool legacy_wallet, int num_co
7069
TestUnloadWallet(std::move(wallet));
7170
}
7271

73-
#ifdef USE_SQLITE
7472
static void WalletIsMineDescriptors(benchmark::Bench& bench) { WalletIsMine(bench, /*legacy_wallet=*/false); }
7573
static void WalletIsMineMigratedDescriptors(benchmark::Bench& bench) { WalletIsMine(bench, /*legacy_wallet=*/false, /*num_combo=*/2000); }
7674
BENCHMARK(WalletIsMineDescriptors, benchmark::PriorityLevel::LOW);
7775
BENCHMARK(WalletIsMineMigratedDescriptors, benchmark::PriorityLevel::LOW);
78-
#endif
7976
} // namespace wallet

src/bench/wallet_loading.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <addresstype.h>
66
#include <bench/bench.h>
7-
#include <bitcoin-build-config.h> // IWYU pragma: keep
87
#include <consensus/amount.h>
98
#include <outputtype.h>
109
#include <primitives/transaction.h>

src/bench/wallet_migration.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
44

5-
#include <bitcoin-build-config.h> // IWYU pragma: keep
6-
75
#include <bench/bench.h>
86
#include <interfaces/chain.h>
97
#include <node/context.h>
@@ -16,8 +14,6 @@
1614

1715
#include <optional>
1816

19-
#if defined(USE_SQLITE) // only enable benchmark when sqlite is enabled
20-
2117
namespace wallet{
2218

2319
static void WalletMigration(benchmark::Bench& bench)
@@ -70,5 +66,3 @@ static void WalletMigration(benchmark::Bench& bench)
7066
BENCHMARK(WalletMigration, benchmark::PriorityLevel::LOW);
7167

7268
} // namespace wallet
73-
74-
#endif // end USE_SQLITE && USE_BDB

src/qt/bitcoingui.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -1215,11 +1215,6 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
12151215
void BitcoinGUI::createWallet()
12161216
{
12171217
#ifdef ENABLE_WALLET
1218-
#ifndef USE_SQLITE
1219-
// Compiled without sqlite support (required for descriptor wallets)
1220-
message(tr("Error creating wallet"), tr("Cannot create new wallet, the software was compiled without sqlite support (required for descriptor wallets)"), CClientUIInterface::MSG_ERROR);
1221-
return;
1222-
#endif // USE_SQLITE
12231218
auto activity = new CreateWalletActivity(getWalletController(), this);
12241219
connect(activity, &CreateWalletActivity::created, this, &BitcoinGUI::setCurrentWallet);
12251220
connect(activity, &CreateWalletActivity::created, rpcConsole, &RPCConsole::setCurrentWallet);

src/wallet/CMakeLists.txt

+6-11
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,12 @@ target_link_libraries(bitcoin_wallet
4242
$<TARGET_NAME_IF_EXISTS:USDT::headers>
4343
)
4444

45-
if(NOT USE_SQLITE AND NOT USE_BDB)
46-
message(FATAL_ERROR "Wallet functionality requested but no BDB or SQLite support available.")
47-
endif()
48-
if(USE_SQLITE)
49-
target_sources(bitcoin_wallet PRIVATE sqlite.cpp)
50-
target_link_libraries(bitcoin_wallet
51-
PRIVATE
52-
$<TARGET_NAME_IF_EXISTS:unofficial::sqlite3::sqlite3>
53-
$<TARGET_NAME_IF_EXISTS:SQLite::SQLite3>
54-
)
55-
endif()
45+
target_sources(bitcoin_wallet PRIVATE sqlite.cpp)
46+
target_link_libraries(bitcoin_wallet
47+
PRIVATE
48+
$<TARGET_NAME_IF_EXISTS:unofficial::sqlite3::sqlite3>
49+
$<TARGET_NAME_IF_EXISTS:SQLite::SQLite3>
50+
)
5651
if(USE_BDB)
5752
target_sources(bitcoin_wallet PRIVATE bdb.cpp)
5853
target_link_libraries(bitcoin_wallet PUBLIC BerkeleyDB::BerkeleyDB)

src/wallet/init.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ void WalletInit::AddWalletOptions(ArgsManager& argsman) const
9090
argsman.AddHiddenArgs({"-dblogsize", "-flushwallet", "-privdb", "-swapbdbendian"});
9191
#endif
9292

93-
#ifdef USE_SQLITE
9493
argsman.AddArg("-unsafesqlitesync", "Set SQLite synchronous=OFF to disable waiting for the database to sync to disk. This is unsafe and can cause data loss and corruption. This option is only used by tests to improve their performance (default: false)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::WALLET_DEBUG_TEST);
95-
#else
96-
argsman.AddHiddenArgs({"-unsafesqlitesync"});
97-
#endif
9894

9995
argsman.AddArg("-walletrejectlongchains", strprintf("Wallet will not create transactions that violate mempool chain limits (default: %u)", DEFAULT_WALLET_REJECT_LONG_CHAINS), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::WALLET_DEBUG_TEST);
10096
argsman.AddArg("-walletcrosschain", strprintf("Allow reusing wallet files across chains (default: %u)", DEFAULT_WALLETCROSSCHAIN), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::WALLET_DEBUG_TEST);

src/wallet/rpc/wallet.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,6 @@ static RPCHelpMan createwallet()
396396
flags |= WALLET_FLAG_AVOID_REUSE;
397397
}
398398
if (self.Arg<bool>("descriptors")) {
399-
#ifndef USE_SQLITE
400-
throw JSONRPCError(RPC_WALLET_ERROR, "Compiled without sqlite support (required for descriptor wallets)");
401-
#endif
402399
flags |= WALLET_FLAG_DESCRIPTORS;
403400
} else {
404401
if (!context.chain->rpcEnableDeprecated("create_bdb")) {

src/wallet/test/db_tests.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#include <bitcoin-build-config.h> // IWYU pragma: keep
6-
75
#include <boost/test/unit_test.hpp>
86

97
#include <test/util/setup_common.h>
108
#include <util/check.h>
119
#include <util/fs.h>
1210
#include <util/translation.h>
13-
#ifdef USE_SQLITE
1411
#include <wallet/sqlite.h>
15-
#endif
1612
#include <wallet/migrate.h>
1713
#include <wallet/test/util.h>
1814
#include <wallet/walletutil.h> // for WALLET_FLAG_DESCRIPTORS
@@ -66,9 +62,7 @@ static std::vector<std::unique_ptr<WalletDatabase>> TestDatabases(const fs::path
6662
DatabaseStatus status;
6763
bilingual_str error;
6864
// Unable to test BerkeleyRO since we cannot create a new BDB database to open
69-
#ifdef USE_SQLITE
7065
dbs.emplace_back(MakeSQLiteDatabase(path_root / "sqlite", options, status, error));
71-
#endif
7266
dbs.emplace_back(CreateMockableWalletDatabase());
7367
return dbs;
7468
}
@@ -207,8 +201,6 @@ BOOST_AUTO_TEST_CASE(erase_prefix)
207201
}
208202
}
209203

210-
#ifdef USE_SQLITE
211-
212204
// Test-only statement execution error
213205
constexpr int TEST_SQLITE_ERROR = -999;
214206

@@ -299,7 +291,6 @@ BOOST_AUTO_TEST_CASE(concurrent_txn_dont_interfere)
299291
BOOST_CHECK(handler2->Read(key, read_value));
300292
BOOST_CHECK_EQUAL(read_value, value2);
301293
}
302-
#endif // USE_SQLITE
303294

304295
BOOST_AUTO_TEST_SUITE_END()
305296
} // namespace wallet

src/wallet/test/fuzz/CMakeLists.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ target_sources(fuzz
88
coinselection.cpp
99
crypter.cpp
1010
fees.cpp
11-
$<$<BOOL:${USE_SQLITE}>:${CMAKE_CURRENT_LIST_DIR}/notifications.cpp>
11+
notifications.cpp
1212
parse_iso8601.cpp
13-
$<$<BOOL:${USE_SQLITE}>:${CMAKE_CURRENT_LIST_DIR}/scriptpubkeyman.cpp>
13+
scriptpubkeyman.cpp
1414
spend.cpp
15+
scriptpubkeyman.cpp
1516
wallet_bdb_parser.cpp
1617
)
1718
target_link_libraries(fuzz bitcoin_wallet)

src/wallet/test/util.h

-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ class WalletDatabase;
2626
struct WalletContext;
2727

2828
static const DatabaseFormat DATABASE_FORMATS[] = {
29-
#ifdef USE_SQLITE
3029
DatabaseFormat::SQLITE,
31-
#endif
3230
#ifdef USE_BDB
3331
DatabaseFormat::BERKELEY,
3432
#endif

src/wallet/walletdb.cpp

+1-14
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
#include <wallet/bdb.h>
2323
#endif
2424
#include <wallet/migrate.h>
25-
#ifdef USE_SQLITE
2625
#include <wallet/sqlite.h>
27-
#endif
2826
#include <wallet/wallet.h>
2927

3028
#include <atomic>
@@ -1436,25 +1434,14 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas
14361434

14371435
// If the format is not specified or detected, choose the default format based on what is available. We prefer BDB over SQLite for now.
14381436
if (!format) {
1439-
#ifdef USE_SQLITE
14401437
format = DatabaseFormat::SQLITE;
1441-
#endif
14421438
#ifdef USE_BDB
14431439
format = DatabaseFormat::BERKELEY;
14441440
#endif
14451441
}
14461442

14471443
if (format == DatabaseFormat::SQLITE) {
1448-
#ifdef USE_SQLITE
1449-
if constexpr (true) {
1450-
return MakeSQLiteDatabase(path, options, status, error);
1451-
} else
1452-
#endif
1453-
{
1454-
error = Untranslated(strprintf("Failed to open database path '%s'. Build does not support SQLite database format.", fs::PathToString(path)));
1455-
status = DatabaseStatus::FAILED_BAD_FORMAT;
1456-
return nullptr;
1457-
}
1444+
return MakeSQLiteDatabase(path, options, status, error);
14581445
}
14591446

14601447
if (format == DatabaseFormat::BERKELEY_RO) {

test/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ function(create_test_config)
1616
endmacro()
1717

1818
set_configure_variable(ENABLE_WALLET ENABLE_WALLET)
19-
set_configure_variable(WITH_SQLITE USE_SQLITE)
2019
set_configure_variable(WITH_BDB USE_BDB)
2120
set_configure_variable(BUILD_CLI BUILD_BITCOIN_CLI)
2221
set_configure_variable(BUILD_UTIL BUILD_BITCOIN_UTIL)

test/config.ini.in

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ RPCAUTH=@abs_top_srcdir@/share/rpcauth/rpcauth.py
1616
[components]
1717
# Which components are enabled. These are commented out by `configure` if they were disabled when running config.
1818
@ENABLE_WALLET_TRUE@ENABLE_WALLET=true
19-
@USE_SQLITE_TRUE@USE_SQLITE=true
2019
@USE_BDB_TRUE@USE_BDB=true
2120
@BUILD_BITCOIN_CLI_TRUE@ENABLE_CLI=true
2221
@BUILD_BITCOIN_UTIL_TRUE@ENABLE_BITCOIN_UTIL=true

test/functional/mempool_persist.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def set_test_params(self):
5757

5858
def run_test(self):
5959
self.mini_wallet = MiniWallet(self.nodes[2])
60-
if self.is_sqlite_compiled():
60+
if self.is_wallet_compiled():
6161
self.nodes[2].createwallet(
6262
wallet_name="watch",
6363
descriptors=True,
@@ -71,7 +71,7 @@ def run_test(self):
7171
tx_creation_time_lower = int(time.time())
7272
for _ in range(5):
7373
last_txid = self.mini_wallet.send_self_transfer(from_node=self.nodes[2])["txid"]
74-
if self.is_sqlite_compiled():
74+
if self.is_wallet_compiled():
7575
self.nodes[2].syncwithvalidationinterfacequeue() # Flush mempool to wallet
7676
node2_balance = wallet_watch.getbalance()
7777
self.sync_all()
@@ -135,7 +135,7 @@ def run_test(self):
135135
assert_equal(entry_prioritised_before_restart['fees']['base'] + Decimal('0.00009999'), entry_prioritised_before_restart['fees']['modified'])
136136

137137
# Verify accounting of mempool transactions after restart is correct
138-
if self.is_sqlite_compiled():
138+
if self.is_wallet_compiled():
139139
self.nodes[2].loadwallet("watch")
140140
wallet_watch = self.nodes[2].get_wallet_rpc("watch")
141141
self.nodes[2].syncwithvalidationinterfacequeue() # Flush mempool to wallet

test/functional/test_framework/test_framework.py

-9
Original file line numberDiff line numberDiff line change
@@ -923,11 +923,6 @@ def skip_if_no_wallet(self):
923923
if not self.is_wallet_compiled():
924924
raise SkipTest("wallet has not been compiled.")
925925

926-
def skip_if_no_sqlite(self):
927-
"""Skip the running test if sqlite has not been compiled."""
928-
if not self.is_sqlite_compiled():
929-
raise SkipTest("sqlite has not been compiled.")
930-
931926
def skip_if_no_bdb(self):
932927
"""Skip the running test if BDB has not been compiled."""
933928
if not self.is_bdb_compiled():
@@ -994,10 +989,6 @@ def is_usdt_compiled(self):
994989
"""Checks whether the USDT tracepoints were compiled."""
995990
return self.config["components"].getboolean("ENABLE_USDT_TRACEPOINTS")
996991

997-
def is_sqlite_compiled(self):
998-
"""Checks whether the wallet module was compiled with Sqlite support."""
999-
return self.config["components"].getboolean("USE_SQLITE")
1000-
1001992
def is_bdb_compiled(self):
1002993
"""Checks whether the wallet module was compiled with BDB support."""
1003994
return self.config["components"].getboolean("USE_BDB")

test/functional/wallet_avoid_mixing_output_types.py

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def set_test_params(self):
124124

125125
def skip_test_if_missing_module(self):
126126
self.skip_if_no_wallet()
127-
self.skip_if_no_sqlite()
128127

129128
def make_payment(self, A, B, v, addr_type):
130129
fee_rate = random.randint(1, 20)

test/functional/wallet_descriptor.py

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def set_test_params(self):
3030

3131
def skip_test_if_missing_module(self):
3232
self.skip_if_no_wallet()
33-
self.skip_if_no_sqlite()
3433
self.skip_if_no_py_sqlite3()
3534

3635
def test_concurrent_writes(self):

test/functional/wallet_fast_rescan.py

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def set_test_params(self):
2525

2626
def skip_test_if_missing_module(self):
2727
self.skip_if_no_wallet()
28-
self.skip_if_no_sqlite()
2928

3029
def get_wallet_txids(self, node: TestNode, wallet_name: str) -> list[str]:
3130
w = node.get_wallet_rpc(wallet_name)

test/functional/wallet_importdescriptors.py

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def set_test_params(self):
4444

4545
def skip_test_if_missing_module(self):
4646
self.skip_if_no_wallet()
47-
self.skip_if_no_sqlite()
4847

4948
def test_importdesc(self, req, success, error_code=None, error_message=None, warnings=None, wallet=None):
5049
"""Run importdescriptors and assert success"""

test/functional/wallet_listdescriptors.py

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def set_test_params(self):
2323

2424
def skip_test_if_missing_module(self):
2525
self.skip_if_no_wallet()
26-
self.skip_if_no_sqlite()
2726

2827
# do not create any wallet by default
2928
def init_wallet(self, *, node):

test/functional/wallet_miniscript.py

-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ def set_test_params(self):
209209

210210
def skip_test_if_missing_module(self):
211211
self.skip_if_no_wallet()
212-
self.skip_if_no_sqlite()
213212

214213
def watchonly_test(self, desc):
215214
self.log.info(f"Importing descriptor '{desc}'")

test/functional/wallet_multisig_descriptor_psbt.py

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def set_test_params(self):
2323

2424
def skip_test_if_missing_module(self):
2525
self.skip_if_no_wallet()
26-
self.skip_if_no_sqlite()
2726

2827
@staticmethod
2928
def _get_xpub(wallet, internal):

0 commit comments

Comments
 (0)