diff --git a/infrastructure/README.md b/infrastructure/README.md index 337ab128c..2e05554f1 100644 --- a/infrastructure/README.md +++ b/infrastructure/README.md @@ -100,6 +100,15 @@ After Docker Compose is successfully executed for the very first time, the follo 1. Find the User Id in the URL 1. Set the value of the `LNBITS_ADMIN_USERS` in the config file `~/volumes/lnbits/.env` to the User Id + ## Secrets Management + +```bash +cd infrastructure/config/docker/secrets +cp boltz-claim.env.example boltz-claim.env +chmod 600 boltz-claim.env +# Edit and add your private key +``` + # Infrastructure Update ## Backup diff --git a/infrastructure/config/docker/prd-docker-compose-boltz.yml b/infrastructure/config/docker/prd-docker-compose-boltz.yml index 896d49be1..bb74a80c4 100644 --- a/infrastructure/config/docker/prd-docker-compose-boltz.yml +++ b/infrastructure/config/docker/prd-docker-compose-boltz.yml @@ -87,6 +87,30 @@ services: - VITE_API_URL=http://backend:9000 - VITE_RSK_LOG_SCAN_ENDPOINT=[VITE_RSK_LOG_SCAN_ENDPOINT] + claim: + image: dfxswiss/boltz-claim:latest + restart: unless-stopped + networks: + - shared + depends_on: + - postgres + ports: + - '3001:3001' + logging: + driver: 'json-file' + options: + max-size: '100m' + max-file: '3' + env_file: + - secrets/boltz-claim.env + environment: + - PORT=3001 + - TARGET_CHAIN=mainnet + - DATABASE_URL=postgresql://[POSTGRES_USERNAME]:[POSTGRES_PASSWORD]@postgres:5432/[POSTGRES_DATABASE] + - RPC_CITREA_MAINNET=https://rpc.juiceswap.com + - RPC_POLYGON=https://polygon-mainnet.g.alchemy.com/v2/[API-KEY] + - RPC_ETHEREUM=https://eth-mainnet.g.alchemy.com/v2/[API-KEY] + networks: shared: external: true diff --git a/infrastructure/config/docker/secrets/boltz-claim.env.example b/infrastructure/config/docker/secrets/boltz-claim.env.example new file mode 100644 index 000000000..72b53c193 --- /dev/null +++ b/infrastructure/config/docker/secrets/boltz-claim.env.example @@ -0,0 +1,4 @@ + # Copy to boltz-claim.env and fill in values + # chmod 600 boltz-claim.env + + SIGNER_PRIVATE_KEY= diff --git a/src/subdomains/monitoring/repositories/monitoring-balance.repository.ts b/src/subdomains/monitoring/repositories/monitoring-balance.repository.ts index 5b9c01fc7..ffb6e713d 100644 --- a/src/subdomains/monitoring/repositories/monitoring-balance.repository.ts +++ b/src/subdomains/monitoring/repositories/monitoring-balance.repository.ts @@ -18,11 +18,11 @@ export class MonitoringBalanceRepository extends BaseRepository= :fromDate', { fromDate }) .orderBy('b.created', 'ASC') @@ -37,21 +37,21 @@ export class MonitoringBalanceRepository extends BaseRepository qb - .select('MAX(sub.id)', 'maxId') + .select('MAX(sub.id)', '"maxId"') .from(MonitoringBalanceEntity, 'sub') .leftJoin('sub.asset', 'a') .where('a.name = :assetName', { assetName }) .andWhere('sub.created >= :fromDate', { fromDate }) .groupBy(`TO_CHAR(sub.created, '${format}')`), 'latest', - 'b.id = latest.maxId', + 'b.id = latest."maxId"', ) .select('b.created', 'timestamp') - .addSelect('b.onchainBalance', 'onchainBalance') - .addSelect('b.lndOnchainBalance', 'lndOnchainBalance') - .addSelect('b.lightningBalance', 'lightningBalance') - .addSelect('b.citreaBalance', 'citreaBalance') - .addSelect('b.customerBalance', 'customerBalance') + .addSelect('b.onchainBalance', '"onchainBalance"') + .addSelect('b.lndOnchainBalance', '"lndOnchainBalance"') + .addSelect('b.lightningBalance', '"lightningBalance"') + .addSelect('b.citreaBalance', '"citreaBalance"') + .addSelect('b.customerBalance', '"customerBalance"') .orderBy('b.created', 'ASC') .setParameters({ assetName, fromDate }) .getRawMany(); @@ -64,11 +64,11 @@ export class MonitoringBalanceRepository extends BaseRepository qb - .select('MAX(sub.id)', 'maxId') + .select('MAX(sub.id)', '"maxId"') .from(MonitoringBalanceEntity, 'sub') - .groupBy('sub.assetId'), + .groupBy('sub."assetId"'), 'latest', - 'b.id = latest.maxId', + 'b.id = latest."maxId"', ) .leftJoinAndSelect('b.asset', 'asset') .getMany(); @@ -104,8 +104,8 @@ export class MonitoringBalanceRepository extends BaseRepository { const maxId = await this.createQueryBuilder() - .select('max(id) as maxId') - .where('assetId = :assetId', { assetId }) + .select('max(id) as "maxId"') + .where('"assetId" = :assetId', { assetId }) .getRawOne<{ maxId: number }>(); if (!maxId) return null; diff --git a/src/subdomains/monitoring/repositories/monitoring-evm-balance.repository.ts b/src/subdomains/monitoring/repositories/monitoring-evm-balance.repository.ts index c4670a94e..8bdfc7566 100644 --- a/src/subdomains/monitoring/repositories/monitoring-evm-balance.repository.ts +++ b/src/subdomains/monitoring/repositories/monitoring-evm-balance.repository.ts @@ -18,8 +18,8 @@ export class MonitoringEvmBalanceRepository extends BaseRepository= :fromDate', { fromDate }) .orderBy('b.created', 'ASC') .getRawMany(); @@ -33,17 +33,17 @@ export class MonitoringEvmBalanceRepository extends BaseRepository qb - .select('MAX(sub.id)', 'maxId') + .select('MAX(sub.id)', '"maxId"') .from(MonitoringEvmBalanceEntity, 'sub') .where('sub.created >= :fromDate', { fromDate }) .groupBy(`sub.blockchain, TO_CHAR(sub.created, '${format}')`), 'latest', - 'b.id = latest.maxId', + 'b.id = latest."maxId"', ) .select('b.created', 'timestamp') .addSelect('b.blockchain', 'blockchain') - .addSelect('b.nativeBalance', 'nativeBalance') - .addSelect('b.tokenBalances', 'tokenBalances') + .addSelect('b.nativeBalance', '"nativeBalance"') + .addSelect('b.tokenBalances', '"tokenBalances"') .orderBy('b.created', 'ASC') .setParameters({ fromDate }) .getRawMany(); @@ -56,17 +56,17 @@ export class MonitoringEvmBalanceRepository extends BaseRepository qb - .select('MAX(sub.id)', 'maxId') + .select('MAX(sub.id)', '"maxId"') .from(MonitoringEvmBalanceEntity, 'sub') .where('sub.created < :beforeDate', { beforeDate }) .groupBy('sub.blockchain'), 'latest', - 'b.id = latest.maxId', + 'b.id = latest."maxId"', ) .select('b.created', 'timestamp') .addSelect('b.blockchain', 'blockchain') - .addSelect('b.nativeBalance', 'nativeBalance') - .addSelect('b.tokenBalances', 'tokenBalances') + .addSelect('b.nativeBalance', '"nativeBalance"') + .addSelect('b.tokenBalances', '"tokenBalances"') .setParameters({ beforeDate }) .getRawMany(); } @@ -76,11 +76,11 @@ export class MonitoringEvmBalanceRepository extends BaseRepository qb - .select('MAX(sub.id)', 'maxId') + .select('MAX(sub.id)', '"maxId"') .from(MonitoringEvmBalanceEntity, 'sub') .groupBy('sub.blockchain'), 'latest', - 'b.id = latest.maxId', + 'b.id = latest."maxId"', ) .getMany(); } diff --git a/src/subdomains/user/application/repositories/lightning-wallet.repository.ts b/src/subdomains/user/application/repositories/lightning-wallet.repository.ts index fd6a11dd4..4af6906f4 100644 --- a/src/subdomains/user/application/repositories/lightning-wallet.repository.ts +++ b/src/subdomains/user/application/repositories/lightning-wallet.repository.ts @@ -21,21 +21,21 @@ export class LightningWalletRepository extends BaseRepository(); } async getCustomerBalances(excludeLnbitsWalletIds: string[]): Promise { const query = this.createQueryBuilder() - .select('assetId') - .addSelect('SUM(balance)', 'totalBalance') - .groupBy('assetId'); + .select('"assetId"') + .addSelect('SUM(balance)', '"totalBalance"') + .groupBy('"assetId"'); if (excludeLnbitsWalletIds.length) { - query.where('lnbitsWalletId NOT IN (:...excludeLnbitsWalletIds)', { excludeLnbitsWalletIds }); + query.where('"lnbitsWalletId" NOT IN (:...excludeLnbitsWalletIds)', { excludeLnbitsWalletIds }); } return query.getRawMany(); diff --git a/src/subdomains/user/application/repositories/user-transaction.repository.ts b/src/subdomains/user/application/repositories/user-transaction.repository.ts index e86f33eb0..b0414fe2c 100644 --- a/src/subdomains/user/application/repositories/user-transaction.repository.ts +++ b/src/subdomains/user/application/repositories/user-transaction.repository.ts @@ -11,7 +11,7 @@ export class UserTransactionRepository extends BaseRepository { return this.createQueryBuilder('ut') - .select('max(ut.creationTimestamp) as maxCreationTimestamp') + .select('max(ut.creationTimestamp) as "maxCreationTimestamp"') .leftJoin('ut.lightningWallet', 'lw') .where('lw.lnbitsWalletId = :lnbitsWalletId', { lnbitsWalletId }) .groupBy('lw.lnbitsWalletId') @@ -24,9 +24,9 @@ export class UserTransactionRepository extends BaseRepository { return this.createQueryBuilder() - .select('lightningWalletId') + .select('"lightningWalletId"') .addSelect('sum(amount - abs(fee)) as balance') - .groupBy('lightningWalletId') + .groupBy('"lightningWalletId"') .getRawMany<{ lightningWalletId: number; balance: number }>(); } } diff --git a/src/subdomains/user/application/services/lightning-wallet.service.ts b/src/subdomains/user/application/services/lightning-wallet.service.ts index 32d788eca..35bf8fd95 100644 --- a/src/subdomains/user/application/services/lightning-wallet.service.ts +++ b/src/subdomains/user/application/services/lightning-wallet.service.ts @@ -121,7 +121,7 @@ export class LightningWalletService { } else { const lightningWalletIterator = this.lightningWalletRepository.getRawIterator( 100, - 'id AS lightningWalletId, lnbitsWalletId, adminKey, assetId AS accountAssetId', + 'id AS "lightningWalletId", "lnbitsWalletId", "adminKey", "assetId" AS "accountAssetId"', ); let lightningWalletInfo = await lightningWalletIterator.next();