Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions infrastructure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions infrastructure/config/docker/prd-docker-compose-boltz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/config/docker/secrets/boltz-claim.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copy to boltz-claim.env and fill in values
# chmod 600 boltz-claim.env

SIGNER_PRIVATE_KEY=
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export class MonitoringBalanceRepository extends BaseRepository<MonitoringBalanc
return this.createQueryBuilder('b')
.leftJoin('b.asset', 'asset')
.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"')
.where('asset.name = :assetName', { assetName })
.andWhere('b.created >= :fromDate', { fromDate })
.orderBy('b.created', 'ASC')
Expand All @@ -37,21 +37,21 @@ export class MonitoringBalanceRepository extends BaseRepository<MonitoringBalanc
.innerJoin(
(qb) =>
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();
Expand All @@ -64,11 +64,11 @@ export class MonitoringBalanceRepository extends BaseRepository<MonitoringBalanc
const results = await this.createQueryBuilder('b')
.leftJoin('b.asset', 'asset')
.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"')
.where('asset.name = :assetName', { assetName })
.andWhere('b.created < :beforeDate', { beforeDate })
.orderBy('b.created', 'DESC')
Expand All @@ -83,11 +83,11 @@ export class MonitoringBalanceRepository extends BaseRepository<MonitoringBalanc
.innerJoin(
(qb) =>
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();
Expand All @@ -104,8 +104,8 @@ export class MonitoringBalanceRepository extends BaseRepository<MonitoringBalanc

private async maxEntity(assetId: number): Promise<MonitoringBalanceEntity | null> {
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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export class MonitoringEvmBalanceRepository extends BaseRepository<MonitoringEvm
return this.createQueryBuilder('b')
.select('b.created', 'timestamp')
.addSelect('b.blockchain', 'blockchain')
.addSelect('b.nativeBalance', 'nativeBalance')
.addSelect('b.tokenBalances', 'tokenBalances')
.addSelect('b.nativeBalance', '"nativeBalance"')
.addSelect('b.tokenBalances', '"tokenBalances"')
.where('b.created >= :fromDate', { fromDate })
.orderBy('b.created', 'ASC')
.getRawMany();
Expand All @@ -33,17 +33,17 @@ export class MonitoringEvmBalanceRepository extends BaseRepository<MonitoringEvm
.innerJoin(
(qb) =>
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();
Expand All @@ -56,17 +56,17 @@ export class MonitoringEvmBalanceRepository extends BaseRepository<MonitoringEvm
.innerJoin(
(qb) =>
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();
}
Expand All @@ -76,11 +76,11 @@ export class MonitoringEvmBalanceRepository extends BaseRepository<MonitoringEvm
.innerJoin(
(qb) =>
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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ export class LightningWalletRepository extends BaseRepository<LightningWalletEnt
if (!internalLnbitsWalletIds.length) return [];

return this.createQueryBuilder()
.select('assetId')
.addSelect('SUM(balance)', 'totalBalance')
.where('lnbitsWalletId IN (:...internalLnbitsWalletIds)', { internalLnbitsWalletIds })
.groupBy('assetId')
.select('"assetId"')
.addSelect('SUM(balance)', '"totalBalance"')
.where('"lnbitsWalletId" IN (:...internalLnbitsWalletIds)', { internalLnbitsWalletIds })
.groupBy('"assetId"')
.getRawMany<LightningWalletTotalBalanceDto>();
}

async getCustomerBalances(excludeLnbitsWalletIds: string[]): Promise<LightningWalletTotalBalanceDto[]> {
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<LightningWalletTotalBalanceDto>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class UserTransactionRepository extends BaseRepository<UserTransactionEnt

async getMaxCreationTimestamp(lnbitsWalletId: string): Promise<{ maxCreationTimestamp: Date } | undefined> {
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')
Expand All @@ -24,9 +24,9 @@ export class UserTransactionRepository extends BaseRepository<UserTransactionEnt

async getBalances(): Promise<{ lightningWalletId: number; balance: number }[]> {
return this.createQueryBuilder()
.select('lightningWalletId')
.select('"lightningWalletId"')
.addSelect('sum(amount - abs(fee)) as balance')
.groupBy('lightningWalletId')
.groupBy('"lightningWalletId"')
.getRawMany<{ lightningWalletId: number; balance: number }>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class LightningWalletService {
} else {
const lightningWalletIterator = this.lightningWalletRepository.getRawIterator<LightningWalletInfoDto>(
100,
'id AS lightningWalletId, lnbitsWalletId, adminKey, assetId AS accountAssetId',
'id AS "lightningWalletId", "lnbitsWalletId", "adminKey", "assetId" AS "accountAssetId"',
);
let lightningWalletInfo = await lightningWalletIterator.next();

Expand Down
Loading