Skip to content

Commit ffe9dc5

Browse files
authored
Merge pull request #134 from LightningDotSpace/develop
Release: develop -> main
2 parents 224b72d + 104d4bc commit ffe9dc5

8 files changed

Lines changed: 68 additions & 17 deletions

File tree

.env.example

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
PORT=
2-
ENVIRONMENT=
3-
SQL_HOST=
4-
SQL_PORT=
5-
SQL_USERNAME=
6-
SQL_PASSWORD=
7-
SQL_DB=
8-
SQL_SYNCHRONIZE=
9-
SQL_MIGRATE=
1+
# --- Local Development (Docker MSSQL) ---
2+
# Copy this file to .env and fill in the values
3+
# Start MSSQL: docker compose up -d
4+
# Create DB once: docker exec lds-mssql /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "YourStrong!Passw0rd" -C -Q "CREATE DATABASE LightningSpace"
5+
# For local dev, only the settings below are required:
6+
ENVIRONMENT=loc
7+
PORT=3000
8+
SQL_HOST=localhost
9+
SQL_PORT=1433
10+
SQL_USERNAME=sa
11+
SQL_PASSWORD=YourStrong!Passw0rd
12+
SQL_DB=LightningSpace
13+
SQL_SYNCHRONIZE=true
14+
SQL_MIGRATE=false
1015
JWT_SECRET=
11-
DISABLED_PROCESSES=
16+
DISABLED_PROCESSES=*
1217

1318
# Debug endpoint (scripts/db-debug.sh, scripts/log-debug.sh)
1419
DEBUG_ADDRESS=

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,10 @@ placeholder.env
4141
placeholder.env
4242

4343
# Custom
44-
thunder-tests/env
44+
thunder-tests/env
45+
46+
# Local SQLite databases
47+
testDB/
48+
*.db
49+
*.sqlite
50+
*.sqlite3

docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
services:
2+
mssql:
3+
image: mcr.microsoft.com/mssql/server:2022-latest
4+
container_name: lds-mssql
5+
environment:
6+
ACCEPT_EULA: 'Y'
7+
MSSQL_SA_PASSWORD: 'YourStrong!Passw0rd'
8+
MSSQL_PID: Developer
9+
ports:
10+
- '1433:1433'
11+
volumes:
12+
- mssql-data:/var/opt/mssql
13+
healthcheck:
14+
test: /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "YourStrong!Passw0rd" -C -Q "SELECT 1" -b -o /dev/null
15+
interval: 10s
16+
timeout: 3s
17+
retries: 10
18+
start_period: 10s
19+
20+
volumes:
21+
mssql-data:

src/config/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class Configuration {
3434
database: TypeOrmModuleOptions = {
3535
type: 'mssql',
3636
host: process.env.SQL_HOST,
37-
port: Number.parseInt(process.env.SQL_PORT ?? '3000'),
37+
port: Number.parseInt(process.env.SQL_PORT ?? '1433'),
3838
username: process.env.SQL_USERNAME,
3939
password: process.env.SQL_PASSWORD,
4040
database: process.env.SQL_DB,
@@ -46,6 +46,7 @@ export class Configuration {
4646
connectionTimeout: 30000,
4747
requestTimeout: 30000,
4848
logging: false,
49+
options: { trustServerCertificate: this.environment === Environment.LOC },
4950
};
5051

5152
auth = {

src/integration/blockchain/citrea/citrea-client.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GetConfig } from 'src/config/config';
1+
import { Environment, GetConfig } from 'src/config/config';
22
import { EvmUtil } from 'src/subdomains/evm/evm.util';
33
import { LightningHelper } from '../lightning/lightning-helper';
44
import { EvmClient, EvmClientParams } from '../shared/evm/evm-client';
@@ -9,7 +9,11 @@ export class CitreaClient extends EvmClient {
99
constructor(params: EvmClientParams) {
1010
super(params);
1111

12-
this.walletAddress = EvmUtil.createWallet({ seed: GetConfig().evm.walletSeed, index: 0 }).address;
12+
const config = GetConfig();
13+
this.walletAddress =
14+
config.environment === Environment.LOC
15+
? ''
16+
: EvmUtil.createWallet({ seed: config.evm.walletSeed, index: 0 }).address;
1317
}
1418

1519
async getNativeCoinBalance(): Promise<number> {

src/integration/blockchain/lightning/services/lightning-ws.service.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Injectable } from '@nestjs/common';
2-
import { Observable, map } from 'rxjs';
3-
import { Configuration, GetConfig } from 'src/config/config';
2+
import { EMPTY, Observable, map } from 'rxjs';
3+
import { Configuration, Environment, GetConfig } from 'src/config/config';
44
import { LightningLogger } from 'src/shared/services/lightning-logger';
55
import { LndOnchainTransactionDto, LndTransactionDto } from '../dto/lnd.dto';
66
import { LightningWebSocketClient } from '../lightning-ws-client';
@@ -19,6 +19,15 @@ export class LightningWebSocketService {
1919

2020
constructor() {
2121
const config = GetConfig();
22+
23+
if (config.environment === Environment.LOC) {
24+
this.logger.info('Local environment detected, skipping WebSocket connections');
25+
this.onChainTransactions = EMPTY;
26+
this.invoiceTransactions = EMPTY;
27+
this.paymentTransactions = EMPTY;
28+
return;
29+
}
30+
2231
this.setupOnchainWebSocketClient(config);
2332
this.setupInvoiceWebSocketClient(config);
2433
this.setupPaymentWebSocketClient(config);

src/subdomains/alchemy/services/alchemy-webhook.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable, NotFoundException, OnModuleInit } from '@nestjs/common';
22
import { AddressActivityWebhook, Alchemy, Network, Webhook, WebhookType } from 'alchemy-sdk';
33
import { Observable, Subject, filter } from 'rxjs';
4-
import { Config, GetConfig } from 'src/config/config';
4+
import { Config, Environment, GetConfig } from 'src/config/config';
55
import { Blockchain } from 'src/shared/enums/blockchain.enum';
66
import { Util } from 'src/shared/utils/util';
77
import { AlchemyNetworkMapper } from '../alchemy-network-mapper';
@@ -31,6 +31,8 @@ export class AlchemyWebhookService implements OnModuleInit {
3131
}
3232

3333
async onModuleInit() {
34+
if (GetConfig().environment === Environment.LOC) return;
35+
3436
const allWebhooks = await this.getAllWebhooks();
3537
allWebhooks.forEach((w) => this.webhookCache.set(w.id, w.signingKey));
3638
}

src/subdomains/evm/payment/strategies/common/evm-payment.strategy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Inject, NotFoundException, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
2+
import { Environment, GetConfig } from 'src/config/config';
23
import { LightningLogger } from 'src/shared/services/lightning-logger';
34
import { QueueHandler } from 'src/shared/utils/queue-handler';
45
import { Util } from 'src/shared/utils/util';
@@ -27,6 +28,8 @@ export abstract class EvmPaymentStrategy extends RegisterStrategy implements OnM
2728

2829
this.addressWebhookMessageQueue = new QueueHandler();
2930

31+
if (GetConfig().environment === Environment.LOC) return;
32+
3033
const network = AlchemyNetworkMapper.toAlchemyNetworkByBlockchain(this.blockchain);
3134
if (!network) throw new Error(`Cannot detect network by blockchain ${this.blockchain}`);
3235

0 commit comments

Comments
 (0)