indicate when a server failure occurs loading a transaction from file

This commit is contained in:
Craig Raw 2022-03-28 09:31:18 +02:00
parent 761ec0659f
commit 79c0f7769a
3 changed files with 36 additions and 1 deletions

View file

@ -0,0 +1,13 @@
package com.sparrowwallet.sparrow.event;
import com.sparrowwallet.drongo.protocol.Transaction;
public class TransactionFetchFailedEvent extends TransactionReferencesFailedEvent {
public TransactionFetchFailedEvent(Transaction transaction, Throwable exception) {
super(transaction, exception);
}
public TransactionFetchFailedEvent(Transaction transaction, Throwable exception, int pageStart, int pageEnd) {
super(transaction, exception, pageStart, pageEnd);
}
}

View file

@ -14,6 +14,7 @@ import com.sparrowwallet.sparrow.AppServices;
import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.control.*;
import com.sparrowwallet.sparrow.event.*;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5Brands;
import com.sparrowwallet.sparrow.io.Device;
import com.sparrowwallet.sparrow.net.ElectrumServer;
@ -1177,6 +1178,23 @@ public class HeadersController extends TransactionFormController implements Init
}
}
@Subscribe
public void transactionFetchFailed(TransactionFetchFailedEvent event) {
if(event.getTransaction().getTxId().equals(headersForm.getTransaction().getTxId())
&& !blockchainForm.isVisible() && !signingWalletForm.isVisible() && !signaturesForm.isVisible()) {
blockchainForm.setVisible(true);
blockStatus.setText("Unknown transaction status, server failed to respond");
Glyph errorGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.EXCLAMATION_CIRCLE);
errorGlyph.setFontSize(12);
blockStatus.setGraphic(errorGlyph);
blockStatus.setContentDisplay(ContentDisplay.LEFT);
errorGlyph.getStyleClass().add("failure");
blockHeightField.setVisible(false);
blockTimestampField.setVisible(false);
blockHashField.setVisible(false);
}
}
@Subscribe
public void bitcoinUnitChanged(BitcoinUnitChangedEvent event) {
fee.refresh(event.getBitcoinUnit());

View file

@ -379,7 +379,11 @@ public class TransactionController implements Initializable {
});
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));
if(references.contains(getTransaction().getTxId())) {
EventManager.get().post(new TransactionFetchFailedEvent(getTransaction(), failedEvent.getSource().getException(), indexStart, maxIndex));
} else {
EventManager.get().post(new TransactionReferencesFailedEvent(getTransaction(), failedEvent.getSource().getException(), indexStart, maxIndex));
}
});
EventManager.get().post(new TransactionReferencesStartedEvent(getTransaction(), indexStart, maxIndex));
transactionReferenceService.start();