-
Notifications
You must be signed in to change notification settings - Fork 9
Detect Ricochet at any hop (0-4) by tracing backward to fee address #47
Description
Background
Issue #36 describes Ricochet detection via the known fee address at hop 0. This issue proposes extending detection to identify Ricochet transactions at any hop (1-4) by walking backward through the chain until the hop 0 fingerprint is found.
Currently, detectRicochet() in spending-patterns.ts only detects generic 1-in-1-out sweep chains and can only look 1 hop back (line 102: "Can't walk further without grandparent data"). It does not check for the known fee address at all.
Proposed algorithm
When analyzing a transaction that is 1-input, 1-output (sweep pattern):
- Walk backward up to 4 hops via
traceBackward()(already exists inrecursive-trace.ts) - At each ancestor, check two things:
- Is it also a 1-in-1-out sweep? (continue walking)
- Does it have an output to the known fee address with the exact fee amount? (hop 0 found)
- If hop 0 is found, label the analyzed transaction with its hop number (distance from hop 0)
- Validation: confirm amounts decrease by ~960 sats (miner fee) per hop for extra confidence
- Early abort: if an ancestor is not 1-in-1-out and doesn't have the fee address output, stop - it's not a Ricochet chain
Known fee addresses and amounts
| Wallet | Fee address | Fee amount |
|---|---|---|
| Ashigaru | bc1qsc887pxce0r3qed50e8he49a3amenemgptakg2 |
100,000 sats |
| Samourai | (to be confirmed - no longer active) | 200,000 sats |
Implementation notes
- Modify
detectRicochet()insrc/lib/analysis/chain/spending-patterns.ts - Use
traceBackward()fromsrc/lib/analysis/chain/recursive-trace.tswithmaxDepth: 4 - The finding should include: which hop the analyzed tx is, the full chain of txids, and whether it's classic (consecutive blocks) or staggered (spaced blocks)
- API cost: max 4 extra calls per candidate tx, only triggered for 1-in-1-out transactions
- PayNym variant remains undetectable by design - document this in the analysis output when a Ricochet is detected (recommend user to use staggered + PayNym)
Scope
This is a sub-task of #36. The parent issue covers full Ricochet detection (hop 0 via fee address + chain tracing forward). This issue specifically covers the backward detection case: identifying a Ricochet when the user analyzes a transaction that is hop 1, 2, 3, or 4.
Example
Using the chain from #36:
If a user analyzes tx db837f91... (hop 2), the tool should:
- See it's 1-in-1-out (candidate)
- Walk back to
cb7bcde5...(hop 1) - also 1-in-1-out, continue - Walk back to
038a94db...(hop 0) - has output of 100,000 sats tobc1qsc887pxce0r3qed50e8he49a3amenemgptakg2 - Confirm: "This transaction is hop 2 of a Ricochet (Ashigaru)" with link to full chain