Browse Source

indicate when entered seed is of unsupported electrum type

terminal
Craig Raw 3 years ago
parent
commit
b9d6cb17d4
  1. 2
      drongo
  2. 4
      src/main/java/com/sparrowwallet/sparrow/control/DateLabel.java
  3. 8
      src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java
  4. 14
      src/main/java/com/sparrowwallet/sparrow/io/Bip39.java

2
drongo

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

4
src/main/java/com/sparrowwallet/sparrow/control/DateLabel.java

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

8
src/main/java/com/sparrowwallet/sparrow/control/MnemonicKeystoreImportPane.java

@ -262,7 +262,13 @@ public class MnemonicKeystoreImportPane extends TitledDescriptionPane {
importer.getKeystore(wallet.getScriptType().getDefaultDerivation(), wordEntriesProperty.get(), passphraseProperty.get());
validChecksum = true;
} 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);
}
}
}

14
src/main/java/com/sparrowwallet/sparrow/io/Bip39.java

@ -1,10 +1,7 @@
package com.sparrowwallet.sparrow.io;
import com.sparrowwallet.drongo.crypto.ChildNumber;
import com.sparrowwallet.drongo.wallet.Bip39MnemonicCode;
import com.sparrowwallet.drongo.wallet.DeterministicSeed;
import com.sparrowwallet.drongo.wallet.Keystore;
import com.sparrowwallet.drongo.wallet.WalletModel;
import com.sparrowwallet.drongo.wallet.*;
import java.util.List;
@ -31,6 +28,15 @@ public class Bip39 implements KeystoreMnemonicImport {
DeterministicSeed seed = new DeterministicSeed(mnemonicWords, passphrase, System.currentTimeMillis(), DeterministicSeed.Type.BIP39);
return Keystore.fromSeed(seed, derivation);
} 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);
}
}

Loading…
Cancel
Save