Skip to content

Wallet: prefilter masternode collateral scans - #1947

Open
navidR wants to merge 1 commit into
firoorg:masterfrom
navidR:dev/navidr/wallet-collateral-scan-prefilter
Open

Wallet: prefilter masternode collateral scans#1947
navidR wants to merge 1 commit into
firoorg:masterfrom
navidR:dev/navidr/wallet-collateral-scan-prefilter

Conversation

@navidR

@navidR navidR commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

PR intention

Check collateral membership before running Spark ownership and spent-state checks during the startup wallet scan, preserving the existing locks and collateral-locking rules.

Code changes brief

Add coverage for internal and external collateral, watch-only and spent outputs, manual locks, and repeated scans.
Debug wallet and deterministic-masternode tests pass, and startup was verified against the existing 1,024-spend regtest fixture.

Check collateral membership before Spark ownership and spent-state checks during startup. Preserve the existing cs_main/cs_wallet locking, collateral predicates, and additive coin-locking behavior.

Cover internal and external collateral, owned/watch-only/unowned outputs, spent outputs, wrong amounts, manual locks, and repeated scans.
@codeant-ai

codeant-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 5ccb44a Sep 04, 2026 · 21:27 21:30

@codeant-ai

codeant-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T21:30:25.626479Z 5ccb44a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: b19cbff6-df9f-4302-8074-f0039ff521b5

📥 Commits

Reviewing files that changed from the base of the PR and between 4f0c771 and 5ccb44a.

📒 Files selected for processing (2)
  • src/wallet/test/wallet_tests.cpp
  • src/wallet/wallet.cpp

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


Summary by CodeRabbit

  • Bug Fixes
    • Improved automatic locking of masternode collateral outputs in the wallet.
    • Ensures only valid masternode collateral is automatically locked, while existing manual locks remain unchanged.
    • Repeated automatic-lock operations now maintain a consistent set of locked outputs.

Walkthrough

The wallet checks masternode collateral status before ownership and spent-state checks. A new wallet test covers owned, watched, foreign, spent, wrong-amount, external, and ordinary outputs, plus manual locks and repeated auto-lock calls.

Changes

Masternode collateral auto-locking

Layer / File(s) Summary
Collateral check ordering
src/wallet/wallet.cpp
AutoLockMasternodeCollaterals checks collateral status before Spark ownership and spent-state checks.
Collateral auto-lock test coverage
src/wallet/test/wallet_tests.cpp
The test creates provider-register and ordinary transactions, registers external collaterals, verifies the expected locked outpoints, preserves a manual lock, and checks repeated-call idempotency.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 5ccb4

Collateral detection now runs before ownership and spent-state checks during wallet scanning, avoiding unnecessary checks for ordinary outputs while retaining the existing auto-locking rules. Covered collateral and lock-state cases indicate no remaining merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: prefiltering masternode collateral scans in the wallet.
Description check ✅ Passed The description includes both required template sections. It states the PR intention, describes the code changes, and summarizes test coverage and validation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Sep 4, 2026
@codeant-ai

codeant-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown

User description

PR intention

Check collateral membership before running Spark ownership and spent-state checks during the startup wallet scan, preserving the existing locks and collateral-locking rules.

Code changes brief

Add coverage for internal and external collateral, watch-only and spent outputs, manual locks, and repeated scans.
Debug wallet and deterministic-masternode tests pass, and startup was verified against the existing 1,024-spend regtest fixture.


CodeAnt-AI Description

Restrict automatic masternode collateral locking to valid collateral outputs

What Changed

  • Startup wallet scans now identify masternode collateral before checking ownership or spent status
  • Only owned or watch-only, unspent collateral outputs with the correct amount are automatically locked
  • Non-collateral outputs, foreign outputs, spent outputs, and incorrectly valued outputs remain unlocked
  • Existing manual locks remain intact, and repeated scans do not change the lock set
  • Added coverage for internal and external collateral and the relevant ownership, spend, amount, and repeat-scan cases

Impact

✅ Fewer unnecessary wallet ownership and spend checks
✅ Correct automatic locking of masternode collateral
✅ Preserved manual wallet locks

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@reubenyap reubenyap left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed head 5ccb44acbae38bf9dc99024666c81a685fdbf7e4. No additional actionable issues were found. I traced AutoLockMasternodeCollaterals() through its sole startup caller and the ownership, spent-state, and deterministic-MN helpers; the collateral-first short-circuit preserves lock semantics, and the regression covers internal/external, watch-only, foreign, spent, manual-lock, and repeat-scan cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants