mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +00:00
avoid displaying any server response in error dialogs
This commit is contained in:
parent
2bebb0925e
commit
546076ea48
3 changed files with 30 additions and 23 deletions
|
@ -485,7 +485,8 @@ public class AppController implements Initializable {
|
||||||
transactionReferenceService.setOnFailed(failEvent -> {
|
transactionReferenceService.setOnFailed(failEvent -> {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
Throwable e = failEvent.getSource().getException();
|
Throwable e = failEvent.getSource().getException();
|
||||||
showErrorDialog("Error fetching transaction", e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
|
log.error("Error fetching transaction " + txId.toString(), e);
|
||||||
|
showErrorDialog("Error fetching transaction", "The server returned an error when fetching the transaction. The server response is contained in sparrow.log");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
transactionReferenceService.start();
|
transactionReferenceService.start();
|
||||||
|
|
|
@ -167,8 +167,13 @@ public class SimpleElectrumServerRpc implements ElectrumServerRpc {
|
||||||
try {
|
try {
|
||||||
VerboseTransaction verboseTransaction = client.createRequest().returnAs(VerboseTransaction.class).method("blockchain.transaction.get").id(txid).params(txid, true).execute();
|
VerboseTransaction verboseTransaction = client.createRequest().returnAs(VerboseTransaction.class).method("blockchain.transaction.get").id(txid).params(txid, true).execute();
|
||||||
result.put(txid, verboseTransaction);
|
result.put(txid, verboseTransaction);
|
||||||
} catch(IllegalStateException | IllegalArgumentException e) {
|
} catch(Exception e) {
|
||||||
log.warn("Error retrieving transaction: " + txid + " (" + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()) + ")");
|
//electrs does not currently support the verbose parameter, so try to fetch an incomplete VerboseTransaction without it
|
||||||
|
//Note that without the script hash associated with the transaction, we can't get a block height as there is no way in the Electrum RPC protocol to do this
|
||||||
|
//We mark this VerboseTransaction as incomplete by assigning it a Sha256Hash.ZERO_HASH blockhash
|
||||||
|
log.debug("Error retrieving transaction: " + txid + " (" + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()) + ")");
|
||||||
|
|
||||||
|
try {
|
||||||
String rawTxHex = client.createRequest().returnAs(String.class).method("blockchain.transaction.get").id(txid).params(txid).execute();
|
String rawTxHex = client.createRequest().returnAs(String.class).method("blockchain.transaction.get").id(txid).params(txid).execute();
|
||||||
Transaction tx = new Transaction(Utils.hexToBytes(rawTxHex));
|
Transaction tx = new Transaction(Utils.hexToBytes(rawTxHex));
|
||||||
String id = tx.getTxId().toString();
|
String id = tx.getTxId().toString();
|
||||||
|
@ -190,8 +195,9 @@ public class SimpleElectrumServerRpc implements ElectrumServerRpc {
|
||||||
verboseTransaction.confirmations = (height <= 0 ? 0 : AppController.getCurrentBlockHeight() - height + 1);
|
verboseTransaction.confirmations = (height <= 0 ? 0 : AppController.getCurrentBlockHeight() - height + 1);
|
||||||
verboseTransaction.blockhash = Sha256Hash.ZERO_HASH.toString();
|
verboseTransaction.blockhash = Sha256Hash.ZERO_HASH.toString();
|
||||||
result.put(txid, verboseTransaction);
|
result.put(txid, verboseTransaction);
|
||||||
} catch(JsonRpcException e) {
|
} catch(Exception ex) {
|
||||||
log.warn("Error retrieving transaction: " + txid + " (" + e.getErrorMessage() + ")");
|
throw new ElectrumServerRpcException("Error retrieving transaction: ", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -749,7 +749,7 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
broadcastTransactionService.setOnFailed(workerStateEvent -> {
|
broadcastTransactionService.setOnFailed(workerStateEvent -> {
|
||||||
broadcastProgressBar.setProgress(0);
|
broadcastProgressBar.setProgress(0);
|
||||||
log.error("Error broadcasting transaction", workerStateEvent.getSource().getException());
|
log.error("Error broadcasting transaction", workerStateEvent.getSource().getException());
|
||||||
AppController.showErrorDialog("Error broadcasting transaction", workerStateEvent.getSource().getException().getMessage());
|
AppController.showErrorDialog("Error broadcasting transaction", "The server returned an error when broadcasting the transaction. The server response is contained in sparrow.log");
|
||||||
broadcastButton.setDisable(false);
|
broadcastButton.setDisable(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue