Skip to content

feat: detect sp coins spent by another wallet on the same seed - #183

Draft
chaitika wants to merge 3 commits into
CypherCommons:masterfrom
chaitika:feat/external-spend-detection-continued
Draft

chaitika wants to merge 3 commits into
CypherCommons:masterfrom
chaitika:feat/external-spend-detection-continued

Conversation

@chaitika

@chaitika chaitika commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Continues #170. A restored wallet, or a second device on the same seed, now detects SP coins spent elsewhere by matching its own outpoints against the indexer's spent index locally (#156).

Needs the indexer's spent index (CypherCommons/shroud-indexer#118), deployed with a reindex. Without it, receiving works as before and spends aren't detected.

On top of #170:

  • A failed spent-index request no longer aborts the scan. The range just isn't checked, and the next sync retries it.
  • The checked height only advances over heights the indexer returned, so blocks it hasn't indexed with the spent index are never skipped. A full rescan re-checks from its start.
  • The last 6 checked blocks are re-read on every sync, so a spend a reorg moves into an already-checked block is still found.
  • The spent index is fetched after each transaction range instead of in parallel, and 429s are retried with backoff.
  • Coins are only matched against blocks at or after the one that created them.
  • Uses the real Signet test vectors shared with the indexer.

Not in this PR: undoing spent marks after a reorg.

Copilot AI balanced review requested due to automatic review settings October 9, 2026 11:23

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Every 4xx was treated as a definitive rejection, including 429 from the
indexer's rate limit, so a scan failed on the first throttled range. 429
now goes through the existing backoff instead of failing at once.
A restored wallet, or a second device on the same seed, kept counting SP
coins spent elsewhere. Each scan now also fetches the indexer's spent
index and matches our outpoints against it on the device. Our own sends
get confirmed; other spends are recorded as one "Unknown" transaction per
block. Existing wallets get a one-off catch-up.

Blocks the indexer has no spent index for stay unchecked until it does,
and receiving works as before.
The Electrum check sent the address of every unspent silent payment coin
to the Electrum server after each scan, which links them to each other and
to the wallet's regular addresses. The spent index finds the same spends by
matching outpoints on the device. Running both also broke the history: a
coin the Electrum check marked spent first was skipped by the spent index,
so its spend was never recorded.
@chaitika
chaitika force-pushed the feat/external-spend-detection-continued branch from 93c6c9e to ed860c3 Compare November 12, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants