From 2647f5085fa3b1c681bc42ec6e49bd33865e9767 Mon Sep 17 00:00:00 2001 From: zeroleak Date: Tue, 12 Mar 2024 17:46:39 +0100 Subject: [PATCH] upgrade to whirlpool 1.0.0-beta13 - HttpException now differenciates HttpResponseException & HttpNetworkException - MixFailReason.CANCEL becomes MixFailReason.STOP_UTXO. Also introduced NETWORK_ERROR, STOP_MIXING, ROTATE, and utilities such as .isError(), .isRequeue(), .isSilent() --- build.gradle | 4 ++-- .../java/com/sparrowwallet/sparrow/control/MixStatusCell.java | 2 +- .../java/com/sparrowwallet/sparrow/net/BroadcastSource.java | 3 ++- .../java/com/sparrowwallet/sparrow/net/ExchangeSource.java | 3 ++- src/main/java/com/sparrowwallet/sparrow/payjoin/Payjoin.java | 3 ++- .../sparrow/terminal/wallet/table/MixTableCell.java | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 15bde121..659ca217 100644 --- a/build.gradle +++ b/build.gradle @@ -124,8 +124,8 @@ dependencies { exclude group: 'org.slf4j' } implementation('com.sparrowwallet.bokmakierie:bokmakierie:1.0') - implementation('io.samourai.code.whirlpool:whirlpool-client:1.0.0-beta10') - implementation('io.samourai.code.wallet:java-http-client:2.0.0-beta3') + implementation('io.samourai.code.whirlpool:whirlpool-client:1.0.0-beta13') + implementation('io.samourai.code.wallet:java-http-client:2.0.0-beta4') implementation('io.reactivex.rxjava2:rxjava:2.2.15') implementation('io.reactivex.rxjava2:rxjavafx:2.2.2') implementation('org.apache.commons:commons-lang3:3.7') diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java b/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java index 68dd71b8..c2027250 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java @@ -70,7 +70,7 @@ public class MixStatusCell extends TreeTableCell { } private void setMixFail(MixFailReason mixFailReason, String mixError, Long mixErrorTimestamp) { - if(mixFailReason != MixFailReason.CANCEL) { + if(mixFailReason != MixFailReason.STOP_UTXO) { long elapsed = mixErrorTimestamp == null ? 0L : System.currentTimeMillis() - mixErrorTimestamp; if(elapsed >= ERROR_DISPLAY_MILLIS) { //Old error, don't set again. diff --git a/src/main/java/com/sparrowwallet/sparrow/net/BroadcastSource.java b/src/main/java/com/sparrowwallet/sparrow/net/BroadcastSource.java index c2e4695f..115b7a3a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/BroadcastSource.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/BroadcastSource.java @@ -2,6 +2,7 @@ package com.sparrowwallet.sparrow.net; import com.google.common.net.HostAndPort; import com.samourai.wallet.api.backend.beans.HttpException; +import com.samourai.wallet.httpClient.HttpResponseException; import com.sparrowwallet.drongo.Network; import com.sparrowwallet.drongo.Utils; import com.sparrowwallet.drongo.protocol.Sha256Hash; @@ -158,7 +159,7 @@ public enum BroadcastSource { } catch(Exception e) { throw new BroadcastException("Could not retrieve txid from broadcast, server returned: " + response); } - } catch(HttpException e) { + } catch(HttpResponseException e) { throw new BroadcastException("Could not broadcast transaction, server returned " + e.getStatusCode() + ": " + e.getResponseBody()); } catch(Exception e) { log.error("Could not post transaction via " + getName(), e); diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java b/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java index ee0dd064..96e233f2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java @@ -1,6 +1,7 @@ package com.sparrowwallet.sparrow.net; import com.samourai.wallet.api.backend.beans.HttpException; +import com.samourai.wallet.httpClient.HttpResponseException; import com.sparrowwallet.sparrow.AppServices; import com.sparrowwallet.sparrow.event.ExchangeRatesUpdatedEvent; import javafx.concurrent.ScheduledService; @@ -107,7 +108,7 @@ public enum ExchangeSource { if(log.isDebugEnabled()) { log.warn("Error retrieving historical currency rates", e); } else { - if(e instanceof HttpException httpException && httpException.getStatusCode() == 404) { + if(e instanceof HttpResponseException httpException && httpException.getStatusCode() == 404) { log.warn("Error retrieving historical currency rates (" + e.getMessage() + "). BTC-" + currency.getCurrencyCode() + " may not be supported by " + this); } else { log.warn("Error retrieving historical currency rates (" + e.getMessage() + ")"); diff --git a/src/main/java/com/sparrowwallet/sparrow/payjoin/Payjoin.java b/src/main/java/com/sparrowwallet/sparrow/payjoin/Payjoin.java index 970edd45..48c6a992 100644 --- a/src/main/java/com/sparrowwallet/sparrow/payjoin/Payjoin.java +++ b/src/main/java/com/sparrowwallet/sparrow/payjoin/Payjoin.java @@ -3,6 +3,7 @@ package com.sparrowwallet.sparrow.payjoin; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import com.samourai.wallet.api.backend.beans.HttpException; +import com.samourai.wallet.httpClient.HttpResponseException; import com.sparrowwallet.drongo.protocol.Script; import com.sparrowwallet.drongo.protocol.Transaction; import com.sparrowwallet.drongo.protocol.TransactionInput; @@ -87,7 +88,7 @@ public class Payjoin { checkProposal(psbt, proposalPsbt, changeOutputIndex, maxAdditionalFeeContribution, allowOutputSubstitution); return proposalPsbt; - } catch(HttpException e) { + } catch(HttpResponseException e) { Gson gson = new Gson(); PayjoinReceiverError payjoinReceiverError = gson.fromJson(e.getResponseBody(), PayjoinReceiverError.class); log.warn("Payjoin receiver returned an error of " + payjoinReceiverError.getErrorCode() + " (" + payjoinReceiverError.getMessage() + ")"); diff --git a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/table/MixTableCell.java b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/table/MixTableCell.java index b4d02397..7969bf98 100644 --- a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/table/MixTableCell.java +++ b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/table/MixTableCell.java @@ -43,7 +43,7 @@ public class MixTableCell extends TableCell { private String getMixFail(UtxoEntry.MixStatus mixStatus) { long elapsed = mixStatus.getMixErrorTimestamp() == null ? 0L : System.currentTimeMillis() - mixStatus.getMixErrorTimestamp(); - if(mixStatus.getMixFailReason() == MixFailReason.CANCEL || elapsed >= ERROR_DISPLAY_MILLIS) { + if(mixStatus.getMixFailReason() == MixFailReason.STOP_UTXO || elapsed >= ERROR_DISPLAY_MILLIS) { return getMixCountOnly(mixStatus); }