Skip to content

Commit

Permalink
Merge pull request #243 from synonymdev/lsp-event
Browse files Browse the repository at this point in the history
feat: append channel monitor details to lsp log
  • Loading branch information
Jasonvdb authored May 24, 2024
2 parents c42e73e + d8623b0 commit 6c7b64e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/src/lightning-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
IAddress,
TLspLogPayload,
TLspLogEvent,
TChannelMonitor,
} from './utils/types';
import {
appendPath,
Expand Down Expand Up @@ -1988,10 +1989,6 @@ class LightningManager {
(p) => p.payment_hash === res.payment_hash,
);

console.error(
`Existing claimed payments: ${JSON.stringify(existingClaimedPayment)}`,
);

if (
existingClaimedPayment &&
existingClaimedPayment.state === 'successful'
Expand Down Expand Up @@ -2248,14 +2245,23 @@ class LightningManager {
await this.syncLdk();
}

private async onLspLogEvent(payload: any): Promise<void> {
private async onLspLogEvent(payload: object): Promise<void> {
if (!this.lspLogEvent) {
return;
}
let body: { channelClose: object; channelFiles: TChannelMonitor[] } = {
channelClose: payload,
channelFiles: [],
};
const nodeIdRes = await ldk.nodeId();

const channelFiles = await ldk.listChannelMonitors(true);
if (channelFiles.isOk()) {
body.channelFiles = channelFiles.value;
}

await this.lspLogEvent({
body: JSON.stringify(payload),
body: JSON.stringify(body),
nodeId: nodeIdRes.isOk() ? nodeIdRes.value : '',
});
}
Expand Down

0 comments on commit 6c7b64e

Please sign in to comment.