fixies
This commit is contained in:
parent
406ffa615b
commit
37693b5e57
2 changed files with 7 additions and 1 deletions
|
|
@ -117,6 +117,9 @@ export class LiquidityProvider {
|
|||
}
|
||||
|
||||
AddInvoice = async (amount: number, memo: string) => {
|
||||
if (this.latestMaxWithdrawable === null) {
|
||||
throw new Error("liquidity provider is not ready yet")
|
||||
}
|
||||
const res = await this.client.NewInvoice({ amountSats: amount, memo })
|
||||
if (res.status === 'ERROR') {
|
||||
this.log("error creating invoice", res.reason)
|
||||
|
|
@ -128,6 +131,9 @@ export class LiquidityProvider {
|
|||
}
|
||||
|
||||
PayInvoice = async (invoice: string) => {
|
||||
if (this.latestMaxWithdrawable === null) {
|
||||
throw new Error("liquidity provider is not ready yet")
|
||||
}
|
||||
const res = await this.client.PayInvoice({ invoice, amount: 0 })
|
||||
if (res.status === 'ERROR') {
|
||||
this.log("error paying invoice", res.reason)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export class LiquidityManager {
|
|||
onNewBlock = async () => {
|
||||
const balance = await this.liquidityProvider.GetLatestMaxWithdrawable()
|
||||
const { remote } = await this.lnd.ChannelBalance()
|
||||
if (remote > balance) {
|
||||
if (remote > balance && balance > 0) {
|
||||
this.log("draining provider balance to channel")
|
||||
const invoice = await this.lnd.NewInvoice(balance, "liqudity provider drain", defaultInvoiceExpiry)
|
||||
const res = await this.liquidityProvider.PayInvoice(invoice.payRequest)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue