Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: append channel monitor details to lsp log #243

Merged
merged 2 commits into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions lib/src/lightning-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@
TCreatePaymentReq,
TBackupServerDetails,
IAddress,
TLspLogPayload,

Check warning on line 58 in lib/src/lightning-manager.ts

View workflow job for this annotation

GitHub Actions / Run lint check

'TLspLogPayload' is defined but never used
TLspLogEvent,
TChannelMonitor,
} from './utils/types';
import {
appendPath,
Expand Down Expand Up @@ -363,7 +364,7 @@
this.account = account;
this.network = network;
this.addresses = await this.readAddressesFromFile();
this.getAddress = async () => {

Check warning on line 367 in lib/src/lightning-manager.ts

View workflow job for this annotation

GitHub Actions / Run lint check

Missing return type on function
const addressObj = await getAddress();
const address = addressObj?.address;
if (address) {
Expand Down Expand Up @@ -1988,10 +1989,6 @@
(p) => p.payment_hash === res.payment_hash,
);

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

if (
existingClaimedPayment &&
existingClaimedPayment.state === 'successful'
Expand Down Expand Up @@ -2102,7 +2099,7 @@
}

private onChannelManagerPendingHtlcsForwardable(
res: TChannelManagerPendingHtlcsForwardable,

Check warning on line 2102 in lib/src/lightning-manager.ts

View workflow job for this annotation

GitHub Actions / Run lint check

'res' is defined but never used. Allowed unused args must match /^_/u
): void {
ldk.processPendingHtlcForwards().catch(console.error);
}
Expand Down Expand Up @@ -2248,14 +2245,23 @@
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
Loading