Browse Source

Merge pull request #603 from mrfelton/fix/existing-wallet-message

fix(onboarding): improve existing wallet found message
renovate/lint-staged-8.x
Ben Woosley 7 years ago
committed by GitHub
parent
commit
148fe6bd72
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/components/Onboarding/Onboarding.js
  2. 1
      app/containers/Root.js
  3. 17
      app/lnd/walletUnlockerMethods/index.js
  4. 11
      app/reducers/onboarding.js

5
app/components/Onboarding/Onboarding.js

@ -161,7 +161,10 @@ const Onboarding = ({
return (
<FormContainer
title="Welcome back!"
description="Enter your wallet password or create a new wallet"
description={`It looks like you have already 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}
>

1
app/containers/Root.js

@ -127,6 +127,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
password: stateProps.onboarding.password,
passwordIsValid: stateProps.passwordIsValid,
hasSeed: stateProps.onboarding.hasSeed,
existingWalletDir: stateProps.onboarding.existingWalletDir,
unlockingWallet: stateProps.onboarding.unlockingWallet,
unlockWalletError: stateProps.onboarding.unlockWalletError,

17
app/lnd/walletUnlockerMethods/index.js

@ -1,13 +1,28 @@
import { dirname } from 'path'
import * as walletController from '../methods/walletController'
import config from '../config'
export default function(walletUnlocker, log, event, msg, data) {
const lndConfig = config.lnd()
const decorateError = error => {
switch (error.code) {
// wallet already exists
case 2:
error.context = {
lndDataDir: dirname(lndConfig.cert)
}
}
return error
}
log.info(`Calling walletUnlocker method '${msg}'`)
switch (msg) {
case 'genSeed':
walletController
.genSeed(walletUnlocker)
.then(genSeedData => event.sender.send('receiveSeed', genSeedData))
.catch(error => event.sender.send('receiveSeedError', error))
.catch(error => event.sender.send('receiveSeedError', decorateError(error)))
break
case 'unlockWallet':
walletController

11
app/reducers/onboarding.js

@ -38,6 +38,8 @@ export const STARTING_LND = 'STARTING_LND'
export const LND_STARTED = 'LND_STARTED'
export const SET_START_LND_ERROR = 'SET_START_LND_ERROR'
export const LOADING_EXISTING_WALLET = 'LOADING_EXISTING_WALLET'
export const CREATING_NEW_WALLET = 'CREATING_NEW_WALLET'
export const UNLOCKING_WALLET = 'UNLOCKING_WALLET'
@ -268,10 +270,14 @@ export const receiveSeed = (event, { cipher_seed_mnemonic }) => dispatch => {
}
// Listener for when LND throws an error on seed creation
export const receiveSeedError = () => dispatch => {
export const receiveSeedError = (event, error) => dispatch => {
dispatch({ type: SET_HAS_SEED, hasSeed: true })
// there is already a seed, send user to the login component
dispatch({ type: CHANGE_STEP, step: 3 })
dispatch({
type: LOADING_EXISTING_WALLET,
existingWalletDir: get(error, 'context.lndDataDir')
})
}
// Unlock an existing wallet with a wallet password
@ -340,6 +346,8 @@ const ACTION_HANDLERS = {
startLndMacaroonError: errors.macaroon
}),
[LOADING_EXISTING_WALLET]: (state, { existingWalletDir }) => ({ ...state, existingWalletDir }),
[CREATING_NEW_WALLET]: state => ({ ...state, creatingNewWallet: true }),
[UNLOCKING_WALLET]: state => ({ ...state, unlockingWallet: true }),
@ -464,6 +472,7 @@ const initialState = {
createWalletPasswordConfirmation: '',
creatingNewWallet: false,
existingWalletDir: null,
unlockingWallet: false,
unlockWalletError: {
isError: false,

Loading…
Cancel
Save