From 92e6c7008d3d6038bb5e8055d0c2100ad6772466 Mon Sep 17 00:00:00 2001 From: DanS Date: Sun, 23 Aug 2026 18:58:24 +0200 Subject: [PATCH] wallet: define CHDChain's static constants out of line hush-gtest failed to link with "undefined reference to CHDChain::VERSION_HD_MNEMONIC". The version constants are static const int with in-class initialisers and no definition anywhere, so any ODR use needs one -- and gtest's EXPECT_*/ASSERT_* macros take their arguments by const reference, which is exactly that. test_mnemonic_compat.cpp:161 passes VERSION_HD_MNEMONIC to EXPECT_LT. dragonxd links either way, because nothing in the daemon binds these to a reference; only the test target exposed it, and the test target was never built on the branch that introduced the test. Define all four rather than only the one that failed: VERSION_HD_BASE, VERSION_HD_TRANSPARENT and CURRENT_VERSION carry the identical latent fault, and the next EXPECT_EQ against any of them would hit the same wall. Fixing the test instead would have hidden the problem rather than removed it. Co-Authored-By: Claude Opus 5 (1M context) --- src/wallet/walletdb.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index abac194ba..31e83e4b5 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -34,6 +34,15 @@ #include #include +// Out-of-line definitions for CHDChain's in-class static constants. These are +// only initialised in the class body, so any ODR use -- binding one to a const +// reference, which is exactly what gtest's EXPECT_*/ASSERT_* macros do -- needs +// a definition or the link fails. hush-gtest hit this on VERSION_HD_MNEMONIC. +const int CHDChain::VERSION_HD_BASE; +const int CHDChain::VERSION_HD_TRANSPARENT; +const int CHDChain::VERSION_HD_MNEMONIC; +const int CHDChain::CURRENT_VERSION; + using namespace std; static uint64_t nAccountingEntryNumber = 0;