Skip to content

feat: fetch --dry-run previews the price without paying#56

Draft
reneaaron wants to merge 1 commit into
masterfrom
feat/fetch-dry-run
Draft

feat: fetch --dry-run previews the price without paying#56
reneaaron wants to merge 1 commit into
masterfrom
feat/fetch-dry-run

Conversation

@reneaaron

Copy link
Copy Markdown
Member

What

Adds fetch --dry-run: sends the request unpaid and reports the 402 challenge instead of settling it. Needs no wallet.

$ alby fetch --dry-run "https://www.l402apps.com/api/apis"
{
  "url": "https://www.l402apps.com/api/apis",
  "status": 402,
  "payment_required": true,
  "amount_in_sats": 10,
  "description": "L402 Apps — Get APIs directory"
}
  • Price in sats is extracted from wherever the protocol puts the lightning invoice: WWW-Authenticate (L402 ... invoice= / MPP Payment ... invoice=) or a lightning-native x402's base64 Payment-Required header.
  • When no lightning invoice is offered (e.g. a USDC-only x402 hit directly instead of through the l402.space bridge), the raw challenge is surfaced so the terms are still visible.
  • A free endpoint reports payment_required: false.
  • Payment flags (--max-amount/--currency/--unit/--network/--credentials) are rejected alongside --dry-run since a dry run never pays.

Why

From the review discussion on getAlby/payments-skill#28: prices listed on 402index.io can be missing, stale, or dynamic — the 402 challenge is the authoritative price at request time, but checking it previously meant hand-crafting a curl. Use case: comparing prices between two providers before paying.

Per that discussion this is deliberately not documented in the skill for now — the --max-amount default already guards automated flows.

Test

  • yarn test green (111 pass, 2 skipped); 5 new unit tests cover L402, MPP, base64-x402 extraction, no-lightning-challenge fallback, and free endpoints (using a real BOLT-11 so decoding is exercised).
  • Verified live against all three challenge shapes without paying: native L402 (10 sats), bridged x402 via l402.space (19 sats), lightning-native x402 (15 sats).

Per payments-skill#28 review: prices listed by 402index.io can be missing,
stale, or dynamic - the 402 challenge is the authoritative price at request
time, but checking it previously meant hand-crafting a curl. --dry-run sends
the request unpaid (no wallet needed) and reports the challenge: price in
sats when a lightning invoice is offered (L402/MPP WWW-Authenticate, or a
lightning-native x402 Payment-Required header), the raw challenge otherwise.
Payment flags are rejected alongside it since a dry run never pays.

Use case: comparing prices between providers before paying.

Verified live against all three challenge shapes: native L402 (10 sats),
bridged x402 via l402.space (19 sats), lightning-native x402 (15 sats).
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ea8bcea7-be69-49c9-b638-1f5f5017fc4a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/fetch-dry-run

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.

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.

1 participant