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

Commit f655361

Browse files
authored
Merge pull request #1247 from lightninglabs/dev/blank-seed-original
Dev/blank seed original
2 parents bce02fe + be12641 commit f655361

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
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: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class WalletAction {
4343
* @param {number} options.index The seed index
4444
*/
4545
setSeedVerify({ word = '', index }) {
46-
this._store.wallet.seedVerify[index] = word.toLowerCase();
46+
this._store.wallet.seedVerify[index] = word.toLowerCase().trim();
4747
}
4848

4949
/**
@@ -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: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ describe('Action Wallet Unit Tests', () => {
5858
wallet.setSeedVerify({ word: 'FOO', index: 1 });
5959
expect(store.wallet.seedVerify[1], 'to equal', 'foo');
6060
});
61+
62+
it('should trim whitespace', () => {
63+
wallet.setSeedVerify({ word: ' foo ', index: 1 });
64+
expect(store.wallet.seedVerify[1], 'to equal', 'foo');
65+
});
6166
});
6267

6368
describe('initSetPassword()', () => {
@@ -237,13 +242,15 @@ describe('Action Wallet Unit Tests', () => {
237242
});
238243

239244
it('init wallet correctly during restore', async () => {
245+
const restoreSeed = ['hi', 'hello', 'hola'];
246+
store.restoreSeedMnemonic = restoreSeed;
240247
store.settings.restoring = true;
241248
wallet.setNewPassword({ password: 'secret123' });
242249
wallet.setPasswordVerify({ password: 'secret123' });
243250
await wallet.checkNewPassword();
244251
expect(wallet.initWallet, 'was called with', {
245252
walletPassword: 'secret123',
246-
seedMnemonic: ['foo', 'bar', 'baz'],
253+
seedMnemonic: restoreSeed,
247254
recoveryWindow: RECOVERY_WINDOW,
248255
});
249256
});
@@ -367,25 +374,25 @@ describe('Action Wallet Unit Tests', () => {
367374
it('should clear attributes and navigate to view', () => {
368375
store.wallet.restoreIndex = 42;
369376
wallet.initRestoreWallet();
370-
expect(store.seedMnemonic.length, 'to equal', 24);
377+
expect(store.restoreSeedMnemonic.length, 'to equal', 24);
371378
expect(store.wallet.restoreIndex, 'to equal', 0);
372379
expect(nav.goRestoreSeed, 'was called once');
373380
});
374381
});
375382

376383
describe('setRestoreSeed()', () => {
377384
beforeEach(() => {
378-
store.seedMnemonic = Array(24).fill('');
385+
store.restoreSeedMnemonic = Array(24).fill('');
379386
});
380387

381388
it('should clear attributes', () => {
382389
wallet.setRestoreSeed({ word: 'foo', index: 1 });
383-
expect(store.seedMnemonic[1], 'to equal', 'foo');
390+
expect(store.restoreSeedMnemonic[1], 'to equal', 'foo');
384391
});
385392

386393
it('should trim whitespace', () => {
387394
wallet.setRestoreSeed({ word: ' foo ', index: 1 });
388-
expect(store.seedMnemonic[1], 'to equal', 'foo');
395+
expect(store.restoreSeedMnemonic[1], 'to equal', 'foo');
389396
});
390397
});
391398

0 commit comments

Comments
 (0)