Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
feat(lnd): increase one time send/receive limits for mpp
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed May 17, 2020
1 parent 7d6493c commit 3ee7c73
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 26 deletions.
57 changes: 31 additions & 26 deletions renderer/reducers/channels/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CoinBig } from '@zap/utils/coin'
import { convert } from '@zap/utils/btc'
import { networkSelectors } from 'reducers/network'
import { settingsSelectors } from 'reducers/settings'
import { infoSelectors } from 'reducers/info'
import { getChannelData, getChannelEffectiveCapacity, decorateChannel } from './utils'
import {
DEFAULT_FILTER,
Expand Down Expand Up @@ -311,35 +312,39 @@ channelsSelectors.selectedChannel = createSelector(
}
)

channelsSelectors.capacity = createSelector(channelsSelectors.allChannelsRaw, allChannels => {
let maxOneTimeSend = 0
let maxOneTimeReceive = 0
let send = 0
let receive = 0

allChannels.forEach(channel => {
const channelData = getChannelData(channel)
const local = CoinBig(get(channelData, 'localBalance', 0))
const remote = CoinBig(get(channelData, 'remoteBalance', 0))

if (local) {
send = CoinBig.sum(send, local)
maxOneTimeSend = CoinBig.max(maxOneTimeSend, local)
}
channelsSelectors.capacity = createSelector(
channelsSelectors.allChannelsRaw,
infoSelectors.hasMppSupport,
(allChannels, hasMppSupport) => {
let maxOneTimeSend = 0
let maxOneTimeReceive = 0
let send = 0
let receive = 0

allChannels.forEach(channel => {
const channelData = getChannelData(channel)
const local = CoinBig(get(channelData, 'localBalance', 0))
const remote = CoinBig(get(channelData, 'remoteBalance', 0))

if (local) {
send = CoinBig.sum(send, local)
maxOneTimeSend = hasMppSupport ? send : CoinBig.max(maxOneTimeSend, local)
}

if (remote) {
receive = CoinBig.sum(receive, remote)
maxOneTimeReceive = hasMppSupport ? receive : CoinBig.max(maxOneTimeReceive, remote)
}
})

if (remote) {
receive = CoinBig.sum(receive, remote)
maxOneTimeReceive = CoinBig.max(maxOneTimeReceive, remote)
return {
send: CoinBig(send).toString(),
receive: CoinBig(receive).toString(),
maxOneTimeReceive: CoinBig(maxOneTimeReceive).toString(),
maxOneTimeSend: CoinBig(maxOneTimeSend).toString(),
}
})

return {
send: CoinBig(send).toString(),
receive: CoinBig(receive).toString(),
maxOneTimeReceive: CoinBig(maxOneTimeReceive).toString(),
maxOneTimeSend: CoinBig(maxOneTimeSend).toString(),
}
})
)

channelsSelectors.sendCapacity = createSelector(
channelsSelectors.capacity,
Expand Down
8 changes: 8 additions & 0 deletions renderer/reducers/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ infoSelectors.hasSendPaymentV2Support = createSelector(infoSelectors.grpcProtoVe
return semver.gte(version, '0.10.0-beta', { includePrerelease: true })
})

// Check whether node has support for mpp
infoSelectors.hasMppSupport = createSelector(infoSelectors.grpcProtoVersion, version => {
if (!version) {
return false
}
return semver.gte(version, '0.10.0-beta', { includePrerelease: true })
})

// Get the node pubkey. If not set, try to extract it from the node uri.
infoSelectors.nodePubkey = createSelector(
infoSelectors.nodeUris,
Expand Down

0 comments on commit 3ee7c73

Please sign in to comment.