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

Commit

Permalink
feat(grpc): ability to unlock remote wallet
Browse files Browse the repository at this point in the history
If when connecting to a remote wallet we detect that it is locked
initialise the wallet unlocker  to allow users to unlock their remote
wallets.

Fix #543
  • Loading branch information
mrfelton committed Sep 5, 2018
1 parent 71ac6ad commit 3c5337e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
18 changes: 9 additions & 9 deletions app/components/Onboarding/Onboarding.js
Expand Up @@ -159,16 +159,16 @@ const Onboarding = ({
</FormContainer>
)
case 3:
// eslint-disable-next-line no-case-declarations
let message = 'It looks like you already have a wallet'
if (initWalletProps.loginProps.existingWalletDir && connectionType === 'local') {
message += ` (we found one at ${initWalletProps.loginProps.existingWalletDir})`
} else {
message += ` at ${connectionHost.split(':')[0]}`
}
message += '. Please enter your wallet password to unlock it.'
return (
<FormContainer
title="Welcome back!"
description={`It looks like you already have a wallet
${Boolean(initWalletProps.loginProps.existingWalletDir) &&
`(we found one at \`${initWalletProps.loginProps.existingWalletDir}\`)`}.
Please enter your wallet password to unlock it.`}
back={null}
next={null}
>
<FormContainer title="Welcome back!" description={`${message}`} back={null} next={null}>
<Login {...initWalletProps.loginProps} />
</FormContainer>
)
Expand Down
10 changes: 3 additions & 7 deletions app/lib/zap/controller.js
Expand Up @@ -199,8 +199,7 @@ class ZapController {
// which indicates that the requested operation is not implemented or not supported/enabled in the service.
// See https://github.com/grpc/grpc-node/blob/master/packages/grpc-native-core/src/constants.js#L129
if (e.code === 12) {
errors.host =
'Unable to connect to host. Please ensure wallet is unlocked before connecting.'
return this.startWalletUnlocker()
}

// Other error codes such as UNAVAILABLE most likely indicate that there is a problem with the host.
Expand Down Expand Up @@ -336,11 +335,6 @@ class ZapController {
this.startWalletUnlocker()
})

this.neutrino.on('lightning-grpc-active', () => {
mainLog.info('Lightning gRPC active')
this.startLightningWallet()
})

this.neutrino.on('chain-sync-waiting', () => {
mainLog.info('Neutrino sync waiting')
this.sendMessage('lndSyncStatus', 'waiting')
Expand Down Expand Up @@ -467,13 +461,15 @@ class ZapController {
*/
_registerIpcListeners() {
ipcMain.on('startLnd', (event, options: onboardingOptions) => this.finishOnboarding(options))
ipcMain.on('startLightningWallet', () => this.startLightningWallet())
}

/**
* Add IPC event listeners...
*/
_removeIpcListeners() {
ipcMain.removeAllListeners('startLnd')
ipcMain.removeAllListeners('startLightningWallet')
ipcMain.removeAllListeners('walletUnlocker')
ipcMain.removeAllListeners('lnd')
}
Expand Down
1 change: 1 addition & 0 deletions app/reducers/onboarding.js
Expand Up @@ -320,6 +320,7 @@ export const unlockWallet = wallet_password => dispatch => {
export const walletUnlocked = () => dispatch => {
dispatch({ type: WALLET_UNLOCKED })
dispatch({ type: ONBOARDING_FINISHED })
ipcRenderer.send('startLightningWallet')
}

export const unlockWalletError = () => dispatch => {
Expand Down

0 comments on commit 3c5337e

Please sign in to comment.