Skip to content

feat(wallet): add opt-in filtered internal script sync - #645

Draft
byhashdong wants to merge 1 commit into
bitcoindevkit:masterfrom
byhashdong:feat/269-filtered-internal-sync
Draft

byhashdong wants to merge 1 commit into
bitcoindevkit:masterfrom
byhashdong:feat/269-filtered-internal-sync

Conversation

@byhashdong

Copy link
Copy Markdown

Description

Related to #269. Add opt-in start_sync_with_pending_spks_at and start_sync_with_pending_spks request builders, preserving the existing all-revealed-script methods and their defaults.

The new policy retains every revealed external script. It omits an internal script only when its canonical receiving outputs have all been spent and every relevant receiving/spending transaction meets the confirmation threshold. None selects six confirmations; zero is treated as one. Unused, unspent, unsettled and incompletely known histories remain included. Expected transaction IDs are preserved.

Notes to the reviewers

This draft is for reviewing the API and filtering policy. Eligibility is recomputed from the current canonical graph on each call; nothing is permanently marked finalized. Received and spent outpoints are compared, rather than transaction counts, so multi-output and partial-history cases cannot accidentally balance. Floating outputs without a full parent are retained conservatively.

This assumes internal addresses are not reused after omission. A payment to an omitted script cannot be discovered through that filtered request; callers need the existing all-revealed request or a full scan to discover it. Learned reuse and learned reorgs cause reconsideration on subsequent calls.

This reduces remote script-history requests, not local asymptotic work: request construction still scans graph history and allocates temporary sets. A synthetic test reduces 38 scripts to 6 while checking the retained identities; it is not a production throughput benchmark.

Validation:

  • 10 focused tests: external/unused/unspent retention, 5/6-confirmation boundary, old API preservation, multiple outputs, conflicts/RBF/eviction, confirmed replacement, reorg, learned reuse, floating/partial history and single-descriptor behavior.
  • Both stable and unstable pre-push configurations passed their compile, no-std/hashbrown, Clippy, workspace tests and documentation checks.
  • Ran the repository's pre-push recipe from a temporary copy with only cargo +nightly fmt pinned to nightly-2026-08-01, the version accepted in [cont_integration] fmt job should pin the nightly compiler #535. Latest nightly rewrites unrelated descriptor macros and can break them; no formatter-only changes or justfile overrides are included in this PR. Changed code and the full tree pass the pinned nightly format check.
  • Commit is GPG-signed by GitHub and verified.

The implementation is independent; the application code linked in #269 informed the intended policy, rather than being copied.

Changelog notice

Added:

  • Opt-in partial-sync request builders that omit sufficiently confirmed, fully spent internal-script histories while retaining external and unsettled scripts.

Before submitting

  • I followed the contribution guidelines, with the formatter-version workaround described above.
  • This PR breaks the existing API

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

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant