From c795009e94021f41553cf73b4bc1ebd59e17ea5e Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sun, 25 Jul 2021 16:55:47 -0400 Subject: [PATCH 1/2] Configuration for debugging connected to Polar --- .vscode/launch.json | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 8be72c0b..3f4e5655 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,7 +1,7 @@ { "configurations": [ { - "name": "Launch Program Via Nodemon", + "name": "Nodemon", "program": "${workspaceFolder}/main.js", "args": ["--", "-h", "0.0.0.0", "-c"], "request": "launch", @@ -22,6 +22,48 @@ // (after 10 seconds). To avoid this, you can increase the timeout by // adding a timeout attribute with a larger value (in milliseconds). + "runtimeExecutable": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js", + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "restart": true + }, + { + "name": "Nodemon+Polar", + "program": "${workspaceFolder}/main.js", + "args": [ + "--", + "-h", + "0.0.0.0", + "-c", + "-s", + "9835", + "-l", + "127.0.0.1:10001", + "-r", + "localhost:9735", + "-m", + "/home/danlugo92/.polar/networks/1/volumes/lnd/alice/data/chain/bitcoin/regtest/admin.macaroon", + "-d", + "/home/danlugo92/.polar/networks/1/volumes/lnd/alice/tls.cert" + ], + "request": "launch", + "skipFiles": ["/**"], + "type": "node", + "envFile": "${workspaceFolder}/.env", + "outputCapture": "std", + + // https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_restarting-debug-sessions-automatically-when-source-is-edited + // Tip: Pressing the Stop button stops the debug session and disconnects + // from Node.js, but nodemon (and Node.js) will continue to run. To stop + // nodemon, you will have to kill it from the command line (which is + // easily possible if you use the integratedTerminal as shown above). + + // Tip: In case of syntax errors, nodemon will not be able to start + // Node.js successfully until the error has been fixed. In this case, VS + // Code will continue trying to attach to Node.js but eventually give up + // (after 10 seconds). To avoid this, you can increase the timeout by + // adding a timeout attribute with a larger value (in milliseconds). + "runtimeExecutable": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js", "console": "integratedTerminal", "internalConsoleOptions": "neverOpen", From 6354962b2f3eb177659c80ff647ca5a0cfba4ebf Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sun, 25 Jul 2021 17:07:07 -0400 Subject: [PATCH 2/2] Initial LND socket has no args, handle --- src/sockets.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/sockets.js b/src/sockets.js index 281b3eec..6f19d9a2 100644 --- a/src/sockets.js +++ b/src/sockets.js @@ -57,7 +57,16 @@ module.exports = ( const { services } = LightningServices - const { service, method, args: unParsed } = socket.handshake.auth + const { + service, + method, + args: unParsed, + isInitial + } = socket.handshake.auth + + if (isInitial) { + return + } const args = JSON.parse(unParsed) @@ -100,6 +109,7 @@ module.exports = ( call.write(args) }) } catch (err) { + logger.error(err) logger.error('LNDRPC: ' + err.message) } })