Skip to content

Commit

Permalink
LSPStore: ChannelAcceptor: parse LNC events correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Aug 29, 2023
1 parent 22d8a05 commit 8fb5201
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions stores/LSPStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,8 @@ export default class LSPStore {
});
};

handleChannelAcceptorEvent = async (event: any) => {
handleChannelAcceptorEvent = async (channelAcceptRequest: any) => {
try {
const channelAcceptRequest = channel.decodeChannelAcceptRequest(
event.data
);

// PEGASUS TODO only allow chans from LSP
const isZeroConfAllowed = true;

Expand All @@ -135,7 +131,7 @@ export default class LSPStore {
isZeroConfAllowed
);
} catch (error: any) {
console.error('channel acceptance error: ' + error.message);
console.error('handleChannelAcceptorEvent error:', error.message);
}
};

Expand All @@ -148,7 +144,17 @@ export default class LSPStore {
this.channelAcceptor = LndMobileEventEmitter.addListener(
'ChannelAcceptor',
async (event: any) => {
await this.handleChannelAcceptorEvent(event);
try {
const result = channel.decodeChannelAcceptRequest(
event.data
);
await this.handleChannelAcceptorEvent(result);
} catch (error: any) {
console.error(
'channelAcceptorEvent embedded-lnd error:',
error.message
);
}
}
);

Expand All @@ -161,7 +167,17 @@ export default class LSPStore {
this.channelAcceptor = eventEmitter.addListener(
'lnrpc.Lightning.ChannelAcceptor',
async (event: any) => {
await this.handleChannelAcceptorEvent(event);
if (event.result) {
try {
const result = JSON.parse(event.result);
await this.handleChannelAcceptorEvent(result);
} catch (error: any) {
console.error(
'channelAcceptorEvent lightning-node-connect error:',
error.message
);
}
}
}
);
}
Expand Down

0 comments on commit 8fb5201

Please sign in to comment.