From 712241873fa1c8cba9936e0d4cea40e9bc88e589 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 27 Sep 2021 08:54:42 +0200 Subject: [PATCH] show reason for mix error in tooltip --- .../sparrowwallet/sparrow/control/MixStatusCell.java | 6 +++--- .../sparrow/event/WhirlpoolMixEvent.java | 10 +++++++++- .../com/sparrowwallet/sparrow/wallet/UtxoEntry.java | 12 +++++++++--- .../sparrow/wallet/UtxosController.java | 3 ++- .../sparrowwallet/sparrow/whirlpool/Whirlpool.java | 2 +- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java b/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java index a405289d..c6140f1c 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java @@ -49,7 +49,7 @@ public class MixStatusCell extends TreeTableCell { if(mixStatus.getNextMixUtxo() != null) { setMixSuccess(mixStatus.getNextMixUtxo()); } else if(mixStatus.getMixFailReason() != null) { - setMixFail(mixStatus.getMixFailReason()); + setMixFail(mixStatus.getMixFailReason(), mixStatus.getMixError()); } else if(mixStatus.getMixProgress() != null) { setMixProgress(mixStatus.getMixProgress()); } else { @@ -67,11 +67,11 @@ public class MixStatusCell extends TreeTableCell { setTooltip(tt); } - private void setMixFail(MixFailReason mixFailReason) { + private void setMixFail(MixFailReason mixFailReason, String mixError) { if(mixFailReason != MixFailReason.CANCEL) { setGraphic(getFailGlyph()); Tooltip tt = new Tooltip(); - tt.setText(mixFailReason.getMessage()); + tt.setText(mixFailReason.getMessage() + (mixError == null ? "" : ": " + mixError)); setTooltip(tt); } else { setGraphic(null); diff --git a/src/main/java/com/sparrowwallet/sparrow/event/WhirlpoolMixEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/WhirlpoolMixEvent.java index 4cf6df58..b7e6844a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/event/WhirlpoolMixEvent.java +++ b/src/main/java/com/sparrowwallet/sparrow/event/WhirlpoolMixEvent.java @@ -12,6 +12,7 @@ public class WhirlpoolMixEvent { private final MixProgress mixProgress; private final Utxo nextUtxo; private final MixFailReason mixFailReason; + private final String mixError; public WhirlpoolMixEvent(Wallet wallet, BlockTransactionHashIndex utxo, MixProgress mixProgress) { this.wallet = wallet; @@ -19,6 +20,7 @@ public class WhirlpoolMixEvent { this.mixProgress = mixProgress; this.nextUtxo = null; this.mixFailReason = null; + this.mixError = null; } public WhirlpoolMixEvent(Wallet wallet, BlockTransactionHashIndex utxo, Utxo nextUtxo) { @@ -27,14 +29,16 @@ public class WhirlpoolMixEvent { this.mixProgress = null; this.nextUtxo = nextUtxo; this.mixFailReason = null; + this.mixError = null; } - public WhirlpoolMixEvent(Wallet wallet, BlockTransactionHashIndex utxo, MixFailReason mixFailReason) { + public WhirlpoolMixEvent(Wallet wallet, BlockTransactionHashIndex utxo, MixFailReason mixFailReason, String mixError) { this.wallet = wallet; this.utxo = utxo; this.mixProgress = null; this.nextUtxo = null; this.mixFailReason = mixFailReason; + this.mixError = mixError; } public Wallet getWallet() { @@ -56,4 +60,8 @@ public class WhirlpoolMixEvent { public MixFailReason getMixFailReason() { return mixFailReason; } + + public String getMixError() { + return mixError; + } } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxoEntry.java b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxoEntry.java index f68f7549..e989c4c9 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxoEntry.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxoEntry.java @@ -102,8 +102,8 @@ public class UtxoEntry extends HashIndexEntry { mixStatusProperty().set(new MixStatus(mixProgress)); } - public void setMixFailReason(MixFailReason mixFailReason) { - mixStatusProperty().set(new MixStatus(mixFailReason)); + public void setMixFailReason(MixFailReason mixFailReason, String mixError) { + mixStatusProperty().set(new MixStatus(mixFailReason, mixError)); } public void setNextMixUtxo(Utxo nextMixUtxo) { @@ -126,6 +126,7 @@ public class UtxoEntry extends HashIndexEntry { private MixProgress mixProgress; private Utxo nextMixUtxo; private MixFailReason mixFailReason; + private String mixError; public MixStatus(MixProgress mixProgress) { this.mixProgress = mixProgress; @@ -135,8 +136,9 @@ public class UtxoEntry extends HashIndexEntry { this.nextMixUtxo = nextMixUtxo; } - public MixStatus(MixFailReason mixFailReason) { + public MixStatus(MixFailReason mixFailReason, String mixError) { this.mixFailReason = mixFailReason; + this.mixError = mixError; } public UtxoEntry getUtxoEntry() { @@ -175,5 +177,9 @@ public class UtxoEntry extends HashIndexEntry { public MixFailReason getMixFailReason() { return mixFailReason; } + + public String getMixError() { + return mixError; + } } } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java index d8a43c67..ef849563 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/UtxosController.java @@ -143,6 +143,7 @@ public class UtxosController extends WalletFormController implements Initializab return Whirlpool.WHIRLPOOL_NETWORKS.contains(Network.get()) && getWalletForm().getWallet().getKeystores().size() == 1 && getWalletForm().getWallet().getKeystores().get(0).hasSeed() + && getWalletForm().getWallet().getKeystores().get(0).getSeed().getType() == DeterministicSeed.Type.BIP39 && !getWalletForm().getWallet().isWhirlpoolMixWallet(); } @@ -528,7 +529,7 @@ public class UtxosController extends WalletFormController implements Initializab if(event.getNextUtxo() != null) { utxoEntry.setNextMixUtxo(event.getNextUtxo()); } else if(event.getMixFailReason() != null) { - utxoEntry.setMixFailReason(event.getMixFailReason()); + utxoEntry.setMixFailReason(event.getMixFailReason(), event.getMixError()); } else { utxoEntry.setMixProgress(event.getMixProgress()); } diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java index 7160b4af..0cdb8459 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java @@ -442,7 +442,7 @@ public class Whirlpool { WalletUtxo walletUtxo = getUtxo(e.getWhirlpoolUtxo()); if(walletUtxo != null) { log.debug("Mix failed for utxo " + e.getWhirlpoolUtxo().getUtxo().tx_hash + ":" + e.getWhirlpoolUtxo().getUtxo().tx_output_n + " " + e.getMixFailReason()); - Platform.runLater(() -> EventManager.get().post(new WhirlpoolMixEvent(walletUtxo.wallet, walletUtxo.utxo, e.getMixFailReason()))); + Platform.runLater(() -> EventManager.get().post(new WhirlpoolMixEvent(walletUtxo.wallet, walletUtxo.utxo, e.getMixFailReason(), e.getError()))); } }