Skip to content

Commit

Permalink
Merge pull request #522 from secinthenet/fix-seed-only-coin-switch2
Browse files Browse the repository at this point in the history
fix "blank mnemonic" errors when using only seed
  • Loading branch information
iancoleman committed Oct 8, 2021
2 parents 58d8444 + 874b6d4 commit c3c7ceb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
network.onSelect();
adjustNetworkForSegwit();
if (seed != null) {
phraseChanged();
seedChanged()
}
else {
rootKeyChanged();
Expand All @@ -232,12 +232,7 @@
else {
DOM.bip32path.prop("readonly", true);
clients[clientIndex].onSelect();
if (seed != null) {
phraseChanged();
}
else {
rootKeyChanged();
}
rootKeyChanged();
}
}

Expand Down Expand Up @@ -491,7 +486,9 @@
else {
network = libs.bitcoin.networks.litecoinXprv;
}
phraseChanged();
// Can't use rootKeyChanged because validation will fail as we changed
// the network but the version bytes stayed as previously.
seedChanged();
}

function toggleSplitMnemonic() {
Expand Down Expand Up @@ -637,7 +634,7 @@
}

function bitcoinCashAddressTypeChange() {
phraseChanged();
rootKeyChanged();
}

function toggleIndexes() {
Expand Down
19 changes: 19 additions & 0 deletions tests/spec/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3076,6 +3076,25 @@ it('Uses the correct derivation for altcoins with root keys', function(done) {
});
});

// Changing the coin when only using a seed (without a mnemonic phrase) should
// work the same as the previous test.
// See https://github.com/iancoleman/bip39/pull/486
it('Uses the correct derivation for altcoins with seed and without mnemonic phrase', function(done) {
driver.findElement(By.css('.seed'))
.sendKeys("20da140d3dd1df8713cefcc4d54ce0e445b4151027a1ab567b832f6da5fcc5afc1c3a3f199ab78b8e0ab4652efd7f414ac2c9a3b81bceb879a70f377aa0a58f3");
driver.sleep(generateDelay).then(function() {
// 4) switch from bitcoin to viacoin
selectNetwork("VIA - Viacoin");
driver.sleep(generateDelay).then(function() {
// 5) ensure the derived address is correct
getFirstAddress(function(address) {
expect(address).toBe("Vq9Eq4N5SQnjqZvxtxzo7hZPW5XnyJsmXT");
done();
});
});
});
});

// Selecting a language with no existing phrase should generate a phrase in
// that language.
it('Generate a random phrase when language is selected and no current phrase', function(done) {
Expand Down

0 comments on commit c3c7ceb

Please sign in to comment.