diff --git a/src/main/java/com/sparrowwallet/sparrow/control/TransactionHexArea.java b/src/main/java/com/sparrowwallet/sparrow/control/TransactionHexArea.java index b0d1aae0..9aa25e94 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/TransactionHexArea.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/TransactionHexArea.java @@ -165,8 +165,9 @@ public class TransactionHexArea extends CodeArea { for(int j = 0; j < witness.getPushes().size(); j++) { byte[] push = witness.getPushes().get(j); VarInt witnessLen = new VarInt(push.length); + boolean isSignature = isSignature(push); cursor = addSegment(segments, cursor, witnessLen.getSizeInBytes() * 2, i, j, "witness-" + getIndexedStyleClass(i, selectedInputIndex, "length")); - cursor = addSegment(segments, cursor, (int) witnessLen.value * 2, i, j, "witness-" + getIndexedStyleClass(i, selectedInputIndex, "data")); + cursor = addSegment(segments, cursor, (int) witnessLen.value * 2, i, j, "witness-" + getIndexedStyleClass(i, selectedInputIndex, "data" + (isSignature ? "-signature" : ""))); } } } @@ -204,6 +205,19 @@ public class TransactionHexArea extends CodeArea { return "other"; } + private boolean isSignature(byte[] data) { + if(data.length >= 64) { + try { + TransactionSignature.decodeFromBitcoin(data, false); + return true; + } catch(Exception e) { + //ignore, not a signature + } + } + + return false; + } + private String describeTransactionPart(Collection styles) { String style = ""; Integer index = null; @@ -238,7 +252,7 @@ public class TransactionHexArea extends CodeArea { case "output-pubkeyscript" -> "Output #" + index + " scriptPubKey"; case "witness-count" -> "Input #" + index + " witness count"; case "witness-length" -> "Input #" + index + " witness #" + witnessIndex + " length"; - case "witness-data" -> "Input #" + index + " witness #" + witnessIndex + " data"; + case "witness-data", "witness-data-signature" -> "Input #" + index + " witness #" + witnessIndex + " data"; case "locktime" -> "Locktime"; default -> ""; }; diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.css b/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.css index 5b56f847..bc1ae3be 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.css +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.css @@ -17,6 +17,7 @@ .witness-count { -fx-fill: color-0 } .witness-length { -fx-fill: color-6 } .witness-data { -fx-fill: color-6 } +.witness-data-signature { -fx-fill: color-3 } .locktime { -fx-fill: color-7 } diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/input.css b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.css index 8ff120d4..ee964aa9 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/input.css +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.css @@ -21,6 +21,7 @@ .witness-count { -fx-fill: color-0 } .witness-length { -fx-fill: color-7 } .witness-data { -fx-fill: color-6 } +.witness-data-signature { -fx-fill: color-3 } .locktime { -fx-fill: color-grey } diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/inputs.css b/src/main/resources/com/sparrowwallet/sparrow/transaction/inputs.css index 996be0f2..2a4fb18e 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/inputs.css +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/inputs.css @@ -17,6 +17,7 @@ .witness-count { -fx-fill: color-0 } .witness-length { -fx-fill: color-7 } .witness-data { -fx-fill: color-6 } +.witness-data-signature { -fx-fill: color-3 } .locktime { -fx-fill: color-grey } diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/output.css b/src/main/resources/com/sparrowwallet/sparrow/transaction/output.css index 8cb66ec6..6ba47b16 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/output.css +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/output.css @@ -19,6 +19,7 @@ .witness-count { -fx-fill: color-grey } .witness-length { -fx-fill: color-grey } .witness-data { -fx-fill: color-grey } +.witness-data-signature { -fx-fill: color-grey } .locktime { -fx-fill: color-grey } diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/outputs.css b/src/main/resources/com/sparrowwallet/sparrow/transaction/outputs.css index 6b06ecef..67a33363 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/outputs.css +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/outputs.css @@ -17,6 +17,7 @@ .witness-count { -fx-fill: color-grey } .witness-length { -fx-fill: color-grey } .witness-data { -fx-fill: color-grey } +.witness-data-signature { -fx-fill: color-grey } .locktime { -fx-fill: color-grey }