Commit graph

473 commits

Author SHA1 Message Date
Patrick Mulligan
2fab50bdfc Add placeholder scaffolding for ui-shared and cashu packages
- ui-shared: Add Vite library config and minimal entry point
- cashu: Add TypeScript config and minimal entry point

These packages are placeholders that will be implemented as needed.
The scaffolding allows the monorepo build to complete.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 05:58:07 -05:00
Patrick Mulligan
8fc22e5291 Implement @lamassu/lightning package
Lightning.Pub client for Nostr-native Lightning operations:

Features:
- Account information and balance queries
- Invoice generation (BOLT11)
- Invoice payment with preimage
- Invoice lookup and status checking
- Payment watching with callbacks
- Exchange rate fetching (mock for now)
- Basic invoice decoding

Communication:
- NIP-47 compatible request/response events
- NIP-44 encrypted content
- Timeout handling

Types:
- AccountInfo, Invoice, PaymentResult
- ExchangeRate, ChannelInfo, NodeInfo

Includes basic unit tests for client initialization.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 05:54:58 -05:00
Patrick Mulligan
f35d0330b9 Implement @lamassu/state-machine package
XState v5 state machine for ATM transaction flows:

States:
- idle: Waiting for user selection
- cashIn: Buy bitcoin (insert bills -> display QR -> payment received)
- cashOut: Sell bitcoin (select amount -> display invoice -> dispense cash)

Features:
- Full cash-in flow with bill accumulation
- Full cash-out flow with cash dispensing
- Exchange rate fetching
- Sats calculation with fee deduction
- Optional Nostr receipt sending
- Error handling with retry logic
- Transaction ID generation
- Timeout handling

Service injection for testability:
- generateClinkOffer
- generateInvoice
- sendNostrReceipt
- dispenseCash
- getExchangeRate

Includes comprehensive tests for state transitions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 05:51:42 -05:00
Patrick Mulligan
6ddb7c7a06 Implement @lamassu/clink package
CLINK protocol implementation for Nostr-native Lightning payments:

- noffer encoding/decoding (bech32 TLV format)
- CLINKClient for protocol communication
- Event kinds: 21001 (Offer), 21002 (Debit), 21003 (Manage)

Features:
- Create static payment codes (noffers) for ATM
- Handle incoming offer requests and generate invoices
- Send/receive debit requests
- Process management commands from operator
- Encrypted communication with NIP-44

Includes tests for noffer encoding/decoding round-trip.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 05:48:29 -05:00
Patrick Mulligan
f4cd45c81c Implement @lamassu/nostr-client package
Core Nostr client library for ATM communication:

- Identity management (generateIdentity, load from nsec/hex)
- NIP-44 encryption/decryption for sensitive data
- Event creation utilities (machine status, transactions, auth)
- NostrClient class with relay management
- NIP-42 authentication support for private relays
- Automatic reconnection with exponential backoff
- Subscription management

Types for ATM-specific events:
- Kind 30078: Machine status (replaceable)
- Kind 30079: Transaction records (replaceable)
- Kind 21001-21003: CLINK protocol events
- Kind 22242: NIP-42 auth

Includes unit tests for identity, encryption, and events.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 05:46:18 -05:00
Patrick Mulligan
e295a37367 Fix devenv configuration and add lock files
- Fix devenv.nix: rename pre-commit to git-hooks (devenv API change)
- Use nixpkgs rust packages directly (avoid rust-overlay dependency)
- Remove non-existent packages (nak, libnfc, httpie)
- Use webkitgtk_4_1 instead of webkitgtk for Tauri compatibility
- Add devenv.lock and pnpm-lock.yaml for reproducible builds
- Update root .gitignore to exclude .claude/ and .pre-commit-config.yaml

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 05:41:49 -05:00
Patrick Mulligan
4ca1adeb0b Initialize lamassu-next monorepo with scaffolding and Claude skills
Monorepo Structure:
- apps/machine/ - Tauri + Vue 3 ATM application (placeholder)
- apps/dashboard/ - Vue 3 operator dashboard (placeholder)
- apps/relay/ - strfry relay configuration
- packages/hal/ - Rust Hardware Abstraction Layer with napi-rs
- packages/nostr-client/ - Nostr client library
- packages/clink/ - CLINK protocol implementation
- packages/state-machine/ - XState v5 ATM state machine
- packages/lightning/ - Lightning.Pub client
- packages/cashu/ - Cashu ecash integration
- packages/ui-shared/ - Shared Vue 3 components

