Skip to content

feat: implement exponential retention for wallet backups - #7005

Open
PastaPastaPasta wants to merge 2 commits into
dashpay:developfrom
PastaPastaPasta:feat/wallet-backups
Open

PastaPastaPasta wants to merge 2 commits into
dashpay:developfrom
PastaPastaPasta:feat/wallet-backups

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Nov 23, 2025 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Automatic backups of legacy wallets keep only the 10 most recent files. Because a
backup is written on every keypool replenishment, a wallet that mixes actively can
churn through all 10 slots in a few hours, leaving no restore point older than that
— exactly the situation where a backup is most useful (a mistake noticed days later,
a wallet corrupted by a bad shutdown, an accidental sweep).

This keeps far more history for roughly the same disk footprint, by spacing older
backups out exponentially instead of deleting them by age alone.

What was done?

Retention now has two parts:

  • The most recent -createwalletbackups files (default 10, max 20) are always kept,
    by count, regardless of age. This is the old behavior, unchanged.
  • Beyond that window, at most one backup is kept per exponentially widening age range,
    measured in hours relative to the newest backup: [1,2) hours, [2,4), [4,8),
    ... [512,1024) (3-6 weeks), [1024,2048) and so on, preferring the oldest file in
    each range. A range can be empty for a while after its backup ages into the next one.
    The total is capped by the new -maxwalletbackups (default 30).

So a wallet that mixes all day and writes a backup every ~72 minutes keeps its last
10 backups (about 11 hours) and, after 60 days, restore points about 13 and 18 hours
and 2, 9, 34 and 60 days old: 16 files. With the old "10 most recent" rule the same
wallet has nothing older than 11 hours.

The ranges start at an hour rather than a day on purpose. The wallets this is for
are exactly the ones writing more backups per day than the count window holds; with
day-sized ranges every backup would be pruned before it ever reached a day old, and
retention would degrade to the old behavior.

Notable details:

  • Age comes from the filename, and only from the filename. AutoBackupWallet()
    already embeds a UTC timestamp in every backup name (wallet.dat.YYYY-MM-DD-HH-MM),
    and the new ParseBackupFileTime() reads it back. Filesystem mtimes are not consulted
    at all. This addresses knst's review: mtimes are not preserved by all filesystems, are
    rewritten by cloud-sync tools, and are reset by cross-device or cross-OS copies — the
    filename survives all of those.
  • Pruning only touches files it recognises as its own. A name that doesn't parse
    isn't a file we wrote, so retention skips it. A renamed backup is therefore kept
    indefinitely and doesn't count towards -maxwalletbackups. The current code
    enumerates every wallet.dat.* file by mtime and will delete a file a user put there
    deliberately.
  • A wrong system clock cannot cost you a recent backup. Pruning only runs right
    after a backup was written, and only considers backups dated at or before that one,
    so the backup just written is always the newest candidate and is inside the by-count
    window. Backups dated later than it (possible only after the clock moved backward)
    are left untouched until the clock catches up. A large forward jump can collapse
    older history into one or two age ranges, but the count window is positional, so the
    result is never fewer backups than the current keep-newest-N rule keeps. Defending
    against that would need an ordinal in the filename, i.e. a new filename format and a
    migration, which this PR deliberately does not do.
  • Retention beyond the count window is time-bucketed, not generational. A
    "keep every Nth" scheme lets a burst of mixing sessions flush out genuinely old
    restore points, which is the failure mode this change exists to prevent.
  • If -maxwalletbackups binds, the most recent age ranges are the ones kept. With
    the defaults (10 + up to 20 ranges, and a year is ~14 ranges) it practically never
    binds; a user who lowers it gets a stable, contiguous recent history.
  • 0 disables. Both -createwalletbackups=0 and -maxwalletbackups=0 disable
    automatic backups entirely. GetBackupsToDelete() deletes nothing when either limit
    is not positive, which also covers the -1/-2 failure states of nWalletBackups.
  • The nWalletBackups global stays where it is (common/system), so the GUI and
    CoinJoin code that read it are untouched. The new cap is a CWallet static,
    nMaxWalletBackups, used only by wallet code.
  • Documentation: a new "Automatic Backups" section in doc/managing-wallets.md, which
    the -createwalletbackups help text points at, and doc/release-notes-7005.md.

How Has This Been Tested?

New unit test suite src/wallet/test/backup_tests.cpp (5 cases):

  • retention_by_count_and_age: exact kept sets for a not-yet-full count window, a
    same-hour burst, 100 daily backups, the -maxwalletbackups cap (binding, and equal to
    the count window), a 60-day gap, and "delete nothing" for non-positive limits.
  • clock_moved_backward: the backup just written survives and later-dated files are
    left alone (fails without the upper_bound(backup_time) cut).
  • frequent_backups_keep_history: replays 60 days of a wallet writing 20 backups a day
    through repeated pruning (fails with day-sized ranges: nothing older than 11 hours
    survives).
  • init_auto_backup_clamping and parse_backup_file_time: argument clamping and the
    filename parser's accept/reject table. The fixtures build their filenames with
    FormatBackupFileTime(), the function AutoBackupWallet() now uses, so the parser is
    tested against what the writer produces.

Locally on macOS arm64 (Autotools build, --enable-debug --enable-werror, before the rebase onto CMake):
test_dash --run_test=backup_tests,init_tests,coinjoin_tests and functional
wallet_backup.py --legacy-wallet and wallet_keypool.py --legacy-wallet pass. Removing
the upper_bound(backup_time) cut and the non-positive guard makes clock_moved_backward
and retention_by_count_and_age fail.

End to end on regtest: seeded a legacy wallet's backups directory with 25 daily files,
a future-dated one, an unparseable name and another wallet's backup, then loaded the
wallet. The new backup plus the 9 most recent stayed, one file stayed for each of the
[512,1024) and [1024,2048) hour ranges, the other 14 were deleted, and the
future-dated, unparseable and other-wallet files were untouched.

After #7481 (the CMake cut-over) merged, this PR was rebased onto it and
backup_tests.cpp is registered in src/wallet/test/CMakeLists.txt. On that head, a
CMake build on macOS arm64 (-DWERROR=ON -DWITH_BDB=ON, no GUI) builds test_dash, and
test_dash --run_test=backup_tests,init_tests,coinjoin_tests,wallet_tests passes with all
five backup_tests cases present. The functional tests, the mutation checks and the
regtest run above were done on the Autotools build before that rebase and were not
repeated.

Breaking Changes

None for existing setups. Default disk usage for automatic backups of legacy wallets
grows from up to 10 files to up to 30 (-maxwalletbackups=10 restores the previous
footprint). -maxwalletbackups is new; -createwalletbackups keeps its meaning and
default, with its documented maximum raised from 10 to 20.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

🤖 Generated with Claude Code

@PastaPastaPasta PastaPastaPasta added this to the 23.1 milestone Nov 23, 2025
@github-actions

github-actions Bot commented Nov 23, 2025 •

Copy link
Copy Markdown

⚠️ Potential Merge Conflicts Detected

This PR has potential conflicts with the following open PRs:

Please coordinate with the authors of these PRs to avoid merge conflicts.

@coderabbitai

coderabbitai Bot commented Nov 23, 2025 •

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

  • Last reviewed commit: 94ffc357d63d46d88568d79dcd720565d93121b6
  • Latest commit, not reviewed: 4713fcd

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This PR makes wallet backup retention configurable and refactors status access: adds CLI options -createwalletbackups=<n> and -maxwalletbackups=<n>, new constants and CWallet static members (nWalletBackups, nMaxWalletBackups), and a GetBackupsToDelete(...) retention helper used by automatic backup and unlock re-init flows. It changes InitAutoBackup to accept ArgsManager, adds unit tests and test registration for retention logic, introduces Wallet::getWalletBackupStatus(), implements it, replaces direct global access with that API in UI and coinjoin code, and removes the old global nWalletBackups.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as Command Line (ArgsManager)
    participant Init as WalletInit
    participant Wallet as CWallet
    participant Backup as BackupLogic
    participant FS as File System
    participant UI as Qt/CoinJoin UI

    CLI->>Init: Parse -createwalletbackups / -maxwalletbackups
    Init->>Wallet: Set nWalletBackups, nMaxWalletBackups

    rect rgba(200,220,240,0.5)
    Wallet->>Backup: Trigger auto/manual backup
    Backup->>Backup: GetBackupsToDelete(backups, nWalletBackups, nMaxWalletBackups)
    Backup->>FS: Write new backup
    Backup->>FS: Delete selected old backups
    end

    rect rgba(220,200,240,0.5)
    Wallet->>Init: On unlock call InitAutoBackup(ArgsManager)
    Init->>Wallet: Clamp/enforce nWalletBackups <= nMaxWalletBackups
    end

    Wallet->>UI: WalletImpl.getWalletBackupStatus()
    UI->>UI: Update coinjoin/overview logic based on status
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Pre-merge checks: Passed 2

Check name Status Explanation
Title check Passed The title "feat: implement exponential retention for wallet backups" names the main change. The changeset adds time-bucketed (exponential) retention through GetBackupsToDelete(), a new -maxwalletbacku…
Description check Passed The description is directly related to the changeset. It explains that automatic wallet backup retention keeps only the 10 most recent files, and it proposes exponential spacing of older backups. It n…
Full details: Title check

Explanation

The title "feat: implement exponential retention for wallet backups" names the main change. The changeset adds time-bucketed (exponential) retention through GetBackupsToDelete(), a new -maxwalletbackups option, and related wallet backup configuration. The title does not mention the new option or the GUI/CoinJoin status changes, which is acceptable because it is not expected to cover every detail.

Full details: Description check

Explanation

The description is directly related to the changeset. It explains that automatic wallet backup retention keeps only the 10 most recent files, and it proposes exponential spacing of older backups. It names the new -maxwalletbackups option, GetBackupsToDelete(), ParseBackupFileTime(), the new backup_tests.cpp suite, and the documentation changes. These match the raw summary of changes across the wallet, interface, and CoinJoin files.

Finishing Touches

🧪 Generate unit tests (beta)

  • Create PR with unit tests
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/wallet/init.cpp (1)

60-63: New wallet backup options look consistent; consider clarifying edge semantics.

