From eb55b9420a03c20a690a65d987979379fa4ab689 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 12 Apr 2021 13:42:36 +0200 Subject: [PATCH] add option to strip sensitive info from psbt serialization --- drongo | 2 +- .../sparrowwallet/sparrow/AppController.java | 18 +++++++++++++----- .../com/sparrowwallet/sparrow/app.fxml | 2 ++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drongo b/drongo index 428054d3..b7038b19 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 428054d375b638bb7e08133fdffe6f1dd438cca9 +Subproject commit b7038b19f9d44cfc50af151927b06f9aada9d5e7 diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 072052eb..a735e6c4 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -532,14 +532,22 @@ public class AppController implements Initializable { } public void savePSBTBinary(ActionEvent event) { - savePSBT(false); + savePSBT(false, true); } public void savePSBTText(ActionEvent event) { - savePSBT(true); + savePSBT(true, true); } - public void savePSBT(boolean asText) { + public void savePSBTBinaryNoXpubs(ActionEvent event) { + savePSBT(false, false); + } + + public void savePSBTTextNoXpubs(ActionEvent event) { + savePSBT(true, false); + } + + public void savePSBT(boolean asText, boolean includeXpubs) { Tab selectedTab = tabs.getSelectionModel().getSelectedItem(); TabData tabData = (TabData)selectedTab.getUserData(); if(tabData.getType() == TabData.TabType.TRANSACTION) { @@ -571,10 +579,10 @@ public class AppController implements Initializable { try(FileOutputStream outputStream = new FileOutputStream(file)) { if(asText) { PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)); - writer.print(transactionTabData.getPsbt().toBase64String()); + writer.print(transactionTabData.getPsbt().toBase64String(includeXpubs)); writer.flush(); } else { - outputStream.write(transactionTabData.getPsbt().serialize()); + outputStream.write(transactionTabData.getPsbt().serialize(includeXpubs)); } } catch(IOException e) { log.error("Error saving PSBT", e); diff --git a/src/main/resources/com/sparrowwallet/sparrow/app.fxml b/src/main/resources/com/sparrowwallet/sparrow/app.fxml index 4e362ebb..137ce39d 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/app.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/app.fxml @@ -30,6 +30,8 @@ + +