Merge bitcoin/bitcoin#36008: wallet: WalletBatch->WriteVersion respect argument

ec5d19665b wallet: WalletBatch->WriteVersion respect argument. (David Gumberg)

Pull request description:

  > Previously would use global `CLIENT_VERSION` no matter what, but this is one sense a refactor since all of the places where WriteVersion is called currently call it with `CLIENT_VERSION` anyways. The `client_version` argument is kept since future test code may want to write other versions.

  > Addresses a review comment from [#32636](https://github.com/bitcoin/bitcoin/pull/32636#discussion_r2356299627):

  This was originally pointed out in https://github.com/bitcoin/bitcoin/pull/32636#discussion_r2356299627, and the followup (#34490) was never merged. However I think it's confusing to have functions that take arguments but ignore them (and it's dead code), so I've cherry-picked the fix up from #34490.

ACKs for top commit:
  achow101:
    ACK ec5d19665b
  pablomartin4btc:
    ACK ec5d19665b
  w0xlt:
    ACK ec5d19665b

Tree-SHA512: 3ad82d979493ac14704975bef504c791ac72fe7910c25097f0019bf61e3d384b0e1646f90c730d2f655733428b14ccd0196c333df2d6153ff5b55ab41918a6dd
This commit is contained in:
Ava Chow
2026-08-18 15:53:00 -07:00

View File

@@ -271,8 +271,14 @@ public:
DBErrors LoadWallet(CWallet* pwallet);
//! Write the given client_version.
bool WriteVersion(int client_version) { return m_batch->Write(DBKeys::VERSION, CLIENT_VERSION); }
/**
* Write the given `client_version` to m_batch, indicating the last version
* of client software to load this wallet.
*
* @param[in] client_version `CLIENT_VERSION` outside of test code.
* @return A bool indicating whether or not the write succeeded.
*/
bool WriteVersion(int client_version) { return m_batch->Write(DBKeys::VERSION, client_version); }
//! Delete records of the given types
bool EraseRecords(const std::unordered_set<std::string>& types);