From 74b4f516406df026bd028b55d837c8c57e0fca16 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 16 Aug 2021 08:48:14 +0200 Subject: [PATCH] add menu items to copy psbt to clipboard in hex or base64 --- .../sparrowwallet/sparrow/AppController.java | 21 +++++++++++++++++++ .../com/sparrowwallet/sparrow/app.fxml | 10 +++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 4033919b..a7df3be4 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -619,6 +619,27 @@ public class AppController implements Initializable { } } + public void copyPSBTHex(ActionEvent event) { + copyPSBT(false); + } + + public void copyPSBTBase64(ActionEvent event) { + copyPSBT(true); + } + + public void copyPSBT(boolean asBase64) { + Tab selectedTab = tabs.getSelectionModel().getSelectedItem(); + TabData tabData = (TabData)selectedTab.getUserData(); + if(tabData.getType() == TabData.TabType.TRANSACTION) { + TransactionTabData transactionTabData = (TransactionTabData)tabData; + String data = asBase64 ? transactionTabData.getPsbt().toBase64String() : transactionTabData.getPsbt().toString(); + + ClipboardContent content = new ClipboardContent(); + content.putString(data); + Clipboard.getSystemClipboard().setContent(content); + } + } + public List getOpenWalletTabData() { List openWalletTabData = new ArrayList<>(); diff --git a/src/main/resources/com/sparrowwallet/sparrow/app.fxml b/src/main/resources/com/sparrowwallet/sparrow/app.fxml index 65337cd3..4e066a8a 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/app.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/app.fxml @@ -31,8 +31,14 @@ - - + + + + + + + +