Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 7caac7d

Browse files
committed
Updated to lnd alpha 0.3, added TLS support
1 parent 0023349 commit 7caac7d

File tree

3 files changed

+39
-18
lines changed

3 files changed

+39
-18
lines changed

apps/desktop/assets/ln-logo.icns

338 KB
Binary file not shown.

apps/desktop/main.dev.js

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import cp from 'child_process'
99
import ps from 'ps-node'
1010
import fileLog from 'electron-log'
1111
import os from 'os'
12-
import lnd from './rpc-server'
13-
14-
global.connection = lnd.connection
15-
global.serverReady = lnd.serverReady
12+
import fs from 'fs'
13+
import grpc from 'grpc'
1614

1715
app.commandLine.appendSwitch('remote-debugging-port', '9997')
1816
app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1')
@@ -43,7 +41,7 @@ const runProcesses = (processes, logs) => {
4341
const filePath = path.join(__dirname, 'bin', plat, proc.name, plat === 'win32' ? '.exe' : '')
4442

4543
try {
46-
const instance = cp.execFile(filePath, proc.args, { cwd: 'bin' }, (error) => {
44+
const instance = cp.execFile(filePath, proc.args, (error) => {
4745
if (error) {
4846
logs.push(error.code ? `${ error.code }: ${ error.errno }` : JSON.stringify(error))
4947
}
@@ -73,16 +71,50 @@ const processes = [
7371
'--neutrino.active',
7472
'--configfile=../lnd.conf',
7573
isDev ? '--bitcoin.simnet' : '--bitcoin.testnet',
76-
isDev ? '--neutrino.addpeer=127.0.0.1:18335' : '--neutrino.addpeer=faucet.lightning.community:18333',
77-
isDev ? '' : '--neutrino.addpeer=127.0.0.1:18333',
74+
isDev ? '--neutrino.connect=127.0.0.1:18335' : '--neutrino.connect=faucet.lightning.community:18333',
75+
isDev ? '' : '--neutrino.connect=127.0.0.1:18333',
7876
'--debuglevel=info',
77+
'--no-macaroons',
7978
],
8079
},
8180
]
8281

8382
runProcesses(processes, logs)
8483

84+
let intervalId
85+
let certPath
86+
const homedir = os.homedir()
87+
88+
switch (os.platform()) {
89+
case 'darwin':
90+
certPath = path.join(homedir, 'Library/Application\ Support/Lnd/tls.cert')
91+
break
92+
case 'linux':
93+
certPath = path.join(homedir, '.lnd/tls.cert')
94+
break
95+
case 'win32':
96+
certPath = path.join(homedir, 'AppData', 'Local', 'Lnd', 'tls.cert')
97+
break
98+
}
99+
85100
const createWindow = () => {
101+
intervalId = setInterval(() => {
102+
if (fs.existsSync(certPath)) {
103+
clearInterval(intervalId)
104+
const lndCert = fs.readFileSync(certPath)
105+
const credentials = grpc.credentials.createSsl(lndCert)
106+
const { lnrpc } = grpc.load(path.join(__dirname, 'rpc.proto'))
107+
const connection = new lnrpc.Lightning('localhost:10009', credentials)
108+
const serverReady = cb =>
109+
grpc.waitForClientReady(connection, Infinity, cb)
110+
global.connection = connection
111+
global.serverReady = serverReady
112+
finishCreateWindow()
113+
}
114+
}, 500)
115+
}
116+
117+
const finishCreateWindow = () => {
86118
const mainWindowState = windowStateKeeper({
87119
defaultWidth: 750,
88120
defaultHeight: 500,

apps/desktop/rpc-server.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)