add menu items to copy psbt to clipboard in hex or base64

This commit is contained in:
Craig Raw 2021-08-16 08:48:14 +02:00
parent 2caee79df4
commit 74b4f51640
2 changed files with 29 additions and 2 deletions

View file

@ -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<WalletTabData> getOpenWalletTabData() { public List<WalletTabData> getOpenWalletTabData() {
List<WalletTabData> openWalletTabData = new ArrayList<>(); List<WalletTabData> openWalletTabData = new ArrayList<>();

View file

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