Skip to content

Wallet: Rescan imported mnemonic wallets - #1319

Open
Tabakkui wants to merge 1 commit into
RavenProject:developfrom
Tabakkui:fix/issue-1081-mnemonic-rescan
Open

Tabakkui wants to merge 1 commit into
RavenProject:developfrom
Tabakkui:fix/issue-1081-mnemonic-rescan

Conversation

@Tabakkui

Copy link
Copy Markdown

Problem

When a first-run wallet is created from an imported BIP39 mnemonic while the chain already has history, CWallet::CreateWalletFromFile writes the current chain locator before its startup rescan. The subsequent rescan therefore starts at the tip and restored funds are not discovered until a manual rescan. This is the behavior reported by #1081.

Approach

  • Track whether the first-run wallet uses an imported mnemonic, including the GUI restore path.
  • Do not persist the current best-chain locator before the imported-mnemonic rescan.
  • Scan from the genesis block without applying the new-wallet birthday shortcut, then persist the locator after the scan.
  • Preserve the existing fast path for newly generated wallets.

Test plan

  • git diff --check
  • python3 -m py_compile test/functional/wallet_mnemonic_rescan.py
  • Structural verification: 7/7 checks passed, including comparison against the pre-fix origin/develop source shape.
  • Added test/functional/wallet_mnemonic_rescan.py, which funds a deterministic address, removes wallet.dat, recreates the wallet from the same mnemonic, and checks the restored balance.
  • The functional test was attempted before and after the fix but cannot start because this ARM64 checkout has no built ravend binary or configured Makefile (FileNotFoundError: [Errno 2] No such file or directory: "ravend").

Risk and exclusions

This changes only first-run imported-mnemonic wallet initialization and its rescan anchor. Newly generated wallets retain the existing best-chain shortcut. It does not change consensus rules, mnemonic derivation, or the general rescan scheduler.

Fixes #1081

A first-run wallet created from an imported mnemonic writes the current chain locator before the startup rescan. This makes the rescan start at the tip, so funds received by the restored deterministic addresses remain absent until a manual rescan.\n\nKeep the initial best-chain write out of imported-mnemonic initialization, scan the full available history, and preserve the normal wallet-birthday optimization for newly generated wallets. Track the GUI restore choice separately from the generated-seed path.\n\nAdd a functional regression that creates a funded chain, removes wallet.dat, and recreates the wallet from the same mnemonic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant