diff --git a/app/components/Onboarding/Onboarding.js b/app/components/Onboarding/Onboarding.js index 762aff3d..37147c75 100644 --- a/app/components/Onboarding/Onboarding.js +++ b/app/components/Onboarding/Onboarding.js @@ -40,6 +40,7 @@ const Onboarding = ({ changeStep, startLnd, submitNewWallet, + recoverOldWallet, aliasProps, initWalletProps, autopilotProps, @@ -225,7 +226,7 @@ const Onboarding = ({ next={() => { const recoverySeed = recoverFormProps.recoverSeedInput.map(input => input.word) - submitNewWallet(createWalletPassword, recoverySeed) + recoverOldWallet(createWalletPassword, recoverySeed) }} > @@ -292,7 +293,8 @@ Onboarding.propTypes = { reEnterSeedProps: PropTypes.object.isRequired, changeStep: PropTypes.func.isRequired, startLnd: PropTypes.func.isRequired, - submitNewWallet: PropTypes.func.isRequired + submitNewWallet: PropTypes.func.isRequired, + recoverOldWallet: PropTypes.func.isRequired } export default Onboarding diff --git a/app/containers/Root.js b/app/containers/Root.js index 76c6765a..ebedb68d 100644 --- a/app/containers/Root.js +++ b/app/containers/Root.js @@ -19,6 +19,7 @@ import { updateCreateWalletPassword, updateCreateWalletPasswordConfirmation, submitNewWallet, + recoverOldWallet, onboardingSelectors, unlockWallet, setSignupCreate, @@ -49,6 +50,7 @@ const mapDispatchToProps = { startLnd, createWallet, submitNewWallet, + recoverOldWallet, unlockWallet, setSignupCreate, setSignupImport, @@ -177,6 +179,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => { changeStep: dispatchProps.changeStep, startLnd: dispatchProps.startLnd, submitNewWallet: dispatchProps.submitNewWallet, + recoverOldWallet: dispatchProps.recoverOldWallet, connectionTypeProps, connectionDetailProps, connectionConfirmProps, diff --git a/app/lib/lnd/methods/walletController.js b/app/lib/lnd/methods/walletController.js index 30920a08..aa3bde63 100644 --- a/app/lib/lnd/methods/walletController.js +++ b/app/lib/lnd/methods/walletController.js @@ -140,7 +140,7 @@ export function unlockWallet(walletUnlocker, { wallet_password }) { */ export function initWallet( walletUnlocker, - { wallet_password, cipher_seed_mnemonic, aezeed_passphrase = '' } + { wallet_password, cipher_seed_mnemonic, aezeed_passphrase = '', recovery_window } ) { return new Promise((resolve, reject) => { walletUnlocker.initWallet( @@ -148,7 +148,7 @@ export function initWallet( wallet_password: Buffer.from(wallet_password), cipher_seed_mnemonic, aezeed_passphrase: Buffer.from(aezeed_passphrase, 'hex'), - recovery_window: 250 + recovery_window }, (err, data) => { if (err) { diff --git a/app/reducers/onboarding.js b/app/reducers/onboarding.js index 7bd4e754..3a23a221 100644 --- a/app/reducers/onboarding.js +++ b/app/reducers/onboarding.js @@ -39,6 +39,8 @@ export const LOADING_EXISTING_WALLET = 'LOADING_EXISTING_WALLET' export const CREATING_NEW_WALLET = 'CREATING_NEW_WALLET' +export const RECOVERING_OLD_WALLET = 'RECOVERING_OLD_WALLET' + export const UNLOCKING_WALLET = 'UNLOCKING_WALLET' export const WALLET_UNLOCKED = 'WALLET_UNLOCKED' export const SET_UNLOCK_WALLET_ERROR = 'SET_UNLOCK_WALLET_ERROR' @@ -227,6 +229,19 @@ export const submitNewWallet = ( dispatch({ type: CREATING_NEW_WALLET }) } +export const recoverOldWallet = ( + wallet_password, + cipher_seed_mnemonic, + aezeed_passphrase +) => dispatch => { + // once the user submits the data needed to start LND we will alert the app that it should start LND + ipcRenderer.send('walletUnlocker', { + msg: 'initWallet', + data: { wallet_password, cipher_seed_mnemonic, aezeed_passphrase, recovery_window: 250 } + }) + dispatch({ type: RECOVERING_OLD_WALLET }) +} + // Listener for errors connecting to LND gRPC export const startOnboarding = (event, lndConfig = {}) => dispatch => { dispatch(setConnectionType(lndConfig.type)) @@ -365,6 +380,8 @@ const ACTION_HANDLERS = { [CREATING_NEW_WALLET]: state => ({ ...state, creatingNewWallet: true }), + [RECOVERING_OLD_WALLET]: state => ({ ...state, recoveringOldWallet: true }), + [UNLOCKING_WALLET]: state => ({ ...state, unlockingWallet: true }), [WALLET_UNLOCKED]: state => ({ ...state, @@ -489,6 +506,7 @@ const initialState = { createWalletPassword: '', createWalletPasswordConfirmation: '', creatingNewWallet: false, + recoveringOldWallet: false, existingWalletDir: null, unlockingWallet: false,