Skip to content

Commit

Permalink
fix npe on soroban counterparty timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
craigraw committed Apr 11, 2024
1 parent 5696e00 commit e178168
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sparrowwallet.sparrow.soroban;

import com.google.common.base.Throwables;
import com.samourai.soroban.client.cahoots.OnlineCahootsMessage;
import com.samourai.soroban.client.meeting.SorobanRequestMessage;
import com.samourai.soroban.client.wallet.SorobanWalletService;
Expand All @@ -8,7 +9,6 @@
import com.samourai.wallet.cahoots.Cahoots;
import com.samourai.wallet.cahoots.CahootsContext;
import com.samourai.wallet.cahoots.CahootsType;
import com.samourai.wallet.cahoots.CahootsWallet;
import com.sparrowwallet.drongo.protocol.Transaction;
import com.sparrowwallet.drongo.psbt.PSBTParseException;
import com.sparrowwallet.drongo.wallet.BlockTransactionHashIndex;
Expand Down Expand Up @@ -39,6 +39,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeoutException;

import static com.sparrowwallet.sparrow.AppServices.showErrorDialog;
import static com.sparrowwallet.sparrow.soroban.Soroban.TIMEOUT_MS;
Expand Down Expand Up @@ -359,11 +360,12 @@ protected Cahoots call() throws Exception {
}
};
cahootsService.setOnFailed(event -> {
Throwable error = event.getSource().getException();
Throwable error = Throwables.getRootCause(event.getSource().getException());
log.error("Error creating mix transaction", error);
String cutFrom = "Exception: ";
int index = error.getMessage().lastIndexOf(cutFrom);
String msg = index < 0 ? error.getMessage() : error.getMessage().substring(index + cutFrom.length());
String message = error.getMessage() == null ? (error instanceof TimeoutException || step3Timer.getProgress() == 0d ? "Timed out receiving response" : "Error receiving response") : error.getMessage();
int index = message.lastIndexOf(cutFrom);
String msg = index < 0 ? message : message.substring(index + cutFrom.length());
msg = msg.replace("#Cahoots", "mix transaction");
step3Desc.setText(msg);
sorobanProgressLabel.setVisible(false);
Expand Down

0 comments on commit e178168

Please sign in to comment.