From b5a1db76ee55384feebe38ccbf6bd3da70e94a04 Mon Sep 17 00:00:00 2001 From: emad-salah Date: Fri, 10 Jul 2020 13:27:13 +0100 Subject: [PATCH] Prevent mediator from being attached to LND socket --- services/lnd/lightning.js | 2 -- src/sockets.js | 17 ++++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/services/lnd/lightning.js b/services/lnd/lightning.js index b92939d9..89fea045 100644 --- a/services/lnd/lightning.js +++ b/services/lnd/lightning.js @@ -1,5 +1,3 @@ - - const grpc = require("grpc"); const protoLoader = require("@grpc/proto-loader"); const fs = require("../../utils/fs"); diff --git a/src/sockets.js b/src/sockets.js index 7476e780..fef09ed4 100644 --- a/src/sockets.js +++ b/src/sockets.js @@ -162,11 +162,12 @@ module.exports = ( logger.info('socket.handshake', socket.handshake) - /** printing out the client who joined */ - logger.info('New socket client connected (id=' + socket.id + ').') - const isOneTimeUseSocket = !!socket.handshake.query.IS_GUN_AUTH const isLNDSocket = !!socket.handshake.query.IS_LND_SOCKET + if (!isLNDSocket) { + /** printing out the client who joined */ + logger.info('New socket client connected (id=' + socket.id + ').') + } if (isOneTimeUseSocket) { logger.info('New socket is one time use') @@ -191,14 +192,16 @@ module.exports = ( } }) } else { + if (isLNDSocket) { + logger.info('[LND] New LND Socket created') + onNewInvoice(socket) + onNewTransaction(socket) + return + } logger.info('New socket is NOT one time use') // this is where we create the websocket connection // with the GunDB service. Mediator.createMediator(socket) - if (isLNDSocket) { - onNewInvoice(socket) - onNewTransaction(socket) - } /** listening if client has disconnected */ socket.on('disconnect', () => {