Commit graph

17 commits

Author SHA1 Message Date
Patrick Mulligan
f37555565e feat(machine): add SQLite persistence and remove npub linking
Add crash-safe persistence for cassette inventory, cashbox state, and
transaction history using better-sqlite3 in the Electron main process.
The state machine now loads inventory from the database at runtime
instead of using hardcoded values, and transactions are automatically
persisted on completion.

Remove the unnecessary npub linking code — Lightning.Pub auto-creates
and associates Nostr users when appId is included in RPC requests,
making the HTTP-based user creation and token linking redundant.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 11:45:09 -05:00
Patrick Mulligan
60f4eb6639 feat(machine): add Zeus and Lightning.Pub QR codes to mock UI
dev.sh atm auto-injects VITE_LNDCONNECT_URL from lnd-3 credentials.
Idle screen shows "Zeus QR" and "Lightning.Pub nprofile" buttons (debug
mode) that open fullscreen overlays with scannable 400px QR codes and
copy-to-clipboard support. Also makes the debug overlay collapsible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 13:38:32 -05:00
Patrick Mulligan
5448a620a9 chore(nostr-client): move dev scripts to dev/ folder
Move 9 development/testing .mjs scripts out of the package root into
dev/ to keep the published package clean. Update relative imports
and dev.sh reference.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 17:48:49 -05:00
Patrick Mulligan
e6e77f808e feat(docker): add fund command and Nostr RPC funding script
- Add './dev.sh fund [amount]' for funding ATM via Nostr RPC
- Create invoices via NIP-44 encrypted RPC instead of HTTP API
- Support existing users without fail_if_exists errors
- Add --fund flag to './dev.sh up' for one-command setup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 16:58:32 -05:00
Patrick Mulligan
5e94cdc11b fix(docker): add extra delay after graph sync for reliable payments
Add 10-second delay after route verification succeeds to ensure
the graph is fully propagated before attempting funding payments.
Also increase max route check attempts from 12 to 15.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 18:43:50 -05:00
Patrick Mulligan
f6c3d62488 fix(docker): improve channel setup timing for clean slate
- Add is_lnd1_wallet_ready() to verify wallet is ready before operations
- Mine initial blocks if blockchain has < 101 blocks (fresh regtest)
- Wait for lnd-1 to sync to chain before opening channels
- Create bitcoind wallet if needed (clean slate)
- Increase channel activation wait from 40s to 60s
- Add explicit graph propagation check via queryroutes
- Wait up to 60s for lnd-3 to find route to lnd-4 before funding

This ensures the environment works from a completely clean Docker
slate without relying on the scheduled miner.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 18:25:32 -05:00
Patrick Mulligan
90eceeafd9 feat(docker): auto-setup Lightning channels for unified regtest mode
Add automatic channel setup to dev.sh for seamless ATM development:

- Add ensure_lnd4_channel() to open channels from lnd-1 hub to lnd-3 and lnd-4
- lnd-4 receives channel for Lightning.Pub invoice creation
- lnd-3 receives channel for paying invoices (ATM funding)
- Auto-fund lnd-1 via mining if balance is low
- Include retry logic for channel opening (5 attempts)
- Mine extra blocks and wait for graph propagation to avoid NO_ROUTE errors
- Show channel balance in status output

This makes the unified mode fully functional from a clean slate:
  ./docker/dev.sh up --fund    # Sets up regtest, channels, and funds ATM
  ./docker/dev.sh atm          # Launch ATM application

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 17:54:40 -05:00
Patrick Mulligan
c3564beccf feat(docker): add standalone mode and external orchestration support
- Add --standalone flag to use self-contained bitcoind/lnd
- Default to unified mode using shared regtest
- Track compose mode in state file for down/logs/reset
- Add _setup_after_start internal command for external orchestration
- Update help text with new options

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 16:03:13 -05:00
Patrick Mulligan
e9ed63770a fix(docker): correct lnd-3 REST port to 8081
Was incorrectly set to 8082, causing Zeus connection to fail.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 14:54:31 -05:00
Patrick Mulligan
b46b415b4e fix(docker): generate PNG QR code for Zeus scanning
Terminal QR codes can be hard to scan. Generate a PNG file instead
and open it with the default image viewer.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 14:50:55 -05:00
Patrick Mulligan
8a3b38f352 feat(docker): add zeus command for QR code display
- Show truncated lndconnect in status instead of large QR
- Add ./dev.sh zeus command to display QR on demand

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 14:48:28 -05:00
Patrick Mulligan
ba3a54265f fix(docker): reduce QR code margin, add scan hint
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 14:41:00 -05:00
Patrick Mulligan
786b118d54 feat(docker): display Zeus lndconnect as QR code
- Add qrencode to devenv.nix packages
- Display QR code in terminal for easy Zeus wallet scanning
- Falls back to text if qrencode not available

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 14:38:40 -05:00
Patrick Mulligan
c8006638b2 refactor(docker): simplify lndconnect to use docker exec only
Remove filesystem fallback with sudo - just read certs from container.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 14:35:57 -05:00
Patrick Mulligan
f70c2b8878 fix(docker): run ATM in background, fix Zeus lndconnect
- Launch ATM with --background flag when using --machine
- ATM logs written to .state/atm.log instead of terminal
- Fix lndconnect generation to read certs via docker exec
- Status output remains visible after ATM starts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 14:34:09 -05:00
Patrick Mulligan
9a4dc759f8 feat(docker): add --machine flag to launch ATM with dev.sh up
Usage: ./dev.sh up --fund --machine

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-15 14:30:13 -05:00
Patrick Mulligan
c98f126ba7 feat(docker): add dev.sh with auto-funding and ATM app setup
- Add dev.sh script for managing regtest development environment
- Implement cmd_fund to fund ATM app owner via Lightning.Pub API
- Add --fund flag to cmd_up for automatic funding on startup
- Update setup_atm_app to write VITE_APP_ID to machine .env
- Fix Electron IPC to pass appId and extensionApiUrl to renderer
- Restructure repo from nested lamassu-next/ to root

The dev.sh script now supports:
- ./dev.sh up --fund  # Start regtest and auto-fund ATM
- ./dev.sh fund       # Fund existing ATM app
- ./dev.sh status     # Show environment status
- ./dev.sh reset      # Clean restart

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