ensure keystore source and wallet model is always filled in

This commit is contained in:
Craig Raw 2020-04-29 15:43:57 +02:00
parent d740895bd6
commit cbffaf3e41
2 changed files with 13 additions and 1 deletions

View file

@ -66,7 +66,7 @@ public class Keystore {
} }
public boolean isValid() { public boolean isValid() {
if(label == null || keyDerivation == null || extendedPublicKey == null) { if(label == null || source == null || walletModel == null || keyDerivation == null || extendedPublicKey == null) {
return false; return false;
} }
@ -85,6 +85,8 @@ public class Keystore {
public Keystore copy() { public Keystore copy() {
Keystore copy = new Keystore(label); Keystore copy = new Keystore(label);
copy.setSource(source);
copy.setWalletModel(walletModel);
if(keyDerivation != null) { if(keyDerivation != null) {
copy.setKeyDerivation(keyDerivation.copy()); copy.setKeyDerivation(keyDerivation.copy());
} }

View file

@ -15,6 +15,16 @@ public enum WalletModel {
return this.toString(); return this.toString();
} }
public static WalletModel fromType(String type) {
for(WalletModel model : values()) {
if(model.getType().equals(type)) {
return model;
}
}
return null;
}
public String toDisplayString() { public String toDisplayString() {
String line = this.toString().toLowerCase(); String line = this.toString().toLowerCase();
String[] words = line.split("_"); String[] words = line.split("_");