mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46: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 {
|
||||
if(!attemptImportWallet(file, password)) {
|
||||
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();
|
||||
}
|
||||
|
@ -822,7 +822,7 @@ public class AppController implements Initializable {
|
|||
} catch(Exception e) {
|
||||
if(!attemptImportWallet(file, null)) {
|
||||
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) {
|
||||
throw new StorageException("Not a Sparrow wallet - invalid header");
|
||||
}
|
||||
try {
|
||||
byte[] decodedHeader = Base64.getDecoder().decode(header);
|
||||
byte[] magic = Arrays.copyOfRange(decodedHeader, 0, HEADER_MAGIC_1.length());
|
||||
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");
|
||||
}
|
||||
} else {
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
secureRandom.nextBytes(salt);
|
||||
|
|
Loading…
Reference in a new issue