diff --git a/backends/EmbeddedLND.ts b/backends/EmbeddedLND.ts index 77b0ef70c..4a2919c7e 100644 --- a/backends/EmbeddedLND.ts +++ b/backends/EmbeddedLND.ts @@ -1,6 +1,7 @@ import LND from './LND'; import OpenChannelRequest from '../models/OpenChannelRequest'; import Base64Utils from './../utils/Base64Utils'; +import { removeListeners } from '../utils/LndMobileUtils'; import lndMobile from '../lndmobile/LndMobileInjection'; @@ -167,6 +168,7 @@ export default class EmbeddedLND extends LND { // subscribeTransactions = () => this.getRequest('/v1/transactions/subscribe'); // initChannelAcceptor = async (callback: any) => // await channelAcceptor(callback); + disconnect = () => removeListeners(); supportsMessageSigning = () => true; supportsLnurlAuth = () => true; diff --git a/utils/LndMobileUtils.ts b/utils/LndMobileUtils.ts index 4b3b41596..0bd678527 100644 --- a/utils/LndMobileUtils.ts +++ b/utils/LndMobileUtils.ts @@ -191,6 +191,11 @@ export async function initializeLnd(isTestnet?: boolean, rescan?: boolean) { await initialize(); } +export function removeListeners() { + LndMobileEventEmitter.removeAllListeners && + LndMobileEventEmitter.removeAllListeners('SubscribeState'); +} + export async function startLnd(walletPassword: string) { const { checkStatus, startLnd, decodeState, subscribeState } = lndMobile.index; diff --git a/views/Settings/Nodes.tsx b/views/Settings/Nodes.tsx index 4fc72d061..b72237540 100644 --- a/views/Settings/Nodes.tsx +++ b/views/Settings/Nodes.tsx @@ -182,7 +182,9 @@ export default class Nodes extends React.Component { }).then(() => { if ( currentImplementation === - 'lightning-node-connect' + 'lightning-node-connect' || + currentImplementation === + 'embedded-lnd' ) { BackendUtils.disconnect(); }