Commit graph

40 commits

Author SHA1 Message Date
7dac898a10 feat(v2): own dca_lp writes + auto-init on first dashboard access
Pairs with the satmachineadmin Phase 1 refactor that hoisted LP state
into `satoshimachine.dca_lp` (one row per user). This extension is now
the WRITER for that table; satmachineadmin only reads it during
distribution.

API surface:
  - `GET  /api/v1/dca-client/preferences` — returns the LP's
    `dca_lp` row, AUTO-CREATING it with the authenticated wallet
    as the default DCA destination on first call. Hitting this
    endpoint is the act that marks the LP as onboarded on the
    operator side (gating their deposit creation).
  - `PUT  /api/v1/dca-client/preferences` — LP-side update of
    wallet / mode / fixed-mode limit / autoforward fields. Ensures
    the row exists before applying. Replaces the old
    `PUT /autoforward` endpoint (which is gone).
  - `GET  /api/v1/dca-client/positions` — same shape as before
    but also auto-inits dca_lp on entry (so opening the dashboard
    onboards the LP). Now INNER JOINs dca_lp so only onboarded
    LPs see positions (matches the operator-side "must onboard
    before deposits" gate).
  - `GET  /api/v1/dca-client/transactions` — unchanged.

Models:
  - New `LpPreferences` / `UpdateLpPreferences` exposing the
    dca_lp fields.
  - `UpdateClientAutoforward` removed (replaced by the broader
    `UpdateLpPreferences`).
  - `PerMachinePosition.dca_mode` now sourced from `dca_lp` (it's
    LP-wide, echoed on each position row for legacy display
    compatibility).

CRUD:
  - `_fetch_user_clients` rewritten: INNER JOIN dca_lp, drop
    references to removed `dca_clients.wallet_id` / `.dca_mode`
    columns (they don't exist anymore post-Phase-1).
  - New: `get_lp_preferences`, `ensure_lp_preferences`,
    `update_lp_preferences`. The first writes nothing; the second
    is the get-or-create that defends the auto-onboard invariant.
  - `update_lp_autoforward` removed — write path is now
    `update_lp_preferences` against `dca_lp`, not the multi-row
    UPDATE on `dca_clients` that used to be needed because the
    state was denormalised across enrolments.

Note: the legacy static/js/index.js in this extension references
endpoints that no longer exist (`/registration-status`, `/register`,
`/dashboard/summary`, ...) — that's pre-existing tech debt from when
the LP UX was moved to ~/dev/webapp. Not regressed by this commit;
the deprecated frontend is out of scope. For now LP onboarding works
via direct API call (curl `GET /preferences` once with the LP's wallet
admin key); the webapp will own the proper UI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 15:11:27 +02:00
ade4e67541 feat(v2): satmachineclient maintenance pass — v2 admin schema (P7)
Updates the LP-facing client extension to work against the v2 admin schema
(per-machine dca_clients, leg_type-discriminated dca_payments, settlement
audit trail) and strips the dead v1 code paths.

Maintenance-mode framing: the richer LP UI is migrating to ~/dev/webapp.
This extension now provides a minimal stable read-mostly surface so
existing LP installs don't break against the v2 admin schema.

models.py — rewrite:
  + PerMachinePosition: LP's position at a single machine
  ~ ClientDashboardSummary: now aggregates across all the LP's machines
    and exposes per-machine breakdown in `positions` field
  ~ ClientTransaction: gains machine_id + machine_npub + settlement_id;
    drops transaction_type / lamassu_transaction_id (v1 fields)
  ~ leg_type discriminator on ClientTransaction so the LP can tell DCA,
    operator-initiated balance-settle, and auto-forward legs apart
  + UpdateClientAutoforward: LPs control their own autoforward setting
  - ClientDashboardSummaryAPI, ClientTransactionAPI: deleted (GTQ-only
    parallel "API" models that duplicated the internal ones)
  - ClientPreferences, ClientRegistrationData, UpdateClientSettings:
    deleted (registration + settings are operator-controlled in v2)

crud.py — rewrite:
  + _fetch_user_clients: all dca_clients rows for the LP, joined with
    dca_machines for display metadata
  + _position_for_client: per-machine aggregation helper
  + get_client_dashboard_summary: aggregates positions + sums sats/fiat
    + computes cost basis on fiat-spent (not gross deposits)
  + get_client_transactions: filters to LP-visible leg_types
    (dca / settlement / autoforward); optional machine_id filter
  + update_lp_autoforward: LP self-manages autoforward across all their
    machine positions
  - get_client_analytics (300+ lines of date-parsing pretzels): deleted;
    webapp will own analytics
  - register_dca_client: deleted (admin owns registration in v2)
  - update_client_dca_settings: deleted (admin owns DCA mode/limits)
  - Lamassu-era status='confirmed' (now 'completed'), transaction_type
    column refs, lamassu_transaction_id column refs: all gone

views_api.py — rewrite to 3 endpoints:
  GET /api/v1/dca-client/positions       (aggregated dashboard)
  GET /api/v1/dca-client/transactions    (filterable history)
  PUT /api/v1/dca-client/autoforward     (LP self-manages forwarding)

All require_admin_key on the LP's wallet. Old registration / settings
/ analytics endpoints removed.

Files deleted:
  tasks.py — empty stub ("No background tasks needed")
  transaction_processor.py — empty stub ("No transaction processing")

README.md gains a status banner pointing LP audience at webapp.

.gitignore gains `data/` + sqlite db files + __pycache__ to prevent
LNbits runtime artifacts (auth keys, dev DBs) from being committed.

4 routes registered. Zero ruff errors across the extension.

Refs: aiolabs/satmachineadmin#9 — completes P7

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 17:53:13 +02:00
8d442b7c6f 01 Refactor currency handling in client models and calculations: Update models to store values in GTQ instead of centavos, adjust cost basis calculations, and modify API responses and frontend currency formatting to reflect the new structure. 2025-10-12 14:36:12 +02:00
8c3faeec3f 00 Add currency conversion utilities and update API models: Introduce functions for converting between GTQ and centavos, and enhance API models to reflect these changes for client dashboard and transaction data. 2025-10-12 14:36:12 +02:00
d2866276a9 Update currency handling in models and views: Modify model attributes to specify values in centavos for precision. Adjust CSV export and currency formatting functions to convert centavos to GTQ for accurate display and export. 2025-10-12 14:36:12 +02:00
315bcae4ca Add client registration functionality: Implement API endpoint for client self-registration, including validation and error handling. Update frontend to support registration form and status checks, enhancing user experience for DCA clients. 2025-10-12 14:36:12 +02:00
79d29f52a1 Enhance transaction history display: Update SQL query and model to include transaction time 2025-10-12 14:36:12 +02:00
9821be0406 Enhance client dashboard summary: Add current fiat value of Bitcoin holdings and wallet currency to the summary metrics. Update model and frontend to display current value and unrealized gains/losses, improving financial insights for users. 2025-10-12 14:36:12 +02:00
e05404fcab Enhance client dashboard summary: Add pending fiat deposits to the summary metrics and update the model and frontend to display pending deposits, improving visibility of cash awaiting confirmation for DCA processing. 2025-10-12 14:36:12 +02:00
edb0b4d05e Refactor migrations and models for client extension: Remove legacy DCA migration functions and simplify database schema. Update Pydantic models to reflect new client dashboard structure, consolidating and renaming classes for clarity and relevance to client extension functionality. 2025-10-12 14:36:12 +02:00
75dd03b15a Refactor MyExtension to DCA Admin: Update extension name and description in config.json, remove legacy MyExtension CRUD operations and related API endpoints, and adjust router tags. Clean up unused files and methods to streamline the codebase for DCA administration functionality.
Refactor DCA Admin page endpoints: Update description, remove unused CRUD operations and API endpoints related to MyExtension, and streamline the code for improved clarity and functionality.

Remove QR Code dialog from MyExtension index.html: streamline the UI by eliminating unused dialog components, enhancing code clarity and maintainability.
2025-06-20 22:00:41 +02:00
dc35cae44e Add CRUD operations for Lamassu transactions: implement create, retrieve, and update functions for storing processed Lamassu transactions in the database. Enhance migration script to create the necessary database table and update models to include transaction data structures. Integrate transaction storage into the LamassuTransactionProcessor for improved audit and UI display capabilities. 2025-06-20 00:49:46 +02:00
df8b36fc0f Add commission wallet support in Lamassu configuration: update database schema to include commission_wallet_id, modify related models and CRUD operations, and implement commission payment functionality in transaction processing. Enhance UI components to allow selection of the commission wallet for improved user experience. 2025-06-19 17:08:07 +02:00
1c1f358d82 Add source wallet ID support for DCA distributions: update Lamassu configuration to include source_wallet_id, modify related models and CRUD operations, and enhance transaction processing to utilize the configured source wallet for payments. Update UI components to allow selection of the source wallet. 2025-06-19 16:35:11 +02:00
b615ed0504 Add username field to DCA clients: update database schema, CRUD operations, and UI components to support username functionality for improved user experience. 2025-06-18 17:04:54 +02:00
a107f825af Add last poll tracking to Lamassu configuration: update database schema to include last_poll_time and last_successful_poll fields, modify CRUD operations to record poll times, and enhance transaction processing to utilize these timestamps for improved polling accuracy. 2025-06-18 15:56:55 +02:00
8f046ad0c5 Add SSH tunnel support to Lamassu configuration: update database schema, models, and UI components to include SSH settings. Implement SSH tunnel setup and teardown in transaction processing for enhanced security. 2025-06-18 13:40:30 +02:00
1f7999a556 Add Lamassu database configuration: implement CRUD operations, polling tasks, and UI components for managing database settings. Introduce hourly transaction polling and manual poll functionality. 2025-06-18 10:56:05 +02:00
22ebdc76bb Add DCA CRUD operations and models for clients, deposits, and payments 2025-06-17 18:29:23 +02:00
Arc
dd1dea90c1 quickfix 2024-11-19 00:57:27 +00:00
Arc
911aabd7d7 Working 2024-11-18 22:45:33 +00:00
Arc
08dad16611 Mostly working 2024-11-18 21:54:27 +00:00
Arc
5a2ba743cf Added lnurl helper, and I hate mypy 2024-11-18 20:49:24 +00:00
Arc
451e89682e Improved comment 2024-11-18 15:49:09 +00:00
Arc
5e988aa9f7 cleaned up api 2024-11-18 15:46:06 +00:00
Arc
5bdc334249 Merge branch 'v1' into feat_lnurl_v1 2024-11-18 13:44:41 +00:00
Arc
8b2b36a4f9 another v1 fixup + moved lnurl stuff to models 2024-11-15 00:06:28 +00:00
dni ⚡
48b1069a9f feat: update to v1.0.0 2024-10-21 14:38:03 +02:00
dni ⚡
42b5edaf5d feat: code quality
format

add ci

fixup ci
2024-08-13 08:20:45 +02:00
benarc
db47653ca6 Cleanup 2024-07-20 18:27:05 +01:00
benarc
c50aaf5d8c More notes and black 2024-02-01 17:47:17 +00:00
benarc
2cac36be17 format 2024-02-01 17:18:55 +00:00
benarc
39339469bb lnurlwithdraw 2024-01-23 09:14:57 +00:00
benarc
044696ffce Adding qrcodes 2024-01-17 12:22:26 +00:00
benarc
0711f583d6 changed name to myextension 2024-01-16 16:38:53 +00:00
arcbtc
ba7e11e30d Switching lnurl links from model to crud 2023-12-30 21:37:52 +00:00
arcbtc
5ca331134c cleaned 2023-12-08 22:09:40 +00:00
arcbtc
551d77a7d9 Item not recognised 2023-12-08 21:32:48 +00:00
arcbtc
c87ccf7107 added simple lnurl 2023-12-08 20:39:27 +00:00
Arc
aa560fd89d Add files via upload 2023-12-08 15:43:40 +00:00