upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/main.h
diff options
context:
space:
mode:
authorBitflash <btf01@proton.me>2026-08-01 14:48:27 -0300
committerGitHub <noreply@github.com>2026-08-01 14:48:27 -0300
commitb65c19e559e2fec511f40a4d5481bcf6a35c311c (patch)
treee54c0c58d44c46befae58924b1df913816b569e9 /src/main.h
parentae81fa37123730982c4e054d7433c9d0c944a373 (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.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/main.h b/src/main.h
index 1d9efac..8d9b7e6 100644
--- a/src/main.h
+++ b/src/main.h
@@ -152,6 +152,11 @@ void TopUpKeyPool();
152vector<unsigned char> GetKeyFromPool(); 152vector<unsigned char> GetKeyFromPool();
153bool AddToWallet(const CWalletTx& wtxIn); 153bool AddToWallet(const CWalletTx& wtxIn);
154void ReacceptWalletTransactions(); 154void 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.
159int ScanForWalletTransactions(CBlockIndex* pindexStart);
155// Returns how many wallet transactions the chain corrected. 160// Returns how many wallet transactions the chain corrected.
156int RescanSpentFlags(); 161int RescanSpentFlags();
157void RelayWalletTransactions(); 162void RelayWalletTransactions();