Compare commits
19 commits
4c69a4d390
...
c08bf4b849
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c08bf4b849 | ||
|
|
ed7e0d1f86 | ||
|
|
9d352e5f07 | ||
|
|
55077d818e | ||
|
|
512c83ad21 | ||
|
|
2cac13b5a4 | ||
|
|
de233b16c7 | ||
|
|
59d3b0e888 | ||
|
|
4d0d12a4d9 | ||
|
|
b31d043d6f | ||
|
|
64bf155bfb | ||
|
|
211776ff2e | ||
|
|
ba999f8b33 | ||
|
|
2ceec5b571 | ||
|
|
01ea762ec0 | ||
|
|
2ce5a8ffcd | ||
|
|
48ee930b36 | ||
|
|
cc9aa49b5b | ||
|
|
3b03c64d0c |
3 changed files with 17 additions and 39 deletions
|
|
@ -192,31 +192,6 @@ export interface ExtensionContext {
|
|||
log(level: 'debug' | 'info' | 'warn' | 'error', message: string, ...args: any[]): void
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTP route handler types
|
||||
* Used by extensions that expose HTTP endpoints (e.g. LNURL, .well-known)
|
||||
*/
|
||||
export interface HttpRequest {
|
||||
method: string
|
||||
path: string
|
||||
params: Record<string, string>
|
||||
query: Record<string, string>
|
||||
headers: Record<string, string>
|
||||
body?: any
|
||||
}
|
||||
|
||||
export interface HttpResponse {
|
||||
status: number
|
||||
body: any
|
||||
headers?: Record<string, string>
|
||||
}
|
||||
|
||||
export interface HttpRoute {
|
||||
method: 'GET' | 'POST'
|
||||
path: string
|
||||
handler: (req: HttpRequest) => Promise<HttpResponse>
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension interface - what extensions must implement
|
||||
*/
|
||||
|
|
@ -243,12 +218,6 @@ export interface Extension {
|
|||
* Return true if extension is healthy
|
||||
*/
|
||||
healthCheck?(): Promise<boolean>
|
||||
|
||||
/**
|
||||
* Get HTTP routes exposed by this extension
|
||||
* The main HTTP server will mount these routes
|
||||
*/
|
||||
getHttpRoutes?(): HttpRoute[]
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -142,15 +142,20 @@ export default class {
|
|||
return new Promise<void>((res, rej) => {
|
||||
const interval = setInterval(async () => {
|
||||
try {
|
||||
await this.GetInfo()
|
||||
const info = await this.GetInfo()
|
||||
if (!info.syncedToChain || !info.syncedToGraph) {
|
||||
this.log("LND responding but not synced yet, waiting...")
|
||||
return
|
||||
}
|
||||
clearInterval(interval)
|
||||
this.ready = true
|
||||
res()
|
||||
} catch (err) {
|
||||
this.log(INFO, "LND is not ready yet, will try again in 1 second")
|
||||
if (Date.now() - now > 1000 * 60) {
|
||||
rej(new Error("LND not ready after 1 minute"))
|
||||
}
|
||||
if (Date.now() - now > 1000 * 60 * 10) {
|
||||
clearInterval(interval)
|
||||
rej(new Error("LND not synced after 10 minutes"))
|
||||
}
|
||||
}, 1000)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -238,13 +238,17 @@ export class Watchdog {
|
|||
const knownMaxIndex = Math.max(maxFromDb, this.latestPaymentIndexOffset)
|
||||
const newLatest = await this.lnd.GetLatestPaymentIndex(knownMaxIndex)
|
||||
const historyMismatch = newLatest > knownMaxIndex
|
||||
const deny = await this.checkBalanceUpdate(deltaLnd, deltaUsers)
|
||||
if (historyMismatch) {
|
||||
getLogger({ component: 'bark' })("History mismatch detected in absolute update, locking outgoing operations")
|
||||
this.log("Payment index advanced from", knownMaxIndex, "to", newLatest, "- updating offset (likely LND restart or external payment)")
|
||||
this.latestPaymentIndexOffset = newLatest
|
||||
}
|
||||
const deny = await this.checkBalanceUpdate(deltaLnd, deltaUsers)
|
||||
if (deny) {
|
||||
if (historyMismatch) {
|
||||
getLogger({ component: 'bark' })("Balance mismatch with unexpected payment history, locking outgoing operations")
|
||||
this.lnd.LockOutgoingOperations()
|
||||
return
|
||||
}
|
||||
if (deny) {
|
||||
this.log("Balance mismatch detected in absolute update, but history is ok")
|
||||
}
|
||||
this.lnd.UnlockOutgoingOperations()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue