From 9060a4b284c1cdf8e437b66a0dd9f2bfafd590f5 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 22 Feb 2021 14:55:31 +0200 Subject: [PATCH] ensure psbt files always have correct extension --- src/main/java/com/sparrowwallet/sparrow/AppController.java | 4 ++++ .../sparrowwallet/sparrow/transaction/HeadersController.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index ae4b39fb..f5bb0237 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -447,6 +447,10 @@ public class AppController implements Initializable { File file = fileChooser.showSaveDialog(window); if(file != null) { + if(!saveTx && !file.getName().toLowerCase().endsWith(".psbt")) { + file = new File(file.getAbsolutePath() + ".psbt"); + } + try { try(PrintWriter writer = new PrintWriter(file, StandardCharsets.UTF_8)) { if(saveTx) { diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index 6d1941be..01e8c693 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -665,6 +665,10 @@ public class HeadersController extends TransactionFormController implements Init File file = fileChooser.showSaveDialog(window); if(file != null) { + if(!file.getName().toLowerCase().endsWith(".psbt")) { + file = new File(file.getAbsolutePath() + ".psbt"); + } + try { try(PrintWriter writer = new PrintWriter(file, StandardCharsets.UTF_8)) { writer.print(headersForm.getPsbt().toBase64String());