ensure psbt files always have correct extension

This commit is contained in:
Craig Raw 2021-02-22 14:55:31 +02:00
parent 759de8e047
commit 9060a4b284
2 changed files with 8 additions and 0 deletions

View file

@ -447,6 +447,10 @@ public class AppController implements Initializable {
File file = fileChooser.showSaveDialog(window); File file = fileChooser.showSaveDialog(window);
if(file != null) { if(file != null) {
if(!saveTx && !file.getName().toLowerCase().endsWith(".psbt")) {
file = new File(file.getAbsolutePath() + ".psbt");
}
try { try {
try(PrintWriter writer = new PrintWriter(file, StandardCharsets.UTF_8)) { try(PrintWriter writer = new PrintWriter(file, StandardCharsets.UTF_8)) {
if(saveTx) { if(saveTx) {

View file

@ -665,6 +665,10 @@ public class HeadersController extends TransactionFormController implements Init
File file = fileChooser.showSaveDialog(window); File file = fileChooser.showSaveDialog(window);
if(file != null) { if(file != null) {
if(!file.getName().toLowerCase().endsWith(".psbt")) {
file = new File(file.getAbsolutePath() + ".psbt");
}
try { try {
try(PrintWriter writer = new PrintWriter(file, StandardCharsets.UTF_8)) { try(PrintWriter writer = new PrintWriter(file, StandardCharsets.UTF_8)) {
writer.print(headersForm.getPsbt().toBase64String()); writer.print(headersForm.getPsbt().toBase64String());