2020-11-22 23:47:27 +07:00
|
|
|
import { Injectable } from '@angular/core';
|
2023-02-16 15:39:09 +01:00
|
|
|
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
|
2022-06-14 16:39:37 +00:00
|
|
|
import { CpfpInfo, OptimizedMempoolStats, AddressInformation, LiquidPegs, ITranslators,
|
2024-01-21 13:19:02 +01:00
|
|
|
PoolStat, BlockExtended, TransactionStripped, RewardStats, AuditScore, BlockSizesAndWeights, RbfTree, BlockAudit, Acceleration, AccelerationHistoryParams, CurrentPegs, AuditStatus, FederationAddress, FederationUtxo } from '../interfaces/node-api.interface';
|
2023-11-11 07:16:59 +00:00
|
|
|
import { BehaviorSubject, Observable, catchError, filter, of, shareReplay, take, tap } from 'rxjs';
|
2020-05-09 20:37:50 +07:00
|
|
|
import { StateService } from './state.service';
|
2023-08-20 22:53:33 +02:00
|
|
|
import { IBackendInfo, WebsocketResponse } from '../interfaces/websocket.interface';
|
2022-12-09 10:32:58 -06:00
|
|
|
import { Outspend, Transaction } from '../interfaces/electrs.interface';
|
2023-02-21 12:36:43 +09:00
|
|
|
import { Conversion } from './price.service';
|
2023-08-17 18:51:39 +02:00
|
|
|
import { MenuGroup } from '../interfaces/services.interface';
|
2023-08-20 08:11:55 +02:00
|
|
|
import { StorageService } from './storage.service';
|
2019-07-21 17:59:47 +03:00
|
|
|
|
2023-08-17 18:59:27 +02:00
|
|
|
// Todo - move to config.json
|
2023-04-01 11:40:04 +09:00
|
|
|
const SERVICES_API_PREFIX = `/api/v1/services`;
|
|
|
|
|
2019-07-21 17:59:47 +03:00
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class ApiService {
|
2020-11-27 23:01:47 +09:00
|
|
|
private apiBaseUrl: string; // base URL is protocol, hostname, and port
|
|
|
|
private apiBasePath: string; // network path is /testnet, etc. or '' for mainnet
|
2020-05-09 20:37:50 +07:00
|
|
|
|
2023-11-11 07:16:59 +00:00
|
|
|
private requestCache = new Map<string, { subject: BehaviorSubject<any>, expiry: number }>;
|
|
|
|
|
2019-07-21 17:59:47 +03:00
|
|
|
constructor(
|
|
|
|
private httpClient: HttpClient,
|
2020-05-09 20:37:50 +07:00
|
|
|
private stateService: StateService,
|
2023-08-20 08:11:55 +02:00
|
|
|
private storageService: StorageService
|
2020-05-09 20:37:50 +07:00
|
|
|
) {
|
2020-11-27 23:01:47 +09:00
|
|
|
this.apiBaseUrl = ''; // use relative URL by default
|
|
|
|
if (!stateService.isBrowser) { // except when inside AU SSR process
|
|
|
|
this.apiBaseUrl = this.stateService.env.NGINX_PROTOCOL + '://' + this.stateService.env.NGINX_HOSTNAME + ':' + this.stateService.env.NGINX_PORT;
|
|
|
|
}
|
|
|
|
this.apiBasePath = ''; // assume mainnet by default
|
2020-05-09 20:37:50 +07:00
|
|
|
this.stateService.networkChanged$.subscribe((network) => {
|
2020-11-23 02:30:46 +07:00
|
|
|
if (network === 'bisq' && !this.stateService.env.BISQ_SEPARATE_BACKEND) {
|
2020-07-03 23:45:19 +07:00
|
|
|
network = '';
|
|
|
|
}
|
2020-11-27 23:01:47 +09:00
|
|
|
this.apiBasePath = network ? '/' + network : '';
|
2020-05-09 20:37:50 +07:00
|
|
|
});
|
2023-08-20 22:53:33 +02:00
|
|
|
|
2023-08-21 08:57:27 +02:00
|
|
|
if (this.stateService.env.GIT_COMMIT_HASH_MEMPOOL_SPACE) {
|
|
|
|
this.getServicesBackendInfo$().subscribe(version => {
|
|
|
|
this.stateService.servicesBackendInfo$.next(version);
|
|
|
|
})
|
|
|
|
}
|
2020-05-09 20:37:50 +07:00
|
|
|
}
|
2019-11-06 15:35:02 +08:00
|
|
|
|
2023-11-11 07:16:59 +00:00
|
|
|
private generateCacheKey(functionName: string, params: any[]): string {
|
|
|
|
return functionName + JSON.stringify(params);
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete expired cache entries
|
|
|
|
private cleanExpiredCache(): void {
|
|
|
|
this.requestCache.forEach((value, key) => {
|
|
|
|
if (value.expiry < Date.now()) {
|
|
|
|
this.requestCache.delete(key);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
cachedRequest<T, F extends (...args: any[]) => Observable<T>>(
|
|
|
|
apiFunction: F,
|
|
|
|
expireAfter: number, // in ms
|
|
|
|
...params: Parameters<F>
|
|
|
|
): Observable<T> {
|
|
|
|
this.cleanExpiredCache();
|
|
|
|
|
|
|
|
const cacheKey = this.generateCacheKey(apiFunction.name, params);
|
|
|
|
if (!this.requestCache.has(cacheKey)) {
|
|
|
|
const subject = new BehaviorSubject<T | null>(null);
|
|
|
|
this.requestCache.set(cacheKey, { subject, expiry: Date.now() + expireAfter });
|
|
|
|
|
|
|
|
apiFunction.bind(this)(...params).pipe(
|
|
|
|
tap(data => {
|
|
|
|
subject.next(data as T);
|
|
|
|
}),
|
|
|
|
catchError((error) => {
|
|
|
|
subject.error(error);
|
|
|
|
return of(null);
|
|
|
|
}),
|
|
|
|
shareReplay(1),
|
|
|
|
).subscribe();
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.requestCache.get(cacheKey).subject.asObservable().pipe(filter(val => val !== null), take(1));
|
|
|
|
}
|
|
|
|
|
2020-02-17 00:26:57 +07:00
|
|
|
list2HStatistics$(): Observable<OptimizedMempoolStats[]> {
|
2020-11-27 23:01:47 +09:00
|
|
|
return this.httpClient.get<OptimizedMempoolStats[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/statistics/2h');
|
2019-11-12 16:39:59 +08:00
|
|
|
}
|
|
|
|
|
2020-02-17 00:26:57 +07:00
|
|
|
list24HStatistics$(): Observable<OptimizedMempoolStats[]> {
|
2020-11-27 23:01:47 +09:00
|
|
|
return this.httpClient.get<OptimizedMempoolStats[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/statistics/24h');
|
2019-11-12 16:39:59 +08:00
|
|
|
}
|
|
|
|
|
2020-02-17 00:26:57 +07:00
|
|
|
list1WStatistics$(): Observable<OptimizedMempoolStats[]> {
|
2020-11-27 23:01:47 +09:00
|
|
|
return this.httpClient.get<OptimizedMempoolStats[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/statistics/1w');
|
2019-11-10 16:44:00 +08:00
|
|
|
}
|
2019-11-13 14:51:44 +08:00
|
|
|
|
2020-02-17 00:26:57 +07:00
|
|
|
list1MStatistics$(): Observable<OptimizedMempoolStats[]> {
|
2020-11-27 23:01:47 +09:00
|
|
|
return this.httpClient.get<OptimizedMempoolStats[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/statistics/1m');
|
2019-11-13 14:51:44 +08:00
|
|
|
}
|
|
|
|
|
2020-02-17 00:26:57 +07:00
|
|
|
list3MStatistics$(): Observable<OptimizedMempoolStats[]> {
|
2020-11-27 23:01:47 +09:00
|
|
|
return this.httpClient.get<OptimizedMempoolStats[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/statistics/3m');
|
2019-11-13 14:51:44 +08:00
|
|
|
}
|
|
|
|
|
2020-02-17 00:26:57 +07:00
|
|
|
list6MStatistics$(): Observable<OptimizedMempoolStats[]> {
|
2020-11-27 23:01:47 +09:00
|
|
|
return this.httpClient.get<OptimizedMempoolStats[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/statistics/6m');
|
2020-02-17 00:26:57 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
list1YStatistics$(): Observable<OptimizedMempoolStats[]> {
|
2020-11-27 23:01:47 +09:00
|
|
|
return this.httpClient.get<OptimizedMempoolStats[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/statistics/1y');
|
2019-11-13 14:51:44 +08:00
|
|
|
}
|
2020-02-28 01:09:07 +07:00
|
|
|
|
2021-11-01 22:06:10 -03:00
|
|
|
list2YStatistics$(): Observable<OptimizedMempoolStats[]> {
|
|
|
|
return this.httpClient.get<OptimizedMempoolStats[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/statistics/2y');
|
|
|
|
}
|
|
|
|
|
|
|
|
list3YStatistics$(): Observable<OptimizedMempoolStats[]> {
|
|
|
|
return this.httpClient.get<OptimizedMempoolStats[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/statistics/3y');
|
|
|
|
}
|
|
|
|
|
2023-03-04 18:48:16 +09:00
|
|
|
list4YStatistics$(): Observable<OptimizedMempoolStats[]> {
|
|
|
|
return this.httpClient.get<OptimizedMempoolStats[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/statistics/4y');
|
|
|
|
}
|
|
|
|
|
2023-06-19 12:46:10 -04:00
|
|
|
listAllTimeStatistics$(): Observable<OptimizedMempoolStats[]> {
|
|
|
|
return this.httpClient.get<OptimizedMempoolStats[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/statistics/all');
|
|
|
|
}
|
|
|
|
|
2020-02-28 01:09:07 +07:00
|
|
|
getTransactionTimes$(txIds: string[]): Observable<number[]> {
|
|
|
|
let params = new HttpParams();
|
|
|
|
txIds.forEach((txId: string) => {
|
|
|
|
params = params.append('txId[]', txId);
|
|
|
|
});
|
2020-11-27 23:01:47 +09:00
|
|
|
return this.httpClient.get<number[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/transaction-times', { params });
|
2020-02-28 01:09:07 +07:00
|
|
|
}
|
2020-10-07 20:15:42 +07:00
|
|
|
|
2023-02-17 18:54:48 +09:00
|
|
|
getAboutPageProfiles$(): Observable<any[]> {
|
2023-08-21 15:27:55 +02:00
|
|
|
return this.httpClient.get<any[]>(this.apiBaseUrl + '/api/v1/services/sponsors');
|
2020-10-07 20:15:42 +07:00
|
|
|
}
|
|
|
|
|
2023-02-17 18:54:48 +09:00
|
|
|
getOgs$(): Observable<any> {
|
2022-05-19 01:54:08 +09:00
|
|
|
return this.httpClient.get<any[]>(this.apiBaseUrl + '/api/v1/donations');
|
2020-10-07 20:15:42 +07:00
|
|
|
}
|
2020-11-07 04:30:52 +07:00
|
|
|
|
2022-01-13 03:58:12 +04:00
|
|
|
getTranslators$(): Observable<ITranslators> {
|
2022-05-19 01:54:08 +09:00
|
|
|
return this.httpClient.get<ITranslators>(this.apiBaseUrl + '/api/v1/translators');
|
2022-01-13 03:58:12 +04:00
|
|
|
}
|
|
|
|
|
2021-03-09 03:56:41 +09:00
|
|
|
getContributor$(): Observable<any[]> {
|
2022-05-19 01:54:08 +09:00
|
|
|
return this.httpClient.get<any[]>(this.apiBaseUrl + '/api/v1/contributors');
|
2021-03-09 03:56:41 +09:00
|
|
|
}
|
|
|
|
|
2020-11-07 04:30:52 +07:00
|
|
|
getInitData$(): Observable<WebsocketResponse> {
|
2020-11-27 23:01:47 +09:00
|
|
|
return this.httpClient.get<WebsocketResponse>(this.apiBaseUrl + this.apiBasePath + '/api/v1/init-data');
|
2020-11-07 04:30:52 +07:00
|
|
|
}
|
2021-03-18 23:47:40 +07:00
|
|
|
|
|
|
|
getCpfpinfo$(txid: string): Observable<CpfpInfo> {
|
|
|
|
return this.httpClient.get<CpfpInfo>(this.apiBaseUrl + this.apiBasePath + '/api/v1/cpfp/' + txid);
|
|
|
|
}
|
2021-07-24 19:26:48 -03:00
|
|
|
|
2021-09-06 10:20:31 +04:00
|
|
|
validateAddress$(address: string): Observable<AddressInformation> {
|
|
|
|
return this.httpClient.get<AddressInformation>(this.apiBaseUrl + this.apiBasePath + '/api/v1/validate-address/' + address);
|
|
|
|
}
|
2021-09-25 03:13:07 +04:00
|
|
|
|
2022-12-17 09:39:06 -06:00
|
|
|
getRbfHistory$(txid: string): Observable<{ replacements: RbfTree, replaces: string[] }> {
|
|
|
|
return this.httpClient.get<{ replacements: RbfTree, replaces: string[] }>(this.apiBaseUrl + this.apiBasePath + '/api/v1/tx/' + txid + '/rbf');
|
2022-12-09 10:32:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
getRbfCachedTx$(txid: string): Observable<Transaction> {
|
|
|
|
return this.httpClient.get<Transaction>(this.apiBaseUrl + this.apiBasePath + '/api/v1/tx/' + txid + '/cached');
|
|
|
|
}
|
|
|
|
|
2022-12-17 09:39:06 -06:00
|
|
|
getRbfList$(fullRbf: boolean, after?: string): Observable<RbfTree[]> {
|
|
|
|
return this.httpClient.get<RbfTree[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/' + (fullRbf ? 'fullrbf/' : '') + 'replacements/' + (after || ''));
|
2022-12-14 16:51:53 -06:00
|
|
|
}
|
|
|
|
|
2024-01-21 13:19:02 +01:00
|
|
|
liquidPegs$(): Observable<CurrentPegs> {
|
|
|
|
return this.httpClient.get<CurrentPegs>(this.apiBaseUrl + this.apiBasePath + '/api/v1/liquid/pegs');
|
|
|
|
}
|
|
|
|
|
2021-09-25 03:13:07 +04:00
|
|
|
listLiquidPegsMonth$(): Observable<LiquidPegs[]> {
|
|
|
|
return this.httpClient.get<LiquidPegs[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/liquid/pegs/month');
|
|
|
|
}
|
2021-10-19 15:37:45 +04:00
|
|
|
|
2024-01-21 13:19:02 +01:00
|
|
|
liquidReserves$(): Observable<CurrentPegs> {
|
|
|
|
return this.httpClient.get<CurrentPegs>(this.apiBaseUrl + this.apiBasePath + '/api/v1/liquid/reserves');
|
|
|
|
}
|
|
|
|
|
|
|
|
listLiquidReservesMonth$(): Observable<LiquidPegs[]> {
|
|
|
|
return this.httpClient.get<LiquidPegs[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/liquid/reserves/month');
|
|
|
|
}
|
|
|
|
|
|
|
|
federationAuditSynced$(): Observable<AuditStatus> {
|
|
|
|
return this.httpClient.get<AuditStatus>(this.apiBaseUrl + this.apiBasePath + '/api/v1/liquid/reserves/status');
|
|
|
|
}
|
|
|
|
|
|
|
|
federationAddresses$(): Observable<FederationAddress[]> {
|
|
|
|
return this.httpClient.get<FederationAddress[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/liquid/reserves/addresses');
|
|
|
|
}
|
|
|
|
|
|
|
|
federationUtxos$(): Observable<FederationUtxo[]> {
|
|
|
|
return this.httpClient.get<FederationUtxo[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/liquid/reserves/utxos');
|
|
|
|
}
|
|
|
|
|
2024-01-23 09:57:26 +01:00
|
|
|
federationAddressesOneMonthAgo$(): Observable<any> {
|
2024-01-21 13:19:02 +01:00
|
|
|
return this.httpClient.get<FederationAddress[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/liquid/reserves/addresses/previous-month');
|
|
|
|
}
|
|
|
|
|
2024-01-23 09:57:26 +01:00
|
|
|
federationUtxosOneMonthAgo$(): Observable<any> {
|
2024-01-21 13:19:02 +01:00
|
|
|
return this.httpClient.get<FederationUtxo[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/liquid/reserves/utxos/previous-month');
|
|
|
|
}
|
|
|
|
|
2022-02-06 01:20:26 +04:00
|
|
|
listFeaturedAssets$(): Observable<any[]> {
|
2022-02-06 20:03:06 +04:00
|
|
|
return this.httpClient.get<any[]>(this.apiBaseUrl + '/api/v1/assets/featured');
|
2022-02-06 01:20:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
getAssetGroup$(id: string): Observable<any> {
|
2022-02-06 20:03:06 +04:00
|
|
|
return this.httpClient.get<any[]>(this.apiBaseUrl + '/api/v1/assets/group/' + id);
|
2022-02-06 01:20:26 +04:00
|
|
|
}
|
|
|
|
|
2021-10-19 15:37:45 +04:00
|
|
|
postTransaction$(hexPayload: string): Observable<any> {
|
|
|
|
return this.httpClient.post<any>(this.apiBaseUrl + this.apiBasePath + '/api/tx', hexPayload, { responseType: 'text' as 'json'});
|
|
|
|
}
|
2022-01-06 19:59:33 +09:00
|
|
|
|
2022-04-15 20:43:10 +09:00
|
|
|
listPools$(interval: string | undefined) : Observable<any> {
|
|
|
|
return this.httpClient.get<any>(
|
2022-02-16 21:20:28 +09:00
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/pools` +
|
2022-04-15 20:43:10 +09:00
|
|
|
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
2022-02-16 21:20:28 +09:00
|
|
|
);
|
2022-06-25 12:14:32 +02:00
|
|
|
}
|
2022-02-09 19:41:05 +09:00
|
|
|
|
2022-03-25 14:22:22 +09:00
|
|
|
getPoolStats$(slug: string): Observable<PoolStat> {
|
|
|
|
return this.httpClient.get<PoolStat>(this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/pool/${slug}`);
|
2022-02-09 19:41:05 +09:00
|
|
|
}
|
|
|
|
|
2022-03-25 14:22:22 +09:00
|
|
|
getPoolHashrate$(slug: string): Observable<any> {
|
|
|
|
return this.httpClient.get<any>(this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/pool/${slug}/hashrate`);
|
2022-03-08 12:50:47 +01:00
|
|
|
}
|
|
|
|
|
2022-03-25 14:22:22 +09:00
|
|
|
getPoolBlocks$(slug: string, fromHeight: number): Observable<BlockExtended[]> {
|
2022-02-15 18:36:58 +09:00
|
|
|
return this.httpClient.get<BlockExtended[]>(
|
2022-03-25 14:22:22 +09:00
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/pool/${slug}/blocks` +
|
2022-02-15 18:36:58 +09:00
|
|
|
(fromHeight !== undefined ? `/${fromHeight}` : '')
|
|
|
|
);
|
2022-02-09 19:41:05 +09:00
|
|
|
}
|
2022-02-16 21:20:28 +09:00
|
|
|
|
2022-03-10 18:35:37 +01:00
|
|
|
getBlocks$(from: number): Observable<BlockExtended[]> {
|
|
|
|
return this.httpClient.get<BlockExtended[]>(
|
2022-05-20 18:11:02 +02:00
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/blocks` +
|
2022-03-10 18:35:37 +01:00
|
|
|
(from !== undefined ? `/${from}` : ``)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-04-27 17:43:32 +09:00
|
|
|
getBlock$(hash: string): Observable<BlockExtended> {
|
|
|
|
return this.httpClient.get<BlockExtended>(this.apiBaseUrl + this.apiBasePath + '/api/v1/block/' + hash);
|
|
|
|
}
|
|
|
|
|
2023-11-30 19:04:14 +01:00
|
|
|
getBlockDataFromTimestamp$(timestamp: number): Observable<any> {
|
|
|
|
return this.httpClient.get<number>(this.apiBaseUrl + this.apiBasePath + '/api/v1/mining/blocks/timestamp/' + timestamp);
|
|
|
|
}
|
|
|
|
|
2022-06-14 16:39:37 +00:00
|
|
|
getStrippedBlockTransactions$(hash: string): Observable<TransactionStripped[]> {
|
|
|
|
return this.httpClient.get<TransactionStripped[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/block/' + hash + '/summary');
|
|
|
|
}
|
|
|
|
|
2022-06-25 12:14:32 +02:00
|
|
|
getDifficultyAdjustments$(interval: string | undefined): Observable<any> {
|
|
|
|
return this.httpClient.get<any[]>(
|
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/difficulty-adjustments` +
|
|
|
|
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-02-19 22:09:35 +09:00
|
|
|
getHistoricalHashrate$(interval: string | undefined): Observable<any> {
|
|
|
|
return this.httpClient.get<any[]>(
|
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/hashrate` +
|
2022-04-15 20:43:10 +09:00
|
|
|
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
2022-02-19 22:09:35 +09:00
|
|
|
);
|
|
|
|
}
|
2022-02-24 16:55:18 +09:00
|
|
|
|
|
|
|
getHistoricalPoolsHashrate$(interval: string | undefined): Observable<any> {
|
|
|
|
return this.httpClient.get<any[]>(
|
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/hashrate/pools` +
|
2022-04-15 20:43:10 +09:00
|
|
|
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
2022-02-24 16:55:18 +09:00
|
|
|
);
|
|
|
|
}
|
2022-03-22 12:34:29 +09:00
|
|
|
|
2022-04-09 01:07:13 +09:00
|
|
|
getHistoricalBlockFees$(interval: string | undefined) : Observable<any> {
|
|
|
|
return this.httpClient.get<any[]>(
|
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/blocks/fees` +
|
2022-04-15 20:43:10 +09:00
|
|
|
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
2022-04-09 01:07:13 +09:00
|
|
|
);
|
2022-04-11 20:57:13 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
getHistoricalBlockRewards$(interval: string | undefined) : Observable<any> {
|
|
|
|
return this.httpClient.get<any[]>(
|
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/blocks/rewards` +
|
2022-04-15 20:43:10 +09:00
|
|
|
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
2022-04-11 20:57:13 +09:00
|
|
|
);
|
|
|
|
}
|
2022-04-09 01:07:13 +09:00
|
|
|
|
2022-04-15 00:21:38 +09:00
|
|
|
getHistoricalBlockFeeRates$(interval: string | undefined) : Observable<any> {
|
|
|
|
return this.httpClient.get<any[]>(
|
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/blocks/fee-rates` +
|
2022-05-20 10:07:57 +02:00
|
|
|
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
2022-04-15 00:21:38 +09:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-02-16 15:39:09 +01:00
|
|
|
getHistoricalBlockSizesAndWeights$(interval: string | undefined) : Observable<HttpResponse<BlockSizesAndWeights>> {
|
|
|
|
return this.httpClient.get<BlockSizesAndWeights>(
|
2022-05-10 16:40:56 +02:00
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/blocks/sizes-weights` +
|
|
|
|
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-03-16 17:03:32 +09:00
|
|
|
getHistoricalBlocksHealth$(interval: string | undefined) : Observable<any> {
|
2022-07-06 22:27:45 +02:00
|
|
|
return this.httpClient.get<any[]>(
|
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/blocks/predictions` +
|
|
|
|
(interval !== undefined ? `/${interval}` : ''), { observe: 'response' }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-06-20 14:54:25 -04:00
|
|
|
getBlockAudit$(hash: string) : Observable<BlockAudit> {
|
|
|
|
return this.httpClient.get<BlockAudit>(
|
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/block/${hash}/audit-summary`
|
2022-07-07 19:11:42 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-11-01 14:01:50 -06:00
|
|
|
getBlockAuditScores$(from: number): Observable<AuditScore[]> {
|
|
|
|
return this.httpClient.get<AuditScore[]>(
|
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/blocks/audit/scores` +
|
|
|
|
(from !== undefined ? `/${from}` : ``)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
getBlockAuditScore$(hash: string) : Observable<any> {
|
|
|
|
return this.httpClient.get<any>(
|
|
|
|
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/blocks/audit/score/` + hash
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-03-22 12:34:29 +09:00
|
|
|
getRewardStats$(blockCount: number = 144): Observable<RewardStats> {
|
|
|
|
return this.httpClient.get<RewardStats>(this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/reward-stats/${blockCount}`);
|
|
|
|
}
|
2022-05-07 11:32:15 +04:00
|
|
|
|
2022-07-21 19:58:12 +02:00
|
|
|
getEnterpriseInfo$(name: string): Observable<any> {
|
2023-11-20 19:12:56 +09:00
|
|
|
return this.httpClient.get<any>(this.apiBaseUrl + this.apiBasePath + `/api/v1/services/enterprise/info/` + name);
|
2022-07-21 19:58:12 +02:00
|
|
|
}
|
|
|
|
|
2022-08-27 16:00:58 +02:00
|
|
|
getChannelByTxIds$(txIds: string[]): Observable<any[]> {
|
2022-05-07 11:32:15 +04:00
|
|
|
let params = new HttpParams();
|
|
|
|
txIds.forEach((txId: string) => {
|
|
|
|
params = params.append('txId[]', txId);
|
|
|
|
});
|
2022-08-27 16:00:58 +02:00
|
|
|
return this.httpClient.get<any[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/lightning/channels/txids/', { params });
|
2022-05-07 11:32:15 +04:00
|
|
|
}
|
|
|
|
|
2022-05-09 18:21:42 +04:00
|
|
|
lightningSearch$(searchText: string): Observable<any[]> {
|
|
|
|
let params = new HttpParams().set('searchText', searchText);
|
2022-07-06 11:58:06 +02:00
|
|
|
return this.httpClient.get<any[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/lightning/search', { params });
|
2022-05-09 18:21:42 +04:00
|
|
|
}
|
|
|
|
|
2022-08-16 18:47:45 +02:00
|
|
|
getNodesPerIsp(): Observable<any> {
|
|
|
|
return this.httpClient.get<any[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/lightning/nodes/isp-ranking');
|
2022-07-16 10:44:05 +02:00
|
|
|
}
|
2022-07-16 15:56:36 +02:00
|
|
|
|
|
|
|
getNodeForCountry$(country: string): Observable<any> {
|
|
|
|
return this.httpClient.get<any[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/lightning/nodes/country/' + country);
|
|
|
|
}
|
2022-07-17 22:57:29 +02:00
|
|
|
|
|
|
|
getNodeForISP$(isp: string): Observable<any> {
|
|
|
|
return this.httpClient.get<any[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/lightning/nodes/isp/' + isp);
|
|
|
|
}
|
2022-07-17 11:10:17 +02:00
|
|
|
|
2022-09-06 19:33:07 +02:00
|
|
|
getNodesPerCountry$(): Observable<any> {
|
2022-07-17 11:10:17 +02:00
|
|
|
return this.httpClient.get<any[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/lightning/nodes/countries');
|
|
|
|
}
|
2022-07-21 22:43:12 +02:00
|
|
|
|
2022-09-06 19:33:07 +02:00
|
|
|
getWorldNodes$(): Observable<any> {
|
|
|
|
return this.httpClient.get<any[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/lightning/nodes/world');
|
|
|
|
}
|
|
|
|
|
2022-08-22 17:55:19 +02:00
|
|
|
getChannelsGeo$(publicKey?: string, style?: 'graph' | 'nodepage' | 'widget' | 'channelpage'): Observable<any> {
|
2022-07-23 15:43:38 +02:00
|
|
|
return this.httpClient.get<any[]>(
|
|
|
|
this.apiBaseUrl + this.apiBasePath + '/api/v1/lightning/channels-geo' +
|
2022-08-22 17:55:19 +02:00
|
|
|
(publicKey !== undefined ? `/${publicKey}` : '') +
|
|
|
|
(style !== undefined ? `?style=${style}` : '')
|
2022-07-23 15:43:38 +02:00
|
|
|
);
|
2022-07-21 22:43:12 +02:00
|
|
|
}
|
2023-02-21 12:36:43 +09:00
|
|
|
|
2023-02-23 13:13:20 +09:00
|
|
|
getHistoricalPrice$(timestamp: number | undefined): Observable<Conversion> {
|
2023-08-06 15:41:57 +09:00
|
|
|
if (this.stateService.isAnyTestnet()) {
|
|
|
|
return of({
|
|
|
|
prices: [],
|
|
|
|
exchangeRates: {
|
|
|
|
USDEUR: 0,
|
|
|
|
USDGBP: 0,
|
|
|
|
USDCAD: 0,
|
|
|
|
USDCHF: 0,
|
|
|
|
USDAUD: 0,
|
|
|
|
USDJPY: 0,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-02-23 13:13:20 +09:00
|
|
|
return this.httpClient.get<Conversion>(
|
|
|
|
this.apiBaseUrl + this.apiBasePath + '/api/v1/historical-price' +
|
|
|
|
(timestamp ? `?timestamp=${timestamp}` : '')
|
|
|
|
);
|
2023-02-21 12:36:43 +09:00
|
|
|
}
|
2023-04-01 11:40:04 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Services
|
|
|
|
*/
|
2023-08-20 08:11:55 +02:00
|
|
|
|
2023-08-17 18:51:39 +02:00
|
|
|
getNodeOwner$(publicKey: string): Observable<any> {
|
2023-04-01 11:40:04 +09:00
|
|
|
let params = new HttpParams()
|
|
|
|
.set('node_public_key', publicKey);
|
|
|
|
return this.httpClient.get<any>(`${SERVICES_API_PREFIX}/lightning/claim/current`, { params, observe: 'response' });
|
|
|
|
}
|
2023-08-17 18:51:39 +02:00
|
|
|
|
|
|
|
getUserMenuGroups$(): Observable<MenuGroup[]> {
|
2023-08-20 08:11:55 +02:00
|
|
|
const auth = this.storageService.getAuth();
|
2023-08-17 18:51:39 +02:00
|
|
|
if (!auth) {
|
|
|
|
return of(null);
|
|
|
|
}
|
|
|
|
|
2023-08-26 15:07:05 +02:00
|
|
|
return this.httpClient.get<MenuGroup[]>(`${SERVICES_API_PREFIX}/account/menu`);
|
2023-08-17 18:51:39 +02:00
|
|
|
}
|
2023-08-18 17:56:07 +02:00
|
|
|
|
2023-08-21 17:04:17 +02:00
|
|
|
getUserInfo$(): Observable<any> {
|
|
|
|
const auth = this.storageService.getAuth();
|
|
|
|
if (!auth) {
|
|
|
|
return of(null);
|
|
|
|
}
|
|
|
|
|
2023-08-26 15:07:05 +02:00
|
|
|
return this.httpClient.get<any>(`${SERVICES_API_PREFIX}/account`);
|
2023-08-21 17:04:17 +02:00
|
|
|
}
|
|
|
|
|
2023-08-20 08:11:55 +02:00
|
|
|
logout$(): Observable<any> {
|
|
|
|
const auth = this.storageService.getAuth();
|
2023-08-18 17:56:07 +02:00
|
|
|
if (!auth) {
|
2023-08-20 08:11:55 +02:00
|
|
|
return of(null);
|
2023-08-18 17:56:07 +02:00
|
|
|
}
|
|
|
|
|
2023-08-21 15:01:31 +02:00
|
|
|
localStorage.removeItem('auth');
|
2023-08-26 15:07:05 +02:00
|
|
|
return this.httpClient.post(`${SERVICES_API_PREFIX}/auth/logout`, {});
|
2023-08-18 17:56:07 +02:00
|
|
|
}
|
2023-08-20 22:53:33 +02:00
|
|
|
|
|
|
|
getServicesBackendInfo$(): Observable<IBackendInfo> {
|
|
|
|
return this.httpClient.get<IBackendInfo>(`${SERVICES_API_PREFIX}/version`);
|
|
|
|
}
|
2023-08-24 14:17:31 +02:00
|
|
|
|
|
|
|
estimate$(txInput: string) {
|
|
|
|
return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/accelerator/estimate`, { txInput: txInput }, { observe: 'response' });
|
|
|
|
}
|
2023-08-26 09:52:55 +02:00
|
|
|
|
|
|
|
accelerate$(txInput: string, userBid: number) {
|
|
|
|
return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/accelerator/accelerate`, { txInput: txInput, userBid: userBid });
|
|
|
|
}
|
2023-12-05 13:40:17 +00:00
|
|
|
|
|
|
|
getAccelerations$(): Observable<Acceleration[]> {
|
|
|
|
return this.httpClient.get<Acceleration[]>(`${SERVICES_API_PREFIX}/accelerator/accelerations`);
|
|
|
|
}
|
|
|
|
|
|
|
|
getAccelerationHistory$(params: AccelerationHistoryParams): Observable<Acceleration[]> {
|
|
|
|
return this.httpClient.get<Acceleration[]>(`${SERVICES_API_PREFIX}/accelerator/accelerations/history`, { params: { ...params } });
|
|
|
|
}
|
2019-07-21 17:59:47 +03:00
|
|
|
}
|