Skip to content

feat: add offer account support (MVP)#955

Closed
gudnuf wants to merge 5 commits intomasterfrom
feat/offers-mvp
Closed

feat: add offer account support (MVP)#955
gudnuf wants to merge 5 commits intomasterfrom
feat/offers-mvp

Conversation

@gudnuf
Copy link
Copy Markdown
Contributor

@gudnuf gudnuf commented Mar 23, 2026

Summary

  • Replace AgicashMintExtension.closed_loop with purpose field ("transactional" | "gift-card" | "offer") matching CDK update
  • Add expiresAt to cashu accounts (stored in JSONB details, read from keyset final_expiry)
  • Show non-expired offer accounts in gift cards UI with expiry date
  • Accept mints with NUT-04 (minting) disabled in validator
  • canReceiveFromLightning checks NUT-04 status generically
  • checkIsTestMint handles minting-disabled mints gracefully
  • DB migration adds 'offer' to account_purpose enum

Note

One known type error in user-repository.ts — resolves after applying the migration and running bun run db:generate-types.

Test plan

  • Apply migration, regenerate types, verify type error resolves
  • Add an offer mint — verify expiresAt is persisted
  • Verify offer accounts appear in "Offers" section on gift cards page
  • Verify expired offers are hidden
  • Verify offer accounts cannot send or receive via Lightning
  • Verify gift card accounts still work unchanged
  • Receive a cashu token from an offer mint — verify it claims correctly

🤖 Generated with Claude Code

gudnuf added 5 commits March 20, 2026 10:18
Two bugs with v2 keysets: getDecodedToken fails without keyset IDs
for resolution, and re-encoded tokens have truncated IDs that can't
be looked up. Fix uses dependency-injected keyset resolver with
cache-first strategy, plus raw token string passthrough in paste/scan.
- extractCashuTokenString validates via getTokenMetadata (not just regex)
- extractCashuToken uses try/catch like cashu.me for v2 detection
- Preserves immediate validation UX in paste/scan handlers
4 tasks: token functions + tests, resolver factory, paste/scan handlers,
route clientLoaders. Includes v2-specific tests with round-trip verification.
- Add extractCashuTokenString for paste/scan handlers (validates via
  getTokenMetadata without full decode, avoids lossy re-encode cycle)
- Update extractCashuToken to async with keyset ID fetcher for v2
  resolution (tries v1 decode first, falls back to mint keyset fetch)
- Add extractCashuToken wrapper in shared/cashu that wires queryClient
- Update route clientLoaders to use v2-aware decode
- Fix getTokenHash to clone proofs before getEncodedToken (cashu-ts
  mutates proof.id, truncating v2 keyset IDs to short form)
  See: cashubtc/cashu-ts#535
- Add token extraction tests covering v1/v2 decode and round-trips
Replace AgicashMintExtension.closed_loop with purpose field matching
CDK update. Add 'offer' to AccountPurpose for promotional ecash with
expiry. Store expiresAt in JSONB details from keyset final_expiry.

- Validator accepts mints with NUT-04 (minting) disabled
- canReceiveFromLightning checks NUT-04 status generically
- checkIsTestMint handles minting-disabled mints
- Show non-expired offers in gift cards UI with expiry date
- DB migration adds 'offer' to account_purpose enum
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agicash Ready Ready Preview, Comment Mar 23, 2026 10:18pm

Request Review

@supabase
Copy link
Copy Markdown

supabase bot commented Mar 23, 2026

Updates to Preview Branch (feat/offers-mvp) ↗︎

Deployments Status Updated
Database Mon, 23 Mar 2026 22:18:09 UTC
Services Mon, 23 Mar 2026 22:18:09 UTC
APIs Mon, 23 Mar 2026 22:18:09 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations ⚠️ Mon, 23 Mar 2026 22:21:21 UTC
Migrations Mon, 23 Mar 2026 22:21:25 UTC
Seeding Mon, 23 Mar 2026 22:21:25 UTC
Edge Functions Mon, 23 Mar 2026 22:21:25 UTC

⚠️ Warning — Service health check failed


View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@gudnuf gudnuf force-pushed the feat/cashu-v2-keyset-support branch from f1d8682 to ecd243b Compare March 25, 2026 17:19
Base automatically changed from feat/cashu-v2-keyset-support to master March 25, 2026 17:24
@orveth
Copy link
Copy Markdown

orveth commented Mar 26, 2026

Closing — superseded by #959 (feat: add offer mint purpose to cashu protocol extensions), which takes a narrower, cleaner approach to offer account support.

@orveth orveth closed this Mar 26, 2026
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