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
  • Loading branch information
JimmyMow committed Aug 21, 2018
1 parent 6b7c04a commit 59f5052
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PROJECT_ROOT>/dll/.*
<PROJECT_ROOT>/release/.*
<PROJECT_ROOT>/git/.*
<PROJECT_ROOT>/.git/.*

[include]

Expand Down
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
14 changes: 13 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,18 @@ 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', null)

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: 1 addition & 1 deletion flow-typed/module_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare module 'module' {
declare module 'grpc' {
declare module.exports: any;
}
12 changes: 12 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 All @@ -8,6 +10,16 @@ import channelsReducer, {
OPENING_FAILURE
} from 'reducers/channels'

jest.mock('electron', () => {
const { normalize } = require('path')
return {
app: {
getPath: name => normalize(`/tmp/zap-test/${name}`),
getAppPath: () => normalize('/tmp/zap-test')
}
}
})

describe('reducers', () => {
describe('channelsReducer', () => {
it('should handle initial state', () => {
Expand Down

0 comments on commit 59f5052

Please sign in to comment.