From 615b78b4975caa261ed81b65fec5d4aebbdcb0fd Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 24 Aug 2021 09:29:54 +0200 Subject: [PATCH] fix mix event handling for multiple wallets --- build.gradle | 4 ++-- .../sparrow/whirlpool/Whirlpool.java | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index d44876c9..0fdf8173 100644 --- a/build.gradle +++ b/build.gradle @@ -91,7 +91,7 @@ dependencies { implementation('org.slf4j:jul-to-slf4j:1.7.30') { exclude group: 'org.slf4j' } - implementation('com.sparrowwallet.nightjar:nightjar:0.2.9') + implementation('com.sparrowwallet.nightjar:nightjar:0.2.10') testImplementation('junit:junit:4.12') } @@ -387,7 +387,7 @@ extraJavaModuleInfo { module('cbor-0.9.jar', 'co.nstant.in.cbor', '0.9') { exports('co.nstant.in.cbor') } - module('nightjar-0.2.9.jar', 'com.sparrowwallet.nightjar', '0.2.9') { + module('nightjar-0.2.10.jar', 'com.sparrowwallet.nightjar', '0.2.10') { requires('com.google.common') requires('net.sourceforge.streamsupport') requires('org.slf4j') diff --git a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java index ab195cf1..ce2279e5 100644 --- a/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java +++ b/src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java @@ -344,10 +344,10 @@ public class Whirlpool { @Subscribe public void onMixSuccess(MixSuccessEvent e) { - log.debug("Mix success, new utxo " + e.getMixSuccess().getReceiveUtxo().getHash() + ":" + e.getMixSuccess().getReceiveUtxo().getIndex()); - persistMixData(); WalletUtxo walletUtxo = getUtxo(e.getWhirlpoolUtxo()); if(walletUtxo != null) { + log.debug("Mix success, new utxo " + e.getMixSuccess().getReceiveUtxo().getHash() + ":" + e.getMixSuccess().getReceiveUtxo().getIndex()); + persistMixData(); Platform.runLater(() -> EventManager.get().post(new WhirlpoolMixSuccessEvent(walletUtxo.wallet, walletUtxo.utxo, e.getMixSuccess().getReceiveUtxo(), getReceiveNode(e, walletUtxo)))); } } @@ -364,30 +364,34 @@ public class Whirlpool { @Subscribe public void onMixFail(MixFailEvent e) { - log.debug("Mix failed for utxo " + e.getWhirlpoolUtxo().getUtxo().tx_hash + ":" + e.getWhirlpoolUtxo().getUtxo().tx_output_n + " " + e.getMixFailReason()); 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()))); } } @Subscribe public void onMixProgress(MixProgressEvent e) { - log.debug("Mix progress for utxo " + e.getWhirlpoolUtxo().getUtxo().tx_hash + ":" + e.getWhirlpoolUtxo().getUtxo().tx_output_n + " " + e.getWhirlpoolUtxo().getMixsDone() + " " + e.getMixProgress().getMixStep() + " " + e.getWhirlpoolUtxo().getUtxoState().getStatus()); WalletUtxo walletUtxo = getUtxo(e.getWhirlpoolUtxo()); if(walletUtxo != null && isMixing()) { + log.debug("Mix progress for utxo " + e.getWhirlpoolUtxo().getUtxo().tx_hash + ":" + e.getWhirlpoolUtxo().getUtxo().tx_output_n + " " + e.getWhirlpoolUtxo().getMixsDone() + " " + e.getMixProgress().getMixStep() + " " + e.getWhirlpoolUtxo().getUtxoState().getStatus()); Platform.runLater(() -> EventManager.get().post(new WhirlpoolMixEvent(walletUtxo.wallet, walletUtxo.utxo, e.getMixProgress()))); } } @Subscribe public void onWalletStart(WalletStartEvent e) { - mixingProperty.set(true); + if(e.getWhirlpoolWallet() == whirlpoolWalletService.whirlpoolWallet()) { + mixingProperty.set(true); + } } @Subscribe public void onWalletStop(WalletStopEvent e) { - mixingProperty.set(false); + if(e.getWhirlpoolWallet() == whirlpoolWalletService.whirlpoolWallet()) { + mixingProperty.set(false); + } } public static class PoolsService extends Service> {