diff --git a/README.md b/README.md index 36b96fc2..1e935b59 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # Sparrow -Bitcoin Transaction Editor +Bitcoin Wallet & Transaction Editor To clone this project, use `git clone --recursive git@github.com:craigraw/sparrow.git` ## Various ways to hex dump a file without spaces: -xxd -p file | tr -d '\n' -hexdump -ve '1/1 "%.2x"' -od -t x1 -An file | tr -d '\n ' \ No newline at end of file +`xxd -p file | tr -d '\n'` + +`hexdump -ve '1/1 "%.2x"'` + +`od -t x1 -An file | tr -d '\n '` \ No newline at end of file diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/InputController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/InputController.java index 8df91117..64db9a10 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/InputController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/InputController.java @@ -108,12 +108,12 @@ public class InputController extends TransactionFormController implements Initia //TODO: Enable select outpoint when wallet present outpointSelect.setDisable(true); - initializeScriptFields(txInput); + initializeScriptFields(txInput, psbtInput); initializeStatusFields(txInput); initializeLocktimeFields(txInput); } - private void initializeScriptFields(TransactionInput txInput) { + private void initializeScriptFields(TransactionInput txInput, PSBTInput psbtInput) { //TODO: Is this safe? Script redeemScript = txInput.getScriptSig().getFirstNestedScript(); diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/OutputController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/OutputController.java index b8d0bf6c..2945c0fa 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/OutputController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/OutputController.java @@ -1,6 +1,11 @@ package com.sparrowwallet.sparrow.transaction; +import com.sparrowwallet.drongo.protocol.TransactionOutput; +import javafx.fxml.FXML; import javafx.fxml.Initializable; +import javafx.scene.control.TextField; +import org.fxmisc.richtext.CodeArea; +import tornadofx.control.Fieldset; import java.net.URL; import java.util.ResourceBundle; @@ -8,12 +13,32 @@ import java.util.ResourceBundle; public class OutputController extends TransactionFormController implements Initializable { private OutputForm outputForm; + @FXML + private Fieldset outputFieldset; + + @FXML + private TextField value; + + @FXML + private CodeArea scriptPubKeyArea; + @Override public void initialize(URL location, ResourceBundle resources) { } + public void initializeView() { + TransactionOutput txOutput = outputForm.getTransactionOutput(); + + outputFieldset.setText("Output #" + txOutput.getIndex()); + value.setText(txOutput.getValue() + " sats"); + + scriptPubKeyArea.clear(); + appendScript(scriptPubKeyArea, txOutput.getScript(), null, null); + } + public void setModel(OutputForm form) { this.outputForm = form; + initializeView(); } } diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionFormController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionFormController.java index f679feeb..f5e1f03a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionFormController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionFormController.java @@ -57,7 +57,23 @@ public abstract class TransactionFormController { } protected void appendScript(CodeArea codeArea, Script script, Script redeemScript, Script witnessScript) { - if(ScriptPattern.isP2WPKH(script)) { + if(ScriptPattern.isP2PKH(script)) { + codeArea.append(script.getChunks().get(0).toString(), "script-opcode"); + codeArea.append(" ", ""); + codeArea.append(script.getChunks().get(1).toString(), "script-opcode"); + codeArea.append(" ", ""); + codeArea.append("", "script-hash"); + codeArea.append(" ", ""); + codeArea.append(script.getChunks().get(3).toString(), "script-opcode"); + codeArea.append(" ", ""); + codeArea.append(script.getChunks().get(4).toString(), "script-opcode"); + } else if(ScriptPattern.isP2SH(script)) { + codeArea.append(script.getChunks().get(0).toString(), "script-opcode"); + codeArea.append(" ", ""); + codeArea.append("", "script-hash"); + codeArea.append(" ", ""); + codeArea.append(script.getChunks().get(2).toString(), "script-opcode"); + } else if(ScriptPattern.isP2WPKH(script)) { codeArea.append(script.getChunks().get(0).toString(), "script-opcode"); codeArea.append(" ", ""); codeArea.append("", "script-hash"); diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/input.css b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.css index 89c183d2..9e309ad1 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/input.css +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.css @@ -24,37 +24,4 @@ .locktime { -fx-fill: #e5e5e6 } -.script-nest { -fx-fill: #000000 } -.script-opcode { -fx-fill: #0184bc; } -.script-hash { -fx-fill: #986801; } -.script-signature { -fx-fill: #50a14f } -.script-pubkey { -fx-fill: #a626a4 } -.script-redeem { -fx-fill: #ca1243 } -.script-other { -fx-fill: #a0a1a7 } - -.uneditable-codearea { - -fx-font: 14px Courier; - -fx-padding: 4; -} - -.virtualized-scroll-pane { - -fx-background-color: linear-gradient(to bottom, derive(-fx-text-box-border, -10%), -fx-text-box-border), linear-gradient(from 0px 0px to 0px 5px, derive(-fx-control-inner-background, -9%), -fx-control-inner-background); - -fx-background-insets: 0, 1; - -fx-background-radius: 3, 2; -} - -.virtualized-scroll-pane:disabled { - -fx-opacity: 0.5; -} - -.virtualized-scroll-pane .styled-text-area { - -fx-background-insets: 0px; - -fx-background-color: transparent; -} - -.virtualized-scroll-pane .scroll-bar:vertical { - -fx-background-radius: 0 2 2 0; - -fx-padding: 0.08333325em 0.08333325em 0.08333325em 0; - -fx-border-insets: 0.08333325em 0.08333325em 0.08333325em 0; - -fx-background-insets: 0.08333325em 0.08333325em 0.08333325em 0; -} + diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml index 083f21ca..59dfc8ff 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/input.fxml @@ -13,7 +13,7 @@ - + diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/output.fxml b/src/main/resources/com/sparrowwallet/sparrow/transaction/output.fxml index 3a98ec75..51d0e31a 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/output.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/output.fxml @@ -5,6 +5,48 @@ + + + + + + - + + + + + + + + + + + + + + +
+
+ + + +
+
+ + + +
+
+ + + + + + + + + +
+
diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/script.css b/src/main/resources/com/sparrowwallet/sparrow/transaction/script.css new file mode 100644 index 00000000..7c266bdb --- /dev/null +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/script.css @@ -0,0 +1,34 @@ +.script-nest { -fx-fill: #000000 } +.script-opcode { -fx-fill: #0184bc } +.script-hash { -fx-fill: #986801 } +.script-signature { -fx-fill: #50a14f } +.script-pubkey { -fx-fill: #a626a4 } +.script-redeem { -fx-fill: #ca1243 } +.script-other { -fx-fill: #a0a1a7 } + +.uneditable-codearea { + -fx-font: 14px Courier; + -fx-padding: 4; +} + +.virtualized-scroll-pane { + -fx-background-color: linear-gradient(to bottom, derive(-fx-text-box-border, -10%), -fx-text-box-border), linear-gradient(from 0px 0px to 0px 5px, derive(-fx-control-inner-background, -9%), -fx-control-inner-background); + -fx-background-insets: 0, 1; + -fx-background-radius: 3, 2; +} + +.virtualized-scroll-pane:disabled { + -fx-opacity: 0.5; +} + +.virtualized-scroll-pane .styled-text-area { + -fx-background-insets: 0px; + -fx-background-color: transparent; +} + +.virtualized-scroll-pane .scroll-bar:vertical { + -fx-background-radius: 0 2 2 0; + -fx-padding: 0.08333325em 0.08333325em 0.08333325em 0; + -fx-border-insets: 0.08333325em 0.08333325em 0.08333325em 0; + -fx-background-insets: 0.08333325em 0.08333325em 0.08333325em 0; +} \ No newline at end of file