diff --git a/src/main/java/com/sparrowwallet/sparrow/control/TransactionHexArea.java b/src/main/java/com/sparrowwallet/sparrow/control/TransactionHexArea.java index 45ce3885..b0d1aae0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/TransactionHexArea.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/TransactionHexArea.java @@ -5,6 +5,7 @@ import com.sparrowwallet.drongo.protocol.*; import javafx.application.Platform; import javafx.geometry.Point2D; import javafx.scene.control.ContextMenu; +import javafx.scene.control.IndexRange; import javafx.scene.control.Label; import javafx.scene.control.MenuItem; import javafx.scene.input.Clipboard; @@ -25,6 +26,7 @@ public class TransactionHexArea extends CodeArea { private static final int TRUNCATE_AT = 30000; private static final int SEGMENTS_INTERVAL = 250; + private String fullHex; private List previousSegmentList = new ArrayList<>(); public TransactionHexArea() { @@ -37,7 +39,7 @@ public class TransactionHexArea extends CodeArea { ByteArrayOutputStream baos = new ByteArrayOutputStream(); transaction.bitcoinSerializeToStream(baos); - String fullHex = Utils.bytesToHex(baos.toByteArray()); + fullHex = Utils.bytesToHex(baos.toByteArray()); String hex = fullHex; if(hex.length() > TRUNCATE_AT) { hex = hex.substring(0, TRUNCATE_AT); @@ -242,6 +244,18 @@ public class TransactionHexArea extends CodeArea { }; } + @Override + public void copy() { + IndexRange selection = getSelection(); + if(fullHex != null && selection.getLength() == getLength()) { + ClipboardContent content = new ClipboardContent(); + content.putString(fullHex); + Clipboard.getSystemClipboard().setContent(content); + } else { + super.copy(); + } + } + private static class TransactionSegment { public TransactionSegment(int start, int length, Integer index, Integer witnessIndex, String style) { this.start = start;