Skip to content

Commit

Permalink
Merge pull request #25 from RadarTech/cf-cc-559-proto-pull-fixes
Browse files Browse the repository at this point in the history
Proto persistence & subscription default fixes
  • Loading branch information
cavanmflynn authored Mar 22, 2019
2 parents 0aaea40 + 5fd1885 commit b6961b6
Show file tree
Hide file tree
Showing 12 changed files with 2,412 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
yarn-error.log
.esm-cache
rpc.proto
/rpc.proto
*.macaroon
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ Install [lnd](https://github.com/lightningnetwork/lnd/blob/master/docs/INSTALL.m
To change the gRPC definitions used for all auto-generated types and RPC methods edit the `config.lnd_release_tag` value in `package.json` to the desired [LND release tag](https://github.com/lightningnetwork/lnd/releases) and run the following:

```sh
npm run update-proto
# OR
yarn update-proto

# AND

npm run generate
# OR
yarn generate
Expand Down
2 changes: 1 addition & 1 deletion generate_types.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PROTOC_VERSION=$2
# Clone LND release and extract rpc.proto
yarn
rm -f ./rpc.proto
node lib/proto-sanitizer.js "./node_modules/lnd#${LND_RELEASE_TAG}/lnrpc/rpc.proto" "./rpc.proto"
node lib/proto-sanitizer.js "./lnd/${LND_RELEASE_TAG}/rpc.proto" "./rpc.proto"

GENERATED_TYPES_DIR=types/generated
if [ -d "$GENERATED_TYPES_DIR" ]
Expand Down
5 changes: 4 additions & 1 deletion lib/lightning.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ module.exports = function createLightningProxy(
get(target, key) {
const method = target[key];

if (typeof method !== 'function' || subscriptionMethods.includes(key)) {
if (typeof method !== 'function') {
return target[key]; // forward
} else {
if (subscriptionMethods.includes(key)) {
return defaultEmptyArg(method);
}
return promisify(defaultEmptyArg(method));
}
},
Expand Down
5 changes: 2 additions & 3 deletions lib/lnrpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const pkgDir = require('pkg-dir');
const {join} = require('path');
const {promisify} = require('util');
const protoLoader = require('@grpc/proto-loader');
const GRPC = require('@grpc/grpc-js');
const GRPC = require('grpc');
const createLightning = require('./lightning');
const createWalletUnlocker = require('./wallet-unlocker');
const readFile = promisify(fs.readFile);
Expand Down Expand Up @@ -38,8 +38,7 @@ module.exports = async function createLnRpc(config = {}) {
const rootPath = await pkgDir(__dirname);
const protoSrc = join(
rootPath,
`node_modules/lnd#${packageJson.config['lnd-release-tag']}` +
`/lnrpc/rpc.proto`,
`lnd/${packageJson.config['lnd-release-tag']}/rpc.proto`,
);
const protoDest = join(rootPath, 'rpc.proto');

Expand Down
Loading

0 comments on commit b6961b6

Please sign in to comment.