bypasses
This commit is contained in:
parent
178140908b
commit
aed90ae929
3 changed files with 33 additions and 13 deletions
|
|
@ -67,20 +67,10 @@ export default class {
|
||||||
if (liquidProvider.getSettings().useOnlyLiquidityProvider) {
|
if (liquidProvider.getSettings().useOnlyLiquidityProvider) {
|
||||||
this.log("USE_ONLY_LIQUIDITY_PROVIDER enabled, skipping LND client initialization")
|
this.log("USE_ONLY_LIQUIDITY_PROVIDER enabled, skipping LND client initialization")
|
||||||
// Create minimal dummy clients - they won't be used but prevent null reference errors
|
// Create minimal dummy clients - they won't be used but prevent null reference errors
|
||||||
// Use insecure credentials since LND won't be accessed
|
// Use insecure credentials directly (can't combine them)
|
||||||
const { lndAddr } = this.getSettings().lndNodeSettings
|
const { lndAddr } = this.getSettings().lndNodeSettings
|
||||||
const insecureCreds = credentials.createInsecure()
|
const insecureCreds = credentials.createInsecure()
|
||||||
const dummyMacaroonCreds = credentials.createFromMetadataGenerator(
|
const dummyTransport = new GrpcTransport({ host: lndAddr || '127.0.0.1:10009', channelCredentials: insecureCreds })
|
||||||
function (args: any, callback: any) {
|
|
||||||
let metadata = new Metadata();
|
|
||||||
callback(null, metadata);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
const dummyCombinedCreds = credentials.combineChannelCredentials(
|
|
||||||
insecureCreds,
|
|
||||||
dummyMacaroonCreds,
|
|
||||||
);
|
|
||||||
const dummyTransport = new GrpcTransport({ host: lndAddr || '127.0.0.1:10009', channelCredentials: dummyCombinedCreds })
|
|
||||||
this.lightning = new LightningClient(dummyTransport)
|
this.lightning = new LightningClient(dummyTransport)
|
||||||
this.invoices = new InvoicesClient(dummyTransport)
|
this.invoices = new InvoicesClient(dummyTransport)
|
||||||
this.router = new RouterClient(dummyTransport)
|
this.router = new RouterClient(dummyTransport)
|
||||||
|
|
@ -163,6 +153,18 @@ export default class {
|
||||||
}
|
}
|
||||||
|
|
||||||
async GetInfo(): Promise<NodeInfo> {
|
async GetInfo(): Promise<NodeInfo> {
|
||||||
|
if (this.liquidProvider.getSettings().useOnlyLiquidityProvider) {
|
||||||
|
// Return dummy info when bypass is enabled
|
||||||
|
return {
|
||||||
|
identityPubkey: '',
|
||||||
|
alias: '',
|
||||||
|
syncedToChain: false,
|
||||||
|
syncedToGraph: false,
|
||||||
|
blockHeight: 0,
|
||||||
|
blockHash: '',
|
||||||
|
uris: []
|
||||||
|
}
|
||||||
|
}
|
||||||
// console.log("Getting info")
|
// console.log("Getting info")
|
||||||
const res = await this.lightning.getInfo({}, DeadLineMetadata())
|
const res = await this.lightning.getInfo({}, DeadLineMetadata())
|
||||||
return res.response
|
return res.response
|
||||||
|
|
@ -384,6 +386,9 @@ export default class {
|
||||||
}
|
}
|
||||||
|
|
||||||
async ChannelBalance(): Promise<{ local: number, remote: number }> {
|
async ChannelBalance(): Promise<{ local: number, remote: number }> {
|
||||||
|
if (this.liquidProvider.getSettings().useOnlyLiquidityProvider) {
|
||||||
|
return { local: 0, remote: 0 }
|
||||||
|
}
|
||||||
// console.log("Getting channel balance")
|
// console.log("Getting channel balance")
|
||||||
const res = await this.lightning.channelBalance({})
|
const res = await this.lightning.channelBalance({})
|
||||||
const r = res.response
|
const r = res.response
|
||||||
|
|
@ -527,6 +532,9 @@ export default class {
|
||||||
}
|
}
|
||||||
|
|
||||||
async GetBalance(): Promise<BalanceInfo> { // TODO: remove this
|
async GetBalance(): Promise<BalanceInfo> { // TODO: remove this
|
||||||
|
if (this.liquidProvider.getSettings().useOnlyLiquidityProvider) {
|
||||||
|
return { confirmedBalance: 0, unconfirmedBalance: 0, totalBalance: 0, channelsBalance: [] }
|
||||||
|
}
|
||||||
// console.log("Getting balance")
|
// console.log("Getting balance")
|
||||||
const wRes = await this.lightning.walletBalance({ account: "", minConfs: 1 }, DeadLineMetadata())
|
const wRes = await this.lightning.walletBalance({ account: "", minConfs: 1 }, DeadLineMetadata())
|
||||||
const { confirmedBalance, unconfirmedBalance, totalBalance } = wRes.response
|
const { confirmedBalance, unconfirmedBalance, totalBalance } = wRes.response
|
||||||
|
|
@ -549,11 +557,17 @@ export default class {
|
||||||
}
|
}
|
||||||
|
|
||||||
async GetAllPaidInvoices(max: number) {
|
async GetAllPaidInvoices(max: number) {
|
||||||
|
if (this.liquidProvider.getSettings().useOnlyLiquidityProvider) {
|
||||||
|
return { invoices: [] }
|
||||||
|
}
|
||||||
// console.log("Getting all paid invoices")
|
// console.log("Getting all paid invoices")
|
||||||
const res = await this.lightning.listInvoices({ indexOffset: 0n, numMaxInvoices: BigInt(max), pendingOnly: false, reversed: true, creationDateEnd: 0n, creationDateStart: 0n }, DeadLineMetadata())
|
const res = await this.lightning.listInvoices({ indexOffset: 0n, numMaxInvoices: BigInt(max), pendingOnly: false, reversed: true, creationDateEnd: 0n, creationDateStart: 0n }, DeadLineMetadata())
|
||||||
return res.response
|
return res.response
|
||||||
}
|
}
|
||||||
async GetAllPayments(max: number) {
|
async GetAllPayments(max: number) {
|
||||||
|
if (this.liquidProvider.getSettings().useOnlyLiquidityProvider) {
|
||||||
|
return { payments: [] }
|
||||||
|
}
|
||||||
// console.log("Getting all payments")
|
// console.log("Getting all payments")
|
||||||
const res = await this.lightning.listPayments({ countTotalPayments: false, includeIncomplete: false, indexOffset: 0n, maxPayments: BigInt(max), reversed: true, creationDateEnd: 0n, creationDateStart: 0n })
|
const res = await this.lightning.listPayments({ countTotalPayments: false, includeIncomplete: false, indexOffset: 0n, maxPayments: BigInt(max), reversed: true, creationDateEnd: 0n, creationDateStart: 0n })
|
||||||
return res.response
|
return res.response
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ export const initMainHandler = async (log: PubLogger, settingsManager: SettingsM
|
||||||
const mainHandler = new Main(settingsManager, storageManager, adminManager, utils, unlocker)
|
const mainHandler = new Main(settingsManager, storageManager, adminManager, utils, unlocker)
|
||||||
adminManager.setLND(mainHandler.lnd)
|
adminManager.setLND(mainHandler.lnd)
|
||||||
await mainHandler.lnd.Warmup()
|
await mainHandler.lnd.Warmup()
|
||||||
if (!settingsManager.getSettings().serviceSettings.skipSanityCheck) {
|
if (!settingsManager.getSettings().serviceSettings.skipSanityCheck && !settingsManager.getSettings().liquiditySettings.useOnlyLiquidityProvider) {
|
||||||
const sanityChecker = new SanityChecker(storageManager, mainHandler.lnd)
|
const sanityChecker = new SanityChecker(storageManager, mainHandler.lnd)
|
||||||
await sanityChecker.VerifyEventsLog()
|
await sanityChecker.VerifyEventsLog()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,12 @@ export class Watchdog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StartWatching = async () => {
|
StartWatching = async () => {
|
||||||
|
// Skip watchdog if using only liquidity provider
|
||||||
|
if (this.liquidProvider.getSettings().useOnlyLiquidityProvider) {
|
||||||
|
this.log("USE_ONLY_LIQUIDITY_PROVIDER enabled, skipping watchdog")
|
||||||
|
this.ready = true
|
||||||
|
return
|
||||||
|
}
|
||||||
this.log("Starting watchdog")
|
this.log("Starting watchdog")
|
||||||
this.startedAtUnix = Math.floor(Date.now() / 1000)
|
this.startedAtUnix = Math.floor(Date.now() / 1000)
|
||||||
const info = await this.lnd.GetInfo()
|
const info = await this.lnd.GetInfo()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue