From 0cd97649cc70b4be8d9efed9429fe182d4f30cf9 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Wed, 17 Jun 2020 12:45:46 +0200 Subject: [PATCH] tx viewer fix various --- .../sparrow/control/TransactionIdDialog.java | 5 +++-- .../sparrow/transaction/HeadersController.java | 12 ++++++++++++ .../sparrow/transaction/InputController.java | 2 +- .../sparrow/transaction/InputsController.java | 7 ++++++- .../sparrow/transaction/TransactionData.java | 2 +- .../sparrowwallet/sparrow/transaction/headers.fxml | 9 ++++++++- 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/TransactionIdDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/TransactionIdDialog.java index 0ae296f2..587cc4b7 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/TransactionIdDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/TransactionIdDialog.java @@ -3,12 +3,12 @@ package com.sparrowwallet.sparrow.control; import com.sparrowwallet.drongo.Utils; import com.sparrowwallet.drongo.protocol.Sha256Hash; import com.sparrowwallet.sparrow.AppController; -import com.sparrowwallet.sparrow.io.Storage; import javafx.application.Platform; import javafx.beans.binding.Bindings; import javafx.beans.binding.BooleanBinding; import javafx.scene.control.*; import javafx.scene.layout.VBox; +import javafx.scene.text.Font; import org.controlsfx.control.textfield.CustomTextField; import org.controlsfx.control.textfield.TextFields; import org.controlsfx.glyphfont.FontAwesome; @@ -23,13 +23,14 @@ public class TransactionIdDialog extends Dialog { public TransactionIdDialog() { this.txid = (CustomTextField) TextFields.createClearableTextField(); + txid.setFont(Font.font ("Courier", txid.getFont().getSize())); final DialogPane dialogPane = getDialogPane(); setTitle("Load Transaction"); dialogPane.setHeaderText("Enter the transaction ID:"); dialogPane.getStylesheets().add(AppController.class.getResource("general.css").toExternalForm()); dialogPane.getButtonTypes().addAll(ButtonType.CANCEL); - dialogPane.setPrefWidth(380); + dialogPane.setPrefWidth(550); dialogPane.setPrefHeight(200); Glyph wallet = new Glyph("FontAwesome", FontAwesome.Glyph.BITCOIN); diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index 09715a6d..fc026772 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -13,6 +13,7 @@ import com.sparrowwallet.sparrow.control.CopyableLabel; import com.sparrowwallet.sparrow.event.BlockTransactionFetchedEvent; import com.sparrowwallet.sparrow.event.TransactionChangedEvent; import com.sparrowwallet.sparrow.event.TransactionLocktimeChangedEvent; +import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.*; @@ -250,11 +251,16 @@ public class HeadersController extends TransactionFormController implements Init } BlockTransaction inputTx = inputTransactions.get(input.getOutpoint().getHash()); + if(inputTx == null) { + inputTx = headersForm.getInputTransactions().get(input.getOutpoint().getHash()); + } + if(inputTx == null) { if(headersForm.allInputsFetched()) { throw new IllegalStateException("Cannot find transaction for hash " + input.getOutpoint().getHash()); } else { //Still paging + fee.setText("Unknown (" + headersForm.getMaxInputFetched() + " of " + headersForm.getTransaction().getInputs().size() + " inputs fetched)"); return null; } } @@ -318,6 +324,12 @@ public class HeadersController extends TransactionFormController implements Init id.setText(headersForm.getTransaction().calculateTxId(false).toString()); } + public void copyId(ActionEvent event) { + ClipboardContent content = new ClipboardContent(); + content.putString(headersForm.getTransaction().getTxId().toString()); + Clipboard.getSystemClipboard().setContent(content); + } + @Subscribe public void transactionChanged(TransactionChangedEvent event) { if(headersForm.getTransaction().equals(event.getTransaction())) { diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/InputController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/InputController.java index 07ef3de9..35e8895d 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/InputController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/InputController.java @@ -493,7 +493,7 @@ public class InputController extends TransactionFormController implements Initia } @Subscribe - public void transctionLocktimeChanged(TransactionLocktimeChangedEvent event) { + public void transactionLocktimeChanged(TransactionLocktimeChangedEvent event) { if(event.getTransaction().equals(inputForm.getTransaction())) { locktimeAbsolute.setText(Long.toString(event.getTransaction().getLocktime())); } diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/InputsController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/InputsController.java index 93ea7c39..046bcf93 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/InputsController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/InputsController.java @@ -124,11 +124,16 @@ public class InputsController extends TransactionFormController implements Initi return; } else { BlockTransaction inputTx = inputTransactions.get(input.getOutpoint().getHash()); + if(inputTx == null) { + inputTx = inputsForm.getInputTransactions().get(input.getOutpoint().getHash()); + } + if(inputTx == null) { if(inputsForm.allInputsFetched()) { throw new IllegalStateException("Cannot find transaction for hash " + input.getOutpoint().getHash()); } else { //Still paging + total.setText("Unknown (" + inputsForm.getMaxInputFetched() + " of " + inputsForm.getTransaction().getInputs().size() + " inputs fetched)"); return; } } @@ -151,7 +156,7 @@ public class InputsController extends TransactionFormController implements Initi @Subscribe public void blockTransactionFetched(BlockTransactionFetchedEvent event) { - if(event.getTxId().equals(inputsForm.getTransaction().getTxId()) && inputsForm.getPsbt() != null) { + if(event.getTxId().equals(inputsForm.getTransaction().getTxId()) && inputsForm.getPsbt() == null) { updateBlockTransactionInputs(event.getInputTransactions()); } } diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionData.java b/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionData.java index 9c1fca72..09680c87 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionData.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionData.java @@ -77,7 +77,7 @@ public class TransactionData { } public boolean allInputsFetched() { - return minInputFetched == 0 && maxInputFetched == transaction.getOutputs().size(); + return minInputFetched == 0 && maxInputFetched == transaction.getInputs().size(); } public List getOutputTransactions() { diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml b/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml index 9497d0c6..fbce7bc9 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml @@ -14,6 +14,8 @@ + + @@ -28,8 +30,13 @@
- + +