Development Environment:
- devenv.nix with pre-commit hooks (prettier, eslint, rustfmt, clippy)
- Security hooks (detect-secrets, no console.log in production)
- Custom Nostr schema validation hook
- Docker Compose for strfry relay and Lightning.Pub

Claude Code Skills:
- /security - Security review for Bitcoin/Lightning/ATM vulnerabilities
- /nostr-check - Nostr NIP conformity validation
- /lightning-check - Lightning.Pub and CLINK protocol validation
- /test - Testing agent for coverage and flow validation
- /docs - Documentation synchronization
- /hal-check - HAL driver porting validation

HAL Foundation:
- Rust crate with napi-rs bindings
- BillValidator and BillDispenser traits
- Mock implementations for development
- Error types for all hardware operations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 16:25:25 -05:00
Patrick Mulligan
e6f280a50b Add comprehensive hardware driver catalog and porting strategy
- Catalog all existing lamassu-machine drivers (7 validators, 5 dispensers,
  3 printers, 4 scanners)
- Add "Port, don't rewrite" principle - leverage battle-tested existing code
- Update HAL structure to include all drivers to port
- Replace NV200 example with ID003 (default validator in lamassu-machine)
- Add Printer trait definition
- Update napi-rs bindings with ValidatorDriver and DispenserDriver enums
- Add configuration mapping for migrating from legacy lamassu-machine config
- Update milestone checklist with prioritized driver porting tasks
- Add driver complexity ranking to guide porting order

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 16:08:47 -05:00
Patrick Mulligan
68b797d938 Prioritize cash-out flow based on market research (95%+ activity)
Market context added:
- 95%+ activity is cash-out (selling Bitcoin for cash)
- Typical for remittance corridors, Bitcoin-paid workers
- Bill dispenser is REQUIRED for testing, not optional

Updated development priorities:
- Cash-out first, cash-in second
- Dispenser in minimum dev kit (~$655-855)
- Bill validator becomes secondary priority

Updated milestones:
- Priority 1: Cash-out with real dispenser
- Priority 2: Cash-in (mock validator OK initially)
- Priority 3: Advanced features (Cashu, etc.)

Phase 4 reorganized to implement cash-out before cash-in.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 15:52:24 -05:00
Patrick Mulligan
05c6d9827c Add bill dispenser to implementation plan
Hardware section now includes:
- One-way dev kit (cash-in only): ~$535-735
- Two-way dev kit (cash-in + cash-out): ~$955-1,555
- Bill dispenser options: Puloon LCDM-1000/2000, Fujitsu F53
- Sourcing tips for used equipment

HAL section now includes:
- BillDispenser trait definition
- Puloon LCDM RS-232 implementation
- napi-rs bindings for dispenser
- TypeScript usage examples for both validator and dispenser

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 15:50:13 -05:00
Patrick Mulligan
b80f174b08 Add concrete implementation plan for Nostr-native ATM
Phased roadmap with code examples:

Phase 0: Foundation
- Monorepo structure (Turborepo + pnpm)
- devenv.nix for reproducible dev environment
- Lightning.Pub local setup
- Private strfry relay

Phase 1: Core Infrastructure
- @lamassu/nostr-client package
- Machine identity (nsec/npub generation)
- Relay connection with NIP-42
- @lamassu/clink package for CLINK offers

Phase 2: Machine Shell
- Tauri 2.x + Vue 3 application
- XState v5 state machine (full ATM logic)
- Nostr composable for Vue
- QR display, screen navigation

Phase 3: Hardware Abstraction Layer
- Rust HAL crate with napi-rs bindings
- BillValidator trait + NV200 implementation
- BillDispenser trait + Puloon implementation
- Mock drivers for development

