From 76f51e2ba7d9979abdc81e79f614300ff93852a3 Mon Sep 17 00:00:00 2001 From: Yaacov Akiba Slama Date: Tue, 16 Mar 2021 10:55:35 +0200 Subject: [PATCH] Ensure that private and public channels have different capacity --- intercept.go | 3 +++ server.go | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/intercept.go b/intercept.go index 68bdb80..60d8afb 100644 --- a/intercept.go +++ b/intercept.go @@ -52,6 +52,9 @@ func isConnected(ctx context.Context, client lnrpc.LightningClient, destination func openChannel(ctx context.Context, client lnrpc.LightningClient, paymentHash, destination []byte, incomingAmountMsat int64) ([]byte, uint32, error) { capacity := incomingAmountMsat/1000 + additionalChannelCapacity + if capacity == publicChannelAmount { + capacity++ + } channelPoint, err := client.OpenChannelSync(ctx, &lnrpc.OpenChannelRequest{ NodePubkey: destination, LocalFundingAmount: capacity, diff --git a/server.go b/server.go index 17b0764..89b01ee 100644 --- a/server.go +++ b/server.go @@ -30,7 +30,7 @@ import ( ) const ( - channelAmount = 1_000_183 + publicChannelAmount = 1_000_183 targetConf = 6 minHtlcMsat = 600 baseFeeMsat = 1000 @@ -58,7 +58,7 @@ func (s *server) ChannelInformation(ctx context.Context, in *lspdrpc.ChannelInfo Name: nodeName, Pubkey: nodePubkey, Host: os.Getenv("NODE_HOST"), - ChannelCapacity: channelAmount, + ChannelCapacity: publicChannelAmount, TargetConf: targetConf, MinHtlcMsat: minHtlcMsat, BaseFeeMsat: baseFeeMsat, @@ -112,7 +112,7 @@ func (s *server) OpenChannel(ctx context.Context, in *lspdrpc.OpenChannelRequest var outputIndex uint32 if len(nodeChannels) == 0 && len(pendingChannels) == 0 { response, err := client.OpenChannelSync(clientCtx, &lnrpc.OpenChannelRequest{ - LocalFundingAmount: channelAmount, + LocalFundingAmount: publicChannelAmount, NodePubkeyString: in.Pubkey, PushSat: 0, TargetConf: targetConf,