Commit graph

47 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
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
340dc22c20 Refactor client configuration access: Remove direct access to sensitive admin config and local client-limits endpoint. Implement fetching of client limits via a secure public API. Update registration form to reflect changes and enhance user experience. 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
c86d650e5a Refactor API authentication: Replace 'require_invoice_key' with 'require_admin_key' for dashboard endpoints to restrict access to admin users only. Update related frontend API calls to use 'adminkey' instead of 'inkey' for consistency. 2025-10-12 14:36:12 +02:00
955eddd817 Improve error handling and data validation in client analytics: Update API to return empty analytics data instead of raising an error when no data is available. Enhance date formatting checks in analytics calculations and frontend chart rendering to ensure robustness against invalid date formats. 2025-10-12 14:36:12 +02:00
9ea8c37940 Enhance client dashboard summary calculations: Update SQL queries to accurately reflect total confirmed and pending deposits, and adjust metrics for average cost basis and remaining balance. Modify API and frontend to ensure values are in full currency units, improving clarity and consistency in financial data representation. 2025-10-12 14:36:12 +02:00
f779d000b4 Update client API and frontend for DCA dashboard: Modify API endpoints to correctly reference wallet user, enhance Vue.js component with loading and error states, and implement data fetching for dashboard summary and transactions. Update HTML template to reflect new client extension structure and improve user experience with dynamic content rendering. 2025-10-12 14:36:12 +02:00
32e8f31b82 Refactor client API endpoints for DCA dashboard: Update endpoint structure to focus on client-specific functionalities, including dashboard summary, transaction history, and analytics. Enhance code readability with improved formatting and add support for exporting transaction data in CSV format. 2025-10-12 14:36:12 +02:00
8328861e22 Clear out 2025-10-12 14:36:12 +02:00
9b04d1af6c replace satmachineadmin varieties with satmachineclient; update pyprojec.toml 2025-10-12 14:36:12 +02:00
6db94179cc Replace [mM]yextension with [sS]at[mM]achine[aA]dmin 2025-06-20 22:16:58 +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
1af15b6e26 Add Lamassu transaction endpoints and UI integration: implement API endpoints for retrieving all processed Lamassu transactions and specific transaction details, including distribution information. Enhance frontend to display transaction data in a table format with export functionality and detailed views for distributions, improving user experience and data accessibility. 2025-06-20 01:37:31 +02:00
5f21a27f0e Add test transaction endpoint and UI integration: implement API for simulating transactions with mock data, including commission and discount calculations. Enhance frontend to trigger test transactions and display results in a dialog, improving user experience and testing capabilities. 2025-06-19 17:33:16 +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
3c6262b309 Refactor transaction processing to utilize SSH for database queries: implement execute_ssh_query method, enhance error handling, and update connection testing steps. Modify API to fetch transactions via SSH configuration, improving security and reliability. 2025-06-18 15:37:00 +02:00
c4ab8c27ef Enhance SSH tunnel functionality in transaction processing: implement subprocess-based SSH tunnel as a fallback, improve error handling, and add detailed connection testing with step-by-step reporting. Update API to utilize new testing method and enhance UI to display detailed results. 2025-06-18 15:33:51 +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
46b7a1450d Add temporary DCA client creation endpoint for testing and enhance quick deposit UI with new form for adding deposits. Clean up code formatting for consistency. 2025-06-17 20:09:53 +02:00
b3332e585a Refactor DCA client management: remove CRUD operations for clients and update UI to focus on deposit management. Introduce quick deposit form for existing clients. 2025-06-17 19:28:53 +02:00
7bafc67370 Add DCA admin extension with CRUD operations for clients and deposits, including UI components for managing deposits and client details. 2025-06-17 19:26:31 +02:00
Arc
532cd08698 fixed update 2024-11-19 01:23:51 +00: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
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
291428313e missed await 2024-11-18 13:32:00 +00:00
Arc
5549ef91f4 changed icon 2024-11-18 13:26:02 +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
43c00b0c7e renamed endpoints and stripped out some dead code 2024-06-03 14:12:39 +01:00
benarc
37d2082082 format 2024-02-01 17:25:38 +00:00
benarc
2cac36be17 format 2024-02-01 17:18:55 +00:00
benarc
d90babebc8 added confetti 2024-01-19 17:40:43 +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
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