diff options
| author | Bitflash <btf01@proton.me> | 2026-08-01 12:56:16 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-01 12:56:16 -0300 |
| commit | 7131c30c33c980f0ba1d37dfc6a3fbe8c319813e (patch) | |
| tree | 668de28f9aec4f8f350146f1d824b487752cf747 /src/db.cpp | |
| parent | b426948b966405b65f3ea6c1994164b462980694 (diff) | |
wallet: generate keys ahead of use so a backup outlives the next block (#85)
The wallet made a key per address and per block mined, so a backup only ever
contained the keys that existed the moment it was taken -- mine one block and
the coin lands on a key the backup has never heard of. The README warned about
it, which is an admission rather than a fix.
Keys are now generated a hundred at a time and handed out one at a time, each
written to wallet.dat before it can be pointed at. A backup covers the next
hundred addresses. Deterministic derivation (#47) stays open; this buys back the
distance between a backup and the next mistake.
Diffstat (limited to 'src/db.cpp')
| -rw-r--r-- | src/db.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
| @@ -636,6 +636,14 @@ bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet) | |||
| 636 | { | 636 | { |
| 637 | ssValue >> vchDefaultKeyRet; | 637 | ssValue >> vchDefaultKeyRet; |
| 638 | } | 638 | } |
| 639 | else if (strType == "pool") | ||
| 640 | { | ||
| 641 | int64 nIndex; | ||
| 642 | ssKey >> nIndex; | ||
| 643 | vector<unsigned char> vchPubKey; | ||
| 644 | ssValue >> vchPubKey; | ||
| 645 | mapKeyPool[nIndex] = vchPubKey; | ||
| 646 | } | ||
| 639 | else if (strType == "setting") /// or settings or option or options or config? | 647 | else if (strType == "setting") /// or settings or option or options or config? |
| 640 | { | 648 | { |
| 641 | string strKey; | 649 | string strKey; |