fix "blank mnemonic" errors when using only seed

This is a follow up to #486 which was reverted because of a failed test which should now pass
This commit is contained in:
Sylvia G
2021-10-02 20:55:08 +03:00
parent c4f0c2908f
commit 874b6d4e08
2 changed files with 25 additions and 9 deletions

View File

@@ -210,7 +210,7 @@
network.onSelect(); network.onSelect();
adjustNetworkForSegwit(); adjustNetworkForSegwit();
if (seed != null) { if (seed != null) {
phraseChanged(); seedChanged()
} }
else { else {
rootKeyChanged(); rootKeyChanged();
@@ -225,12 +225,7 @@
else { else {
DOM.bip32path.prop("readonly", true); DOM.bip32path.prop("readonly", true);
clients[clientIndex].onSelect(); clients[clientIndex].onSelect();
if (seed != null) { rootKeyChanged();
phraseChanged();
}
else {
rootKeyChanged();
}
} }
} }
@@ -455,7 +450,9 @@
else { else {
network = libs.bitcoin.networks.litecoinXprv; 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() { function toggleSplitMnemonic() {
@@ -601,7 +598,7 @@
} }
function bitcoinCashAddressTypeChange() { function bitcoinCashAddressTypeChange() {
phraseChanged(); rootKeyChanged();
} }
function toggleIndexes() { function toggleIndexes() {

View File

@@ -3045,6 +3045,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 // Selecting a language with no existing phrase should generate a phrase in
// that language. // that language.
it('Generate a random phrase when language is selected and no current phrase', function(done) { it('Generate a random phrase when language is selected and no current phrase', function(done) {