Phase 4: Payment Flows
- Lightning.Pub client integration
- Cash-in: CLINK offers -> invoice -> payment
- Cash-out: Invoice -> payment -> dispense
- NIP-17 encrypted receipts
- Cashu offline mode

Phase 5: Operator Tools
- Vue 3 dashboard
- Real-time machine monitoring via Nostr
- Transaction history
- Remote command sending

Includes:
- Complete XState machine definition
- Rust HAL trait definitions
- TypeScript/Vue code examples
- Testing strategy
- Dev hardware recommendations (~$535-735)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 15:46:57 -05:00
Patrick Mulligan
af358bf158 Add Nostr-native architecture - Nostr as infrastructure backbone
Comprehensive redesign using Nostr for all ATM communication:

Lightning.Pub as Core Server:
- Replaces lamassu-server entirely
- Nostr-native account system wrapping LND
- Zero server config (no DNS/SSL/ports)
- CLINK native, one-line deployment
- Built-in liquidity management

Private Nostr Relay:
- NIP-42 authenticated relay (strfry/rnostr)
- Whitelist: ATM npubs + Operator npubs only
- Encrypted command/control channel
- Negentropy sync for offline reconciliation

Machine Identity:
- Each ATM has Nostr keypair (nsec/npub)
- Replaces client certificates
- Cryptographic authentication
- No PKI/CA required

Replacing SMS (KYC vector elimination):
- NIP-17 encrypted DMs for receipts
- No phone numbers collected
- User provides npub voluntarily
- Operator alerts via Nostr events

Event Schema:
- Kind 21001-21003: CLINK protocol
- Kind 30078: Machine status (replaceable)
- Kind 30079: Transaction records
- Kind 14: Encrypted receipt DMs

This is the logical extension of CLINK - if we're using
Nostr for payments, why not use it for everything?

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 15:36:10 -05:00
Patrick Mulligan
108cd83d69 Replace BOLT12 with CLINK Offers in architecture
BOLT12 problems (per @justin_shocknet):
- Onion messages add latency and failure probability
- Every hop is a point of failure (Tor-like)
- Normalizes mobile nodes (bad for Lightning)
- Redundant (LND keysend already exists)
- Astroturfed by NGOs with questionable motives

CLINK Offers advantages:
- Uses Nostr relays (commodity, trustless via NIP-44)
- No HTTP callbacks, WebSockets, or onion messages
- Keys decoupled from Lightning node identity
- Already working: ShockWallet, Lightning.Pub, Stacker News
- More traction in weeks than BOLT12 in years

Updated:
- Protocol stack recommendation
- New components (clink-handler)
- Implementation roadmap
- References section

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 15:25:34 -05:00
Patrick Mulligan
528c2d6fa8 Add KYC-free Lightning-first architecture review
Comprehensive rethinking of the project vision:

Core Principles:
- KYC-free: No identity collection
- Lightning-native: Security through protocol
- Self-custodial: Operator and user control keys
- Privacy by default: Minimize data retention
- Autonomous machines: Reduce server dependency

Key Technical Decisions:
- LNbits as primary Lightning backend
- Cashu ecash for offline capability and privacy
- LNURL-withdraw/pay for user-friendly flows
- BOLT12 offers for static payment codes
- NFC BOLT cards for tap-to-withdraw
- Fedimint option for community custody

Architecture Options:
- A: Lean Server (recommended starting point)
- B: Serverless Machine (maximum autonomy)
- C: Fedimint Community Model

Assessment: 60%+ of existing lamassu-server is compliance code.
Recommendation: Rebuild core, reuse hardware drivers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 15:16:53 -05:00
Patrick Mulligan
e55f11ab3a Add experimental e-ink display section to hardware docs
Documents e-ink options for testing:
- Modos Paper (75Hz, open-source FPGA) - ships Jan 2026
- DASUNG Paperlike 253 (33Hz, frontlight)
- Waveshare development boards
- Industrial/outdoor options (SEEKINK, Geniatech)

