Skip to content

Commit

Permalink
Merge pull request #1768 from ExchangeUnion/fix/max-outbound-balance-lnd
Browse files Browse the repository at this point in the history
fix(lnd): totalOutboundAmount
  • Loading branch information
sangaman authored Jul 30, 2020
2 parents 272fef1 + caf3782 commit 6e8d2d5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/lndclient/LndClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,12 @@ class LndClient extends SwapClient {
let maxInbound = 0;
let balance = 0;
let inactiveBalance = 0;
let totalOutboundAmount = 0;
channels.toObject().channelsList.forEach((channel) => {
if (channel.active) {
balance += channel.localBalance;
const outbound = channel.localBalance - channel.localChanReserveSat;
totalOutboundAmount += outbound;
if (maxOutbound < outbound) {
maxOutbound = outbound;
}
Expand All @@ -714,14 +716,19 @@ class LndClient extends SwapClient {

if (this._maxChannelOutboundAmount !== maxOutbound) {
this._maxChannelOutboundAmount = maxOutbound;
this.logger.debug(`new channel outbound capacity: ${maxOutbound}`);
this.logger.debug(`new channel maximum outbound capacity: ${maxOutbound}`);
}

if (this._maxChannelInboundAmount !== maxInbound) {
this._maxChannelInboundAmount = maxInbound;
this.logger.debug(`new channel inbound capacity: ${maxInbound}`);
}

if (this._totalOutboundAmount !== totalOutboundAmount) {
this._totalOutboundAmount = totalOutboundAmount;
this.logger.debug(`new channel total outbound capacity: ${maxOutbound}`);
}

const pendingOpenBalance = pendingChannels.toObject().pendingOpenChannelsList.
reduce((sum, pendingChannel) => sum + (pendingChannel.channel?.localBalance ?? 0), 0);

Expand Down

0 comments on commit 6e8d2d5

Please sign in to comment.