mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 13:26:44 +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,31 +167,37 @@ 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
|
||||||
String rawTxHex = client.createRequest().returnAs(String.class).method("blockchain.transaction.get").id(txid).params(txid).execute();
|
//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
|
||||||
Transaction tx = new Transaction(Utils.hexToBytes(rawTxHex));
|
//We mark this VerboseTransaction as incomplete by assigning it a Sha256Hash.ZERO_HASH blockhash
|
||||||
String id = tx.getTxId().toString();
|
log.debug("Error retrieving transaction: " + txid + " (" + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()) + ")");
|
||||||
int height = 0;
|
|
||||||
|
|
||||||
if(scriptHash != null) {
|
try {
|
||||||
ScriptHashTx[] scriptHashTxes = client.createRequest().returnAs(ScriptHashTx[].class).method("blockchain.scripthash.get_history").id(id).params(scriptHash).execute();
|
String rawTxHex = client.createRequest().returnAs(String.class).method("blockchain.transaction.get").id(txid).params(txid).execute();
|
||||||
for(ScriptHashTx scriptHashTx : scriptHashTxes) {
|
Transaction tx = new Transaction(Utils.hexToBytes(rawTxHex));
|
||||||
if(scriptHashTx.tx_hash.equals(id)) {
|
String id = tx.getTxId().toString();
|
||||||
height = scriptHashTx.height;
|
int height = 0;
|
||||||
break;
|
|
||||||
|
if(scriptHash != null) {
|
||||||
|
ScriptHashTx[] scriptHashTxes = client.createRequest().returnAs(ScriptHashTx[].class).method("blockchain.scripthash.get_history").id(id).params(scriptHash).execute();
|
||||||
|
for(ScriptHashTx scriptHashTx : scriptHashTxes) {
|
||||||
|
if(scriptHashTx.tx_hash.equals(id)) {
|
||||||
|
height = scriptHashTx.height;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
VerboseTransaction verboseTransaction = new VerboseTransaction();
|
VerboseTransaction verboseTransaction = new VerboseTransaction();
|
||||||
verboseTransaction.txid = id;
|
verboseTransaction.txid = id;
|
||||||
verboseTransaction.hex = rawTxHex;
|
verboseTransaction.hex = rawTxHex;
|
||||||
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