From 25aa15ee7fc6d8f941fff7be5b3abed09a2ce12a Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Sun, 18 May 2025 11:39:51 -0700 Subject: [PATCH] walletdb: Log the wallet version after it has been read from disk Logging the wallet version before anything has been read from disk results in the wrong version being logged. Also split the last client version logging as it may not always be present to be logged. Github-Pull: #32553 Rebased-From: 359ecd3704993422eb53e3da2a7d0bea2f575ab0 --- src/wallet/walletdb.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index c939ebb1fd4..981f8c61617 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -471,6 +471,7 @@ static DBErrors LoadMinVersion(CWallet* pwallet, DatabaseBatch& batch) EXCLUSIVE AssertLockHeld(pwallet->cs_wallet); int nMinVersion = 0; if (batch.Read(DBKeys::MINVERSION, nMinVersion)) { + pwallet->WalletLogPrintf("Wallet file version = %d\n", nMinVersion); if (nMinVersion > FEATURE_LATEST) return DBErrors::TOO_NEW; pwallet->LoadMinVersion(nMinVersion); @@ -1181,7 +1182,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet) // Last client version to open this wallet int last_client = CLIENT_VERSION; bool has_last_client = m_batch->Read(DBKeys::VERSION, last_client); - pwallet->WalletLogPrintf("Wallet file version = %d, last client version = %d\n", pwallet->GetVersion(), last_client); + if (has_last_client) pwallet->WalletLogPrintf("Last client version = %d\n", last_client); try { if ((result = LoadMinVersion(pwallet, *m_batch)) != DBErrors::LOAD_OK) return result;