Merge bitcoin/bitcoin#32553: wallet: Fix logging of wallet version

4b2cd0b41f test: check that creating a wallet does not log version info (Ava Chow)
39a483c8e9 test: Check that the correct versions are logged on wallet load (Ava Chow)
359ecd3704 walletdb: Log the wallet version after it has been read from disk (Ava Chow)

Pull request description:

  The wallet's version (in the minversion record) needs to be logged only after we have read it from disk. Otherwise, we always log the lowest version number of 10500 which is incorrect. Furthermore, it doesn't make sense to log the last client version number if the record didn't exist. This is a regression caused by #26021.

  The wallet file version logging is moved inside of `LoadMinVersion` so that it is logged after the record is read. It will also log unconditionally if a version is read so that the version number is reported even when there is an error. The last client logging is split into its own log line that will only occur if a last client record is read. The only situation where we expect no version numbers to be logged is when a wallet is being created.

  A test is added in the second commit to check that the version number is correctly logged on loading. This commit can be cherrypicked to master to verify that it fails there. The last commit adds an additional check that creating a new wallet does not log any version info at all.

ACKs for top commit:
  laanwj:
    Code review ACK 4b2cd0b41f
  janb84:
    ACK 4b2cd0b41f
  furszy:
    ACK 4b2cd0b41f
  rkrux:
    ACK 4b2cd0b41f

Tree-SHA512: b30c76f414d87be6c14b42d2d3c8794a91a7e8601501f4c24641d51ff2b5c5144776563baf41ca1c38415844740b760b19a3e5791f78013b39984dfedd3b1de7
This commit is contained in:
merge-script
2025-05-20 12:22:25 +01:00
2 changed files with 15 additions and 1 deletions

View File

@@ -165,6 +165,19 @@ class CreateWalletTest(BitcoinTestFramework):
self.log.info("Test that legacy wallets cannot be created")
assert_raises_rpc_error(-4, 'descriptors argument must be set to "true"; it is no longer possible to create a legacy wallet.', self.nodes[0].createwallet, wallet_name="legacy", descriptors=False)
self.log.info("Check that the version number is being logged correctly")
with node.assert_debug_log(expected_msgs=[], unexpected_msgs=["Last client version = ", "Wallet file version = "]):
node.createwallet("version_check")
wallet = node.get_wallet_rpc("version_check")
wallet_version = wallet.getwalletinfo()["walletversion"]
client_version = node.getnetworkinfo()["version"]
wallet.unloadwallet()
with node.assert_debug_log(
expected_msgs=[f"Last client version = {client_version}", f"Wallet file version = {wallet_version}"],
unexpected_msgs=["Wallet file version = 10500"]
):
node.loadwallet("version_check")
if __name__ == '__main__':
CreateWalletTest(__file__).main()