Includes honest assessment of trade-offs and recommended
use cases (outdoor, solar-powered, idle signage).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 15:12:15 -05:00
Patrick Mulligan
f1469f9c5b Add hardware recommendations for lamassu-machine modernization
Comprehensive document covering:
- Compute: Raspberry Pi CM5 (recommended), Pine64 RISC-V (future)
- Bill validators: ITL NV200 with eSSP protocol, MEI Cashflow
- Bill dispensers: Puloon LCDM series, Fujitsu F53/F56
- Displays: Elo I-Series, Waveshare, Faytech open-frame
- Printers: ESC/POS compatible thermal printers
- NFC: ACR122U with libnfc, PN532 modules
- Protocol support matrix and driver migration strategy
- Bill of materials for MVP and full-featured ATMs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 15:07:24 -05:00
Patrick Mulligan
9550d132dd Switch UI component library from PrimeVue to shadcn-vue
Benefits of shadcn-vue:
- Copy components to repo (you own the code)
- Tailwind-native (no style conflicts)
- Radix Vue primitives (a11y-first)
- Much smaller bundle (~15kb vs ~80kb tree-shaken)
- Full control over styling and behavior

Updated:
- Admin UI: Complete shadcn-vue examples with TanStack Table
- Machine UI: Note about shared shadcn-vue components
- Modernization plan: Updated architecture diagram and bundle sizes
- Bundle target: ~60kb total (down from ~120kb with PrimeVue)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 14:54:45 -05:00
Patrick Mulligan
7251692464 Update modernization plan: Vue 3 for all UIs
- Update architecture diagram to show Vue 3 for both admin and machine
- Replace React decision with Vue 3 unification strategy
- Update machine UI section to include Vue 3 + Tauri
- Add Vue 3 to trade-offs table
- Link to new detailed migration docs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 14:48:34 -05:00
Patrick Mulligan
efddb0db5f Add Vue 3 migration plan for admin UI
Migrate from React 18 + MUI to Vue 3 for consistency with machine UI:
- PrimeVue for components (tree-shakeable vs MUI's 300kb)
- tRPC replacing Apollo GraphQL (~5kb vs ~50kb)
- Pinia for state (same as machine UI)
- Shared ui-shared package for common components

Benefits:
- Single framework across all UIs
- ~70% bundle size reduction (400kb → 120kb)
- End-to-end type safety with tRPC
- Shared composables between admin and machine

Includes:
- Complete project structure
- PrimeVue integration with Tailwind
- tRPC client setup
- Passkey authentication flow
- 4-phase migration strategy

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 14:46:42 -05:00
Patrick Mulligan
775c847c23 Add Vue 3 UI modernization plan for lamassu-machine
Replaces legacy vanilla JS + jQuery with modern stack:
- Vue 3 with Composition API
- TypeScript throughout
- Pinia for state management
- Vite for building
- Vue I18n for localization

Includes:
- Complete project structure
- Core component examples (App.vue, stores, composables)
- WebSocket integration pattern
- i18n strategy preserving existing translations
- 4-phase migration plan
- Testing patterns with Vitest
- Performance targets (<120kb total bundle)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 14:36:30 -05:00
Patrick Mulligan
a5e6b32c24 Add membership & LNbits integration documentation
Feature specification:
- Membership/loyalty system with tiered discounts (Bronze/Silver/Gold/Platinum)
- Lightning wallet integration via Lightning Addresses
- Simplified cash-in flow (no wallet QR needed for members)
- Database schema, API design, machine state changes

LNbits integration:
- Full TypeScript client implementation
- REST API reference
- Deployment architecture options
- NixOS configuration examples
- Monitoring & error handling patterns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 14:33:04 -05:00
Patrick Mulligan
3eb0e7e85d Add lnbits as submodule
Lightning Network wallet/accounts system for potential integration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 14:20:10 -05:00
Patrick Mulligan
9adee6e37f Initial commit: Lamassu modernization project
- Add lamassu-server, lamassu-machine, lamassu-install as submodules
- Add CLAUDE.md with development guidance
- Add docs/modernization-plan.md with 2026 refactoring roadmap
- Add .gitignore for Node.js/Nix development

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 14:19:00 -05:00