up
This commit is contained in:
parent
4f4552248d
commit
72659e640c
4 changed files with 12 additions and 3 deletions
|
|
@ -102,7 +102,7 @@ export class LiquidityProvider {
|
||||||
}
|
}
|
||||||
this.latestMaxWithdrawable = res.max_withdrawable
|
this.latestMaxWithdrawable = res.max_withdrawable
|
||||||
this.latestBalance = res.balance
|
this.latestBalance = res.balance
|
||||||
this.log("latest provider balance:", res.max_withdrawable)
|
this.log("latest provider balance:", res.balance, "latest max withdrawable:", res.max_withdrawable)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,9 @@ export class VoltageLSP extends LSP {
|
||||||
body: JSON.stringify({ amount_msat: amtMsat, pubkey }),
|
body: JSON.stringify({ amount_msat: amtMsat, pubkey }),
|
||||||
headers: { "Content-Type": "application/json" }
|
headers: { "Content-Type": "application/json" }
|
||||||
})
|
})
|
||||||
const json = await res.json() as { fee_amount_msat: number, id: string }
|
const resText = await res.text()
|
||||||
|
this.log("fee response", resText)
|
||||||
|
const json = JSON.parse(resText) as { fee_amount_msat: number, id: string }
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ export default class {
|
||||||
const balanceEvents = await this.paymentManager.GetLndBalance()
|
const balanceEvents = await this.paymentManager.GetLndBalance()
|
||||||
await this.metricsManager.NewBlockCb(height, balanceEvents)
|
await this.metricsManager.NewBlockCb(height, balanceEvents)
|
||||||
confirmed = await this.paymentManager.CheckNewlyConfirmedTxs(height)
|
confirmed = await this.paymentManager.CheckNewlyConfirmedTxs(height)
|
||||||
|
this.liquidityManager.onNewBlock()
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
log(ERROR, "failed to check transactions after new block", err.message || err)
|
log(ERROR, "failed to check transactions after new block", err.message || err)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ export class LiquidityManager {
|
||||||
flashsatsLSP: FlashsatsLSP
|
flashsatsLSP: FlashsatsLSP
|
||||||
log = getLogger({ component: "liquidityManager" })
|
log = getLogger({ component: "liquidityManager" })
|
||||||
channelRequested = false
|
channelRequested = false
|
||||||
|
channelRequesting = false
|
||||||
constructor(settings: LiquiditySettings, storage: Storage, liquidityProvider: LiquidityProvider, lnd: LND) {
|
constructor(settings: LiquiditySettings, storage: Storage, liquidityProvider: LiquidityProvider, lnd: LND) {
|
||||||
this.settings = settings
|
this.settings = settings
|
||||||
this.storage = storage
|
this.storage = storage
|
||||||
|
|
@ -58,14 +59,16 @@ export class LiquidityManager {
|
||||||
if (existingOrder) {
|
if (existingOrder) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.channelRequested) {
|
if (this.channelRequested || this.channelRequesting) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
this.channelRequesting = true
|
||||||
this.log("checking if channel should be requested")
|
this.log("checking if channel should be requested")
|
||||||
const olympusOk = await this.olympusLSP.openChannelIfReady()
|
const olympusOk = await this.olympusLSP.openChannelIfReady()
|
||||||
if (olympusOk) {
|
if (olympusOk) {
|
||||||
this.log("requested channel from olympus")
|
this.log("requested channel from olympus")
|
||||||
this.channelRequested = true
|
this.channelRequested = true
|
||||||
|
this.channelRequesting = false
|
||||||
await this.storage.liquidityStorage.SaveLspOrder({ service_name: 'olympus', invoice: olympusOk.invoice, total_paid: olympusOk.totalSats, order_id: olympusOk.orderId, fees: olympusOk.fees })
|
await this.storage.liquidityStorage.SaveLspOrder({ service_name: 'olympus', invoice: olympusOk.invoice, total_paid: olympusOk.totalSats, order_id: olympusOk.orderId, fees: olympusOk.fees })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -73,6 +76,7 @@ export class LiquidityManager {
|
||||||
if (voltageOk) {
|
if (voltageOk) {
|
||||||
this.log("requested channel from voltage")
|
this.log("requested channel from voltage")
|
||||||
this.channelRequested = true
|
this.channelRequested = true
|
||||||
|
this.channelRequesting = false
|
||||||
await this.storage.liquidityStorage.SaveLspOrder({ service_name: 'voltage', invoice: voltageOk.invoice, total_paid: voltageOk.totalSats, order_id: voltageOk.orderId, fees: voltageOk.fees })
|
await this.storage.liquidityStorage.SaveLspOrder({ service_name: 'voltage', invoice: voltageOk.invoice, total_paid: voltageOk.totalSats, order_id: voltageOk.orderId, fees: voltageOk.fees })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -81,9 +85,11 @@ export class LiquidityManager {
|
||||||
if (flashsatsOk) {
|
if (flashsatsOk) {
|
||||||
this.log("requested channel from flashsats")
|
this.log("requested channel from flashsats")
|
||||||
this.channelRequested = true
|
this.channelRequested = true
|
||||||
|
this.channelRequesting = false
|
||||||
await this.storage.liquidityStorage.SaveLspOrder({ service_name: 'flashsats', invoice: flashsatsOk.invoice, total_paid: flashsatsOk.totalSats, order_id: flashsatsOk.orderId, fees: flashsatsOk.fees })
|
await this.storage.liquidityStorage.SaveLspOrder({ service_name: 'flashsats', invoice: flashsatsOk.invoice, total_paid: flashsatsOk.totalSats, order_id: flashsatsOk.orderId, fees: flashsatsOk.fees })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
this.channelRequesting = false
|
||||||
this.log("no channel requested")
|
this.log("no channel requested")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue