diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 41e765fb..296703c4 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -993,7 +993,7 @@ public class AppController implements Initializable { public void openFile(File file) { if(isWalletFile(file)) { openWalletFile(file, true); - } else if(isSignatureFile(file)) { + } else if(isSignatureOrManifestFile(file)) { verifyDownload(new ActionEvent(file, rootStack)); } else { openTransactionFile(file); diff --git a/src/main/java/com/sparrowwallet/sparrow/AppServices.java b/src/main/java/com/sparrowwallet/sparrow/AppServices.java index 8f25979f..ef71dbfc 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppServices.java @@ -885,7 +885,7 @@ public class AppServices { for(File file : openFiles) { if(isWalletFile(file)) { EventManager.get().post(new RequestWalletOpenEvent(openWindow, file)); - } else if(isSignatureFile(file)) { + } else if(isSignatureOrManifestFile(file)) { EventManager.get().post(new RequestVerifyDownloadEvent(openWindow, file)); } else { EventManager.get().post(new RequestTransactionOpenEvent(openWindow, file)); diff --git a/src/main/java/com/sparrowwallet/sparrow/control/DownloadVerifierDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/DownloadVerifierDialog.java index 335f4463..dd553060 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/DownloadVerifierDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/DownloadVerifierDialog.java @@ -364,7 +364,7 @@ public class DownloadVerifierDialog extends Dialog { return field; } - public Map getManifest(File manifest) throws IOException, InvalidManifestException { + public static Map getManifest(File manifest) throws IOException, InvalidManifestException { if(manifest.length() > MAX_VALID_MANIFEST_SIZE) { throw new InvalidManifestException(); } @@ -374,7 +374,7 @@ public class DownloadVerifierDialog extends Dialog { } } - public Map getManifest(InputStream manifestStream) throws IOException { + public static Map getManifest(InputStream manifestStream) throws IOException { Map manifest = new HashMap<>(); BufferedReader reader = new BufferedReader(new InputStreamReader(manifestStream, StandardCharsets.UTF_8)); @@ -477,8 +477,23 @@ public class DownloadVerifierDialog extends Dialog { return message; } - public static boolean isSignatureFile(File file) { - return file != null && file.getName().length() > 4 && SIGNATURE_EXTENSIONS.stream().anyMatch(ext -> file.getName().toLowerCase(Locale.ROOT).endsWith("." + ext)); + public static boolean isSignatureOrManifestFile(File file) { + if(file != null) { + if(file.getName().length() > 4 && SIGNATURE_EXTENSIONS.stream().anyMatch(ext -> file.getName().toLowerCase(Locale.ROOT).endsWith("." + ext))) { + return true; + } + + if(file.getName().toLowerCase(Locale.ROOT).endsWith(".txt")) { + try { + Map manifest = getManifest(file); + return !manifest.isEmpty(); + } catch(Exception e) { + //ignore + } + } + } + + return false; } private static class Header extends GridPane {