Merge Lightning backend into Mempool backend

This commit is contained in:
nymkappa
2022-07-06 11:58:06 +02:00
committed by softsimon
parent faafa6db3b
commit a238420d7f
47 changed files with 298 additions and 5424 deletions

View File

@@ -103,13 +103,13 @@ if (configContent && configContent.BASE_MODULE === 'bisq') {
PROXY_CONFIG.push(...[
{
context: ['/lightning/api/v1/**'],
target: `http://localhost:8899`,
context: ['/testnet/api/v1/lightning/**'],
target: `http://localhost:8999`,
secure: false,
changeOrigin: true,
proxyTimeout: 30000,
pathRewrite: {
"^/lightning/api": "/api"
"^/testnet": ""
},
},
{

View File

@@ -1,23 +1,33 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
const API_BASE_URL = '/lightning/api/v1';
import { StateService } from '../services/state.service';
@Injectable({
providedIn: 'root'
})
export class LightningApiService {
private apiBasePath = ''; // network path is /testnet, etc. or '' for mainnet
constructor(
private httpClient: HttpClient,
) { }
private stateService: StateService,
) {
this.apiBasePath = ''; // assume mainnet by default
this.stateService.networkChanged$.subscribe((network) => {
if (network === 'bisq' && !this.stateService.env.BISQ_SEPARATE_BACKEND) {
network = '';
}
this.apiBasePath = network ? '/' + network : '';
});
}
getNode$(publicKey: string): Observable<any> {
return this.httpClient.get<any>(API_BASE_URL + '/nodes/' + publicKey);
return this.httpClient.get<any>(this.apiBasePath + '/api/v1/lightning/nodes/' + publicKey);
}
getChannel$(shortId: string): Observable<any> {
return this.httpClient.get<any>(API_BASE_URL + '/channels/' + shortId);
return this.httpClient.get<any>(this.apiBasePath + '/api/v1/lightning/channels/' + shortId);
}
getChannelsByNodeId$(publicKey: string, index: number = 0, status = 'open'): Observable<any> {
@@ -27,22 +37,22 @@ export class LightningApiService {
.set('status', status)
;
return this.httpClient.get<any>(API_BASE_URL + '/channels', { params, observe: 'response' });
return this.httpClient.get<any>(this.apiBasePath + '/api/v1/lightning/channels', { params, observe: 'response' });
}
getLatestStatistics$(): Observable<any> {
return this.httpClient.get<any>(API_BASE_URL + '/statistics/latest');
return this.httpClient.get<any>(this.apiBasePath + '/api/v1/lightning/statistics/latest');
}
listNodeStats$(publicKey: string): Observable<any> {
return this.httpClient.get<any>(API_BASE_URL + '/nodes/' + publicKey + '/statistics');
return this.httpClient.get<any>(this.apiBasePath + '/api/v1/lightning/nodes/' + publicKey + '/statistics');
}
listTopNodes$(): Observable<any> {
return this.httpClient.get<any>(API_BASE_URL + '/nodes/top');
return this.httpClient.get<any>(this.apiBasePath + '/api/v1/lightning/nodes/top');
}
listStatistics$(): Observable<any> {
return this.httpClient.get<any>(API_BASE_URL + '/statistics');
return this.httpClient.get<any>(this.apiBasePath + '/api/v1/lightning/statistics');
}
}

View File

@@ -237,12 +237,12 @@ export class ApiService {
txIds.forEach((txId: string) => {
params = params.append('txId[]', txId);
});
return this.httpClient.get<{ inputs: any[], outputs: any[] }>(this.apiBaseUrl + this.apiBasePath + '/lightning/api/v1/channels/txids/', { params });
return this.httpClient.get<{ inputs: any[], outputs: any[] }>(this.apiBaseUrl + this.apiBasePath + '/api/v1/lightning/channels/txids/', { params });
}
lightningSearch$(searchText: string): Observable<any[]> {
let params = new HttpParams().set('searchText', searchText);
return this.httpClient.get<any[]>(this.apiBaseUrl + this.apiBasePath + '/lightning/api/v1/search', { params });
return this.httpClient.get<any[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/lightning/search', { params });
}
}