Skip to content

Detect Ricochet at any hop (0-4) by tracing backward to fee address #47

@4rkad

Description

@4rkad

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):

  1. Walk backward up to 4 hops via traceBackward() (already exists in recursive-trace.ts)
  2. 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)
  3. If hop 0 is found, label the analyzed transaction with its hop number (distance from hop 0)
  4. Validation: confirm amounts decrease by ~960 sats (miner fee) per hop for extra confidence
  5. 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() in src/lib/analysis/chain/spending-patterns.ts
  • Use traceBackward() from src/lib/analysis/chain/recursive-trace.ts with maxDepth: 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:

  1. See it's 1-in-1-out (candidate)
  2. Walk back to cb7bcde5... (hop 1) - also 1-in-1-out, continue
  3. Walk back to 038a94db... (hop 0) - has output of 100,000 sats to bc1qsc887pxce0r3qed50e8he49a3amenemgptakg2
  4. Confirm: "This transaction is hop 2 of a Ricochet (Ashigaru)" with link to full chain

Metadata

Metadata

Assignees

No one assigned

    Labels

    analysisHeuristics, scoring, detection, Boltzmann, chain tracingenhancementImprove something that works

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions