Browse Source

fix(clightning): fix duplicate channel displayed for clightning nodes

master
jamaljsr 5 years ago
parent
commit
c01cace396
  1. 7
      TODO.md
  2. 4
      src/lib/lightning/clightning/clightningService.ts
  3. 10
      src/lib/lightning/lnd/mappers.ts

7
TODO.md

@ -1,9 +1,12 @@
# TODO List # TODO List
Small Stuff - run bitcoind.getinfo when depositing funds
- check if nodes are started before getinfo after a mine
- fix unknown channel initiator producing an incorrect graph - fix unknown channel initiator producing an incorrect graph
- add persisted storage for lang, openChan c-ln notice - add persisted storage for lang, openChan c-ln notice
Small Stuff
- implement real-time channel updates from LND via GRPC streams - implement real-time channel updates from LND via GRPC streams
- implement option to auto-mine every X minutes - implement option to auto-mine every X minutes
- switch renovatebot to dependabot and use automatic security fixes - switch renovatebot to dependabot and use automatic security fixes

4
src/lib/lightning/clightning/clightningService.ts

@ -61,8 +61,8 @@ class CLightningService implements LightningService {
const status = ChannelStateToStatus[c.state]; const status = ChannelStateToStatus[c.state];
return { return {
pending: status !== 'Open', pending: status !== 'Open',
uniqueId: c.shortChannelId, uniqueId: c.fundingTxid.slice(-12),
channelPoint: c.channelId, channelPoint: c.fundingTxid,
pubkey: c.id, pubkey: c.id,
capacity: this.toSats(c.msatoshiTotal), capacity: this.toSats(c.msatoshiTotal),
localBalance: this.toSats(c.msatoshiToUs), localBalance: this.toSats(c.msatoshiToUs),

10
src/lib/lightning/lnd/mappers.ts

@ -1,10 +1,12 @@
import { Channel, PendingChannel } from '@radar/lnrpc'; import { Channel, PendingChannel } from '@radar/lnrpc';
import { LightningNodeChannel } from 'lib/lightning/types'; import { LightningNodeChannel } from 'lib/lightning/types';
const txid = (channelPoint: string) => channelPoint.split(':')[0];
export const mapOpenChannel = (chan: Channel): LightningNodeChannel => ({ export const mapOpenChannel = (chan: Channel): LightningNodeChannel => ({
pending: false, pending: false,
uniqueId: chan.channelPoint.slice(-12), uniqueId: txid(chan.channelPoint).slice(-12),
channelPoint: chan.channelPoint, channelPoint: txid(chan.channelPoint),
pubkey: chan.remotePubkey, pubkey: chan.remotePubkey,
capacity: chan.capacity, capacity: chan.capacity,
localBalance: chan.localBalance, localBalance: chan.localBalance,
@ -16,8 +18,8 @@ export const mapPendingChannel = (status: LightningNodeChannel['status']) => (
chan: PendingChannel, chan: PendingChannel,
): LightningNodeChannel => ({ ): LightningNodeChannel => ({
pending: true, pending: true,
uniqueId: chan.channelPoint.slice(-12), uniqueId: txid(chan.channelPoint).slice(-12),
channelPoint: chan.channelPoint, channelPoint: txid(chan.channelPoint),
pubkey: chan.remoteNodePub, pubkey: chan.remoteNodePub,
capacity: chan.capacity, capacity: chan.capacity,
localBalance: chan.localBalance, localBalance: chan.localBalance,

Loading…
Cancel
Save