From 5bf20370eb39dd2daa6fda6d052e129d9194c7ff Mon Sep 17 00:00:00 2001 From: nahuhh <50635951+nahuhh@users.noreply.github.com> Date: Thu, 14 Nov 2024 22:45:28 +0000 Subject: [PATCH 1/2] basicswap: remove extra xmr wallet open --- basicswap/basicswap.py | 12 ------------ basicswap/interface/xmr.py | 20 ++++++++++++++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 3e29940..2946d38 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -1055,18 +1055,6 @@ class BasicSwap(BaseApp): except Exception as e: self.log.error("Sanity checks failed: %s", str(e)) - elif c == Coins.XMR: - try: - ci.ensureWalletExists() - except Exception as e: # noqa: F841 - self.log.warning("Can't open XMR wallet, could be locked.") - continue - elif c == Coins.WOW: - try: - ci.ensureWalletExists() - except Exception as e: # noqa: F841 - self.log.warning("Can't open WOW wallet, could be locked.") - continue elif c == Coins.LTC: ci_mweb = self.ci(Coins.LTC_MWEB) is_encrypted, _ = self.getLockedState() diff --git a/basicswap/interface/xmr.py b/basicswap/interface/xmr.py index 1f2759f..71c9535 100644 --- a/basicswap/interface/xmr.py +++ b/basicswap/interface/xmr.py @@ -182,11 +182,23 @@ class XMRInterface(CoinInterface): params["password"] = self._wallet_password try: - # Can't reopen the same wallet in windows, !is_keys_file_locked() - self.rpc_wallet("close_wallet") + self.rpc_wallet("open_wallet", params) + # TODO Remove `refresh` after upstream fix to refresh on open_wallet + self.rpc_wallet("refresh") except Exception: - pass - self.rpc_wallet("open_wallet", params) + self._log.debug(f"Failed to open {self.coin_name()} wallet") + try: + # TODO Remove `store` after upstream fix to autosave on close_wallet + self.rpc_wallet("store") + self.rpc_wallet("close_wallet") + self._log.debug(f"Attempt to save and close {self.coin_name()} wallet") + except Exception as e: + self._log.debug(f"{self.coin_name()}: {e}") + pass + self.rpc_wallet("open_wallet", params) + # TODO Remove `refresh` after upstream fix to refresh on open_wallet + self.rpc_wallet("refresh") + self._log.debug(f"Reattempt to open {self.coin_name()} wallet") def initialiseWallet( self, key_view: bytes, key_spend: bytes, restore_height=None From 8795ecc2318bf5b879f51ea5c6a3b0d01e09c4ac Mon Sep 17 00:00:00 2001 From: nahuhh <50635951+nahuhh@users.noreply.github.com> Date: Sat, 16 Nov 2024 14:05:10 +0000 Subject: [PATCH 2/2] interface: xmr.py - remove extra refreshs --- basicswap/interface/xmr.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/basicswap/interface/xmr.py b/basicswap/interface/xmr.py index 71c9535..80cb7c1 100644 --- a/basicswap/interface/xmr.py +++ b/basicswap/interface/xmr.py @@ -135,6 +135,7 @@ class XMRInterface(CoinInterface): self._rpctimeout = coin_settings.get("rpctimeout", 60) self._walletrpctimeout = coin_settings.get("walletrpctimeout", 120) + # walletrpctimeoutlong likely unneeded self._walletrpctimeoutlong = coin_settings.get("walletrpctimeoutlong", 600) self.rpc = make_xmr_rpc_func( @@ -284,7 +285,6 @@ class XMRInterface(CoinInterface): raise e rv = {} - self.rpc_wallet("refresh") balance_info = self.rpc_wallet("get_balance") rv["balance"] = self.format_amount(balance_info["unlocked_balance"]) @@ -385,7 +385,6 @@ class XMRInterface(CoinInterface): ) -> bytes: with self._mx_wallet: self.openWallet(self._wallet_filename) - self.rpc_wallet("refresh") Kbv = self.getPubkey(kbv) shared_addr = xmr_util.encode_address(Kbv, Kbs, self._addr_prefix) @@ -425,8 +424,6 @@ class XMRInterface(CoinInterface): self.createWallet(params) self.openWallet(address_b58) - self.rpc_wallet("refresh", timeout=self._walletrpctimeoutlong) - """ # Debug try: @@ -478,7 +475,6 @@ class XMRInterface(CoinInterface): def findTxnByHash(self, txid): with self._mx_wallet: self.openWallet(self._wallet_filename) - self.rpc_wallet("refresh", timeout=self._walletrpctimeoutlong) try: current_height = self.rpc2("get_height", timeout=self._rpctimeout)[ @@ -547,7 +543,6 @@ class XMRInterface(CoinInterface): self.createWallet(params) self.openWallet(wallet_filename) - self.rpc_wallet("refresh") rv = self.rpc_wallet("get_balance") if rv["balance"] < cb_swap_value: self._log.warning("Balance is too low, checking for existing spend.") @@ -602,7 +597,6 @@ class XMRInterface(CoinInterface): ) -> str: with self._mx_wallet: self.openWallet(self._wallet_filename) - self.rpc_wallet("refresh") if sweepall: balance = self.rpc_wallet("get_balance") @@ -682,8 +676,6 @@ class XMRInterface(CoinInterface): self.createWallet(params) self.openWallet(address_b58) - self.rpc_wallet("refresh") - rv = self.rpc_wallet( "get_transfers", {"in": True, "out": True, "pending": True, "failed": True}, @@ -697,7 +689,6 @@ class XMRInterface(CoinInterface): with self._mx_wallet: self.openWallet(self._wallet_filename) - self.rpc_wallet("refresh") balance_info = self.rpc_wallet("get_balance") return balance_info["unlocked_balance"]