add option to strip sensitive info from psbt serialization

This commit is contained in:
Craig Raw 2021-04-12 13:42:36 +02:00
parent 3b3e46983f
commit eb55b9420a
3 changed files with 16 additions and 6 deletions

2
drongo

@ -1 +1 @@
Subproject commit 428054d375b638bb7e08133fdffe6f1dd438cca9
Subproject commit b7038b19f9d44cfc50af151927b06f9aada9d5e7

View file

@ -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);

View file

@ -30,6 +30,8 @@
<Menu fx:id="savePSBT" mnemonicParsing="false" text="Save PSBT">
<MenuItem text="As Binary..." onAction="#savePSBTBinary" accelerator="Shortcut+S"/>
<MenuItem text="As Base64..." onAction="#savePSBTText"/>
<MenuItem text="As Binary (No Xpubs)..." onAction="#savePSBTBinaryNoXpubs"/>
<MenuItem text="As Base64 (No Xpubs)..." onAction="#savePSBTTextNoXpubs"/>
</Menu>
<SeparatorMenuItem />
<MenuItem mnemonicParsing="false" text="Import Wallet..." onAction="#importWallet"/>