Browse Source

Merge pull request #688 from mrfelton/fix/sync-restart

fix(lnd): prevent full chain sync on wallet init
renovate/lint-staged-8.x
JimmyMow 6 years ago
committed by GitHub
parent
commit
2a6f95cf8f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/components/Onboarding/Onboarding.js
  2. 3
      app/containers/Root.js
  3. 4
      app/lib/lnd/methods/walletController.js
  4. 18
      app/reducers/onboarding.js

6
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)
}}
>
<RecoverForm {...recoverFormProps} />
@ -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

3
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,

4
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) {

18
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,

Loading…
Cancel
Save