Andrew Chow 5690848dfb
Merge bitcoin/bitcoin#26532: wallet: bugfix, invalid crypted key "checksum_valid" set
13d97608297bd56ed033d0e754d2e50447b02af0 test: load wallet, coverage for crypted keys (furszy)
373c99633ec7f20557db2734c49116ee4ad15423 refactor: move DuplicateMockDatabase to wallet/test/util.h (furszy)
ee7a984f85015b610be4929b7c35cb501c1fbf7c refactor: unify test/util/wallet.h with wallet/test/util.h (furszy)
cc5a5e81217506ec6f9fff34056290f8f40a7396 wallet: bugfix, invalid crypted key "checksum_valid" set (furszy)

Pull request description:

  At wallet load time, the crypted key "checksum_valid" variable is always set to false. Which, on every wallet decryption call, forces the process to re-write all the ckeys to db when it's not needed.

  Note:
  The first commit fixes the issue, the two commits in the middle are cleanups so `DuplicateMockDatabase`
  can be used without duplicating code. And, the last one is pure test coverage for the crypted keys loading
  process.

  Includes test coverage for the following scenarios:

  1) "All ckeys checksums valid" test:
  Loads an encrypted wallet with all the crypted keys with a valid checksum and
  verifies that 'CWallet::Unlock' doesn't force an entire crypted keys re-write.

      (we force a complete ckeys re-write if we find any missing crypted key checksum
  during the wallet loading process)

  2) "Missing checksum in one ckey" test:
  Verifies that loading up a wallet with, at least one, 'ckey' with no checksum
  triggers a complete re-write of the crypted keys.

  3) "Invalid ckey checksum error" test:
  Verifies that loading up a ckey with an invalid checksum stops the wallet loading
  process with a corruption error.

  4) "Invalid ckey pubkey error" test:
  Verifies that loading up a ckey with an invalid pubkey stops the wallet loading
  process with a corruption error.

ACKs for top commit:
  achow101:
    ACK 13d97608297bd56ed033d0e754d2e50447b02af0
  aureleoules:
    ACK 13d97608297bd56ed033d0e754d2e50447b02af0

Tree-SHA512: 9ea630ee4a355282fbeee61ca04737294382577bb4b2631f50e732568fdab8f72491930807fbda58206446c4f26200cdc34d8afa14dbe1241aec713887d06a0b
2022-11-29 18:54:57 -05:00
..
2022-10-26 15:55:29 +03:00
2022-09-23 10:48:47 +01:00
2022-10-10 15:44:02 +01:00
2022-04-20 14:29:29 +01:00
2022-10-18 14:12:42 +02:00
2022-07-20 15:34:36 +02:00
2022-11-01 10:14:49 +00:00
2022-11-01 10:14:49 +00:00
2021-12-30 19:36:57 +02:00
2022-08-04 11:32:25 +02:00
2022-11-01 10:14:49 +00:00
2022-08-04 11:32:25 +02:00
2022-07-26 11:05:04 +02:00
2021-12-30 19:36:57 +02:00
2021-12-30 19:36:57 +02:00
2022-08-05 14:59:15 +02:00
2022-08-05 14:59:15 +02:00