diff --git a/src/main/java/com/sparrowwallet/sparrow/control/TitledDescriptionPane.java b/src/main/java/com/sparrowwallet/sparrow/control/TitledDescriptionPane.java index f2aab341..349132d5 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/TitledDescriptionPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/TitledDescriptionPane.java @@ -125,7 +125,7 @@ public class TitledDescriptionPane extends TitledPane { contentBox.setPadding(new Insets(10, 30, 10, 30)); double width = TextUtils.computeTextWidth(details.getFont(), message, 0.0D); - double numLines = Math.max(1, width / 400); + double numLines = Math.max(1, Math.ceil(width / 400d)); //Handle long words like txids OptionalDouble maxWordLength = Arrays.stream(message.split(" ")).mapToDouble(word -> TextUtils.computeTextWidth(details.getFont(), message, 0.0D)).max(); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java b/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java index 6a6e675e..28d789d7 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java @@ -266,20 +266,7 @@ public class Electrum implements KeystoreFileImport, WalletImport, WalletExport @Override public boolean isEncrypted(File file) { - if(FileType.BINARY.equals(IOUtils.getFileType(file))) { - try { - try(Scanner s = new Scanner(file)) { - if(s.hasNextLine() && s.nextLine().equals("{")) { - return false; - } - } - return true; - } catch(FileNotFoundException e) { - //Can't happen - } - } - - return false; + return (FileType.BINARY.equals(IOUtils.getFileType(file))); } @Override diff --git a/src/main/java/com/sparrowwallet/sparrow/io/IOUtils.java b/src/main/java/com/sparrowwallet/sparrow/io/IOUtils.java index 839c9aab..624e94b8 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/IOUtils.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/IOUtils.java @@ -7,7 +7,7 @@ public class IOUtils { public static FileType getFileType(File file) { try { String type = Files.probeContentType(file.toPath()); - if (type == null) { + if(type == null) { if(file.getName().toLowerCase().endsWith("txn") || file.getName().toLowerCase().endsWith("psbt")) { return FileType.TEXT; } @@ -17,6 +17,8 @@ public class IOUtils { String line = br.readLine(); if(line.startsWith("01000000") || line.startsWith("cHNid")) { return FileType.TEXT; + } else if(line.startsWith("{")) { + return FileType.JSON; } } }