Browse Source

Merge pull request #406 from mrfelton/fix/rpc-proto-dup

Consolidate lnd build resources
renovate/lint-staged-8.x
JimmyMow 7 years ago
committed by GitHub
parent
commit
b43ed52c15
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .travis.yml
  2. 25
      app/lnd/config/index.js
  3. 3
      app/lnd/lib/lightning.js
  4. 1676
      app/lnd/lib/rpc.proto
  5. 3
      app/lnd/lib/walletUnlocker.js
  6. 1676
      app/rpc.proto
  7. 11
      package.json
  8. 3
      resources/rpc.proto
  9. 955
      yarn.lock

3
.travis.yml

@ -3,6 +3,9 @@ sudo: false
language: node_js
env:
global:
- DEBUG=electron-builder
matrix:
- TEST=lint-ci
- TEST=test-ci

25
app/lnd/config/index.js

@ -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)

3
app/lnd/lib/lightning.js

@ -1,5 +1,4 @@
import fs from 'fs'
import path from 'path'
import grpc from 'grpc'
import config from '../config'
@ -22,7 +21,7 @@ const lightning = (rpcpath, host) => {
const lndConfig = config.lnd()
const lndCert = fs.readFileSync(lndConfig.cert)
const sslCreds = grpc.credentials.createSsl(lndCert)
const rpc = grpc.load(path.join(__dirname, 'rpc.proto'))
const rpc = grpc.load(lndConfig.lightningRpc)
const metadata = new grpc.Metadata()
const macaroonHex = fs.readFileSync(lndConfig.macaroon).toString('hex')

1676
app/lnd/lib/rpc.proto

File diff suppressed because it is too large

3
app/lnd/lib/walletUnlocker.js

@ -1,5 +1,4 @@
import fs from 'fs'
import path from 'path'
import grpc from 'grpc'
import config from '../config'
@ -22,7 +21,7 @@ const walletUnlocker = (rpcpath, host) => {
const lndConfig = config.lnd()
const lndCert = fs.readFileSync(lndConfig.cert)
const credentials = grpc.credentials.createSsl(lndCert)
const rpc = grpc.load(path.join(__dirname, 'rpc.proto'))
const rpc = grpc.load(lndConfig.lightningRpc)
return new rpc.lnrpc.WalletUnlocker(host, credentials)
}

1676
app/rpc.proto

File diff suppressed because it is too large

11
package.json

@ -51,8 +51,7 @@
"app.html",
"main.prod.js",
"main.prod.js.map",
"package.json",
"rpc.proto"
"package.json"
],
"dmg": {
"icon": "./resources/icon.icns",
@ -86,9 +85,11 @@
"output": "release"
},
"extraResources": [
"resources/rpc.proto",
{
"from": "./resources/bin/win32/lnd.exe",
"to": "./bin/lnd.exe"
"from": "resources/bin/${platform}",
"to": "bin",
"filter": [ "lnd*" ]
}
]
},
@ -157,7 +158,7 @@
"cross-env": "^5.0.0",
"cross-spawn": "^5.1.0",
"css-loader": "^0.28.3",
"electron-builder": "^19.49.2",
"electron-builder": "^20.15.1",
"electron-devtools-installer": "^2.2.1",
"enzyme": "^2.9.1",
"enzyme-to-json": "^1.5.1",

3
app/lnd/config/rpc.proto → resources/rpc.proto

@ -1673,4 +1673,5 @@ message ForwardingHistoryResponse {
/// The index of the last time in the set of returned forwarding events. Can be used to seek further, pagination style.
uint32 last_offset_index = 2 [json_name = "last_offset_index"];
}
}

955
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save