indicate when entered seed is of unsupported electrum type

This commit is contained in:
Craig Raw 2021-10-06 08:23:08 +02:00
parent 3b730a1711
commit b9d6cb17d4
4 changed files with 22 additions and 6 deletions

2
drongo

@ -1 +1 @@
Subproject commit e0302cef22a3dd9401f9070318fec5ea15543bd7 Subproject commit 2fd7e8e7e417212c7b6555a463f25004650d3a01

View file

@ -17,6 +17,10 @@ public class DateLabel extends CopyableLabel {
} }
public static String getShortDateFormat(Date date) { public static String getShortDateFormat(Date date) {
if(date == null) {
return "Unknown";
}
Date now = new Date(); Date now = new Date();
long elapsed = (now.getTime() - date.getTime()) / 1000; long elapsed = (now.getTime() - date.getTime()) / 1000;

View file

@ -262,7 +262,13 @@ public class MnemonicKeystoreImportPane extends TitledDescriptionPane {
importer.getKeystore(wallet.getScriptType().getDefaultDerivation(), wordEntriesProperty.get(), passphraseProperty.get()); importer.getKeystore(wallet.getScriptType().getDefaultDerivation(), wordEntriesProperty.get(), passphraseProperty.get());
validChecksum = true; validChecksum = true;
} catch(ImportException e) { } catch(ImportException e) {
//ignore if(e.getCause() instanceof MnemonicException.MnemonicTypeException) {
invalidLabel.setText("Unsupported Electrum seed");
invalidLabel.setTooltip(new Tooltip("Seeds created in Electrum do not follow the BIP39 standard. Import the Electrum wallet file directly."));
} else {
invalidLabel.setText("Invalid checksum");
invalidLabel.setTooltip(null);
}
} }
} }

View file

@ -1,10 +1,7 @@
package com.sparrowwallet.sparrow.io; package com.sparrowwallet.sparrow.io;
import com.sparrowwallet.drongo.crypto.ChildNumber; import com.sparrowwallet.drongo.crypto.ChildNumber;
import com.sparrowwallet.drongo.wallet.Bip39MnemonicCode; import com.sparrowwallet.drongo.wallet.*;
import com.sparrowwallet.drongo.wallet.DeterministicSeed;
import com.sparrowwallet.drongo.wallet.Keystore;
import com.sparrowwallet.drongo.wallet.WalletModel;
import java.util.List; import java.util.List;
@ -31,6 +28,15 @@ public class Bip39 implements KeystoreMnemonicImport {
DeterministicSeed seed = new DeterministicSeed(mnemonicWords, passphrase, System.currentTimeMillis(), DeterministicSeed.Type.BIP39); DeterministicSeed seed = new DeterministicSeed(mnemonicWords, passphrase, System.currentTimeMillis(), DeterministicSeed.Type.BIP39);
return Keystore.fromSeed(seed, derivation); return Keystore.fromSeed(seed, derivation);
} catch (Exception e) { } catch (Exception e) {
try {
ElectrumMnemonicCode.INSTANCE.check(mnemonicWords);
throw new ImportException(new MnemonicException.MnemonicTypeException(DeterministicSeed.Type.ELECTRUM));
} catch(Exception ex) {
if(ex instanceof ImportException && ex.getCause() instanceof MnemonicException.MnemonicTypeException) {
throw (ImportException)ex;
}
}
throw new ImportException(e); throw new ImportException(e);
} }
} }