mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 20:56:45 +00:00
identify and color code signatures in transaction hex witness data
This commit is contained in:
parent
95d8201bd9
commit
281fad5970
6 changed files with 21 additions and 2 deletions
|
@ -165,8 +165,9 @@ public class TransactionHexArea extends CodeArea {
|
||||||
for(int j = 0; j < witness.getPushes().size(); j++) {
|
for(int j = 0; j < witness.getPushes().size(); j++) {
|
||||||
byte[] push = witness.getPushes().get(j);
|
byte[] push = witness.getPushes().get(j);
|
||||||
VarInt witnessLen = new VarInt(push.length);
|
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, 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";
|
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<String> styles) {
|
private String describeTransactionPart(Collection<String> styles) {
|
||||||
String style = "";
|
String style = "";
|
||||||
Integer index = null;
|
Integer index = null;
|
||||||
|
@ -238,7 +252,7 @@ public class TransactionHexArea extends CodeArea {
|
||||||
case "output-pubkeyscript" -> "Output #" + index + " scriptPubKey";
|
case "output-pubkeyscript" -> "Output #" + index + " scriptPubKey";
|
||||||
case "witness-count" -> "Input #" + index + " witness count";
|
case "witness-count" -> "Input #" + index + " witness count";
|
||||||
case "witness-length" -> "Input #" + index + " witness #" + witnessIndex + " length";
|
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";
|
case "locktime" -> "Locktime";
|
||||||
default -> "";
|
default -> "";
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
.witness-count { -fx-fill: color-0 }
|
.witness-count { -fx-fill: color-0 }
|
||||||
.witness-length { -fx-fill: color-6 }
|
.witness-length { -fx-fill: color-6 }
|
||||||
.witness-data { -fx-fill: color-6 }
|
.witness-data { -fx-fill: color-6 }
|
||||||
|
.witness-data-signature { -fx-fill: color-3 }
|
||||||
|
|
||||||
.locktime { -fx-fill: color-7 }
|
.locktime { -fx-fill: color-7 }
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
.witness-count { -fx-fill: color-0 }
|
.witness-count { -fx-fill: color-0 }
|
||||||
.witness-length { -fx-fill: color-7 }
|
.witness-length { -fx-fill: color-7 }
|
||||||
.witness-data { -fx-fill: color-6 }
|
.witness-data { -fx-fill: color-6 }
|
||||||
|
.witness-data-signature { -fx-fill: color-3 }
|
||||||
|
|
||||||
.locktime { -fx-fill: color-grey }
|
.locktime { -fx-fill: color-grey }
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
.witness-count { -fx-fill: color-0 }
|
.witness-count { -fx-fill: color-0 }
|
||||||
.witness-length { -fx-fill: color-7 }
|
.witness-length { -fx-fill: color-7 }
|
||||||
.witness-data { -fx-fill: color-6 }
|
.witness-data { -fx-fill: color-6 }
|
||||||
|
.witness-data-signature { -fx-fill: color-3 }
|
||||||
|
|
||||||
.locktime { -fx-fill: color-grey }
|
.locktime { -fx-fill: color-grey }
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
.witness-count { -fx-fill: color-grey }
|
.witness-count { -fx-fill: color-grey }
|
||||||
.witness-length { -fx-fill: color-grey }
|
.witness-length { -fx-fill: color-grey }
|
||||||
.witness-data { -fx-fill: color-grey }
|
.witness-data { -fx-fill: color-grey }
|
||||||
|
.witness-data-signature { -fx-fill: color-grey }
|
||||||
|
|
||||||
.locktime { -fx-fill: color-grey }
|
.locktime { -fx-fill: color-grey }
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
.witness-count { -fx-fill: color-grey }
|
.witness-count { -fx-fill: color-grey }
|
||||||
.witness-length { -fx-fill: color-grey }
|
.witness-length { -fx-fill: color-grey }
|
||||||
.witness-data { -fx-fill: color-grey }
|
.witness-data { -fx-fill: color-grey }
|
||||||
|
.witness-data-signature { -fx-fill: color-grey }
|
||||||
|
|
||||||
.locktime { -fx-fill: color-grey }
|
.locktime { -fx-fill: color-grey }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue