Skip to content

Commit d042ad3

Browse files
authored
Merge pull request #2889 from DFXswiss/develop
Release: develop -> master
2 parents 7ad9cd0 + e3eb43e commit d042ad3

37 files changed

Lines changed: 281 additions & 89 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
3+
* @typedef {import('typeorm').QueryRunner} QueryRunner
4+
*/
5+
6+
/**
7+
* @class
8+
* @implements {MigrationInterface}
9+
*/
10+
module.exports = class MaerkiRemoved1767952500437 {
11+
name = 'MaerkiRemoved1767952500437'
12+
13+
/**
14+
* @param {QueryRunner} queryRunner
15+
*/
16+
async up(queryRunner) {
17+
await queryRunner.query(`ALTER TABLE "country" DROP CONSTRAINT "DF_687dc858f7aff3f03ffbb214f2c"`);
18+
await queryRunner.query(`ALTER TABLE "country" DROP COLUMN "maerkiBaumannEnable"`);
19+
}
20+
21+
/**
22+
* @param {QueryRunner} queryRunner
23+
*/
24+
async down(queryRunner) {
25+
await queryRunner.query(`ALTER TABLE "country" ADD "maerkiBaumannEnable" bit NOT NULL`);
26+
await queryRunner.query(`ALTER TABLE "country" ADD CONSTRAINT "DF_687dc858f7aff3f03ffbb214f2c" DEFAULT 0 FOR "maerkiBaumannEnable"`);
27+
}
28+
}

src/config/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ export class Configuration {
5656
priceSourceManual = 'DFX'; // source name for priceStep if price is set manually in buy-crypto
5757
priceSourcePayment = 'Payment'; // source name for priceStep if price is defined by payment quote
5858

59+
isDomesticIban(iban: string): boolean {
60+
return ['CH', 'LI'].includes(iban?.substring(0, 2));
61+
}
62+
5963
defaults = {
6064
currency: 'EUR',
6165
language: 'EN',

src/integration/exchange/services/binance.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class BinanceService extends ExchangeService {
1313
Arbitrum: 'ARBITRUM',
1414
BinanceSmartChain: 'BSC',
1515
Bitcoin: 'BTC',
16-
Lightning: undefined,
16+
Lightning: 'LIGHTNING',
1717
Spark: undefined,
1818
Monero: 'XMR',
1919
Zano: undefined,

src/integration/lightning/dto/lnbits.dto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export interface LnBitsWalletPaymentParamsDto {
1515
amount: number;
1616
memo: string;
1717
expirySec: number;
18-
webhook: string;
19-
extra: {
18+
webhook?: string;
19+
extra?: {
2020
link: string;
2121
signature: string;
2222
};

src/integration/lightning/dto/lnd.dto.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@ export enum LndPaymentStatus {
2727
FAILED = 'FAILED',
2828
}
2929

30+
export enum LndInvoiceState {
31+
OPEN = 'OPEN',
32+
SETTLED = 'SETTLED',
33+
CANCELED = 'CANCELED',
34+
ACCEPTED = 'ACCEPTED',
35+
}
36+
37+
export interface LndInvoiceDto {
38+
memo: string;
39+
r_hash: string;
40+
payment_request: string;
41+
value_sat: string;
42+
state: LndInvoiceState;
43+
settled: boolean;
44+
settle_date: string;
45+
amt_paid_sat: string;
46+
}
47+
3048
export interface LndPaymentDto {
3149
payment_hash: string;
3250
value_sat: number;

src/integration/lightning/lightning-client.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
LndChannelBalanceDto,
99
LndChannelDto,
1010
LndInfoDto,
11+
LndInvoiceDto,
1112
LndPaymentDto,
1213
LndRouteDto,
1314
LndSendPaymentResponseDto,
@@ -115,6 +116,13 @@ export class LightningClient {
115116
.then((p) => p.payments);
116117
}
117118

119+
async lookupInvoice(paymentHashHex: string): Promise<LndInvoiceDto> {
120+
return this.http.get<LndInvoiceDto>(
121+
`${Config.blockchain.lightning.lnd.apiUrl}/invoice/${paymentHashHex}`,
122+
this.httpLndConfig(),
123+
);
124+
}
125+
118126
async sendPaymentByInvoice(invoice: string): Promise<LndSendPaymentResponseDto> {
119127
return this.http.post<LndSendPaymentResponseDto>(
120128
`${Config.blockchain.lightning.lnd.apiUrl}/channels/transactions`,

src/shared/models/country/__mocks__/country.entity.mock.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const defaultCountry: Partial<Country> = {
77
dfxEnable: true,
88
lockEnable: true,
99
ipEnable: true,
10-
maerkiBaumannEnable: true,
1110
yapealEnable: true,
1211
updated: undefined,
1312
created: undefined,

src/shared/models/country/country.entity.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ export class Country extends IEntity {
3030
@Column({ default: true })
3131
ipEnable: boolean;
3232

33-
@Column({ default: false })
34-
maerkiBaumannEnable: boolean;
35-
3633
@Column({ default: false })
3734
yapealEnable: boolean;
3835

src/shared/services/payment-info.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class PaymentInfoService {
9090
if (!dto.currency) throw new NotFoundException('Currency not found');
9191
if (!dto.currency.buyable) throw new BadRequestException('Currency not buyable');
9292

93-
if ('iban' in dto && dto.currency?.name === 'CHF' && !dto.iban.startsWith('CH') && !dto.iban.startsWith('LI'))
93+
if ('iban' in dto && dto.currency?.name === 'CHF' && !Config.isDomesticIban(dto.iban))
9494
throw new BadRequestException(
9595
'CHF transactions are only permitted to Liechtenstein or Switzerland. Use EUR for other countries.',
9696
);

src/shared/utils/test.util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DeepPartial } from 'typeorm';
44

55
export class TestUtil {
66
static provideConfig(config: DeepPartial<Configuration> = {}): Provider {
7-
const conf = { ...new Configuration(), ...config } as Configuration;
7+
const conf = Object.assign(new Configuration(), config);
88
return { provide: ConfigService, useValue: new ConfigService(conf) };
99
}
1010
}

0 commit comments

Comments
 (0)