mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-05 05:46:44 +00:00
fix import of encrypted json wallet on linux
This commit is contained in:
parent
c566dea232
commit
cb41a1ed66
2 changed files with 8 additions and 4 deletions
|
@ -101,9 +101,12 @@ public class Sparrow implements WalletImport, WalletExport {
|
||||||
java.nio.file.Files.copy(inputStream, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
java.nio.file.Files.copy(inputStream, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
PersistenceType persistenceType = Storage.detectPersistenceType(tempFile);
|
PersistenceType persistenceType = Storage.detectPersistenceType(tempFile);
|
||||||
persistenceType = (persistenceType == null ? PersistenceType.JSON : persistenceType);
|
persistenceType = (persistenceType == null ? PersistenceType.JSON : persistenceType);
|
||||||
File tempTypedFile = new File(tempFile.getParentFile(), tempFile.getName() + "." + persistenceType.getExtension());
|
if(persistenceType != PersistenceType.JSON || !isEncrypted(tempFile)) {
|
||||||
tempFile.renameTo(tempTypedFile);
|
File tempTypedFile = new File(tempFile.getParentFile(), tempFile.getName() + "." + persistenceType.getExtension());
|
||||||
tempFile = tempTypedFile;
|
tempFile.renameTo(tempTypedFile);
|
||||||
|
tempFile = tempTypedFile;
|
||||||
|
}
|
||||||
|
|
||||||
storage = new Storage(persistenceType, tempFile);
|
storage = new Storage(persistenceType, tempFile);
|
||||||
if(!isEncrypted(tempFile)) {
|
if(!isEncrypted(tempFile)) {
|
||||||
wallet = storage.loadUnencryptedWallet().getWallet();
|
wallet = storage.loadUnencryptedWallet().getWallet();
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.attribute.PosixFilePermission;
|
import java.nio.file.attribute.PosixFilePermission;
|
||||||
import java.nio.file.attribute.PosixFilePermissions;
|
import java.nio.file.attribute.PosixFilePermissions;
|
||||||
|
@ -373,7 +374,7 @@ public class Storage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PersistenceType detectPersistenceType(File walletFile) {
|
public static PersistenceType detectPersistenceType(File walletFile) {
|
||||||
try(Reader reader = new FileReader(walletFile)) {
|
try(Reader reader = new FileReader(walletFile, StandardCharsets.UTF_8)) {
|
||||||
int firstChar = reader.read();
|
int firstChar = reader.read();
|
||||||
|
|
||||||
if(firstChar == 'U' || firstChar == '{') {
|
if(firstChar == 'U' || firstChar == '{') {
|
||||||
|
|
Loading…
Reference in a new issue