mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-06 02:38:11 +01:00
xmr: detect corrupt wallets
This commit is contained in:
@@ -1054,7 +1054,9 @@ class BasicSwap(BaseApp):
|
|||||||
elif c in (Coins.XMR, Coins.WOW):
|
elif c in (Coins.XMR, Coins.WOW):
|
||||||
try:
|
try:
|
||||||
ci.ensureWalletExists()
|
ci.ensureWalletExists()
|
||||||
except Exception as e: # noqa: F841
|
except Exception as e:
|
||||||
|
if "invalid signature" in str(e): # wallet is corrupt
|
||||||
|
raise
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
f"Can't open {ci.coin_name()} wallet, could be locked."
|
f"Can't open {ci.coin_name()} wallet, could be locked."
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -30,3 +30,27 @@ class WOWInterface(XMRInterface):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def depth_spendable() -> int:
|
def depth_spendable() -> int:
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
|
# below only needed until wow is rebased to monero v0.18.4.0+
|
||||||
|
def openWallet(self, filename):
|
||||||
|
params = {"filename": filename}
|
||||||
|
if self._wallet_password is not None:
|
||||||
|
params["password"] = self._wallet_password
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.rpc_wallet("open_wallet", params)
|
||||||
|
except Exception as e:
|
||||||
|
if "no connection to daemon" in str(e):
|
||||||
|
self._log.debug(f"{self.coin_name()} {e}")
|
||||||
|
return # bypass refresh error to allow startup with a busy daemon
|
||||||
|
|
||||||
|
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: # noqa: F841
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.rpc_wallet("open_wallet", params)
|
||||||
|
self._log.debug(f"Reattempt to open {self.coin_name()} wallet")
|
||||||
|
|||||||
@@ -205,17 +205,18 @@ class XMRInterface(CoinInterface):
|
|||||||
if "no connection to daemon" in str(e):
|
if "no connection to daemon" in str(e):
|
||||||
self._log.debug(f"{self.coin_name()} {e}")
|
self._log.debug(f"{self.coin_name()} {e}")
|
||||||
return # bypass refresh error to allow startup with a busy daemon
|
return # bypass refresh error to allow startup with a busy daemon
|
||||||
|
if "invalid signature" in str(e):
|
||||||
|
self._log.debug(f"{self.coin_name()} wallet is corrupt")
|
||||||
|
raise
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# TODO Remove `store` after upstream fix to autosave on close_wallet
|
|
||||||
self.rpc_wallet("store")
|
|
||||||
self.rpc_wallet("close_wallet")
|
self.rpc_wallet("close_wallet")
|
||||||
self._log.debug(f"Attempt to save and close {self.coin_name()} wallet")
|
self._log.debug(f"Closing {self.coin_name()} wallet")
|
||||||
except Exception as e: # noqa: F841
|
except Exception as e: # noqa: F841
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.rpc_wallet("open_wallet", params)
|
self.rpc_wallet("open_wallet", params)
|
||||||
self._log.debug(f"Reattempt to open {self.coin_name()} wallet")
|
self._log.debug(f"Attempting to open {self.coin_name()} wallet")
|
||||||
|
|
||||||
def initialiseWallet(
|
def initialiseWallet(
|
||||||
self, key_view: bytes, key_spend: bytes, restore_height=None
|
self, key_view: bytes, key_spend: bytes, restore_height=None
|
||||||
|
|||||||
Reference in New Issue
Block a user