From 702d92d4f2cfb2acd14098293ff74b86c8b10410 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 19 Apr 2021 10:34:47 +0200 Subject: [PATCH] handle failure to retrieve broadcasted transaction from mempool, allow retry --- .../sparrow/transaction/HeadersController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index 362f1292..b41083c8 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -815,6 +815,7 @@ public class HeadersController extends TransactionFormController implements Init transactionMempoolService = new ElectrumServer.TransactionMempoolService(headersForm.getSigningWallet(), headersForm.getTransaction().getTxId(), headersForm.getSigningWalletNodes()); transactionMempoolService.setDelay(Duration.seconds(3)); transactionMempoolService.setPeriod(Duration.seconds(10)); + transactionMempoolService.setRestartOnFailure(false); transactionMempoolService.setOnSucceeded(mempoolWorkerStateEvent -> { Set scriptHashes = transactionMempoolService.getValue(); if(!scriptHashes.isEmpty()) { @@ -829,6 +830,13 @@ public class HeadersController extends TransactionFormController implements Init broadcastButton.setDisable(false); } }); + transactionMempoolService.setOnFailed(mempoolWorkerStateEvent -> { + transactionMempoolService.cancel(); + broadcastProgressBar.setProgress(0); + log.error("Timeout searching for broadcasted transaction"); + AppServices.showErrorDialog("Timeout searching for broadcasted transaction", "The transaction was broadcast but the server did not indicate it had entered the mempool. It is safe to try broadcasting again."); + broadcastButton.setDisable(false); + }); transactionMempoolService.start(); } else { Sha256Hash txid = headersForm.getTransaction().getTxId();