Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit be12641

Browse files
valentinewallacetanx
authored andcommitted
Fix blank seed error: don't reuse seed store prop for restore seed
1 parent 24a627a commit be12641

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

src/action/index-mobile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ store.seedMnemonic = [
242242
'quit',
243243
'cashew',
244244
];
245+
store.restoreSeedMnemonic = Array(24).fill('');
245246
store.logs = [
246247
'[14:00:24.995] [info] Using lnd in path lnd',
247248
'Checking for update',

src/action/wallet.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class WalletAction {
5353
* @param {number} options.index The seed index
5454
*/
5555
setRestoreSeed({ word, index }) {
56-
this._store.seedMnemonic[index] = word.trim();
56+
this._store.restoreSeedMnemonic[index] = word.trim();
5757
}
5858

5959
/**
@@ -221,7 +221,9 @@ class WalletAction {
221221
await this.initWallet({
222222
walletPassword: newPassword,
223223
recoveryWindow: this._store.settings.restoring ? RECOVERY_WINDOW : 0,
224-
seedMnemonic: this._store.seedMnemonic.toJSON(),
224+
seedMnemonic: this._store.settings.restoring
225+
? this._store.restoreSeedMnemonic.toJSON()
226+
: this._store.seedMnemonic.toJSON(),
225227
});
226228
}
227229

@@ -320,7 +322,7 @@ class WalletAction {
320322
* @return {undefined}
321323
*/
322324
initRestoreWallet() {
323-
this._store.seedMnemonic = Array(24).fill('');
325+
this._store.restoreSeedMnemonic = Array(24).fill('');
324326
this._store.wallet.restoreIndex = 0;
325327
this._nav.goRestoreSeed();
326328
}

src/store.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export class Store {
8282
},
8383
paymentRequest: null,
8484
seedMnemonic: [],
85+
restoreSeedMnemonic: [],
8586
notifications: [],
8687
unseenNtfnCount: 0,
8788
logs: '',

src/view/restore-seed-mobile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const RestoreSeedView = ({ store, wallet }) => (
5757
{store.restoreVerifyIndexes.map((seedIndex, i) => (
5858
<SeedEntry
5959
seedIndex={seedIndex}
60-
value={store.seedMnemonic[seedIndex - 1]}
60+
value={store.restoreSeedMnemonic[seedIndex - 1]}
6161
onChangeText={word =>
6262
wallet.setRestoreSeed({ word, index: seedIndex - 1 })
6363
}

src/view/restore-seed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const RestoreSeedView = ({ store, wallet }) => (
4747
{store.restoreVerifyIndexes.map((seedIndex, i) => (
4848
<SeedEntry
4949
seedIndex={seedIndex}
50-
value={store.seedMnemonic[seedIndex - 1]}
50+
value={store.restoreSeedMnemonic[seedIndex - 1]}
5151
onChangeText={word =>
5252
wallet.setRestoreSeed({ word, index: seedIndex - 1 })
5353
}

test/unit/action/wallet.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,15 @@ describe('Action Wallet Unit Tests', () => {
242242
});
243243

244244
it('init wallet correctly during restore', async () => {
245+
const restoreSeed = ['hi', 'hello', 'hola'];
246+
store.restoreSeedMnemonic = restoreSeed;
245247
store.settings.restoring = true;
246248
wallet.setNewPassword({ password: 'secret123' });
247249
wallet.setPasswordVerify({ password: 'secret123' });
248250
await wallet.checkNewPassword();
249251
expect(wallet.initWallet, 'was called with', {
250252
walletPassword: 'secret123',
251-
seedMnemonic: ['foo', 'bar', 'baz'],
253+
seedMnemonic: restoreSeed,
252254
recoveryWindow: RECOVERY_WINDOW,
253255
});
254256
});
@@ -372,25 +374,25 @@ describe('Action Wallet Unit Tests', () => {
372374
it('should clear attributes and navigate to view', () => {
373375
store.wallet.restoreIndex = 42;
374376
wallet.initRestoreWallet();
375-
expect(store.seedMnemonic.length, 'to equal', 24);
377+
expect(store.restoreSeedMnemonic.length, 'to equal', 24);
376378
expect(store.wallet.restoreIndex, 'to equal', 0);
377379
expect(nav.goRestoreSeed, 'was called once');
378380
});
379381
});
380382

381383
describe('setRestoreSeed()', () => {
382384
beforeEach(() => {
383-
store.seedMnemonic = Array(24).fill('');
385+
store.restoreSeedMnemonic = Array(24).fill('');
384386
});
385387

386388
it('should clear attributes', () => {
387389
wallet.setRestoreSeed({ word: 'foo', index: 1 });
388-
expect(store.seedMnemonic[1], 'to equal', 'foo');
390+
expect(store.restoreSeedMnemonic[1], 'to equal', 'foo');
389391
});
390392

391393
it('should trim whitespace', () => {
392394
wallet.setRestoreSeed({ word: ' foo ', index: 1 });
393-
expect(store.seedMnemonic[1], 'to equal', 'foo');
395+
expect(store.restoreSeedMnemonic[1], 'to equal', 'foo');
394396
});
395397
});
396398

0 commit comments

Comments
 (0)