Browse Source

fix(lnd): support tilde in connection params

Expand the tilde character when used in connection parameters.

Fix #596
renovate/lint-staged-8.x
Tom Kirkpatrick 7 years ago
parent
commit
eb4fe31e27
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 33
      app/lnd/config/index.js
  2. 1
      package.json
  3. 4
      yarn.lock

33
app/lnd/config/index.js

@ -8,6 +8,7 @@ import { dirname, join, normalize } from 'path'
import Store from 'electron-store'
import { app } from 'electron'
import isDev from 'electron-is-dev'
import untildify from 'untildify'
// 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.
@ -22,9 +23,6 @@ import isDev from 'electron-is-dev'
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 tlsCertPathation of various lnd resources.
const plat = platform()
@ -58,17 +56,34 @@ if (isDev) {
export default {
lnd: () => {
const cert = store.get('cert')
const host = store.get('host')
const macaroon = store.get('macaroon')
// Get an electromn store named 'connection' in which the saved connection detailes are stored.
const store = new Store({ name: 'connection' })
// Determine what hostname to use.
let host = store.get('host')
if (typeof host === 'undefined') {
host = 'localhost:10009'
}
// Determine what cert to use.
let cert = store.get('cert')
if (typeof cert === 'undefined') {
cert = join(lndDataDir, 'tls.cert')
}
// Determine what macaroon to use.
let macaroon = store.get('macaroon')
if (typeof macaroon === 'undefined') {
macaroon = join(lndDataDir, 'admin.macaroon')
}
return {
lndPath,
configPath: join(appRootPath, 'resources', 'lnd.conf'),
rpcProtoPath: join(appRootPath, 'resources', 'rpc.proto'),
host: typeof host === 'undefined' ? 'localhost:10009' : host,
cert: typeof cert === 'undefined' ? join(lndDataDir, 'tls.cert') : cert,
macaroon: typeof macaroon === 'undefined' ? join(lndDataDir, 'admin.macaroon') : macaroon
host,
cert: untildify(cert),
macaroon: untildify(macaroon)
}
}
}

1
package.json

@ -277,6 +277,7 @@
"satoshi-bitcoin": "^1.0.4",
"source-map-support": "^0.5.6",
"split2": "^2.2.0",
"untildify": "^3.0.3",
"validator": "^10.4.0"
},
"main": "webpack.config.base.js",

4
yarn.lock

@ -11847,6 +11847,10 @@ unset-value@^1.0.0:
has-value "^0.3.1"
isobject "^3.0.0"
untildify@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/untildify/-/untildify-3.0.3.tgz#1e7b42b140bcfd922b22e70ca1265bfe3634c7c9"
unzip-response@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97"

Loading…
Cancel
Save