|
|
@ -3,10 +3,27 @@ |
|
|
|
// Linux: ~/.lnd/tls.cert
|
|
|
|
// Windows: TODO find out where cert is located for windows machine
|
|
|
|
import { userInfo, platform } from 'os' |
|
|
|
import { join } from 'path' |
|
|
|
import { join, normalize } from 'path' |
|
|
|
import Store from 'electron-store' |
|
|
|
import { app } from 'electron' |
|
|
|
|
|
|
|
// Get a path to prepend to any nodejs calls that are getting at files in the package,
|
|
|
|
// so that it works both from source and in an asar-packaged mac app.
|
|
|
|
// See https://github.com/electron-userland/electron-builder/issues/751
|
|
|
|
//
|
|
|
|
// windows from source: "C:\myapp\node_modules\electron\dist\resources\default_app.asar"
|
|
|
|
// mac from source: "/Users/me/dev/myapp/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar"
|
|
|
|
// mac from a package: <somewhere>"/my.app/Contents/Resources/app.asar"
|
|
|
|
//
|
|
|
|
// If we are run from outside of a packaged app, our working directory is the right place to be.
|
|
|
|
// And no, we can't just set our working directory to somewhere inside the asar. The OS can't handle that.
|
|
|
|
const appPath = app.getAppPath() |
|
|
|
const appRootPath = appPath.indexOf('default_app.asar') < 0 ? normalize(`${appPath}/..`) : '' |
|
|
|
|
|
|
|
// Get an electromn store named 'connection' in which the saved connection detailes are stored.
|
|
|
|
const store = new Store({ name: 'connection' }) |
|
|
|
|
|
|
|
// Get the name of the current platform which we can use to determine the location of various lnd resources.
|
|
|
|
const plat = platform() |
|
|
|
|
|
|
|
let loc |
|
|
@ -35,15 +52,15 @@ switch (plat) { |
|
|
|
} |
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'development') { |
|
|
|
lndPath = join(__dirname, '..', '..', '..', 'resources', 'bin', plat, lndBin) |
|
|
|
lndPath = join(appRootPath, 'resources', 'bin', plat, lndBin) |
|
|
|
} else { |
|
|
|
lndPath = join(__dirname, '..', '..', '..', 'bin', lndBin) |
|
|
|
lndPath = join(appRootPath, 'bin', lndBin) |
|
|
|
} |
|
|
|
|
|
|
|
export default { |
|
|
|
lnd: () => ({ |
|
|
|
lndPath, |
|
|
|
lightningRpc: `${__dirname}/rpc.proto`, |
|
|
|
lightningRpc: join(appRootPath, 'resources', 'rpc.proto'), |
|
|
|
lightningHost: store.get('host') || 'localhost:10009', |
|
|
|
cert: store.get('cert') || join(userInfo().homedir, loc), |
|
|
|
macaroon: store.get('macaroon') || join(userInfo().homedir, macaroonPath) |
|
|
|