Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(lnd): handle early walletunlocker disconenct
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed May 3, 2020
1 parent dc69302 commit 245c28b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions services/grpc/grpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,16 @@ class ZapGrpc extends EventEmitter {
* @returns {Promise} Promise that resolves after unlocking a wallet and connecting to the Lightning interface.
*/
async unlock(password) {
const { grpc } = this
try {
const { grpc } = this
await promiseTimeout(
WALLET_UNLOCKER_TIMEOUT,
grpc.services.WalletUnlocker.unlockWallet({ walletPassword: Buffer.from(password) })
)
return await promiseTimeout(WALLET_UNLOCKER_TIMEOUT, grpc.activateLightning())
await grpc.services.WalletUnlocker.unlockWallet({ walletPassword: Buffer.from(password) })
} catch (e) {
grpcLog.error(`Error when trying to connect to LND grpc: %o`, e)
throw e
if (e.code !== status.UNAVAILABLE) {
grpcLog.error(`Error when trying to connect to LND grpc: %o`, e)
throw e
}
}
await grpc.activateLightning()
}

/**
Expand Down

0 comments on commit 245c28b

Please sign in to comment.