Skip to content

Commit

Permalink
fix(core): add watcher for pending held invoices (#3480)
Browse files Browse the repository at this point in the history
  • Loading branch information
dolcalmi authored Nov 2, 2023
1 parent 28f89af commit 8b2b2ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/api/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ConfigError } from "./error"
import { toDays } from "@/domain/primitives"

export const MS_PER_SEC = 1000 as MilliSeconds
export const MS_PER_5_MINS = (60 * 5 * MS_PER_SEC) as MilliSeconds
export const MS_PER_HOUR = (60 * 60 * MS_PER_SEC) as MilliSeconds
export const MS_PER_DAY = (24 * MS_PER_HOUR) as MilliSeconds
export const TWO_MONTHS_IN_MS = (60 * MS_PER_DAY) as MilliSeconds
Expand Down
15 changes: 14 additions & 1 deletion core/api/src/servers/trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ import { briaEventHandler } from "./event-handlers/bria"

import healthzHandler from "./middlewares/healthz"

import { getSwapConfig, NETWORK, ONCHAIN_MIN_CONFIRMATIONS, TRIGGER_PORT } from "@/config"
import {
getSwapConfig,
MS_PER_5_MINS,
NETWORK,
ONCHAIN_MIN_CONFIRMATIONS,
TRIGGER_PORT,
} from "@/config"

import {
Payments,
Expand Down Expand Up @@ -177,6 +183,12 @@ const publishCurrentPrice = () => {
}, interval)
}

const watchHeldInvoices = () => {
return setInterval(async () => {
await Wallets.handleHeldInvoices(logger)
}, MS_PER_5_MINS)
}

const listenerOnchain = (lnd: AuthenticatedLnd) => {
const subTransactions = subscribeToTransactions({ lnd })
const onChainTxHandler = wrapAsyncToRunInSpan({
Expand Down Expand Up @@ -488,6 +500,7 @@ const main = () => {

activateLndHealthCheck()
publishCurrentPrice()
watchHeldInvoices()

if (getSwapConfig().feeAccountingEnabled) listenerSwapMonitor()

Expand Down

0 comments on commit 8b2b2ac

Please sign in to comment.