diff options
| author | Bitflash <btf01@proton.me> | 2026-08-01 14:48:27 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-01 14:48:27 -0300 |
| commit | b65c19e559e2fec511f40a4d5481bcf6a35c311c (patch) | |
| tree | e54c0c58d44c46befae58924b1df913816b569e9 /src/main.h | |
| parent | ae81fa37123730982c4e054d7433c9d0c944a373 (diff) | |
wallet: walk the chain for coins a key owns but the wallet never saw (#88)
A transaction only entered the wallet when its block arrived over the network,
so a key added afterwards was invisible: coins on the chain, private key in
wallet.dat, balance zero. /importwallet has always ended that way -- it writes
the keys and the money never shows up, which looks exactly like a failed import.
ScanForWalletTransactions walks the main chain and hands every transaction that
IsMine() to AddToWalletIfMine, the same two primitives the live path uses. Wired
into /importwallet, and offered as /rescan.
It is also the half that any recovery-phrase feature has to stand on: deriving
keys from twelve words is easy, and without this a restore restores nothing.
Diffstat (limited to 'src/main.h')
| -rw-r--r-- | src/main.h | 5 |
1 files changed, 5 insertions, 0 deletions
| @@ -152,6 +152,11 @@ void TopUpKeyPool(); | |||
| 152 | vector<unsigned char> GetKeyFromPool(); | 152 | vector<unsigned char> GetKeyFromPool(); |
| 153 | bool AddToWallet(const CWalletTx& wtxIn); | 153 | bool AddToWallet(const CWalletTx& wtxIn); |
| 154 | void ReacceptWalletTransactions(); | 154 | void ReacceptWalletTransactions(); |
| 155 | // Walk the chain from pindexStart forward, adding every transaction that pays | ||
| 156 | // a key this wallet holds. Returns how many were added or updated. Needed by | ||
| 157 | // anything that puts a key into the wallet after the fact -- an import, a | ||
| 158 | // restored backup, and later a recovery phrase. | ||
| 159 | int ScanForWalletTransactions(CBlockIndex* pindexStart); | ||
| 155 | // Returns how many wallet transactions the chain corrected. | 160 | // Returns how many wallet transactions the chain corrected. |
| 156 | int RescanSpentFlags(); | 161 | int RescanSpentFlags(); |
| 157 | void RelayWalletTransactions(); | 162 | void RelayWalletTransactions(); |