mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
improve open wallet error dialog message
This commit is contained in:
parent
7e93b6b198
commit
3a885b3a28
2 changed files with 11 additions and 7 deletions
|
@ -809,7 +809,7 @@ public class AppController implements Initializable {
|
||||||
} else {
|
} else {
|
||||||
if(!attemptImportWallet(file, password)) {
|
if(!attemptImportWallet(file, password)) {
|
||||||
log.error("Error Opening Wallet", exception);
|
log.error("Error Opening Wallet", exception);
|
||||||
showErrorDialog("Error Opening Wallet", exception.getMessage());
|
showErrorDialog("Error Opening Wallet", exception.getMessage() == null ? "Unsupported file format" : exception.getMessage());
|
||||||
}
|
}
|
||||||
password.clear();
|
password.clear();
|
||||||
}
|
}
|
||||||
|
@ -822,7 +822,7 @@ public class AppController implements Initializable {
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
if(!attemptImportWallet(file, null)) {
|
if(!attemptImportWallet(file, null)) {
|
||||||
log.error("Error opening wallet", e);
|
log.error("Error opening wallet", e);
|
||||||
showErrorDialog("Error Opening Wallet", e.getMessage());
|
showErrorDialog("Error Opening Wallet", e.getMessage() == null ? "Unsupported file format" : e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,12 +222,16 @@ public class Storage {
|
||||||
if(read != BINARY_HEADER_LENGTH) {
|
if(read != BINARY_HEADER_LENGTH) {
|
||||||
throw new StorageException("Not a Sparrow wallet - invalid header");
|
throw new StorageException("Not a Sparrow wallet - invalid header");
|
||||||
}
|
}
|
||||||
byte[] decodedHeader = Base64.getDecoder().decode(header);
|
try {
|
||||||
byte[] magic = Arrays.copyOfRange(decodedHeader, 0, HEADER_MAGIC_1.length());
|
byte[] decodedHeader = Base64.getDecoder().decode(header);
|
||||||
if(!HEADER_MAGIC_1.equals(new String(magic, StandardCharsets.UTF_8))) {
|
byte[] magic = Arrays.copyOfRange(decodedHeader, 0, HEADER_MAGIC_1.length());
|
||||||
throw new StorageException("Not a Sparrow wallet - invalid magic");
|
if(!HEADER_MAGIC_1.equals(new String(magic, StandardCharsets.UTF_8))) {
|
||||||
|
throw new StorageException("Not a Sparrow wallet - invalid magic");
|
||||||
|
}
|
||||||
|
salt = Arrays.copyOfRange(decodedHeader, HEADER_MAGIC_1.length(), decodedHeader.length);
|
||||||
|
} catch(IllegalArgumentException e) {
|
||||||
|
throw new StorageException("Not a Sparrow wallet - invalid header");
|
||||||
}
|
}
|
||||||
salt = Arrays.copyOfRange(decodedHeader, HEADER_MAGIC_1.length(), decodedHeader.length);
|
|
||||||
} else {
|
} else {
|
||||||
SecureRandom secureRandom = new SecureRandom();
|
SecureRandom secureRandom = new SecureRandom();
|
||||||
secureRandom.nextBytes(salt);
|
secureRandom.nextBytes(salt);
|
||||||
|
|
Loading…
Reference in a new issue