Removes the test transaction button from the admin UI. The test transaction endpoint is still available in the API for development and debugging purposes. |
||
|---|---|---|
| .github/workflows | ||
| static | ||
| templates/satmachineadmin | ||
| tests | ||
| .gitignore | ||
| .prettierrc | ||
| __init__.py | ||
| CLAUDE.md | ||
| config.json | ||
| crud.py | ||
| description.md | ||
| Lamassu-Database-Analysis.md | ||
| LICENSE | ||
| Makefile | ||
| manifest.json | ||
| migrations.py | ||
| models.py | ||
| package-lock.json | ||
| package.json | ||
| poetry.lock | ||
| pyproject.toml | ||
| README.md | ||
| tasks.py | ||
| toc.md | ||
| transaction_processor.py | ||
| views.py | ||
| views_api.py | ||
DCA Admin Extension for LNBits
A Dollar Cost Averaging (DCA) administration extension for LNBits that integrates with Lamassu ATM machines to automatically distribute Bitcoin to registered clients based on their deposit balances.
Overview
This extension enables automated Bitcoin distribution from Lamassu ATM transactions to DCA clients. When customers use a Lamassu ATM to purchase Bitcoin, the system automatically distributes the purchased amount (minus commission) proportionally to clients who have active DCA balances.
Features
🏦 DCA Client Management
- View all registered DCA clients from the client extension
- Monitor client balances and deposit history
- Support for both "flow" and "fixed" DCA modes
- Real-time balance tracking with remaining amounts
💰 Deposit Management
- Quick deposit creation for existing clients
- Individual deposit confirmation workflow
- Status tracking (pending/confirmed)
- Notes and documentation for each deposit
🔄 Lamassu ATM Integration
- Real-time polling of Lamassu database transactions
- Secure SSH tunnel support for database access
- Automatic commission calculation and handling
- Proportional distribution to active DCA clients
📊 Transaction Audit Trail
- Complete record of all processed Lamassu transactions
- Clickable transaction details showing exact distribution breakdown
- Commission tracking with discount support
- Export capabilities for all data
⚙️ Configuration Management
- Secure database connection configuration
- Source wallet selection for Bitcoin distributions
- Commission wallet configuration for earnings
- SSH tunnel setup for secure remote access
Installation
- Copy this extension to your LNBits extensions directory
- Enable the extension in LNBits admin panel
- Install the companion DCA client extension for end-users
Configuration
Database Setup
-
Configure Lamassu Database Connection
- Navigate to the DCA Admin extension
- Click "Configure Database" in the sidebar
- Enter your Lamassu PostgreSQL connection details:
- Host and port
- Database name (usually "lamassu")
- Username and password
- Select source wallet for Bitcoin distributions
- Optionally select commission wallet for earnings
-
SSH Tunnel (Recommended)
- Enable SSH tunnel for secure database access
- Provide SSH server details and authentication
- Supports both password and private key authentication
-
Test Connection
- Use the "Test Connection" button to verify setup
- Check SSH tunnel and database connectivity
Wallet Configuration
- Source Wallet: Must contain sufficient Bitcoin for distributions
- Commission Wallet: Optional separate wallet for commission earnings
- Wallets are automatically credited with Lamassu transaction amounts
Usage
For Administrators
-
Client Registration
- Clients register using the DCA client extension
- Admins can view all registered clients in the admin panel
-
Deposit Management
- Add deposits for clients when they provide fiat currency
- Confirm deposits once money is physically placed in ATM
- Track deposit status and client balances
-
Transaction Processing
- System automatically polls Lamassu database hourly
- Manual polling available for immediate processing
- Test transaction feature for system validation
-
Monitoring
- View all processed transactions with full audit trail
- Click transactions to see distribution details
- Export data for accounting and compliance
For End Users (DCA Client Extension)
-
Registration
- Install DCA client extension
- Choose DCA mode (flow or fixed)
- Make initial deposit with administrator
-
DCA Modes
- Flow Mode: Receives proportional share of all transactions
- Fixed Mode: Receives up to daily limit from transactions
Technical Details
Architecture
- Backend: FastAPI with PostgreSQL database
- Frontend: Vue.js 3 with Quasar UI components
- Database: Extends LNBits database with dedicated tables
- Integration: Direct PostgreSQL connection to Lamassu database
Database Schema
The extension creates several tables:
dca_clients: Registered DCA usersdca_deposits: Client deposit trackingdca_payments: Individual Bitcoin distributionslamassu_config: Database connection settingslamassu_transactions: Processed ATM transaction audit trail
Security
- SSH tunnel support for secure database access
- Encrypted storage of database credentials
- Read-only access to Lamassu database
- Internal LNBits payment system for Bitcoin distributions
Commission Handling
- Configurable commission percentage from Lamassu
- Discount support for promotional rates
- Automatic commission calculation:
base_amount = total / (1 + commission_rate) - Separate wallet option for commission earnings
API Endpoints
DCA Clients
GET /api/v1/dca/clients- List all clientsGET /api/v1/dca/clients/{id}/balance- Get client balancePOST /api/v1/dca/clients- Create test client (dev only)
Deposits
GET /api/v1/dca/deposits- List all depositsPOST /api/v1/dca/deposits- Create new depositPUT /api/v1/dca/deposits/{id}/status- Update deposit status
Transactions
GET /api/v1/dca/transactions- List processed transactionsGET /api/v1/dca/transactions/{id}/distributions- Get distribution details
Configuration
GET /api/v1/dca/config- Get database configurationPOST /api/v1/dca/config- Create/update configurationPOST /api/v1/dca/test-connection- Test database connection
Operations
POST /api/v1/dca/manual-poll- Trigger manual pollingPOST /api/v1/dca/test-transaction- Process test transaction
Development
Setup Development Environment
- Clone LNBits and this extension
- Install dependencies:
poetry install - Set up test Lamassu database or use test mode
- Configure SSH tunnel for development access
Code Structure
├── README.md # This file
├── __init__.py # Extension initialization
├── models.py # Pydantic data models
├── crud.py # Database operations
├── views.py # Frontend page routes
├── views_api.py # API endpoints
├── migrations.py # Database migrations
├── transaction_processor.py # Lamassu integration
├── helpers.py # Utility functions
├── config.json # Extension configuration
├── manifest.json # Extension manifest
├── templates/
│ └── satmachineadmin/
│ └── index.html # Main UI template
└── static/
└── js/
└── index.js # Frontend JavaScript
Testing
- Use "Test Connection" to verify Lamassu database access
- Use "Test Transaction" to simulate ATM transaction processing
- Monitor logs for debugging transaction processing
- Test SSH tunnel connectivity independently
Troubleshooting
Common Issues
-
SSH Connection Failed
- Verify SSH credentials and host accessibility
- Check SSH key permissions (600 for private keys)
- Ensure SSH server allows database user connections
-
Database Connection Failed
- Verify PostgreSQL connection details
- Check database user permissions (SELECT access required)
- Confirm database name and schema
-
No Transactions Found
- Check Lamassu database for recent transactions
- Verify transaction polling timestamps
- Review database query filters
-
Distribution Errors
- Ensure source wallet has sufficient balance
- Check client deposit confirmations
- Verify wallet configuration
Debugging
- Enable debug logging:
DEBUG=true - Check LNBits logs for transaction processing
- Use manual polling to test individual transactions
- Verify database queries with SSH tunnel
Security Considerations
- Use SSH tunnels for production database access
- Regularly rotate database credentials
- Monitor transaction processing logs
- Implement proper backup procedures
- Use read-only database access where possible
Support
For issues and questions:
- Check the troubleshooting section above
- Review LNBits extension documentation
- Check connection test results for specific errors
- Monitor system logs for detailed error messages
License
This extension follows the same license as LNBits.
Note: This extension requires the companion DCA client extension for end-users to register and participate in the DCA program.