From f17c5803b59771625974400b87219adbdaf73b3d Mon Sep 17 00:00:00 2001 From: woodser Date: Mon, 27 Jun 2022 21:21:32 -0400 Subject: [PATCH] stopping wallet rpc instance does not assume to close wallet --- .../core/btc/setup/MoneroWalletRpcManager.java | 6 ++---- .../bisq/core/btc/wallet/XmrWalletService.java | 14 +++++++++++--- .../bisq/desktop/components/TextFieldWithIcon.java | 6 ++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/bisq/core/btc/setup/MoneroWalletRpcManager.java b/core/src/main/java/bisq/core/btc/setup/MoneroWalletRpcManager.java index 6d207d48..afc32160 100644 --- a/core/src/main/java/bisq/core/btc/setup/MoneroWalletRpcManager.java +++ b/core/src/main/java/bisq/core/btc/setup/MoneroWalletRpcManager.java @@ -97,9 +97,8 @@ public class MoneroWalletRpcManager { * Stop an instance of monero-wallet-rpc. * * @param walletRpc the client connected to the monero-wallet-rpc instance to stop - * @param save specifies if the wallet should be saved before closing */ - public void stopInstance(MoneroWalletRpc walletRpc, boolean save) { + public void stopInstance(MoneroWalletRpc walletRpc) { // unregister port synchronized (registeredPorts) { @@ -118,8 +117,7 @@ public class MoneroWalletRpcManager { if (!found) throw new RuntimeException("MoneroWalletRpc instance not registered with a port"); } - // close wallet and stop process - walletRpc.close(save); + // stop process walletRpc.stopProcess(); } diff --git a/core/src/main/java/bisq/core/btc/wallet/XmrWalletService.java b/core/src/main/java/bisq/core/btc/wallet/XmrWalletService.java index f168f191..98fd3be3 100644 --- a/core/src/main/java/bisq/core/btc/wallet/XmrWalletService.java +++ b/core/src/main/java/bisq/core/btc/wallet/XmrWalletService.java @@ -40,6 +40,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.inject.Inject; +import monero.common.MoneroError; import monero.common.MoneroRpcConnection; import monero.common.MoneroUtils; import monero.daemon.MoneroDaemon; @@ -434,7 +435,7 @@ public class XmrWalletService { return walletRpc; } catch (Exception e) { e.printStackTrace(); - MONERO_WALLET_RPC_MANAGER.stopInstance(walletRpc, false); + MONERO_WALLET_RPC_MANAGER.stopInstance(walletRpc); throw e; } } @@ -451,7 +452,7 @@ public class XmrWalletService { return walletRpc; } catch (Exception e) { e.printStackTrace(); - MONERO_WALLET_RPC_MANAGER.stopInstance(walletRpc, false); + MONERO_WALLET_RPC_MANAGER.stopInstance(walletRpc); throw e; } } @@ -549,7 +550,14 @@ public class XmrWalletService { private void closeWallet(MoneroWallet walletRpc, boolean save) { log.info("{}.closeWallet({}, {})", getClass().getSimpleName(), walletRpc.getPath(), save); - MONERO_WALLET_RPC_MANAGER.stopInstance((MoneroWalletRpc) walletRpc, save); + MoneroError err = null; + try { + walletRpc.close(save); + } catch (MoneroError e) { + err = e; + } + MONERO_WALLET_RPC_MANAGER.stopInstance((MoneroWalletRpc) walletRpc); + if (err != null) throw err; } private void deleteWallet(String walletName) { diff --git a/desktop/src/main/java/bisq/desktop/components/TextFieldWithIcon.java b/desktop/src/main/java/bisq/desktop/components/TextFieldWithIcon.java index d2a28028..eee8e4cc 100644 --- a/desktop/src/main/java/bisq/desktop/components/TextFieldWithIcon.java +++ b/desktop/src/main/java/bisq/desktop/components/TextFieldWithIcon.java @@ -19,7 +19,7 @@ package bisq.desktop.components; import de.jensd.fx.fontawesome.AwesomeDude; import de.jensd.fx.fontawesome.AwesomeIcon; - +import bisq.common.UserThread; import com.jfoenix.controls.JFXTextField; import javafx.scene.control.Label; @@ -66,7 +66,9 @@ public class TextFieldWithIcon extends AnchorPane { } public void setIcon(AwesomeIcon iconLabel) { - AwesomeDude.setIcon(this.iconLabel, iconLabel); + UserThread.execute(() -> { + AwesomeDude.setIcon(this.iconLabel, iconLabel); + }); } public void setText(String text) {