Replacing ln-service library and wait for graph sync.
This commit is contained in:
@@ -3,5 +3,5 @@ import { ILightningApi } from './lightning-api.interface';
|
||||
export interface AbstractLightningApi {
|
||||
$getNetworkInfo(): Promise<ILightningApi.NetworkInfo>;
|
||||
$getNetworkGraph(): Promise<ILightningApi.NetworkGraph>;
|
||||
$getChanInfo(id: string): Promise<ILightningApi.Channel>;
|
||||
$getInfo(): Promise<ILightningApi.Info>;
|
||||
}
|
||||
|
||||
@@ -21,17 +21,17 @@ export namespace ILightningApi {
|
||||
policies: Policy[];
|
||||
transaction_id: string;
|
||||
transaction_vout: number;
|
||||
updated_at: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
interface Policy {
|
||||
public_key: string;
|
||||
base_fee_mtokens?: number;
|
||||
base_fee_mtokens?: string;
|
||||
cltv_delta?: number;
|
||||
fee_rate?: number;
|
||||
is_disabled?: boolean;
|
||||
max_htlc_mtokens?: number;
|
||||
min_htlc_mtokens?: number;
|
||||
max_htlc_mtokens?: string;
|
||||
min_htlc_mtokens?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
@@ -41,13 +41,31 @@ export namespace ILightningApi {
|
||||
features: Feature[];
|
||||
public_key: string;
|
||||
sockets: string[];
|
||||
updated_at: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
interface Feature {
|
||||
export interface Info {
|
||||
chains: string[];
|
||||
color: string;
|
||||
active_channels_count: number;
|
||||
alias: string;
|
||||
current_block_hash: string;
|
||||
current_block_height: number;
|
||||
features: Feature[];
|
||||
is_synced_to_chain: boolean;
|
||||
is_synced_to_graph: boolean;
|
||||
latest_block_at: string;
|
||||
peers_count: number;
|
||||
pending_channels_count: number;
|
||||
public_key: string;
|
||||
uris: any[];
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface Feature {
|
||||
bit: number;
|
||||
is_known: boolean;
|
||||
is_required: boolean;
|
||||
type: string;
|
||||
type?: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AbstractLightningApi } from '../lightning-api-abstract-factory';
|
||||
import { ILightningApi } from '../lightning-api.interface';
|
||||
import * as fs from 'fs';
|
||||
import * as lnService from 'ln-service';
|
||||
import { authenticatedLndGrpc, getWalletInfo, getNetworkGraph, getNetworkInfo } from 'lightning';
|
||||
import config from '../../../config';
|
||||
import logger from '../../../logger';
|
||||
|
||||
@@ -15,7 +15,7 @@ class LndApi implements AbstractLightningApi {
|
||||
const tls = fs.readFileSync(config.LND.TLS_CERT_PATH).toString('base64');
|
||||
const macaroon = fs.readFileSync(config.LND.MACAROON_PATH).toString('base64');
|
||||
|
||||
const { lnd } = lnService.authenticatedLndGrpc({
|
||||
const { lnd } = authenticatedLndGrpc({
|
||||
cert: tls,
|
||||
macaroon: macaroon,
|
||||
socket: config.LND.SOCKET,
|
||||
@@ -29,15 +29,16 @@ class LndApi implements AbstractLightningApi {
|
||||
}
|
||||
|
||||
async $getNetworkInfo(): Promise<ILightningApi.NetworkInfo> {
|
||||
return await lnService.getNetworkInfo({ lnd: this.lnd });
|
||||
return await getNetworkInfo({ lnd: this.lnd });
|
||||
}
|
||||
|
||||
async $getInfo(): Promise<ILightningApi.Info> {
|
||||
// @ts-ignore
|
||||
return await getWalletInfo({ lnd: this.lnd });
|
||||
}
|
||||
|
||||
async $getNetworkGraph(): Promise<ILightningApi.NetworkGraph> {
|
||||
return await lnService.getNetworkGraph({ lnd: this.lnd });
|
||||
}
|
||||
|
||||
async $getChanInfo(id: string): Promise<ILightningApi.Channel> {
|
||||
return await lnService.getChannel({ lnd: this.lnd, id });
|
||||
return await getNetworkGraph({ lnd: this.lnd });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user