From 4078c61d6bc6758ec722a6467bcd18cf004c866e Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 16 Mar 2021 12:07:55 +0200 Subject: [PATCH] add tab label icons, show loading and failure status there --- .../sparrowwallet/sparrow/AppController.java | 106 +++++++++++++++++- .../event/BlockTransactionFetchedEvent.java | 19 +--- .../BlockTransactionOutputsFetchedEvent.java | 9 +- .../sparrowwallet/sparrow/event/TabEvent.java | 3 +- .../event/TransactionReferencesEvent.java | 20 ++++ .../TransactionReferencesFailedEvent.java | 21 ++++ .../TransactionReferencesFinishedEvent.java | 22 ++++ .../TransactionReferencesStartedEvent.java | 13 +++ .../event/WalletHistoryFailedEvent.java | 16 +++ .../event/WalletHistoryFinishedEvent.java | 4 - .../event/WalletHistoryStartedEvent.java | 10 +- .../sparrow/net/ElectrumServer.java | 2 +- .../sparrow/net/SimpleElectrumServerRpc.java | 3 + .../transaction/HeadersController.java | 6 + .../transaction/TransactionController.java | 8 +- .../sparrow/wallet/WalletForm.java | 8 +- .../com/sparrowwallet/sparrow/app.css | 4 + .../com/sparrowwallet/sparrow/darktheme.css | 4 + src/main/resources/logback.xml | 2 + 19 files changed, 241 insertions(+), 39 deletions(-) create mode 100644 src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesEvent.java create mode 100644 src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesFailedEvent.java create mode 100644 src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesFinishedEvent.java create mode 100644 src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesStartedEvent.java create mode 100644 src/main/java/com/sparrowwallet/sparrow/event/WalletHistoryFailedEvent.java diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index f7108056..5a2f51c4 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -21,6 +21,7 @@ import com.sparrowwallet.drongo.psbt.PSBTParseException; import com.sparrowwallet.drongo.wallet.*; import com.sparrowwallet.sparrow.control.*; import com.sparrowwallet.sparrow.event.*; +import com.sparrowwallet.sparrow.glyphfont.FontAwesome5; import com.sparrowwallet.sparrow.io.*; import com.sparrowwallet.sparrow.net.ElectrumServer; import com.sparrowwallet.sparrow.net.ServerType; @@ -53,6 +54,8 @@ import javafx.stage.*; import javafx.util.Duration; import org.controlsfx.control.Notifications; import org.controlsfx.control.StatusBar; +import org.controlsfx.glyphfont.FontAwesome; +import org.controlsfx.glyphfont.Glyph; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -70,6 +73,8 @@ public class AppController implements Initializable { private static final Logger log = LoggerFactory.getLogger(AppController.class); public static final String DRAG_OVER_CLASS = "drag-over"; + public static final double TAB_LABEL_GRAPHIC_OPACITY_INACTIVE = 0.8; + public static final double TAB_LABEL_GRAPHIC_OPACITY_ACTIVE = 0.95; @FXML private MenuItem saveTransaction; @@ -163,7 +168,11 @@ public class AppController implements Initializable { }); tabs.getSelectionModel().selectedItemProperty().addListener((observable, old_val, selectedTab) -> { + tabs.getTabs().forEach(tab -> ((Label)tab.getGraphic()).getGraphic().setOpacity(TAB_LABEL_GRAPHIC_OPACITY_INACTIVE)); if(selectedTab != null) { + Label tabLabel = (Label)selectedTab.getGraphic(); + tabLabel.getGraphic().setOpacity(TAB_LABEL_GRAPHIC_OPACITY_ACTIVE); + TabData tabData = (TabData)selectedTab.getUserData(); if(tabData.getType() == TabData.TabType.TRANSACTION) { EventManager.get().post(new TransactionTabSelectedEvent(selectedTab)); @@ -920,7 +929,14 @@ public class AppController implements Initializable { if(!name.equals(wallet.getName())) { wallet.setName(name); } - Tab tab = new Tab(name); + Tab tab = new Tab(""); + Glyph glyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.WALLET); + glyph.setFontSize(9.0); + glyph.setOpacity(TAB_LABEL_GRAPHIC_OPACITY_ACTIVE); + Label tabLabel = new Label(name); + tabLabel.setGraphic(glyph); + tabLabel.setGraphicTextGap(5.0); + tab.setGraphic(tabLabel); tab.setContextMenu(getTabContextMenu(tab)); tab.setClosable(true); FXMLLoader walletLoader = new FXMLLoader(getClass().getResource("wallet/wallet.fxml")); @@ -1057,7 +1073,14 @@ public class AppController implements Initializable { tabName = "[" + transaction.getTxId().toString().substring(0, 6) + "]"; } - Tab tab = new Tab(tabName); + Tab tab = new Tab(""); + Glyph glyph = new Glyph("FontAwesome", FontAwesome.Glyph.SEND); + glyph.setFontSize(9.0); + glyph.setOpacity(TAB_LABEL_GRAPHIC_OPACITY_ACTIVE); + Label tabLabel = new Label(tabName); + tabLabel.setGraphic(glyph); + tabLabel.setGraphicTextGap(5.0); + tab.setGraphic(tabLabel); tab.setContextMenu(getTabContextMenu(tab)); tab.setClosable(true); FXMLLoader transactionLoader = new FXMLLoader(getClass().getResource("transaction/transaction.fxml")); @@ -1138,6 +1161,57 @@ public class AppController implements Initializable { EventManager.get().post(new ThemeChangedEvent(selectedTheme)); } + private void tabLabelStartAnimation(Wallet wallet) { + tabs.getTabs().stream().filter(tab -> tab.getUserData() instanceof WalletTabData && ((WalletTabData)tab.getUserData()).getWallet() == wallet).forEach(this::tabLabelStartAnimation); + } + + private void tabLabelStartAnimation(Transaction transaction) { + tabs.getTabs().stream().filter(tab -> tab.getUserData() instanceof TransactionTabData && ((TransactionTabData)tab.getUserData()).getTransaction().getTxId().equals(transaction.getTxId())).forEach(this::tabLabelStartAnimation); + } + + private void tabLabelStartAnimation(Tab tab) { + Label tabLabel = (Label) tab.getGraphic(); + if(tabLabel.getUserData() == null) { + FadeTransition fadeTransition = new FadeTransition(Duration.millis(1000), tabLabel.getGraphic()); + fadeTransition.setFromValue(tabLabel.getGraphic().getOpacity()); + fadeTransition.setToValue(0.1); + fadeTransition.setAutoReverse(true); + fadeTransition.setCycleCount(Animation.INDEFINITE); + fadeTransition.play(); + tabLabel.setUserData(fadeTransition); + } + } + + private void tabLabelAddFailure(Tab tab) { + Label tabLabel = (Label)tab.getGraphic(); + if(!tabLabel.getStyleClass().contains("failure")) { + tabLabel.getGraphic().getStyleClass().add("failure"); + } + } + + private void tabLabelStopAnimation(Wallet wallet) { + tabs.getTabs().stream().filter(tab -> tab.getUserData() instanceof WalletTabData && ((WalletTabData)tab.getUserData()).getWallet() == wallet).forEach(this::tabLabelStopAnimation); + } + + private void tabLabelStopAnimation(Transaction transaction) { + tabs.getTabs().stream().filter(tab -> tab.getUserData() instanceof TransactionTabData && ((TransactionTabData)tab.getUserData()).getTransaction().getTxId().equals(transaction.getTxId())).forEach(this::tabLabelStopAnimation); + } + + private void tabLabelStopAnimation(Tab tab) { + Label tabLabel = (Label) tab.getGraphic(); + if(tabLabel.getUserData() != null) { + FadeTransition fadeTransition = (FadeTransition)tabLabel.getUserData(); + fadeTransition.stop(); + tabLabel.setUserData(null); + tabLabel.getGraphic().setOpacity(tab.isSelected() ? TAB_LABEL_GRAPHIC_OPACITY_ACTIVE : TAB_LABEL_GRAPHIC_OPACITY_INACTIVE); + } + } + + private void tabLabelRemoveFailure(Tab tab) { + Label tabLabel = (Label)tab.getGraphic(); + tabLabel.getGraphic().getStyleClass().remove("failure"); + } + @Subscribe public void themeChanged(ThemeChangedEvent event) { String darkCss = getClass().getResource("darktheme.css").toExternalForm(); @@ -1384,14 +1458,26 @@ public class AppController implements Initializable { } } + @Subscribe + public void transactionReferences(TransactionReferencesEvent event) { + if(AppServices.isConnected() && event instanceof TransactionReferencesStartedEvent) { + tabLabelStartAnimation(event.getTransaction()); + } else { + tabLabelStopAnimation(event.getTransaction()); + } + } + @Subscribe public void walletHistoryStarted(WalletHistoryStartedEvent event) { if(AppServices.isConnected() && getOpenWallets().containsKey(event.getWallet())) { - statusUpdated(new StatusEvent("Loading transactions...", 120)); - if(statusTimeline == null || statusTimeline.getStatus() != Animation.Status.RUNNING) { - statusBar.setProgress(-1); - loadingWallets.add(event.getWallet()); + if(event.getWalletNode() == null && event.getWallet().getTransactions().isEmpty()) { + statusUpdated(new StatusEvent("Loading transactions...", 120)); + if(statusTimeline == null || statusTimeline.getStatus() != Animation.Status.RUNNING) { + statusBar.setProgress(-1); + loadingWallets.add(event.getWallet()); + } } + tabLabelStartAnimation(event.getWallet()); } } @@ -1404,10 +1490,18 @@ public class AppController implements Initializable { if(statusTimeline == null || statusTimeline.getStatus() != Animation.Status.RUNNING) { statusBar.setProgress(0); } + tabLabelStopAnimation(event.getWallet()); loadingWallets.remove(event.getWallet()); + tabs.getTabs().stream().filter(tab -> tab.getUserData() instanceof WalletTabData && ((WalletTabData)tab.getUserData()).getWallet() == event.getWallet()).forEach(this::tabLabelRemoveFailure); } } + @Subscribe + public void walletHistoryFailed(WalletHistoryFailedEvent event) { + walletHistoryFinished(new WalletHistoryFinishedEvent(event.getWallet())); + tabs.getTabs().stream().filter(tab -> tab.getUserData() instanceof WalletTabData && ((WalletTabData) tab.getUserData()).getWallet() == event.getWallet()).forEach(this::tabLabelAddFailure); + } + @Subscribe public void bwtBootStatus(BwtBootStatusEvent event) { serverToggle.setDisable(true); diff --git a/src/main/java/com/sparrowwallet/sparrow/event/BlockTransactionFetchedEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/BlockTransactionFetchedEvent.java index b53546e2..85d10cf4 100644 --- a/src/main/java/com/sparrowwallet/sparrow/event/BlockTransactionFetchedEvent.java +++ b/src/main/java/com/sparrowwallet/sparrow/event/BlockTransactionFetchedEvent.java @@ -1,23 +1,18 @@ package com.sparrowwallet.sparrow.event; import com.sparrowwallet.drongo.protocol.Sha256Hash; +import com.sparrowwallet.drongo.protocol.Transaction; import com.sparrowwallet.drongo.wallet.BlockTransaction; import java.util.Map; -public class BlockTransactionFetchedEvent extends PagedEvent { +public class BlockTransactionFetchedEvent extends TransactionReferencesFinishedEvent { private final Sha256Hash txId; - private final BlockTransaction blockTransaction; private final Map inputTransactions; - public BlockTransactionFetchedEvent(Sha256Hash txId, BlockTransaction blockTransaction, Map inputTransactions) { - this(txId, blockTransaction, inputTransactions, 0, blockTransaction.getTransaction().getInputs().size()); - } - - public BlockTransactionFetchedEvent(Sha256Hash txId, BlockTransaction blockTransaction, Map inputTransactions, int pageStart, int pageEnd) { - super(pageStart, pageEnd); - this.txId = txId; - this.blockTransaction = blockTransaction; + public BlockTransactionFetchedEvent(Transaction transaction, BlockTransaction blockTransaction, Map inputTransactions, int pageStart, int pageEnd) { + super(transaction, blockTransaction, pageStart, pageEnd); + this.txId = transaction.getTxId(); this.inputTransactions = inputTransactions; } @@ -25,10 +20,6 @@ public class BlockTransactionFetchedEvent extends PagedEvent { return txId; } - public BlockTransaction getBlockTransaction() { - return blockTransaction; - } - public Map getInputTransactions() { return inputTransactions; } diff --git a/src/main/java/com/sparrowwallet/sparrow/event/BlockTransactionOutputsFetchedEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/BlockTransactionOutputsFetchedEvent.java index cef66ba2..7b748170 100644 --- a/src/main/java/com/sparrowwallet/sparrow/event/BlockTransactionOutputsFetchedEvent.java +++ b/src/main/java/com/sparrowwallet/sparrow/event/BlockTransactionOutputsFetchedEvent.java @@ -1,17 +1,18 @@ package com.sparrowwallet.sparrow.event; import com.sparrowwallet.drongo.protocol.Sha256Hash; +import com.sparrowwallet.drongo.protocol.Transaction; import com.sparrowwallet.drongo.wallet.BlockTransaction; import java.util.List; -public class BlockTransactionOutputsFetchedEvent extends PagedEvent { +public class BlockTransactionOutputsFetchedEvent extends TransactionReferencesEvent { private final Sha256Hash txId; private final List outputTransactions; - public BlockTransactionOutputsFetchedEvent(Sha256Hash txId, List outputTransactions, int pageStart, int pageEnd) { - super(pageStart, pageEnd); - this.txId = txId; + public BlockTransactionOutputsFetchedEvent(Transaction transaction, List outputTransactions, int pageStart, int pageEnd) { + super(transaction, pageStart, pageEnd); + this.txId = transaction.getTxId(); this.outputTransactions = outputTransactions; } diff --git a/src/main/java/com/sparrowwallet/sparrow/event/TabEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/TabEvent.java index dfbc3e72..376a5409 100644 --- a/src/main/java/com/sparrowwallet/sparrow/event/TabEvent.java +++ b/src/main/java/com/sparrowwallet/sparrow/event/TabEvent.java @@ -1,6 +1,7 @@ package com.sparrowwallet.sparrow.event; import com.sparrowwallet.sparrow.TabData; +import javafx.scene.control.Label; import javafx.scene.control.Tab; public class TabEvent { @@ -15,7 +16,7 @@ public class TabEvent { } public String getTabName() { - return tab.getText(); + return ((Label)tab.getGraphic()).getText(); } public TabData getTabData() { diff --git a/src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesEvent.java new file mode 100644 index 00000000..b4c7ea88 --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesEvent.java @@ -0,0 +1,20 @@ +package com.sparrowwallet.sparrow.event; + +import com.sparrowwallet.drongo.protocol.Transaction; + +public class TransactionReferencesEvent extends PagedEvent { + private final Transaction transaction; + + public TransactionReferencesEvent(Transaction transaction) { + this(transaction, 0, 0); + } + + public TransactionReferencesEvent(Transaction transaction, int pageStart, int pageEnd) { + super(pageStart, pageEnd); + this.transaction = transaction; + } + + public Transaction getTransaction() { + return transaction; + } +} diff --git a/src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesFailedEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesFailedEvent.java new file mode 100644 index 00000000..9dc002b6 --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesFailedEvent.java @@ -0,0 +1,21 @@ +package com.sparrowwallet.sparrow.event; + +import com.sparrowwallet.drongo.protocol.Transaction; + +public class TransactionReferencesFailedEvent extends TransactionReferencesEvent { + private final Throwable exception; + + public TransactionReferencesFailedEvent(Transaction transaction, Throwable exception) { + super(transaction); + this.exception = exception; + } + + public TransactionReferencesFailedEvent(Transaction transaction, Throwable exception, int pageStart, int pageEnd) { + super(transaction, pageStart, pageEnd); + this.exception = exception; + } + + public Throwable getException() { + return exception; + } +} diff --git a/src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesFinishedEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesFinishedEvent.java new file mode 100644 index 00000000..07f92f48 --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesFinishedEvent.java @@ -0,0 +1,22 @@ +package com.sparrowwallet.sparrow.event; + +import com.sparrowwallet.drongo.protocol.Transaction; +import com.sparrowwallet.drongo.wallet.BlockTransaction; + +public class TransactionReferencesFinishedEvent extends TransactionReferencesEvent { + private final BlockTransaction blockTransaction; + + public TransactionReferencesFinishedEvent(Transaction transaction, BlockTransaction blockTransaction) { + super(transaction); + this.blockTransaction = blockTransaction; + } + + public TransactionReferencesFinishedEvent(Transaction transaction, BlockTransaction blockTransaction, int pageStart, int pageEnd) { + super(transaction, pageStart, pageEnd); + this.blockTransaction = blockTransaction; + } + + public BlockTransaction getBlockTransaction() { + return blockTransaction; + } +} diff --git a/src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesStartedEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesStartedEvent.java new file mode 100644 index 00000000..b9da5ea6 --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/event/TransactionReferencesStartedEvent.java @@ -0,0 +1,13 @@ +package com.sparrowwallet.sparrow.event; + +import com.sparrowwallet.drongo.protocol.Transaction; + +public class TransactionReferencesStartedEvent extends TransactionReferencesEvent { + public TransactionReferencesStartedEvent(Transaction transaction) { + super(transaction); + } + + public TransactionReferencesStartedEvent(Transaction transaction, int pageStart, int pageEnd) { + super(transaction, pageStart, pageEnd); + } +} diff --git a/src/main/java/com/sparrowwallet/sparrow/event/WalletHistoryFailedEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/WalletHistoryFailedEvent.java new file mode 100644 index 00000000..a14c9470 --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/event/WalletHistoryFailedEvent.java @@ -0,0 +1,16 @@ +package com.sparrowwallet.sparrow.event; + +import com.sparrowwallet.drongo.wallet.Wallet; + +public class WalletHistoryFailedEvent extends WalletHistoryStatusEvent { + private final Throwable exception; + + public WalletHistoryFailedEvent(Wallet wallet, Throwable exception) { + super(wallet, exception.getCause() == null ? exception.getMessage() : exception.getCause().getMessage()); + this.exception = exception; + } + + public Throwable getException() { + return exception; + } +} diff --git a/src/main/java/com/sparrowwallet/sparrow/event/WalletHistoryFinishedEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/WalletHistoryFinishedEvent.java index 41f463dd..2895d5ab 100644 --- a/src/main/java/com/sparrowwallet/sparrow/event/WalletHistoryFinishedEvent.java +++ b/src/main/java/com/sparrowwallet/sparrow/event/WalletHistoryFinishedEvent.java @@ -6,8 +6,4 @@ public class WalletHistoryFinishedEvent extends WalletHistoryStatusEvent { public WalletHistoryFinishedEvent(Wallet wallet) { super(wallet, false); } - - public WalletHistoryFinishedEvent(Wallet wallet, String errorMessage) { - super(wallet, errorMessage); - } } diff --git a/src/main/java/com/sparrowwallet/sparrow/event/WalletHistoryStartedEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/WalletHistoryStartedEvent.java index 81e98946..6fc3c0ce 100644 --- a/src/main/java/com/sparrowwallet/sparrow/event/WalletHistoryStartedEvent.java +++ b/src/main/java/com/sparrowwallet/sparrow/event/WalletHistoryStartedEvent.java @@ -1,9 +1,17 @@ package com.sparrowwallet.sparrow.event; import com.sparrowwallet.drongo.wallet.Wallet; +import com.sparrowwallet.drongo.wallet.WalletNode; public class WalletHistoryStartedEvent extends WalletHistoryStatusEvent { - public WalletHistoryStartedEvent(Wallet wallet) { + private final WalletNode walletNode; + + public WalletHistoryStartedEvent(Wallet wallet, WalletNode walletNode) { super(wallet, true); + this.walletNode = walletNode; + } + + public WalletNode getWalletNode() { + return walletNode; } } diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java index 59fcd77e..b29ed130 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java @@ -944,7 +944,7 @@ public class ElectrumServer { }); disconnectionService.start(); } else if(subscribe) { - EventManager.get().post(new DisconnectionEvent()); + Platform.runLater(() -> EventManager.get().post(new DisconnectionEvent())); } } diff --git a/src/main/java/com/sparrowwallet/sparrow/net/SimpleElectrumServerRpc.java b/src/main/java/com/sparrowwallet/sparrow/net/SimpleElectrumServerRpc.java index 5bbd5884..14dfb288 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/SimpleElectrumServerRpc.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/SimpleElectrumServerRpc.java @@ -145,6 +145,9 @@ public class SimpleElectrumServerRpc implements ElectrumServerRpc { String blockHeader = new RetryLogic(MAX_RETRIES, RETRY_DELAY, List.of(IllegalStateException.class, IllegalArgumentException.class)).getResult(() -> client.createRequest().returnAs(String.class).method("blockchain.block.header").id(idCounter.incrementAndGet()).params(blockHeight).execute()); result.put(blockHeight, blockHeader); + } catch(ServerException e) { + //If there is an error with the server connection, don't keep trying - this may take too long given many blocks + throw new ElectrumServerRpcException("Failed to retrieve block header for block height: " + blockHeight, e); } catch(JsonRpcException e) { log.warn("Failed to retrieve block header for block height: " + blockHeight + " (" + e.getErrorMessage() + ")"); } catch(Exception e) { diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index 402ad84f..9d338545 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -846,10 +846,13 @@ public class HeadersController extends TransactionFormController implements Init headersForm.setBlockTransaction(blockTransaction); updateBlockchainForm(blockTransaction, AppServices.getCurrentBlockHeight()); } + EventManager.get().post(new TransactionReferencesFinishedEvent(headersForm.getTransaction(), blockTransaction)); }); transactionReferenceService.setOnFailed(failedEvent -> { log.error("Error fetching broadcasted transaction", failedEvent.getSource().getException()); + EventManager.get().post(new TransactionReferencesFailedEvent(headersForm.getTransaction(), failedEvent.getSource().getException())); }); + EventManager.get().post(new TransactionReferencesStartedEvent(headersForm.getTransaction())); transactionReferenceService.start(); } }); @@ -1132,10 +1135,13 @@ public class HeadersController extends TransactionFormController implements Init headersForm.setBlockTransaction(blockTransaction); updateBlockchainForm(blockTransaction, AppServices.getCurrentBlockHeight()); } + EventManager.get().post(new TransactionReferencesFinishedEvent(headersForm.getTransaction(), blockTransaction)); }); transactionReferenceService.setOnFailed(failEvent -> { log.error("Could not update block transaction", failEvent.getSource().getException()); + EventManager.get().post(new TransactionReferencesFailedEvent(headersForm.getTransaction(), failEvent.getSource().getException())); }); + EventManager.get().post(new TransactionReferencesStartedEvent(headersForm.getTransaction())); transactionReferenceService.start(); } } diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionController.java index ae540ac4..49e327f5 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/TransactionController.java @@ -374,12 +374,14 @@ public class TransactionController implements Initializable { final BlockTransaction blockTx = thisBlockTx; Platform.runLater(() -> { - EventManager.get().post(new BlockTransactionFetchedEvent(getTransaction().getTxId(), blockTx, inputTransactions, indexStart, maxIndex)); + EventManager.get().post(new BlockTransactionFetchedEvent(getTransaction(), blockTx, inputTransactions, indexStart, maxIndex)); }); }); transactionReferenceService.setOnFailed(failedEvent -> { log.error("Error fetching transaction or input references", failedEvent.getSource().getException()); + EventManager.get().post(new TransactionReferencesFailedEvent(getTransaction(), failedEvent.getSource().getException(), indexStart, maxIndex)); }); + EventManager.get().post(new TransactionReferencesStartedEvent(getTransaction(), indexStart, maxIndex)); transactionReferenceService.start(); } } @@ -391,12 +393,14 @@ public class TransactionController implements Initializable { transactionOutputsReferenceService.setOnSucceeded(successEvent -> { List outputTransactions = transactionOutputsReferenceService.getValue(); Platform.runLater(() -> { - EventManager.get().post(new BlockTransactionOutputsFetchedEvent(getTransaction().getTxId(), outputTransactions, indexStart, maxIndex)); + EventManager.get().post(new BlockTransactionOutputsFetchedEvent(getTransaction(), outputTransactions, indexStart, maxIndex)); }); }); transactionOutputsReferenceService.setOnFailed(failedEvent -> { log.error("Error fetching transaction output references", failedEvent.getSource().getException()); + EventManager.get().post(new TransactionReferencesFailedEvent(getTransaction(), failedEvent.getSource().getException(), indexStart, maxIndex)); }); + EventManager.get().post(new TransactionReferencesStartedEvent(getTransaction(), indexStart, maxIndex)); transactionOutputsReferenceService.start(); } } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletForm.java b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletForm.java index 1d023797..5f54e5f0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletForm.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletForm.java @@ -105,14 +105,10 @@ public class WalletForm { }); historyService.setOnFailed(workerStateEvent -> { log.error("Error retrieving wallet history", workerStateEvent.getSource().getException()); - EventManager.get().post(new WalletHistoryFinishedEvent(wallet, workerStateEvent.getSource().getException().getMessage())); + EventManager.get().post(new WalletHistoryFailedEvent(wallet, workerStateEvent.getSource().getException())); }); - if(node == null && wallet.getTransactions().isEmpty()) { - EventManager.get().post(new WalletHistoryStartedEvent(wallet)); - } else { - EventManager.get().post(new WalletHistoryStatusEvent(wallet, true)); - } + EventManager.get().post(new WalletHistoryStartedEvent(wallet, node)); historyService.start(); } } diff --git a/src/main/resources/com/sparrowwallet/sparrow/app.css b/src/main/resources/com/sparrowwallet/sparrow/app.css index b36096b7..a03bba41 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/app.css +++ b/src/main/resources/com/sparrowwallet/sparrow/app.css @@ -20,6 +20,10 @@ -fx-fill: #383a42; } +.tab-label .failure { + -fx-text-fill: rgb(202, 18, 67); +} + .status-bar .status-label { -fx-alignment: center-left; } diff --git a/src/main/resources/com/sparrowwallet/sparrow/darktheme.css b/src/main/resources/com/sparrowwallet/sparrow/darktheme.css index 08f318ae..10c17d12 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/darktheme.css +++ b/src/main/resources/com/sparrowwallet/sparrow/darktheme.css @@ -82,6 +82,10 @@ -fx-bar-fill: rgba(135, 138, 149, 0.5); } +.tab-label .failure { + -fx-fill: #e06c75; +} + .root .titled-description-pane .status-error .text, .root .titled-description-pane .description-error .text { -fx-fill: #e06c75; } diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 0df5b25a..dca3918a 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -5,6 +5,8 @@ + +