show reason for mix error in tooltip

This commit is contained in:
Craig Raw 2021-09-27 08:54:42 +02:00
parent 31f9cca33a
commit 712241873f
5 changed files with 24 additions and 9 deletions

View file

@ -49,7 +49,7 @@ public class MixStatusCell extends TreeTableCell<Entry, UtxoEntry.MixStatus> {
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<Entry, UtxoEntry.MixStatus> {
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);

View file

@ -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;
}
}

View file

@ -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;
}
}
}

View file

@ -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());
}

View file

@ -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())));
}
}