diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/InputForm.java b/src/main/java/com/sparrowwallet/sparrow/transaction/InputForm.java
index eceb08e7..462fd581 100644
--- a/src/main/java/com/sparrowwallet/sparrow/transaction/InputForm.java
+++ b/src/main/java/com/sparrowwallet/sparrow/transaction/InputForm.java
@@ -13,6 +13,10 @@ public class InputForm extends TransactionForm {
this.transactionInput = transactionInput;
}
+ public TransactionInput getTransactionInput() {
+ return transactionInput;
+ }
+
public Node getContents() throws IOException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("input.fxml"));
Node node = loader.load();
diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/OutputForm.java b/src/main/java/com/sparrowwallet/sparrow/transaction/OutputForm.java
index 7fe8eeae..34297219 100644
--- a/src/main/java/com/sparrowwallet/sparrow/transaction/OutputForm.java
+++ b/src/main/java/com/sparrowwallet/sparrow/transaction/OutputForm.java
@@ -13,6 +13,10 @@ public class OutputForm extends TransactionForm {
this.transactionOutput = transactionOutput;
}
+ public TransactionOutput getTransactionOutput() {
+ return transactionOutput;
+ }
+
public Node getContents() throws IOException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("output.fxml"));
Node node = loader.load();
diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionController.java
index a69ab2ff..0b53c3b9 100644
--- a/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionController.java
+++ b/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionController.java
@@ -33,6 +33,8 @@ public class TransactionController implements Initializable, TransactionListener
private Transaction transaction;
private PSBT psbt;
+ private int selectedInputIndex = -1;
+ private int selectedOutputIndex = -1;
@Override
public void initialize(URL location, ResourceBundle resources) {
@@ -94,6 +96,18 @@ public class TransactionController implements Initializable, TransactionListener
Parent parent = (Parent)node;
txhex.getStylesheets().clear();
txhex.getStylesheets().addAll(parent.getStylesheets());
+
+ selectedInputIndex = -1;
+ selectedOutputIndex = -1;
+ if(transactionForm instanceof InputForm) {
+ InputForm inputForm = (InputForm)transactionForm;
+ selectedInputIndex = inputForm.getTransactionInput().getIndex();
+ } else if(transactionForm instanceof OutputForm) {
+ OutputForm outputForm = (OutputForm)transactionForm;
+ selectedOutputIndex = outputForm.getTransactionOutput().getIndex();
+ }
+
+ refreshTxHex();
}
} catch (IOException e) {
throw new IllegalStateException("Can't find pane", e);
@@ -132,13 +146,14 @@ public class TransactionController implements Initializable, TransactionListener
cursor = addText(hex, cursor, numInputs.getSizeInBytes()*2, "num-inputs");
//Inputs
- for(TransactionInput input : transaction.getInputs()) {
- cursor = addText(hex, cursor, 32*2, "input-hash");
- cursor = addText(hex, cursor, 4*2, "input-index");
+ for (int i = 0; i < transaction.getInputs().size(); i++) {
+ TransactionInput input = transaction.getInputs().get(i);
+ cursor = addText(hex, cursor, 32*2, "input-" + getIndexedStyleClass(i, selectedInputIndex, "hash"));
+ cursor = addText(hex, cursor, 4*2, "input-" + getIndexedStyleClass(i, selectedInputIndex, "index"));
VarInt scriptLen = new VarInt(input.getScriptBytes().length);
- cursor = addText(hex, cursor, scriptLen.getSizeInBytes()*2, "input-sigscript-length");
- cursor = addText(hex, cursor, (int)scriptLen.value*2, "input-sigscript");
- cursor = addText(hex, cursor, 4*2, "input-sequence");
+ cursor = addText(hex, cursor, scriptLen.getSizeInBytes()*2, "input-" + getIndexedStyleClass(i, selectedInputIndex, "sigscript-length"));
+ cursor = addText(hex, cursor, (int)scriptLen.value*2, "input-" + getIndexedStyleClass(i, selectedInputIndex, "sigscript"));
+ cursor = addText(hex, cursor, 4*2, "input-" + getIndexedStyleClass(i, selectedInputIndex, "sequence"));
}
//Number of outputs
@@ -146,11 +161,12 @@ public class TransactionController implements Initializable, TransactionListener
cursor = addText(hex, cursor, numOutputs.getSizeInBytes()*2, "num-outputs");
//Outputs
- for(TransactionOutput output : transaction.getOutputs()) {
- cursor = addText(hex, cursor, 8*2, "output-value");
+ for (int i = 0; i < transaction.getOutputs().size(); i++) {
+ TransactionOutput output = transaction.getOutputs().get(i);
+ cursor = addText(hex, cursor, 8*2, "output-" + getIndexedStyleClass(i, selectedOutputIndex, "value"));
VarInt scriptLen = new VarInt(output.getScriptBytes().length);
- cursor = addText(hex, cursor, scriptLen.getSizeInBytes()*2, "output-pubkeyscript-length");
- cursor = addText(hex, cursor, (int)scriptLen.value*2, "output-pubkeyscript");
+ cursor = addText(hex, cursor, scriptLen.getSizeInBytes()*2, "output-" + getIndexedStyleClass(i, selectedOutputIndex, "pubkeyscript-length"));
+ cursor = addText(hex, cursor, (int)scriptLen.value*2, "output-" + getIndexedStyleClass(i, selectedOutputIndex, "pubkeyscript"));
}
if(transaction.hasWitnesses()) {
@@ -169,8 +185,16 @@ public class TransactionController implements Initializable, TransactionListener
}
}
- private int addText(String hex, int cursor, int length, String description) {
- txhex.append(hex.substring(cursor, cursor+=length), description + "-color");
+ private String getIndexedStyleClass(int iterableIndex, int selectedIndex, String styleClass) {
+ if(selectedIndex == -1 || selectedIndex == iterableIndex) {
+ return styleClass;
+ }
+
+ return "other";
+ }
+
+ private int addText(String hex, int cursor, int length, String styleClass) {
+ txhex.append(hex.substring(cursor, cursor+=length), styleClass);
return cursor;
}
diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.css b/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.css
index 20180d6d..bc522676 100644
--- a/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.css
+++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.css
@@ -1,18 +1,18 @@
-.version-color { -fx-fill: #986801 }
-.segwit-marker-color { -fx-fill: #000000 }
-.segwit-flag-color { -fx-fill: #4078f2 }
+.version { -fx-fill: #986801 }
+.segwit-marker { -fx-fill: #000000 }
+.segwit-flag { -fx-fill: #4078f2 }
-.num-inputs-color { -fx-fill: #ca1243 }
-.input-hash-color { -fx-fill: #0184bc }
-.input-index-color { -fx-fill: #0184bc }
-.input-sigscript-length-color { -fx-fill: #0184bc }
-.input-sigscript-color { -fx-fill: #0184bc }
-.input-sequence-color { -fx-fill: #0184bc }
+.num-inputs { -fx-fill: #ca1243 }
+.input-hash { -fx-fill: #0184bc }
+.input-index { -fx-fill: #0184bc }
+.input-sigscript-length { -fx-fill: #0184bc }
+.input-sigscript { -fx-fill: #0184bc }
+.input-sequence { -fx-fill: #0184bc }
-.num-outputs-color { -fx-fill: #ca1243 }
-.output-value-color { -fx-fill: #50a14f }
-.output-pubkeyscript-length-color { -fx-fill: #50a14f }
-.output-pubkeyscript-color { -fx-fill: #50a14f }
+.num-outputs { -fx-fill: #ca1243 }
+.output-value { -fx-fill: #50a14f }
+.output-pubkeyscript-length { -fx-fill: #50a14f }
+.output-pubkeyscript { -fx-fill: #50a14f }
-.witnesses-color { -fx-fill: #a626a4 }
-.locktime-color { -fx-fill: #986801 }
\ No newline at end of file
+.witnesses { -fx-fill: #a626a4 }
+.locktime { -fx-fill: #986801 }
\ No newline at end of file
diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/input.css b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.css
new file mode 100644
index 00000000..ebba946c
--- /dev/null
+++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.css
@@ -0,0 +1,21 @@
+.version { -fx-fill: #e5e5e6 }
+.segwit-marker { -fx-fill: #e5e5e6 }
+.segwit-flag { -fx-fill: #e5e5e6 }
+
+.num-inputs { -fx-fill: #e5e5e6 }
+.input-other { -fx-fill: #e5e5e6 }
+
+.input-hash { -fx-fill: #0184bc }
+.input-index { -fx-fill: #000000 }
+.input-sigscript-length { -fx-fill: #a626a4 }
+.input-sigscript { -fx-fill: #50a14f }
+.input-sequence { -fx-fill: #986801 }
+
+.num-outputs { -fx-fill: #e5e5e6 }
+.output-value { -fx-fill: #e5e5e6 }
+.output-pubkeyscript-length { -fx-fill: #e5e5e6 }
+.output-pubkeyscript { -fx-fill: #e5e5e6 }
+
+.witnesses { -fx-fill: #e5e5e6 }
+.locktime { -fx-fill: #e5e5e6 }
+
diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml
index 891d21fd..44ec9f61 100644
--- a/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml
+++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml
@@ -5,10 +5,42 @@
+
+
+
+
-