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

Commit

Permalink
fix(channels): neutrino clients manual channels flagged private
Browse files Browse the repository at this point in the history
Make sure that if a user of ours is using neutrino that we flag their
channels as private when they manually open them. Reason for this is
because light consumer clients are not expected to have high uptime.

However we cannot hardcode channels as private every time because we
do support more power users driving their remote nodes or BTCPay
Server with Zap. So we only flag channels as private if the
activeConnection is local.
  • Loading branch information
JimmyMow committed Aug 22, 2018
1 parent 48280c1 commit ad062c2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/lib/lnd/methods/channelController.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ function ensurePeerConnected(lnd, pubkey, host) {
* @return {[type]} [description]
*/
export function connectAndOpen(lnd, event, payload) {
const { pubkey, host, localamt } = payload
const { pubkey, host, localamt, private: privateChannel } = payload

return ensurePeerConnected(lnd, pubkey, host)
.then(() => {
const call = lnd.openChannel({
node_pubkey: Buffer.from(pubkey, 'hex'),
local_funding_amount: Number(localamt)
local_funding_amount: Number(localamt),
private: privateChannel
})

call.on('data', data => event.sender.send('pushchannelupdated', { pubkey, data }))
Expand Down
12 changes: 11 additions & 1 deletion app/reducers/channels.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron'
import Store from 'electron-store'
import { btc } from 'lib/utils'
import { showNotification } from 'lib/utils/notifications'
import { requestSuggestedNodes } from 'lib/utils/api'
Expand Down Expand Up @@ -191,7 +192,16 @@ export const openChannel = ({ pubkey, host, local_amt }) => (dispatch, getState)
dispatch(openingChannel())
dispatch(addLoadingPubkey(pubkey))

ipcRenderer.send('lnd', { msg: 'connectAndOpen', data: { pubkey, host, localamt } })
// Grab the activeConnection type from our local store. If the active connection type is local (light clients using
// neutrino) we will flag manually created channels as private. Other connections like remote node and BTCPay Server
// we will announce to the network as these users are using Zap to drive nodes that are online 24/7
const store = new Store({ name: 'settings' })
const { type } = store.get('activeConnection', {})

ipcRenderer.send('lnd', {
msg: 'connectAndOpen',
data: { pubkey, host, localamt, private: type === 'local' }
})
}

// TODO: Decide how to handle streamed updates for channels
Expand Down
2 changes: 2 additions & 0 deletions test/unit/reducers/channels.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @flow

import channelsReducer, {
SET_CHANNEL_FORM,
SET_CHANNEL,
Expand Down

0 comments on commit ad062c2

Please sign in to comment.