lamassu-server/packages/server/tools/build-dev-env.js
padreug fc761844b7 feat: add LNBits wallet plugin integration
- Introduced LNBits as a Lightning Network wallet provider for Lamassu ATMs.
- Added configuration options for LNBits in the environment variables.
- Implemented core functionalities including invoice creation, payment processing, balance monitoring, and payment status tracking.
- Created unit tests for the LNBits plugin to ensure functionality and error handling.
- Updated development environment setup to include LNBits configuration.
2025-10-12 14:24:29 +02:00

76 lines
No EOL
2.4 KiB
JavaScript

#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
const envPath = path.resolve(__dirname, '../.env')
const sampleEnvPath = path.resolve(__dirname, '../.sample.env')
// Check if .env already exists
if (fs.existsSync(envPath)) {
console.log('.env file already exists. To rebuild, delete it first.')
process.exit(0)
}
// Copy sample env
const sampleContent = fs.readFileSync(sampleEnvPath, 'utf8')
// Development defaults
const devDefaults = {
NODE_ENV: 'development',
// Database
POSTGRES_USER: 'lamassu',
POSTGRES_PASSWORD: 'lamassu',
POSTGRES_HOST: 'localhost',
POSTGRES_PORT: '5432',
POSTGRES_DB: 'lamassu',
// Paths
CA_PATH: path.resolve(__dirname, '../Lamassu_CA.pem'),
CERT_PATH: path.resolve(__dirname, '../../../certs/Lamassu_LS.pem'),
KEY_PATH: path.resolve(__dirname, '../../../certs/Lamassu_LS.key'),
MNEMONIC_PATH: path.resolve(__dirname, '../../../mnemonic.txt'),
// Directories
BLOCKCHAIN_DIR: path.resolve(__dirname, '../../../blockchain'),
OFAC_DATA_DIR: path.resolve(__dirname, '../../../ofac'),
ID_PHOTO_CARD_DIR: path.resolve(__dirname, '../../../photos/idcard'),
FRONT_CAMERA_DIR: path.resolve(__dirname, '../../../photos/front'),
OPERATOR_DATA_DIR: path.resolve(__dirname, '../../../operator-data'),
// Misc
HOSTNAME: 'localhost',
LOG_LEVEL: 'debug',
// Bitcoin (for development, use remote node to avoid full sync)
BTC_NODE_LOCATION: 'remote',
BTC_WALLET_LOCATION: 'local',
BTC_NODE_HOST: 'blockstream.info',
BTC_NODE_PORT: '8333',
// LNBits development defaults
LNBITS_ENDPOINT: 'https://legend.lnbits.com',
LNBITS_ADMIN_KEY: '' // User needs to set this
}
// Build .env content
let envContent = sampleContent
// Replace empty values with dev defaults
Object.keys(devDefaults).forEach(key => {
const regex = new RegExp(`^${key}=.*$`, 'gm')
envContent = envContent.replace(regex, `${key}=${devDefaults[key]}`)
})
// Write .env file
fs.writeFileSync(envPath, envContent)
console.log('Development .env file created with defaults.')
console.log('IMPORTANT: You still need to:')
console.log(' 1. Generate certificates using: bash tools/cert-gen.sh')
console.log(' 2. Create a mnemonic file at: ../../../mnemonic.txt')
console.log(' 3. Set up PostgreSQL database')
console.log(' 4. Configure LNBits admin key if using Lightning')
console.log('')
console.log('Run migrations with: node bin/lamassu-migrate')