Merge pull request #2252 from mempool/nymkappa/bugfix/cln-channel-id

Fix CLN channel short_id conversion
This commit is contained in:
wiz 2022-08-08 15:40:28 +09:00 committed by GitHub
commit 632da54146
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -71,8 +71,11 @@ export async function convertAndmergeBidirectionalChannels(clChannels: any[]): P
} }
export function convertChannelId(channelId): string { export function convertChannelId(channelId): string {
const s = channelId.split('x').map(part => parseInt(part)); if (channelId.indexOf('/') !== -1) {
return BigInt((s[0] << 40) | (s[1] << 16) | s[2]).toString(); channelId = channelId.slice(0, -2);
}
const s = channelId.split('x').map(part => BigInt(part));
return ((s[0] << 40n) | (s[1] << 16n) | s[2]).toString();
} }
/** /**

View File

@ -430,10 +430,13 @@ class NetworkSyncService {
} }
private toIntegerId(id: string): string { private toIntegerId(id: string): string {
if (config.LIGHTNING.BACKEND === 'lnd') { if (config.LIGHTNING.BACKEND === 'cln') {
return convertChannelId(id);
}
else if (config.LIGHTNING.BACKEND === 'lnd') {
return id; return id;
} }
return convertChannelId(id); return '';
} }
/** Decodes a channel id returned by lnd as uint64 to a short channel id */ /** Decodes a channel id returned by lnd as uint64 to a short channel id */