achow101
commented at 10:24 PM on September 23, 2019:
member
Adds a checksum to the encrypted key record in the wallet database so that encrypted keys can be checked for corruption on wallet loading, in the same way that unencrypted keys are. This allows for us to skip the full decryption of keys upon the first unlocking of the wallet in that session as any key corruption will have already been detected. The checksum is just the double SHA256 of the encrypted key and it is appended to the record after the encrypted key itself.
This is backwards compatible as old wallets will be able to read the encrypted key and ignore that there is more data in the stream. Additionally, old wallets will be upgraded upon their first unlocking (so that key decryption is checked before we commit to a checksum of the encrypted key) and a wallet flag set indicating that. The presence of the wallet flag lets us skip the full decryption as if fDecryptionThoroughlyChecked were true.
This does mean that the first time an old wallet is unlocked in a new version will take much longer, but subsequent unlocks will be instantaneous. Furthermore, corruption will be detected upon loading rather than on trying to send so wallet corruption will be detected sooner.
Please note the first return false; which makes the re-try logic unreachable :)
achow101 force-pushed on Sep 25, 2019
achow101
commented at 10:09 PM on September 25, 2019:
member
I'm afraid the current version of this PR will introduce a bug in WalletBatch::WriteCryptedKey:
Please note the first return false; which makes the re-try logic unreachable :)
Whoops, fixed.
laanwj added the label Feature on Sep 30, 2019
laanwj
commented at 7:27 PM on October 28, 2019:
member
Concept ACK
laanwj added this to the milestone 0.20.0 on Oct 28, 2019
DrahtBot added the label Needs rebase on Oct 29, 2019
achow101 force-pushed on Oct 29, 2019
DrahtBot removed the label Needs rebase on Oct 29, 2019
luke-jr
commented at 2:18 AM on November 3, 2019:
member
a wallet flag set indicating that. The presence of the wallet flag lets us skip the full decryption as if fDecryptionThoroughlyChecked were true.
What happens if I open with new version, then switch back to an old version, generate some new keys, then switch back to the new?
Is a wallet flag really needed at all? Shouldn't verifying checksums also reveal if there are checksums missing?
DrahtBot added the label Needs rebase on Nov 4, 2019
achow101 force-pushed on Nov 4, 2019
achow101
commented at 6:44 PM on November 4, 2019:
member
This is currently getting messed up by the ScriptPubKeyMan changes. Will fix, rebase, and address comments after ScriptPubKeyMan is fully introduced.
achow101 force-pushed on Nov 4, 2019
achow101 force-pushed on Dec 4, 2019
achow101
commented at 12:26 AM on December 4, 2019:
member
I've rebased onto master and included #17369 as a prerequisite. I've also reworked it according to @luke-jr's suggestions. Instead of a wallet flag, we reuse fDecryptionThoroughlyChecked to let as avoid the decryption check. This also makes it easier for us to write (or rewrite) the checksums if they don't exist (or are invalid).
DrahtBot removed the label Needs rebase on Dec 4, 2019
DrahtBot added the label Needs rebase on Dec 6, 2019
achow101 force-pushed on Dec 6, 2019
DrahtBot removed the label Needs rebase on Dec 6, 2019
laanwj
commented at 12:23 PM on December 12, 2019:
member
Might want to rebase to get rid of the commits from #17369 and make it easier to review.
achow101 force-pushed on Dec 12, 2019
achow101
commented at 4:13 PM on December 12, 2019:
member
Rebased
DrahtBot added the label Needs rebase on Jan 30, 2020
Read and write a checksum for encrypted keysa8334f7ac3
Set fDecryptionThoroughlyChecked based on whether crypted key checksums are valid
Change fDecryptionThoroughlyChecked to default to true so that it can
latch to false when an invalid checksum is seen. Checksums may be invalid
if the wallet does not have checksums or if the wallet became corrupted.
It is safe to default fDecryptionThoroughlyChecked to true because any
existing wallet without a checksum will set it to false. Any new or
blank wallet where encrypted keys are added will then set this to true
when the first encrypted key is generated by virtue of CheckDecryptionKey
doing that during the initial Unlock prior to keys being added.
c9a9ddb414
Upgrade or rewrite encrypted key checksums
If fDecryptionThoroughlyChecked is false, after a key has been checked,
write (or rewrite) its checksum. This serves to upgrade wallets
and correct those which have the checksum corrupted but not the key.
d67055e00d
achow101 force-pushed on Jan 30, 2020
DrahtBot removed the label Needs rebase on Jan 30, 2020
jonatack
commented at 5:31 PM on March 24, 2020:
member
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2026-04-17 09:14 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me