The -createwalletbackups=<n> and -maxwalletbackups=<n> args are wired correctly and the help text mentions defaults and exponential spacing. As a follow‑up, you may want to explicitly document how negative or zero values are treated (e.g., clamping and whether 0 disables backups or the max cap) to avoid confusion for operators.

src/wallet/wallet.h (1)

82-86: Backup policy declarations are fine; tighten documentation of retention rule.

The new defaults (DEFAULT_MAX_BACKUPS, DEFAULT_N_WALLET_BACKUPS, MAX_N_WALLET_BACKUPS) and the GetBackupsToDelete API plus static CWallet::nWalletBackups / nMaxWalletBackups provide a clean central configuration. One improvement would be to make the comment on GetBackupsToDelete explicit that backups are sorted newest‑first and that “powers of 2 indices” refer to 1‑based positions from the newest backup, so behavior is unambiguous and matches the tests/CLI help.

Also applies to: 87-94, 505-507

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c51cb2e and 3d31016.

📒 Files selected for processing (4)
  • src/Makefile.test.include (1 hunks)
  • src/wallet/init.cpp (1 hunks)
  • src/wallet/wallet.cpp (4 hunks)
  • src/wallet/wallet.h (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: kwvg
Repo: dashpay/dash PR: 6543
File: src/wallet/receive.cpp:240-251
Timestamp: 2025-02-06T14:34:30.466Z
Learning: Pull request #6543 is focused on move-only changes and refactoring, specifically backporting from Bitcoin. Behavior changes should be proposed in separate PRs.
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.
📚 Learning: 2025-08-08T07:01:47.332Z
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.

Applied to files:

  • src/Makefile.test.include
  • src/wallet/wallet.h
  • src/wallet/init.cpp
  • src/wallet/wallet.cpp
📚 Learning: 2025-08-11T17:16:36.654Z
Learnt from: PastaPastaPasta
Repo: dashpay/dash PR: 6804
File: src/qt/proposalwizard.cpp:40-42
Timestamp: 2025-08-11T17:16:36.654Z
Learning: In the Dash repository, when a PR adds new files that are not from Bitcoin backports, these files must be added to the list in test/util/data/non-backported.txt. This applies to newly created files like qt/proposalwizard.{h,cpp} and forms/proposalwizard.ui. Limited exemptions may exist for subtrees and similar cases.

Applied to files:

  • src/Makefile.test.include
📚 Learning: 2025-02-14T15:19:17.218Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6529
File: src/wallet/rpcwallet.cpp:3002-3003
Timestamp: 2025-02-14T15:19:17.218Z
Learning: The `GetWallet()` function calls in `src/wallet/rpcwallet.cpp` are properly validated with null checks that throw appropriate RPC errors, making additional validation unnecessary.

Applied to files:

  • src/wallet/wallet.cpp
🧬 Code graph analysis (3)
src/wallet/wallet.h (1)
src/wallet/wallet.cpp (2)
  • GetBackupsToDelete (3258-3305)
  • GetBackupsToDelete (3258-3258)
src/wallet/init.cpp (1)
src/dummywallet.cpp (1)
  • argsman (31-31)
src/wallet/wallet.cpp (1)
src/wallet/init.cpp (2)
  • InitAutoBackup (237-240)
  • InitAutoBackup (237-237)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: linux64_tsan-build / Build source
  • GitHub Check: Lint / Run linters
  • GitHub Check: x86_64-w64-mingw32 / Build depends
  • GitHub Check: x86_64-apple-darwin / Build depends
  • GitHub Check: x86_64-pc-linux-gnu_nowallet / Build depends
  • GitHub Check: x86_64-pc-linux-gnu / Build depends
  • GitHub Check: arm-linux-gnueabihf / Build depends
🔇 Additional comments (1)
src/Makefile.test.include (1)

208-223: Backup tests correctly wired into test suite; ensure non‑backported tracking updated.

Adding wallet/test/backup_tests.cpp under ENABLE_WALLET integrates the new tests properly into test_dash. Also, if wallet/test/backup_tests.cpp is Dash‑specific and not a direct Bitcoin backport, it should be added to test/util/data/non-backported.txt to keep the tracking list consistent. Based on learnings.

Comment thread src/wallet/wallet.cpp Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

♻️ Duplicate comments (1)
src/wallet/test/backup_tests.cpp (1)

106-108: Same file_time_type construction issue.

This has the same issue as lines 20-22. Use fs::file_time_type::clock::now() - std::chrono::seconds(seconds_ago) instead.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d31016 and 6c39d25.

📒 Files selected for processing (1)
  • src/wallet/test/backup_tests.cpp (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.{cpp,h,hpp,cc}

📄 CodeRabbit inference engine (CLAUDE.md)

Dash Core implementation must be written in C++20, requiring at least Clang 16 or GCC 11.1

Files:

  • src/wallet/test/backup_tests.cpp
src/{test,wallet/test}/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Unit tests in src/test/ and src/wallet/test/ must use Boost::Test framework

Files:

  • src/wallet/test/backup_tests.cpp
src/wallet/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Wallet implementation must use Berkeley DB and SQLite

Files:

  • src/wallet/test/backup_tests.cpp
🧠 Learnings (3)
📓 Common learnings
Learnt from: kwvg
Repo: dashpay/dash PR: 6543
File: src/wallet/receive.cpp:240-251
Timestamp: 2025-02-06T14:34:30.466Z
Learning: Pull request #6543 is focused on move-only changes and refactoring, specifically backporting from Bitcoin. Behavior changes should be proposed in separate PRs.
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{test,wallet/test}/**/*.{cpp,h} : Unit tests in src/test/ and src/wallet/test/ must use Boost::Test framework

Applied to files:

  • src/wallet/test/backup_tests.cpp
📚 Learning: 2025-08-08T07:01:47.332Z
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.

Applied to files:

  • src/wallet/test/backup_tests.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: linux64_tsan-build / Build source
  • GitHub Check: Lint / Run linters
  • GitHub Check: x86_64-w64-mingw32 / Build depends
  • GitHub Check: x86_64-pc-linux-gnu_nowallet / Build depends
  • GitHub Check: x86_64-apple-darwin / Build depends
  • GitHub Check: x86_64-pc-linux-gnu / Build depends
  • GitHub Check: arm-linux-gnueabihf / Build depends
🔇 Additional comments (3)
src/wallet/test/backup_tests.cpp (3)

31-44: LGTM!

Cases 1 and 2 correctly test that no deletions occur when the backup count is at or below nWalletBackups.


72-101: LGTM!

Case 4 correctly tests index-based exponential distribution with varied ages. The expected deletion count (7) matches the logic of keeping the latest 10 plus the 16th backup.


12-13: No action needed—GetBackupsToDelete is properly accessible for testing.

The function is declared in the public header src/wallet/wallet.h:93 without static or anonymous namespace restrictions, giving it external linkage. The forward declaration in the test file is valid and matches the exact signature. The linker will successfully resolve the external reference.

Likely an incorrect or invalid review comment.

Comment thread src/wallet/test/backup_tests.cpp Resolved
Comment thread src/wallet/test/backup_tests.cpp Resolved
Comment thread src/wallet/test/backup_tests.cpp Resolved
Comment thread src/wallet/test/backup_tests.cpp Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/wallet/test/backup_tests.cpp (1)

31-102: Good coverage of index‑based exponential retention; consider one assertion on actual paths if behavior changes later.

The exponential_backup_logic case nicely documents and tests:

  • “< nWalletBackups” and “== nWalletBackups” no‑deletion behavior.
  • Index‑based exponential retention (latest N plus 16th, 32nd, etc.), via deletion counts.

Because you only assert on to_delete.size(), these tests will still pass if the implementation changes which specific historical backups it keeps, as long as the total count matches. That’s fine for now, but if the retention policy ever relies on keeping particular historical points (e.g., exact 16th/32nd snapshots), you may want to add at least one check on the actual kept/deleted indices (e.g., by comparing the returned fs::path names) to catch regressions.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 114a725 and d1d379a.

📒 Files selected for processing (1)
  • src/wallet/test/backup_tests.cpp (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.{cpp,h,hpp,cc}

📄 CodeRabbit inference engine (CLAUDE.md)

Dash Core implementation must be written in C++20, requiring at least Clang 16 or GCC 11.1

Files:

  • src/wallet/test/backup_tests.cpp
src/{test,wallet/test}/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Unit tests in src/test/ and src/wallet/test/ must use Boost::Test framework

Files:

  • src/wallet/test/backup_tests.cpp
src/wallet/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Wallet implementation must use Berkeley DB and SQLite

Files:

  • src/wallet/test/backup_tests.cpp
🧠 Learnings (4)
📓 Common learnings
Learnt from: kwvg
Repo: dashpay/dash PR: 6543
File: src/wallet/receive.cpp:240-251
Timestamp: 2025-02-06T14:34:30.466Z
Learning: Pull request #6543 is focused on move-only changes and refactoring, specifically backporting from Bitcoin. Behavior changes should be proposed in separate PRs.
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{test,wallet/test}/**/*.{cpp,h} : Unit tests in src/test/ and src/wallet/test/ must use Boost::Test framework

Applied to files:

  • src/wallet/test/backup_tests.cpp
📚 Learning: 2025-08-08T07:01:47.332Z
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.

Applied to files:

  • src/wallet/test/backup_tests.cpp
📚 Learning: 2025-06-09T16:43:20.996Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6718
File: test/functional/test_framework/test_framework.py:2102-2102
Timestamp: 2025-06-09T16:43:20.996Z
Learning: In the test framework consolidation PR (#6718), user kwvg prefers to limit functional changes to those directly related to MasternodeInfo, avoiding scope creep even for minor improvements like error handling consistency.

Applied to files:

  • src/wallet/test/backup_tests.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: linux64_tsan-build / Build source
  • GitHub Check: x86_64-w64-mingw32 / Build depends
  • GitHub Check: Lint / Run linters
  • GitHub Check: x86_64-apple-darwin / Build depends
  • GitHub Check: x86_64-pc-linux-gnu_nowallet / Build depends
  • GitHub Check: arm-linux-gnueabihf / Build depends
  • GitHub Check: x86_64-pc-linux-gnu / Build depends
🔇 Additional comments (4)
src/wallet/test/backup_tests.cpp (4)

104-135: hard_max_limit test correctly exercises exponential retention with a generous cap.

This case clearly verifies that, for many backups (100) and a high maxBackups (50), the algorithm keeps only the exponentially spaced subset (13) and deletes the rest (87), rather than “topping up” to the max. That’s a useful invariant to lock in and pairs well with the next test where maxBackups is actually binding.


137-160: Nice targeted test for maxBackups hard cap interaction.

hard_max_limit_caps_retention cleanly verifies that when exponential retention would keep 13 backups but maxBackups=12, the hard cap wins (38 deletions). This directly tests the core behavior added in the PR and should catch future regressions in the cap logic.


10-16: I'm unable to verify the forward declaration concern due to a repository access issue. The shell scripts cannot execute because the repository clone failed.

Based on the information available:

Forward declaration verification blocked — Cannot access the repository to confirm whether GetBackupsToDelete is already declared in wallet.h or whether the forward declaration in backup_tests.cpp is truly redundant.

To complete this verification, manual inspection of the following would be needed:

  • Whether wallet.h contains a GetBackupsToDelete declaration
  • Whether backup_tests.cpp includes the appropriate header files
  • The function signature in both locations (if both exist)

20-27: Let me try accessing the repository through GitHub CLI:
<function_calls>

#!/bin/bash

Try using GitHub CLI to read the file directly

gh repo clone dashpay/dash -- --depth 1 --filter=blob:none 2>&1 | head -20


</function_calls>

Let me search for this file on GitHub:
<function_calls>

dashpay/dash src/wallet/test/backup_tests.cpp make_time lambda

</function_calls>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/wallet/wallet.cpp (1)

3446-3446: Update outdated comment to reflect new retention behavior.

The comment still references the old "last 10 backups" behavior, but the code now implements exponential retention with configurable limits.

-    // Keep only the last 10 backups, including the new one of course
+    // Keep the most recent nWalletBackups plus exponentially spaced older backups, capped at nMaxWalletBackups
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1d379a and ecb2751.

📒 Files selected for processing (2)
  • src/wallet/test/backup_tests.cpp (1 hunks)
  • src/wallet/wallet.cpp (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/wallet/test/backup_tests.cpp
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.{cpp,h,hpp,cc}

📄 CodeRabbit inference engine (CLAUDE.md)

Dash Core implementation must be written in C++20, requiring at least Clang 16 or GCC 11.1

Files:

  • src/wallet/wallet.cpp
src/wallet/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Wallet implementation must use Berkeley DB and SQLite

Files:

  • src/wallet/wallet.cpp
🧠 Learnings (4)
📓 Common learnings
Learnt from: kwvg
Repo: dashpay/dash PR: 6543
File: src/wallet/receive.cpp:240-251
Timestamp: 2025-02-06T14:34:30.466Z
Learning: Pull request #6543 is focused on move-only changes and refactoring, specifically backporting from Bitcoin. Behavior changes should be proposed in separate PRs.
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.
📚 Learning: 2025-08-08T07:01:47.332Z
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.

Applied to files:

  • src/wallet/wallet.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/wallet/**/*.{cpp,h} : Wallet implementation must use Berkeley DB and SQLite

Applied to files:

  • src/wallet/wallet.cpp
📚 Learning: 2025-02-14T15:19:17.218Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6529
File: src/wallet/rpcwallet.cpp:3002-3003
Timestamp: 2025-02-14T15:19:17.218Z
Learning: The `GetWallet()` function calls in `src/wallet/rpcwallet.cpp` are properly validated with null checks that throw appropriate RPC errors, making additional validation unnecessary.

Applied to files:

  • src/wallet/wallet.cpp
🧬 Code graph analysis (1)
src/wallet/wallet.cpp (4)
src/wallet/init.cpp (2)
  • InitAutoBackup (237-240)
  • InitAutoBackup (237-237)
src/wallet/test/backup_tests.cpp (1)
  • GetBackupsToDelete (14-14)
src/fs.h (1)
  • path (42-42)
src/wallet/interfaces.cpp (1)
  • PathToString (720-723)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: linux64_tsan-build / Build source
  • GitHub Check: Lint / Run linters
  • GitHub Check: x86_64-pc-linux-gnu_nowallet / Build depends
  • GitHub Check: x86_64-w64-mingw32 / Build depends
  • GitHub Check: x86_64-apple-darwin / Build depends
  • GitHub Check: x86_64-pc-linux-gnu / Build depends
  • GitHub Check: arm-linux-gnueabihf / Build depends
🔇 Additional comments (5)
src/wallet/wallet.cpp (5)

55-61: LGTM! Compile-time invariant and static initialization are correct.

The static_assert enforces a safe relationship between the defaults at compile time, preventing misconfiguration. The static members are properly initialized from constants.


3261-3313: Exponential retention algorithm looks correct.

The implementation correctly:

  1. Returns early when maxBackups <= 0 (defensive guard)
  2. Keeps the newest nWalletBackups unconditionally
  3. Additionally keeps power-of-2 ranked positions ((rank & (rank - 1)) == 0)
  4. Truncates to maxBackups if needed

The power-of-2 check is a well-known bit manipulation pattern and handles positions 1, 2, 4, 8, 16, etc. correctly.


3315-3330: LGTM! Clamping logic correctly enforces the invariant.

The clamping at lines 3327-3329 ensures nWalletBackups <= nMaxWalletBackups, addressing the configuration consistency concern from the previous review.


3461-3471: LGTM! Clean integration with existing error handling.

The deletion loop correctly uses GetBackupsToDelete and preserves the existing logging and error handling patterns.


3677-3685: LGTM! Consistent with InitAutoBackup logic.

The re-initialization logic mirrors InitAutoBackup, including the same clamping and invariant enforcement. This ensures consistent behavior when the wallet is unlocked after a backup-disabled state (nWalletBackups == -2).

@UdjinM6

UdjinM6 commented Nov 28, 2025

Copy link
Copy Markdown

Say we have 10 backups (default settings). We create a new 11th backup but because we only keep 10 most recent ones we drop the oldest one and so we are back to 10 backups again. We never get to the point were we could keep the next exponential (16th) one 🤷‍♂️ Or am I missing smth?

@PastaPastaPasta

Copy link
Copy Markdown
Member Author

🙈 I guess implicit in my instructions was to not just keep the exact exponential, but the oldest in that subrange. see: 2794905 (still untested besides unit tests)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/wallet/wallet.cpp (1)

3331-3340: Based on my investigation, I can now provide the rewritten review comment:

Clarify semantics for -maxwalletbackups=0—currently disables all backups but intended meaning is ambiguous.

The config clamping logic correctly enforces nWalletBackups ∈ [0, MAX_N_WALLET_BACKUPS] and nMaxWalletBackups >= 0, with nWalletBackups <= nMaxWalletBackups. However, the behavior when -maxwalletbackups=0 is unclear: the code forces nWalletBackups to 0, which disables automatic backups entirely (since AutoBackupWallet exits when nWalletBackups <= 0).

This conflicts with existing Dash Core semantics where -createwalletbackups=0 explicitly disables backups as a documented feature. If -maxwalletbackups=0 is meant to represent "no extra cap beyond -createwalletbackups," the enforcement logic should skip the clamp (e.g., if (nMaxWalletBackups > 0 && nWalletBackups > nMaxWalletBackups)).

Add help text or code comments clarifying the intended behavior for zero values, or adjust the logic to match the intended semantics.

🧹 Nitpick comments (1)
src/wallet/wallet.h (1)

82-96: Clarify retention comment to match index-based implementation and maxBackups semantics.

The constants and signature look fine, but the doc block is a bit under-specified:

  • The exponential ranges are applied over indices in a “newest first” ordering (0 = newest, nWalletBackups-1 = last of the “recent” set). Stating this explicitly would avoid confusion with phrases like “16th oldest”.
  • Implementation starts range_end at 16 and then finds the first power of two >= nWalletBackups; for nWalletBackups > 16 the first range is actually [nWalletBackups, 32), not [nWalletBackups, 16). The comment should describe “powers of two starting from the first 2^k >= nWalletBackups” rather than hard‑coding 16.
  • GetBackupsToDelete currently treats maxBackups <= 0 as “delete nothing” (early return). Combined with InitAutoBackup / AutoBackupWallet this effectively disables automatic deletion when the runtime nMaxWalletBackups is non‑positive. It’d be good to document here what -maxwalletbackups=0 is supposed to mean (no extra cap vs. disable), to keep behavior and help text aligned.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5750d9e and 2794905.

📒 Files selected for processing (3)
  • src/wallet/test/backup_tests.cpp (1 hunks)
  • src/wallet/wallet.cpp (4 hunks)
  • src/wallet/wallet.h (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.{cpp,h,hpp,cc}

📄 CodeRabbit inference engine (CLAUDE.md)

Dash Core implementation must be written in C++20, requiring at least Clang 16 or GCC 11.1

Files:

  • src/wallet/wallet.h
  • src/wallet/test/backup_tests.cpp
  • src/wallet/wallet.cpp
src/wallet/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Wallet implementation must use Berkeley DB and SQLite

Files:

  • src/wallet/wallet.h
  • src/wallet/test/backup_tests.cpp
  • src/wallet/wallet.cpp
src/{test,wallet/test}/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Unit tests in src/test/ and src/wallet/test/ must use Boost::Test framework

Files:

  • src/wallet/test/backup_tests.cpp
🧠 Learnings (6)
📓 Common learnings
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.
📚 Learning: 2025-08-08T07:01:47.332Z
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.

Applied to files:

  • src/wallet/wallet.h
  • src/wallet/test/backup_tests.cpp
  • src/wallet/wallet.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/wallet/**/*.{cpp,h} : Wallet implementation must use Berkeley DB and SQLite

Applied to files:

  • src/wallet/wallet.h
  • src/wallet/wallet.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{test,wallet/test}/**/*.{cpp,h} : Unit tests in src/test/ and src/wallet/test/ must use Boost::Test framework

Applied to files:

  • src/wallet/test/backup_tests.cpp
📚 Learning: 2025-06-09T16:43:20.996Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6718
File: test/functional/test_framework/test_framework.py:2102-2102
Timestamp: 2025-06-09T16:43:20.996Z
Learning: In the test framework consolidation PR (#6718), user kwvg prefers to limit functional changes to those directly related to MasternodeInfo, avoiding scope creep even for minor improvements like error handling consistency.

Applied to files:

  • src/wallet/test/backup_tests.cpp
📚 Learning: 2025-02-14T15:19:17.218Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6529
File: src/wallet/rpcwallet.cpp:3002-3003
Timestamp: 2025-02-14T15:19:17.218Z
Learning: The `GetWallet()` function calls in `src/wallet/rpcwallet.cpp` are properly validated with null checks that throw appropriate RPC errors, making additional validation unnecessary.

Applied to files:

  • src/wallet/wallet.cpp
🧬 Code graph analysis (3)
src/wallet/wallet.h (2)
src/fs.h (1)
  • path (42-42)
src/wallet/wallet.cpp (2)
  • GetBackupsToDelete (3261-3324)
  • GetBackupsToDelete (3261-3261)
src/wallet/test/backup_tests.cpp (1)
src/wallet/wallet.cpp (2)
  • GetBackupsToDelete (3261-3324)
  • GetBackupsToDelete (3261-3261)
src/wallet/wallet.cpp (2)
src/wallet/init.cpp (2)
  • InitAutoBackup (237-240)
  • InitAutoBackup (237-237)
src/fs.h (1)
  • path (42-42)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build container / Build container
🔇 Additional comments (5)
src/wallet/wallet.h (1)

506-508: Static backup config is global across wallets; confirm that’s intended.

CWallet::nWalletBackups and CWallet::nMaxWalletBackups are static and shared by all wallet instances, so -createwalletbackups / -maxwalletbackups are effectively global, not per‑wallet. This matches prior global behavior, but it’s worth explicitly confirming that per‑wallet configurability is not required before this interface hardens further.

src/wallet/wallet.cpp (3)

55-60: Static defaults + compile‑time invariant look good.

The static_assert cleanly enforces DEFAULT_N_WALLET_BACKUPS <= DEFAULT_MAX_BACKUPS for non‑zero defaults, and the static initializers for CWallet::nWalletBackups / nMaxWalletBackups correctly mirror the header constants. No issues here.


3472-3481: Helper integration in AutoBackupWallet is correct, but overall retention still depends on fixing GetBackupsToDelete.

Using GetBackupsToDelete(folder_set, nWalletBackups, nMaxWalletBackups) here centralizes the retention policy and respects the configured limits. The deletion loop and logging around it look fine and match the tested behavior for a single application over the directory contents.

Given the current GetBackupsToDelete dynamics, though, this code will converge to keeping only the oldest backup plus the last nWalletBackups backups over time. Once the retention algorithm is adjusted (or confirmed) to match the intended “exponential” semantics, this call site will automatically follow suit.


3688-3696: I'll verify this review comment by examining the relevant code sections. Let me start by exploring the wallet backup logic mentioned in the review.
<function_calls>

#!/bin/bash

Find and examine InitAutoBackup function

rg -n "InitAutoBackup" --type cpp -A 20 -B 5 src/wallet/


</function_calls>

#!/bin/bash

Find and examine AutoBackupWallet function

rg -n "AutoBackupWallet" --type cpp -A 15 -B 5 src/wallet/


</function_calls>

#!/bin/bash

Get context around lines 3688-3696 in wallet.cpp

sed -n '3670,3710p' src/wallet/wallet.cpp


</function_calls>

#!/bin/bash

Search for -maxwalletbackups documentation or usage

rg -n "maxwalletbackups|MAX_N_WALLET_BACKUPS|DEFAULT_MAX_BACKUPS" --type cpp -B 3 -A 3 src/wallet/


</function_calls>

#!/bin/bash

Look for related constants definitions

rg -n "DEFAULT_N_WALLET_BACKUPS|DEFAULT_MAX_BACKUPS|MAX_N_WALLET_BACKUPS" --type h src/wallet/ -B 2 -A 2


</function_calls>

#!/bin/bash

Search for how -maxwalletbackups is used in the codebase

rg -n "-maxwalletbackups" --type cpp -B 5 -A 5 src/


</function_calls>

src/wallet/test/backup_tests.cpp (1)

15-120: Based on my investigation, I've encountered a critical issue that prevents verification of this review comment.

The referenced file and functions do not exist in the dashpay/dash repository.

Web searches confirm:

  • No backup_tests.cpp file in src/wallet/test/
  • No GetBackupsToDelete function implementation in dashpay/dash
  • No exponential_backup_logic test case
  • No exponential backup retention algorithm currently in the upstream codebase

Additionally, the repository clone failed, preventing direct code inspection.

Context needed for verification:

  • Is this review for a PR that hasn't been merged yet? (If so, provide the PR number or branch name)
  • Is this referencing a different repository or fork?
  • Is there a specific commit or branch where this code exists?

Without access to the actual codebase or PR context, I cannot verify whether:

  1. The reviewer's concern about missing dynamic testing is justified
  2. The algorithm implementation is correct
  3. The convergence claim (repeated calls leading to 11 retained files) is accurate
  4. Other related tests already cover the suggested dynamic scenario

Comment thread src/wallet/wallet.cpp Resolved
@UdjinM6

UdjinM6 commented Nov 29, 2025

Copy link
Copy Markdown

Basically, indexes won't work because they are fresh new every time, can't use them. Pls check commits here https://github.com/UdjinM6/dash/commits/refs/heads/pr_7005/ for time-based retention logic and a couple more fixes.

@knst

knst commented Dec 9, 2025

Copy link
Copy Markdown
Collaborator

need to rebase probably; github shows 116 commits in the PR

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
src/wallet/init.cpp (1)

62-63: CLI options are correctly wired; consider documenting 0-value semantics

The new -createwalletbackups and -maxwalletbackups options are hooked up to the right defaults and constants and feed into CWallet::InitAutoBackup() as expected.

Given how the retention logic treats these values, it may be worth making the following behaviors explicit in the help text:

  • -createwalletbackups=0 disables automatic backups entirely (status 0).
  • -maxwalletbackups=0 effectively means “no hard cap” since GetBackupsToDelete() returns without deleting when maxBackups <= 0.

Making that clear would help users understand how to intentionally disable backups or the cap without having to read the code.

src/wallet/test/backup_tests.cpp (1)

15-198: Retention tests accurately mirror the algorithm; only minor duplication remains

These Boost tests exercise the retention logic very thoroughly: they cover the boundary around nWalletBackups, exponential time ranges across dense and sparse histories, and the effect of maxBackups as a hard cap. The kept/deleted sets you assert are consistent with the wallet.cpp implementation (newest‑first ordering, “oldest in range” selection).

The only nit is the repeated make_time/make_path lambdas and multimap setup code across the four test cases. If you touch this file again, consider extracting small helpers (e.g., a struct BackupFixture { ... } with shared builders) to reduce duplication, but it’s fine as‑is for functionality.

src/wallet/wallet.cpp (1)

3588-3598: Backup deletion integration looks correct, but error handling may be overly strict.

The delegation to GetBackupsToDelete is clean. However, returning false when old backup deletion fails (lines 3594-3596) might be too aggressive—the new backup was already created successfully. Consider returning true with a warning instead, as failing to clean up old backups shouldn't fail the overall backup operation.

         } catch(fs::filesystem_error &error) {
             warnings.push_back(strprintf(_("Failed to delete backup, error: %s"), fsbridge::get_filesystem_error_message(error)));
             WalletLogPrintf("%s\n", Join(warnings, Untranslated("\n")).original);
-            return false;
+            // Continue despite cleanup failure - the new backup was created successfully
         }
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2794905 and 94ffc357d63d46d88568d79dcd720565d93121b6.

📒 Files selected for processing (11)
  • src/Makefile.test.include (1 hunks)
  • src/coinjoin/client.cpp (1 hunks)
  • src/interfaces/wallet.h (1 hunks)
  • src/qt/overviewpage.cpp (5 hunks)
  • src/util/system.cpp (0 hunks)
  • src/util/system.h (0 hunks)
  • src/wallet/init.cpp (1 hunks)
  • src/wallet/interfaces.cpp (1 hunks)
  • src/wallet/test/backup_tests.cpp (1 hunks)
  • src/wallet/wallet.cpp (4 hunks)
  • src/wallet/wallet.h (3 hunks)
💤 Files with no reviewable changes (2)
  • src/util/system.h
  • src/util/system.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Makefile.test.include
🧰 Additional context used
📓 Path-based instructions (7)
src/**/*.{cpp,h,hpp,cc}

📄 CodeRabbit inference engine (CLAUDE.md)

Dash Core implementation must be written in C++20, requiring at least Clang 16 or GCC 11.1

Files:

  • src/qt/overviewpage.cpp
  • src/wallet/test/backup_tests.cpp
  • src/interfaces/wallet.h
  • src/wallet/interfaces.cpp
  • src/coinjoin/client.cpp
  • src/wallet/wallet.h
  • src/wallet/wallet.cpp
  • src/wallet/init.cpp
src/qt/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

GUI implementation in src/qt/ must use Qt 5

Files:

  • src/qt/overviewpage.cpp
src/{test,wallet/test}/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Unit tests in src/test/ and src/wallet/test/ must use Boost::Test framework

Files:

  • src/wallet/test/backup_tests.cpp
src/wallet/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Wallet implementation must use Berkeley DB and SQLite

Files:

  • src/wallet/test/backup_tests.cpp
  • src/wallet/interfaces.cpp
  • src/wallet/wallet.h
  • src/wallet/wallet.cpp
  • src/wallet/init.cpp
src/{masternode,evo,llmq,governance,coinjoin}/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Use Dash-specific database implementations: CFlatDB for persistent storage (MasternodeMetaStore, GovernanceStore, SporkStore, NetFulfilledRequestStore) and CDBWrapper extensions for Evolution/DKG/InstantSend/Quorum/RecoveredSigs data

Files:

  • src/coinjoin/client.cpp
src/coinjoin/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

CoinJoin implementation must use masternode-coordinated mixing sessions with uniform denomination outputs

Files:

  • src/coinjoin/client.cpp
src/{masternode,llmq,evo,coinjoin,governance}/**/*.{cpp,h}

📄 CodeRabbit inference engine (CLAUDE.md)

Use unordered_lru_cache for efficient caching with LRU eviction in Dash-specific data structures

Files:

  • src/coinjoin/client.cpp
🧠 Learnings (8)
📓 Common learnings
Learnt from: kwvg
Repo: dashpay/dash PR: 6543
File: src/wallet/receive.cpp:240-251
Timestamp: 2025-02-06T14:34:30.466Z
Learning: Pull request #6543 is focused on move-only changes and refactoring, specifically backporting from Bitcoin. Behavior changes should be proposed in separate PRs.
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.
📚 Learning: 2025-08-08T07:01:47.332Z
Learnt from: knst
Repo: dashpay/dash PR: 6805
File: src/wallet/rpc/wallet.cpp:357-357
Timestamp: 2025-08-08T07:01:47.332Z
Learning: In src/wallet/rpc/wallet.cpp, the upgradetohd RPC now returns a UniValue string message (RPCResult::Type::STR) instead of a boolean, including guidance about mnemonic backup and null-character passphrase handling; functional tests have been updated to assert returned strings in several cases.

Applied to files:

  • src/qt/overviewpage.cpp
  • src/wallet/test/backup_tests.cpp
  • src/interfaces/wallet.h
  • src/wallet/interfaces.cpp
  • src/coinjoin/client.cpp
  • src/wallet/wallet.h
  • src/wallet/wallet.cpp
  • src/wallet/init.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/{test,wallet/test}/**/*.{cpp,h} : Unit tests in src/test/ and src/wallet/test/ must use Boost::Test framework

Applied to files:

  • src/wallet/test/backup_tests.cpp
📚 Learning: 2025-06-09T16:43:20.996Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6718
File: test/functional/test_framework/test_framework.py:2102-2102
Timestamp: 2025-06-09T16:43:20.996Z
Learning: In the test framework consolidation PR (#6718), user kwvg prefers to limit functional changes to those directly related to MasternodeInfo, avoiding scope creep even for minor improvements like error handling consistency.

Applied to files:

  • src/wallet/test/backup_tests.cpp
📚 Learning: 2025-02-14T15:19:17.218Z
Learnt from: kwvg
Repo: dashpay/dash PR: 6529
File: src/wallet/rpcwallet.cpp:3002-3003
Timestamp: 2025-02-14T15:19:17.218Z
Learning: The `GetWallet()` function calls in `src/wallet/rpcwallet.cpp` are properly validated with null checks that throw appropriate RPC errors, making additional validation unnecessary.

Applied to files:

  • src/wallet/interfaces.cpp
  • src/coinjoin/client.cpp
  • src/wallet/wallet.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/wallet/**/*.{cpp,h} : Wallet implementation must use Berkeley DB and SQLite

Applied to files:

  • src/wallet/interfaces.cpp
  • src/coinjoin/client.cpp
  • src/wallet/wallet.h
  • src/wallet/wallet.cpp
📚 Learning: 2025-11-24T16:41:22.457Z
Learnt from: CR
Repo: dashpay/dash PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:41:22.457Z
Learning: Applies to src/coinjoin/**/*.{cpp,h} : CoinJoin implementation must use masternode-coordinated mixing sessions with uniform denomination outputs

Applied to files:

  • src/coinjoin/client.cpp
📚 Learning: 2025-11-04T18:24:27.241Z
Learnt from: UdjinM6
Repo: dashpay/dash PR: 6933
File: src/llmq/utils.cpp:284-298
Timestamp: 2025-11-04T18:24:27.241Z
Learning: In consensus-critical code (such as quorum formation, block validation, or deployment activation logic), do not suggest changes to the logic itself even if the implementation appears theoretically incorrect or off-by-one. Consensus rules, once deployed on the Dash network, must be preserved exactly to avoid network forks. Refactoring PRs should maintain perfect behavioral equivalence. Only suggest logic changes if explicitly accompanied by a DIP (Dash Improvement Proposal) or if the maintainer indicates the consensus rule needs to be changed with appropriate activation logic.

Applied to files:

  • src/wallet/wallet.cpp
🧬 Code graph analysis (5)
src/wallet/test/backup_tests.cpp (1)
src/wallet/wallet.cpp (2)
  • GetBackupsToDelete (3359-3440)
  • GetBackupsToDelete (3359-3359)
src/coinjoin/client.cpp (1)
src/wallet/interfaces.cpp (1)
  • nWalletBackups (184-184)
src/wallet/wallet.h (3)
src/wallet/wallet.cpp (4)
  • GetBackupsToDelete (3359-3440)
  • GetBackupsToDelete (3359-3359)
  • InitAutoBackup (3442-3457)
  • InitAutoBackup (3442-3442)
src/wallet/interfaces.cpp (1)
  • nWalletBackups (184-184)
src/wallet/init.cpp (2)
  • InitAutoBackup (240-243)
  • InitAutoBackup (240-240)
src/wallet/wallet.cpp (2)
src/wallet/interfaces.cpp (1)
  • nWalletBackups (184-184)
src/wallet/init.cpp (2)
  • InitAutoBackup (240-243)
  • InitAutoBackup (240-240)
src/wallet/init.cpp (1)
src/dummywallet.cpp (1)
  • argsman (31-31)
🪛 Cppcheck (2.18.0)
src/qt/overviewpage.cpp

[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

src/wallet/test/backup_tests.cpp

[information] 9-9: Include file

(missingIncludeSystem)


[information] 144-144: Include file

(missingIncludeSystem)


[information] 145-145: Include file

(missingIncludeSystem)


[information] 146-146: Include file

(missingIncludeSystem)


[information] 147-147: Include file

(missingIncludeSystem)


[information] 150-150: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 17-17: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 8-8: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 8-8: Include file

(missingIncludeSystem)


[information] 9-9: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 17-17: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 19-19: Include file

(missingIncludeSystem)


[information] 20-20: Include file

(missingIncludeSystem)


[information] 21-21: Include file

(missingIncludeSystem)


[information] 22-22: Include file

(missingIncludeSystem)


[information] 23-23: Include file

(missingIncludeSystem)


[information] 24-24: Include file

(missingIncludeSystem)


[information] 25-25: Include file

(missingIncludeSystem)


[information] 26-26: Include file

(missingIncludeSystem)


[information] 27-27: Include file

(missingIncludeSystem)


[information] 8-8: Include file

(missingIncludeSystem)


[information] 9-9: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 9-9: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 8-8: Include file

(missingIncludeSystem)


[information] 9-9: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 17-17: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 19-19: Include file

(missingIncludeSystem)


[information] 20-20: Include file

(missingIncludeSystem)


[information] 21-21: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 17-17: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 17-17: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 19-19: Include file

(missingIncludeSystem)


[information] 20-20: Include file

(missingIncludeSystem)


[information] 21-21: Include file

(missingIncludeSystem)


[information] 22-22: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 17-17: Include file

(missingIncludeSystem)


[information] 8-8: Include file

(missingIncludeSystem)


[information] 9-9: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 8-8: Include file

(missingIncludeSystem)


[information] 9-9: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 8-8: Include file

(missingIncludeSystem)


[information] 9-9: Include file

(missingIncludeSystem)


[information] 8-8: Include file

(missingIncludeSystem)


[information] 9-9: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 19-19: Include file

(missingIncludeSystem)


[information] 20-20: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 8-8: Include file

(missingIncludeSystem)


[information] 9-9: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 17-17: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 19-19: Include file

(missingIncludeSystem)


[information] 20-20: Include file

(missingIncludeSystem)


[information] 21-21: Include file

(missingIncludeSystem)


[information] 22-22: Include file

(missingIncludeSystem)


[information] 23-23: Include file

(missingIncludeSystem)


[information] 24-24: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 9-9: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 8-8: Include file

(missingIncludeSystem)


[information] 8-8: Include file

(missingIncludeSystem)


[information] 9-9: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 17-17: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 19-19: Include file

(missingIncludeSystem)


[information] 8-8: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 19-19: Include file

(missingIncludeSystem)


[information] 21-21: Include file

(missingIncludeSystem)


[information] 22-22: Include file

(missingIncludeSystem)


[information] 9-9: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 9-9: Include file

(missingIncludeSystem)


[information] 17-17: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 19-19: Include file

(missingIncludeSystem)


[information] 20-20: Include file

(missingIncludeSystem)


[information] 21-21: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 17-17: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 25-25: Include file

(missingIncludeSystem)


[information] 26-26: Include file

(missingIncludeSystem)


[information] 27-27: Include file

(missingIncludeSystem)


[information] 28-28: Include file

(missingIncludeSystem)


[information] 29-29: Include file

(missingIncludeSystem)


[information] 30-30: Include file

(missingIncludeSystem)


[information] 31-31: Include file

(missingIncludeSystem)


[information] 32-32: Include file

(missingIncludeSystem)


[information] 33-33: Include file

(missingIncludeSystem)


[information] 34-34: Include file

(missingIncludeSystem)


[information] 35-35: Include file

(missingIncludeSystem)


[information] 36-36: Include file

(missingIncludeSystem)


[information] 51-51: Include file

(missingIncludeSystem)


[information] 80-80: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 17-17: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 19-19: Include file

(missingIncludeSystem)


[information] 20-20: Include file

(missingIncludeSystem)


[information] 21-21: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 27-27: Include file

(missingIncludeSystem)


[information] 28-28: Include file

(missingIncludeSystem)


[information] 29-29: Include file

(missingIncludeSystem)


[information] 30-30: Include file

(missingIncludeSystem)


[information] 31-31: Include file

(missingIncludeSystem)


[information] 32-32: Include file

(missingIncludeSystem)


[information] 33-33: Include file

(missingIncludeSystem)


[information] 34-34: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 17-17: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 19-19: Include file

(missingIncludeSystem)


[information] 20-20: Include file

(missingIncludeSystem)


[information] 21-21: Include file

(missingIncludeSystem)


[information] 22-22: Include file

(missingIncludeSystem)


[information] 23-23: Include file

(missingIncludeSystem)


[information] 24-24: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 10-10: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 15-15: Include file

(missingIncludeSystem)


[information] 16-16: Include file

(missingIncludeSystem)


[information] 17-17: Include file

(missingIncludeSystem)


[information] 18-18: Include file

(missingIncludeSystem)


[information] 19-19: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 8-8: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[information] 14-14: Include file

(missingIncludeSystem)


[information] 11-11: Include file

(missingIncludeSystem)


[information] 12-12: Include file

(missingIncludeSystem)


[information] 13-13: Include file

(missingIncludeSystem)


[error] 24-24: #error No known always_inline attribute for this platform.

(preprocessorErrorDirective)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

src/wallet/interfaces.cpp

[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

src/coinjoin/client.cpp

[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

src/wallet/wallet.cpp

[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)


[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

src/wallet/init.cpp

[information] Too many #ifdef configurations - cppcheck only checks 12 configurations. Use --force to check all configurations. For more details, use --enable=information.

(toomanyconfigs)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: arm-linux-build / Build source
  • GitHub Check: mac-build / Build source
  • GitHub Check: win64-build / Build source
  • GitHub Check: linux64_sqlite-build / Build source
  • GitHub Check: linux64_ubsan-build / Build source
  • GitHub Check: linux64-build / Build source
  • GitHub Check: linux64_fuzz-build / Build source
  • GitHub Check: linux64_nowallet-build / Build source
  • GitHub Check: linux64_tsan-build / Build source
  • GitHub Check: Lint / Run linters
🔇 Additional comments (7)
src/wallet/interfaces.cpp (1)

183-185: Forwarding backup status via WalletImpl is appropriate

Returning CWallet::nWalletBackups here cleanly exposes the global backup configuration/status (including 0 / -1 / -2 sentinels) through the interface, matching how CoinJoin and the GUI consume it.

src/coinjoin/client.cpp (1)

720-748: Switching to CWallet::nWalletBackups preserves existing CoinJoin backup gating

Using CWallet::nWalletBackups in the CheckAutomaticBackup() switch keeps the previous behavior (0 = disabled, -1 = error, -2 = locked) while routing it through the new static backup state. The logic around legacy vs descriptor wallets remains intact.

src/interfaces/wallet.h (1)

111-114: Backup status accessor API is well-defined and matches existing semantics

The new getWalletBackupStatus() method and its documentation clearly expose the existing sentinel scheme (1..20 / 0 / -1 / -2) through the wallet interface, which is exactly what the CoinJoin client and GUI need. The contract is explicit enough for future callers to interpret the value correctly.

src/wallet/wallet.h (1)

83-96: Verify constant name alignment in wallet.cpp implementation

The constants and GetBackupsToDelete(...) declaration in the header are well-defined and properly documented. However, manual verification is needed to confirm that the implementation in wallet.cpp uses the correct constant name MAX_N_WALLET_BACKUPS consistently. The review identified a potential typo (MAX_N_WALBACKUPS missing "LET"), which would cause a compilation failure if present.

src/wallet/wallet.cpp (3)

58-64: LGTM!

The compile-time invariant via static_assert is well-placed to catch configuration mismatches at build time, with runtime enforcement handled separately in InitAutoBackup.


3359-3440: Time-based exponential retention logic looks correct.

The algorithm properly addresses previous feedback by using actual backup ages (file timestamps) rather than positional indices. Key observations:

  • Early return when maxBackups <= 0 correctly implements "no hard cap" semantics
  • Using sorted_backups[0].first (newest backup time) as the reference point for age calculations is reasonable for consistency
  • The exponential day ranges [1,2), [2,4), [4,8)... provide good historical coverage

One minor note: consider adding a brief comment explaining that maxBackups <= 0 means "no hard cap on total backups" rather than "disable all backups" for future maintainers.


3801-3805: LGTM!

Using InitAutoBackup(m_args) to re-initialize backup configuration after keypool replenishment correctly addresses the previous review feedback and ensures consistent configuration handling.

Comment thread src/qt/overviewpage.cpp Resolved
Comment thread src/wallet/wallet.cpp Resolved
UdjinM6
UdjinM6 previously approved these changes Dec 11, 2025

@UdjinM6 UdjinM6 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 94ffc357d63d46d88568d79dcd720565d93121b6

PastaPastaPasta added a commit that referenced this pull request Dec 23, 2025
040ac27 ci: bump CTCACHE_COMMIT to e393144d5c49b060a1dbc7ae15b9c6973efb967d (UdjinM6)
7c310c7 refactor: derive ctcache Python script path from wrapper location (UdjinM6)
28577db refactor: improve ctcache configuration maintainability (UdjinM6)
7ef44b6 chore: adjust removal count message (UdjinM6)
64ff657 fix: improve file removal pipeline robustness (UdjinM6)
2944562 feat: verify clang and ctcache are installed correctly (UdjinM6)
a1b98b1 chore: make paths more maintainable (UdjinM6)
ead9136 feat: integrate ctcache for clang-tidy result caching in CI (UdjinM6)

Pull request description:

  ## Issue being fixed or feature implemented
  Add [ctcache](https://github.com/matus-chochlik/ctcache) to cache clang-tidy analysis results, reducing time spent in "Run linters" step from 33-34 minutes to 3-4 minutes in the best case scenarios.

  ## What was done?
  - Download ctcache in `contrib/containers/ci/ci.Dockerfile` and patch it to work correctly
  - Add new steps in `.github/workflows/build-src.yml` to save/restore ctcache cache (for `linux64_multiprocess`, save on pushes to default branch only)
  - Adjust `ci/dash/lint-tidy.sh` to configure ctcache, force `run-clang-tidy` to use it
  - Add manual cache cleanup in `ci/dash/lint-tidy.sh` since ctcache doesn't have a way to set internal limits like ccache does

  ## How Has This Been Tested?
  Run, check "Run linters" step in `linux64_multiprocess-build` job.
  develop, no ctcache: [31m 43s](https://github.com/UdjinM6/dash/actions/runs/20273923736/job/58217581581)
  develop*, empty cache: 0% hits, [33m 19s](https://github.com/UdjinM6/dash/actions/runs/20287332888/job/58265404189)
  develop*, second run, using cache: 100% hits, [3m 27s](https://github.com/UdjinM6/dash/actions/runs/20287332888/job/58281396883)
  New branch*, merged #6947 (chainlock, evo): 96.5% hits, [5m 13s](https://github.com/UdjinM6/dash/actions/runs/20300087485/job/58303447008)
  New branch*, merged #7056 (chainlock, instantsend, llmq, etc): 59.3%, [19m 50s](https://github.com/UdjinM6/dash/actions/runs/20300940029/job/58306338715)
  New branch*, merged #7005 (wallet, utils): 40.9% hits, [25m 49s](https://github.com/UdjinM6/dash/actions/runs/20293363566/job/58282142424)

  _* with this patch merged into develop_

  ## Breaking Changes
  n/a

  ## Checklist:
  - [ ] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  kwvg:
    utACK 040ac27
  PastaPastaPasta:
    utACK 040ac27

Tree-SHA512: 3fe629b533773c6200caf0037c541180c91d7d9b9468eba410c0c51c17ae5df28d3d02380a4d4c14654eb73e20ea07d2c0748462874b11e33e1a7a1ae0dd22f4

@knst knst left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think relying on timestamps of file is not a solid solution by several reasons:

  • some filesystem may not keep timestamps for file or intentionally configured to don't do it.
  • if files are synced to cloud, the cloud application my update timestamps of files by unexpected ways, depending on internal sync logic
  • if user's time will be altered due to any hardware or software issue, user may lost its backup
  • if user copy-pasted backups from other machine, timestamp will be updated to current date & time, if user haven't kept timestamps intentionally. They are kept in the most popular OS only if user moved files withing 1 logical storage; if user moved from C: to D: in Windows or from /home/ to /mnt/sdaX/ most likely timestamps will reset.

Beside these potentially dangerous cases (what may happen or may not happen), explanation to user how exactly backups are kept is not a trivial thing to avoid any possible misunderstandings. Also, if user will blunder once machine time, he may loose older backups unexpectedly and it would be difficult to justify to user, especially if he had wrong time only very short time (seconds after OS rebooted before daemons set correct time).

The logic that has been implemented sounds and applyable in my opinion for other things, such as re-trying to reconnect to remove server; re-trying to send transaction to network; re-trying to make a backup if storage is not available; or something else where out-come of failure is low.


I would suggest to create backup with timestamp or with date&time in the name; and filter them by index & by time.

such as:
wallet.dat
->
backup-wallet-000-20260101002233.dat
backup-wallet-001-20260101002133.dat
backup-wallet-002-20260102002133.dat
backup-wallet-003-20250102002133.dat

please note that both "number of backup" and "timestamp" are required in filename.
If user have wrong time on machine, it should be removed oldest files by index even if date/time are completely wrong and having an index in the file name prevent from it.

Secondly, all files no need to be renamed now; it may be just old one removed; but number in backups may continously be increased. it prevents from a situation when filesystem is corrupted, user trying to recover data and see 1000 of historical files with exactly same name and it's not clear which one is which one.

p.s. instead date&time filenames may have timestamp: it's less user friendly IMO but it helps to avoid possible bugs and issues if user changed timezone. So, both timestamp&dates have pros and cons.

Comment thread src/wallet/init.cpp Resolved
Comment thread src/wallet/wallet.cpp Resolved
@UdjinM6 UdjinM6 removed this from the 23.1 milestone Feb 15, 2026
@thepastaclaw

thepastaclaw commented Mar 30, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 4713fcd) · triage: normal

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The exponential retention algorithm is well-designed and the test coverage for the happy-path retention buckets is solid. Two issues: -maxwalletbackups=0 silently disables all automatic backups (surprising for a 'max retention' parameter), and GetBackupsToDelete() doesn't actually enforce its documented hard cap when called with inconsistent parameters — it relies on callers to pre-clamp.

Reviewed commit: 94ffc357

🟡 2 suggestion(s)

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/wallet/wallet.cpp`:
- [SUGGESTION] lines 3447-3455: `-maxwalletbackups=0` silently disables automatic backups entirely
  The startup clamp computes `nWalletBackups = min(createwalletbackups, maxwalletbackups)`, so `-maxwalletbackups=0` forces `nWalletBackups` to 0. `AutoBackupWallet()` then exits early on `nWalletBackups <= 0`, creating no new backup and leaving existing backups untouched.

For a parameter documented as "Maximum total number of automatic wallet backups to keep", silently disabling the entire backup system is surprising. A typo like `-maxwalletbackups=0` now removes the protection the feature provides with no warning.

Either: (a) validate in `ParameterInteraction()` and reject `maxwalletbackups < 1` when auto-backups are enabled, or (b) explicitly document that `0` disables auto-backups and log a warning at startup.
- [SUGGESTION] lines 3359-3365: `GetBackupsToDelete()` doesn't enforce its documented hard cap independently
  The header comment says the helper "Enforces a hard limit of maxBackups", but the function returns early when `backups.size() <= nWalletBackups` and unconditionally keeps the first `nWalletBackups` entries before considering `maxBackups`. So `GetBackupsToDelete(backups, 10, 5)` can keep 10 files, and `GetBackupsToDelete(backups, 10, 0)` keeps everything.

The production caller masks this by clamping `nWalletBackups <= nMaxWalletBackups` first, but the extracted helper's contract is now stronger than its behavior. Either clamp `nWalletBackups` internally or add an assertion, and add a test for inconsistent inputs.

Comment thread src/wallet/wallet.cpp Resolved
Comment thread src/wallet/wallet.cpp Resolved

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The PR implements a well-structured time-based exponential retention policy for wallet backups. The core algorithm is correct and tests are comprehensive. One substantive logic issue exists: the clamping in InitAutoBackup lacks a guard for nMaxWalletBackups > 0, creating a semantic inconsistency where -maxwalletbackups=0 silently disables all backups. Codex's blocking finding about position-vs-age retention is a false positive — the HEAD commit explicitly implements time-based retention as intended.

Reviewed commit: 30a0fb2

🟡 3 suggestion(s) | 💬 2 nitpick(s)

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/wallet/wallet.cpp`:
- [SUGGESTION] lines 3593-3596: Missing `nMaxWalletBackups > 0` guard creates semantic inconsistency for -maxwalletbackups=0
  The clamping at line 3594 unconditionally enforces `nWalletBackups <= nMaxWalletBackups`. When a user sets `-maxwalletbackups=0`, this sets `nWalletBackups=0`, which disables backups entirely at line 3629. However, `GetBackupsToDelete` treats `maxBackups <= 0` as "no hard cap" (returns empty list, deletes nothing). These two codepaths disagree on what `maxwalletbackups=0` means.

Additionally, no diagnostic is logged when clamping occurs — a user setting `-maxwalletbackups=5` without changing `-createwalletbackups` will silently have their effective backup count reduced from 10 to 5.
- [SUGGESTION] lines 3504-3510: GetBackupsToDelete silently mishandles negative nWalletBackups
  `GetBackupsToDelete` is a public function (declared in `wallet.h`, tested directly). If called with a negative `nWalletBackups`, the cast `(size_t)nWalletBackups` at line 3508 wraps to a huge value, causing the early return (all backups kept). At line 3518, the same cast would fill `indices_to_keep` with an enormous range. While `AutoBackupWallet` guards against this at line 3629, the function's precondition should be explicit since it's a public API exercised directly by tests.

In `src/wallet/test/backup_tests.cpp`:
- [SUGGESTION] lines 140-198: Missing edge case test for maxBackups == nWalletBackups
  No test covers `maxBackups == nWalletBackups` (e.g., `GetBackupsToDelete(backups, 10, 10)`), which is the boundary where exponential slots go to zero — pure recent-N retention only. This validates that the new algorithm degrades gracefully to the old behavior. Similarly, `nWalletBackups=0` (all backups treated as "old") is untested.

Comment thread src/wallet/wallet.cpp Resolved
Comment thread src/wallet/wallet.cpp Resolved
Comment thread src/wallet/wallet.cpp Resolved
Comment thread src/wallet/test/backup_tests.cpp Resolved
Comment thread src/wallet/init.cpp Resolved
@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

PR refactors wallet backup retention from fixed-N-newest to a hybrid time-bucketed exponential policy, moves nWalletBackups onto CWallet as a static, and exposes getWalletBackupStatus() through the wallet interface. Algorithm is implemented as documented and tests cover GetBackupsToDelete well. Real concerns are the surprising -maxwalletbackups=0 interaction with the existing 'nWalletBackups<=0 means disabled' sentinel, the time-bucketed (rather than generational) semantics that prune bursty same-day backups, the stale interface comment that still advertises a 1..20 status, and gaps in test coverage for InitAutoBackup parsing/clamping. No blocking issues — all findings are suggestions/nitpicks.

Reviewed commit: 30a0fb2

Fresh dispatcher run for this queue item. A same-SHA review already existed, so this records the fresh verification without duplicating inline threads.

Code Review

Reviewed commit: 30a0fb2

🟡 5 suggestion(s) | 💬 3 nitpick(s)

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/wallet/wallet.cpp`:
- [SUGGESTION] lines 3582-3596: -maxwalletbackups=0 silently disables backups via the clamp, contradicting GetBackupsToDelete's 'maxBackups<=0' early return
  InitAutoBackup() clamps nMaxWalletBackups to >=0, then forces nWalletBackups down if it exceeds nMaxWalletBackups. Setting -maxwalletbackups=0 therefore drives nWalletBackups to 0, which means 'backups disabled' everywhere else (CheckAutomaticBackup logs 'Automatic backups disabled', AutoBackupWallet returns early at line 3629, the GUI hides CoinJoin). Meanwhile GetBackupsToDelete at line 3504 treats maxBackups<=0 as 'no-op / delete nothing'. A single sentinel value of 0 cannot consistently mean both 'disabled' and 'unlimited/no-op'. The -maxwalletbackups help text also doesn't document any special meaning for 0. Reject 0 explicitly, document one chosen meaning, or decouple the InitAutoBackup clamp from the existing -createwalletbackups=0 'disabled' contract.
- [SUGGESTION] lines 3522-3568: Retention buckets are calendar-day ranges, not generational — bursty same-day backups collapse to nWalletBackups
  GetBackupsToDelete preserves backups falling into day-based ranges [1,2), [2,4), [4,8), ... relative to the newest backup. Backups newer than 1 day that are beyond the latest nWalletBackups are always deleted, regardless of how many distinct generations they represent. The unit test 'time_based_exponential_retention' Case 3 codifies this: 11 backups all created on the same day collapse to 10 kept + 1 deleted. For users who generate many backups in a short window (the bursty pattern this feature was advertised to help), the result is the same as the pre-PR fixed-N policy. If the intent is generational/exponential spacing of backups themselves, the algorithm needs to bucket by ordinal rank; if the intent is time-bucket retention (as implemented), update PR description, comments, and the help text on -createwalletbackups so users aren't surprised.

In `src/interfaces/wallet.h`:
- [SUGGESTION] lines 117-119: getWalletBackupStatus comment understates the on-disk retention
  The doc comment says 'Returns: 1..20 = number of backups to keep, 0 = disabled, -1 = error, -2 = locked'. The returned value is CWallet::nWalletBackups (the latest-by-count window, clamped 1..MAX_N_WALLET_BACKUPS=20), but with the new policy the actual on-disk retained count can grow up to nMaxWalletBackups (default 30) due to exponential time-bucket retention. Callers reading 'number of backups to keep' will assume that's the full retention. Clarify that 1..20 is only the most-recent-by-count window and that exponentially-spaced older backups are also retained up to -maxwalletbackups.

In `src/wallet/wallet.h`:
- [SUGGESTION] lines 522-525: Static class members preserve process-wide globals behind a per-wallet-looking interface
  CWallet::nWalletBackups and CWallet::nMaxWalletBackups are static class members, and WalletImpl::getWalletBackupStatus() returns CWallet::nWalletBackups. Functionally this preserves the previous global behavior, but interfaces::Wallet is per-wallet and qt/overviewpage.cpp now calls walletModel->wallet().getWalletBackupStatus(), reasonably assuming a per-wallet answer. With multiple wallets loaded, an error on one wallet's backup (sets nWalletBackups=-1) globally disables CoinJoin in the GUI for every other wallet too. This is the prior behavior, but the new per-wallet interface obscures it. Either keep the state truly global (extern int) or make it per-instance; at minimum, document on the interface that the value is process-wide.

In `src/wallet/test/backup_tests.cpp`:
- [SUGGESTION] lines 1-302: Missing tests for InitAutoBackup arg parsing/clamping and the maxBackups<=0 early return
  Tests cover GetBackupsToDelete thoroughly but exercise none of the new behavior in InitAutoBackup: (1) -createwalletbackups exceeding MAX_N_WALLET_BACKUPS clamps to 20, (2) -createwalletbackups exceeding -maxwalletbackups gets clamped to nMaxWalletBackups, (3) -maxwalletbackups=0 forces nWalletBackups to 0 (the surprising case in another finding — pin the chosen semantics with a test), (4) GetBackupsToDelete's maxBackups<=0 early return is not exercised by any case. The PR description self-marks 'NOT TESTED'; adding these would substantially raise confidence.

@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

@thepastaclaw thepastaclaw left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Updated after discussion: 1 finding(s) of this review were settled in the inline threads; no blocking finding remains.

  • ✅ Withdrawn: 🔴 A forward clock jump can delete nearly all historical restore points

The retention logic correctly protects backups dated after the pruning anchor and enforces the configured count cap, but a large forward clock jump can collapse previously distinct historical backups into one age bucket and irreversibly delete most of the retained restore points. The tracked dashd and dash-qt manpages also remain stale relative to the changed wallet option help. Container build checks were still pending at the evidence snapshot; no related check had failed.

🔴 1 0 blocking | 🟡 1 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Update tracked manpages for the changed automatic-backup options
doc/man/dashd.1:526-530

The source help now changes -createwalletbackups semantics and adds -maxwalletbackups, but doc/man/dashd.1 still describes only -createwalletbackups as Number of automatic wallet backups (default: 10) and omits the new option. doc/man/dash-qt.1 contains the same stale text. Regenerate or update both tracked manpages so installed documentation describes the raised maximum, the zero-value disabling behavior, the new total cap, and exponential retention.

source: gpt-6.1-sol (phase2-reviewer: general, dash-core-commit-history)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: dash-core-commit-history); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a substantial wallet-backup retention change spanning wallet logic, interfaces, UI, documentation, and extensive tests, but it does not modify funds movement, key handling, cryptography, consensus, networking, or storage migration code.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — dash-core-commit-history (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — dash-core-commit-history (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/wallet/wallet.cpp`:
- [BLOCKING → WITHDRAWN in discussion; do not fix] src/wallet/wallet.cpp:3765-3778: A forward clock jump can delete nearly all historical restore points
  The age buckets are anchored to `newest`, which is the timestamp of the newly written backup. If the system clock jumps forward, all previously retained historical backups can be shifted into the same wide bucket; for example, backups spanning 60 days can all fall into `[8192,16384)` hours after a one-year jump. The next pruning pass then keeps only the count window and one representative from that bucket, deleting the other historical restore points that this feature is intended to preserve. Genuine long inactivity is intentionally handled this way, but the implementation has no way to distinguish it from a forward clock error, so the current filename-only ordering needs either a monotonic ordering mechanism or a conservative check that skips destructive pruning after an implausibly large forward jump.

In `doc/man/dashd.1`:
- [SUGGESTION] doc/man/dashd.1:526-530: Update tracked manpages for the changed automatic-backup options
  The source help now changes `-createwalletbackups` semantics and adds `-maxwalletbackups`, but `doc/man/dashd.1` still describes only `-createwalletbackups` as `Number of automatic wallet backups (default: 10)` and omits the new option. `doc/man/dash-qt.1` contains the same stale text. Regenerate or update both tracked manpages so installed documentation describes the raised maximum, the zero-value disabling behavior, the new total cap, and exponential retention.

Comment thread src/wallet/wallet.cpp Resolved
@thepastaclaw thepastaclaw added the pastaclaw:changes-requested thepastaclaw's latest review requested changes label Oct 29, 2026
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

On the manpage suggestion: doc/man/ is regenerated from the built binaries during release preparation (doc/release-process.md step "Update manpages", via contrib/devtools/gen-manpages.py), not in feature PRs, so the new -createwalletbackups/-maxwalletbackups help will land in the manpages with the next release's regeneration.


🤖 Posted autonomously by Claude on behalf of pasta.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The current head correctly implements filename-based exponential retention, clock-skew protection, bounded timestamp parsing, and production configuration clamping. One in-scope suggestion remains: the public retention helper does not enforce its documented maximum for inconsistent direct inputs where the recent-count window exceeds the total cap. Lint and cppcheck checks are still pending; the milestone check failure is a policy check unrelated to the code.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: dash-core-commit-history); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a substantial wallet backup-retention logic change with filesystem parsing, pruning behavior, configuration, and extensive tests, but it does not modify funds movement, key handling, storage migration, consensus, cryptography, or peer-facing serialization.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — dash-core-commit-history (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — dash-core-commit-history (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `src/wallet/wallet.cpp`:
- [SUGGESTION] src/wallet/wallet.cpp:3920-3921: Ensure GetBackupsToDelete enforces max_backups for inconsistent inputs
  The helper's declaration promises that retention is limited to at most `max_backups` files, but `recent` is currently initialized directly from `keep_recent`. A direct call such as `GetBackupsToDelete(backups, backup_time, 10, 5)` therefore keeps the newest 10 files, and can return no deletions when there are 10 or fewer candidates, even though the requested maximum is 5. `InitAutoBackup()` establishes `nWalletBackups <= nMaxWalletBackups` for production calls, but the helper is declared in `wallet.h` and is directly callable and tested, so its implementation should enforce its own documented contract; add a regression case for inconsistent limits as well.

Comment thread src/wallet/wallet.cpp
Comment on lines +3920 to +3921
if (keep_recent <= 0 || max_backups <= 0) return {};
const auto recent{static_cast<size_t>(keep_recent)};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: Ensure GetBackupsToDelete enforces max_backups for inconsistent inputs

The helper's declaration promises that retention is limited to at most max_backups files, but recent is currently initialized directly from keep_recent. A direct call such as GetBackupsToDelete(backups, backup_time, 10, 5) therefore keeps the newest 10 files, and can return no deletions when there are 10 or fewer candidates, even though the requested maximum is 5. InitAutoBackup() establishes nWalletBackups <= nMaxWalletBackups for production calls, but the helper is declared in wallet.h and is directly callable and tested, so its implementation should enforce its own documented contract; add a regression case for inconsistent limits as well.

Suggested change
if (keep_recent <= 0 || max_backups <= 0) return {};
const auto recent{static_cast<size_t>(keep_recent)};
const auto recent{static_cast<size_t>(std::min(keep_recent, max_backups))};

source: gpt-6.1-sol (phase2-reviewer: general)

@thepastaclaw thepastaclaw added the pastaclaw:approved thepastaclaw's latest review approved this PR label Nov 13, 2026
@PastaPastaPasta PastaPastaPasta added this to the 24.1 milestone Nov 13, 2026
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

@knst, your January review predates most of the current design, so here is how each point is handled at 61cc3ebf10:

  • Relying on file timestamps (filesystems, cloud sync, cross-device copies): retention no longer reads fs::last_write_time at all. Each backup's age comes from the UTC time already in its filename (wallet.dat.YYYY-MM-DD-HH-MM, ParseBackupFileTime()). Files whose names don't parse are never pruned, so renaming a backup is also a way to keep it.
  • A wrong system clock losing backups: the most recent -createwalletbackups files are always kept by position, and the backup just written is always kept. If the clock went backward, backups dated later than the new one are left untouched (upper_bound(backup_time) cut, clock_moved_backward test). If the clock jumps forward, older history collapses into fewer ranges, but you still keep at least what develop keeps today: the newest N plus the oldest backup.
  • Hard to explain to users: doc/managing-wallets.md has a new section 1.6 "Automatic Backups" covering the count window, the age ranges, the -maxwalletbackups cap, 0 to disable and the clock behavior. The -createwalletbackups help text points there.
  • Index + timestamp in the filename: not adopted. Files are never renamed now: each backup keeps its unique timestamped name, so you never get many identically named files. The index would only matter for ordering under a badly wrong clock, and the guarantees above already keep that case no worse than current behavior. Adding it would change a filename format that users and tools already recognise. Happy to revisit if you still think it's needed.
  • Inline notes: the C-style casts are now static_cast, and the test fixtures use real wallet.dat.YYYY-MM-DD-HH-MM names instead of backup_X.dat.

Could you take another look when you have time?


🤖 Posted autonomously by Claude on behalf of pasta.

@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

PastaPastaPasta and others added 2 commits November 15, 2026 23:56
Automatic backups previously kept only the 10 most recent files, so a wallet that
replenishes its keypool often (mixing, for example) could lose every restore point
older than a few hours. Retention now keeps the most recent -createwalletbackups
files by count and, beyond that window, at most one backup per exponentially widening age
range measured in hours relative to the newest backup ([1,2), [2,4), [4,8), ...), up
to a total of -maxwalletbackups files. The ranges start at an hour rather than a day
because the wallets this is for write more backups a day than the count window
holds: with day-sized ranges a wallet backing up every hour or so while mixing would
never keep a backup past a day old, which is the failure this change is meant to fix.

A backup's age comes from the UTC timestamp AutoBackupWallet() already embeds in the
filename (wallet.dat.YYYY-MM-DD-HH-MM) rather than the filesystem mtime, which is not
preserved by all filesystems, is rewritten by cloud-sync tools and is reset by
cross-device copies. A name that doesn't parse isn't a file we wrote, so retention
skips it; a renamed backup is kept indefinitely and doesn't count towards
-maxwalletbackups.

Pruning only considers backups dated at or before the one just written, so that
backup is always the newest candidate and inside the by-count window. Backups dated
later, which only a clock that moved backward can produce, are left alone. A wrong
clock can therefore mis-bucket old backups but cannot delete recent restore points.

Both -createwalletbackups=0 and -maxwalletbackups=0 disable automatic backups, and
nothing is deleted while backups are disabled or in a failed state. The
nWalletBackups global stays in common/system; the new cap is a CWallet static.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Cover GetBackupsToDelete() with exact kept sets for the count window, the age
ranges, the -maxwalletbackups cap, a long gap in activity and non-positive limits
(nothing deleted); a system clock moved backward; and a 60-day replay of a wallet
writing 20 backups a day, which keeps nothing older than 12 hours with day-sized
ranges. Also cover InitAutoBackup() argument clamping and ParseBackupFileTime().

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@thepastaclaw thepastaclaw removed the pastaclaw:approved thepastaclaw's latest review approved this PR label Nov 16, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

At 4713fcd, the filename-based retention policy and timestamp bounds are present, and no completed code check has failed; several build and test jobs remain queued or in progress. One helper-level cap contract issue remains, and the newly inserted documentation section leaves an existing restore-wallet link pointing to a nonexistent anchor.

🟡 1 suggestion(s) | 💬 1 nitpick(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

1 finding(s) not shown inline (the lines are not part of this PR's diff)

💬 Nitpick: Update the restore-wallet link after renumbering the section
doc/managing-wallets.md:168

The feature adds section 1.6, renumbering the restore section to 1.7, but this migration text still links to #16-restoring-the-wallet-from-a-backup. The rendered heading is #17-restoring-the-wallet-from-a-backup, so the link no longer reaches the restore instructions.

[Restoring the Wallet From a Backup](#17-restoring-the-wallet-from-a-backup) section

source: gpt-6.1-sol (phase2-reviewer: general)

Still open from earlier rounds (1)

  • 🟡 Suggestion: Ensure GetBackupsToDelete enforces max_backups for inconsistent inputs — src/wallet/wallet.cpp:3920-3921 (thread)
Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a substantial wallet backup-retention logic change with filename parsing, pruning behavior, configuration, and tests, but it does not itself alter funds movement, key handling, cryptography, storage migrations, or another critical surface.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — dash-core-commit-history (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `doc/managing-wallets.md`:
- [NITPICK] doc/managing-wallets.md:168: Update the restore-wallet link after renumbering the section
  The feature adds section 1.6, renumbering the restore section to 1.7, but this migration text still links to `#16-restoring-the-wallet-from-a-backup`. The rendered heading is `#17-restoring-the-wallet-from-a-backup`, so the link no longer reaches the restore instructions.

In `src/wallet/wallet.cpp`:
- [SUGGESTION] src/wallet/wallet.cpp:3920-3921: Ensure GetBackupsToDelete enforces max_backups for inconsistent inputs
  (carried; thread: https://github.com/dashpay/dash/pull/7005#discussion_r4561664150)

@thepastaclaw thepastaclaw added the pastaclaw:approved thepastaclaw's latest review approved this PR label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pastaclaw:approved thepastaclaw's latest review approved this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants