Fix errors when one coin wallet fails to unlock.
This commit is contained in:
parent
66d1abd888
commit
1068694990
@ -1,3 +1,3 @@
|
|||||||
name = "basicswap"
|
name = "basicswap"
|
||||||
|
|
||||||
__version__ = "0.12.4"
|
__version__ = "0.12.5"
|
||||||
|
@ -244,6 +244,10 @@ class BasicSwap(BaseApp):
|
|||||||
self._possibly_revoked_offers = collections.deque([], maxlen=48) # TODO: improve
|
self._possibly_revoked_offers = collections.deque([], maxlen=48) # TODO: improve
|
||||||
self._updating_wallets_info = {}
|
self._updating_wallets_info = {}
|
||||||
self._last_updated_wallets_info = 0
|
self._last_updated_wallets_info = 0
|
||||||
|
self._zmq_queue_enabled = self.settings.get('zmq_queue_enabled', True)
|
||||||
|
self._poll_smsg = self.settings.get('poll_smsg', False)
|
||||||
|
self.check_smsg_seconds = self.settings.get('check_smsg_seconds', 10)
|
||||||
|
self._last_checked_smsg = 0
|
||||||
|
|
||||||
self._notifications_enabled = self.settings.get('notifications_enabled', True)
|
self._notifications_enabled = self.settings.get('notifications_enabled', True)
|
||||||
self._disabled_notification_types = self.settings.get('disabled_notification_types', [])
|
self._disabled_notification_types = self.settings.get('disabled_notification_types', [])
|
||||||
@ -336,6 +340,7 @@ class BasicSwap(BaseApp):
|
|||||||
session.close()
|
session.close()
|
||||||
session.remove()
|
session.remove()
|
||||||
|
|
||||||
|
if self._zmq_queue_enabled:
|
||||||
self.zmqContext = zmq.Context()
|
self.zmqContext = zmq.Context()
|
||||||
self.zmqSubscriber = self.zmqContext.socket(zmq.SUB)
|
self.zmqSubscriber = self.zmqContext.socket(zmq.SUB)
|
||||||
|
|
||||||
@ -388,6 +393,7 @@ class BasicSwap(BaseApp):
|
|||||||
else:
|
else:
|
||||||
self.thread_pool.shutdown()
|
self.thread_pool.shutdown()
|
||||||
|
|
||||||
|
if self._zmq_queue_enabled:
|
||||||
self.zmqContext.destroy()
|
self.zmqContext.destroy()
|
||||||
|
|
||||||
self.swaps_in_progress.clear()
|
self.swaps_in_progress.clear()
|
||||||
@ -690,6 +696,9 @@ class BasicSwap(BaseApp):
|
|||||||
upgradeDatabase(self, self.db_version)
|
upgradeDatabase(self, self.db_version)
|
||||||
upgradeDatabaseData(self, self.db_data_version)
|
upgradeDatabaseData(self, self.db_data_version)
|
||||||
|
|
||||||
|
if self._zmq_queue_enabled and self._poll_smsg:
|
||||||
|
self.log.warning('SMSG polling and zmq listener enabled.')
|
||||||
|
|
||||||
for c in Coins:
|
for c in Coins:
|
||||||
if c not in chainparams:
|
if c not in chainparams:
|
||||||
continue
|
continue
|
||||||
@ -908,18 +917,26 @@ class BasicSwap(BaseApp):
|
|||||||
self._is_encrypted, self._is_locked = self.ci(Coins.PART).isWalletEncryptedLocked()
|
self._is_encrypted, self._is_locked = self.ci(Coins.PART).isWalletEncryptedLocked()
|
||||||
|
|
||||||
def unlockWallets(self, password: str, coin=None) -> None:
|
def unlockWallets(self, password: str, coin=None) -> None:
|
||||||
|
try:
|
||||||
self._read_zmq_queue = False
|
self._read_zmq_queue = False
|
||||||
for c in self.getListOfWalletCoins():
|
for c in self.getListOfWalletCoins():
|
||||||
if coin and c != coin:
|
if coin and c != coin:
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
self.ci(c).unlockWallet(password)
|
self.ci(c).unlockWallet(password)
|
||||||
|
except Exception as e:
|
||||||
|
self.log.warning('Failed to unlock wallet {}'.format(getCoinName(c)))
|
||||||
|
if coin is not None or c == Coins.PART:
|
||||||
|
raise e
|
||||||
if c == Coins.PART:
|
if c == Coins.PART:
|
||||||
self._is_locked = False
|
self._is_locked = False
|
||||||
|
|
||||||
self.loadFromDB()
|
self.loadFromDB()
|
||||||
|
finally:
|
||||||
self._read_zmq_queue = True
|
self._read_zmq_queue = True
|
||||||
|
|
||||||
def lockWallets(self, coin=None) -> None:
|
def lockWallets(self, coin=None) -> None:
|
||||||
|
try:
|
||||||
self._read_zmq_queue = False
|
self._read_zmq_queue = False
|
||||||
self.swaps_in_progress.clear()
|
self.swaps_in_progress.clear()
|
||||||
|
|
||||||
@ -929,6 +946,7 @@ class BasicSwap(BaseApp):
|
|||||||
self.ci(c).lockWallet()
|
self.ci(c).lockWallet()
|
||||||
if c == Coins.PART:
|
if c == Coins.PART:
|
||||||
self._is_locked = True
|
self._is_locked = True
|
||||||
|
finally:
|
||||||
self._read_zmq_queue = True
|
self._read_zmq_queue = True
|
||||||
|
|
||||||
def initialiseWallet(self, coin_type, raise_errors: bool = False) -> None:
|
def initialiseWallet(self, coin_type, raise_errors: bool = False) -> None:
|
||||||
@ -4236,7 +4254,7 @@ class BasicSwap(BaseApp):
|
|||||||
self.log.error(traceback.format_exc())
|
self.log.error(traceback.format_exc())
|
||||||
|
|
||||||
now: int = self.getTime()
|
now: int = self.getTime()
|
||||||
options = {'encoding': 'none'}
|
options = {'encoding': 'none', 'setread': False}
|
||||||
inbox_messages = ci_part.json_request(rpc_conn, 'smsginbox', ['all', '', options])['messages']
|
inbox_messages = ci_part.json_request(rpc_conn, 'smsginbox', ['all', '', options])['messages']
|
||||||
for msg in inbox_messages:
|
for msg in inbox_messages:
|
||||||
remove_if_expired(msg)
|
remove_if_expired(msg)
|
||||||
@ -6055,6 +6073,7 @@ class BasicSwap(BaseApp):
|
|||||||
self.processMsg(msg)
|
self.processMsg(msg)
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
|
if self._zmq_queue_enabled:
|
||||||
try:
|
try:
|
||||||
if self._read_zmq_queue:
|
if self._read_zmq_queue:
|
||||||
message = self.zmqSubscriber.recv(flags=zmq.NOBLOCK)
|
message = self.zmqSubscriber.recv(flags=zmq.NOBLOCK)
|
||||||
@ -6065,6 +6084,15 @@ class BasicSwap(BaseApp):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.logException(f'smsg zmq {ex}')
|
self.logException(f'smsg zmq {ex}')
|
||||||
|
|
||||||
|
if self._poll_smsg:
|
||||||
|
now: int = self.getTime()
|
||||||
|
if now - self._last_checked_smsg >= self.check_smsg_seconds:
|
||||||
|
self._last_checked_smsg = now
|
||||||
|
options = {'encoding': 'hex', 'setread': True}
|
||||||
|
msgs = self.callrpc('smsginbox', ['unread', '', options])
|
||||||
|
for msg in msgs['messages']:
|
||||||
|
self.processMsg(msg)
|
||||||
|
|
||||||
self.mxDB.acquire()
|
self.mxDB.acquire()
|
||||||
try:
|
try:
|
||||||
# TODO: Wait for blocks / txns, would need to check multiple coins
|
# TODO: Wait for blocks / txns, would need to check multiple coins
|
||||||
|
@ -61,6 +61,8 @@ def page_unlock(self, url_split, post_string):
|
|||||||
self.end_headers()
|
self.end_headers()
|
||||||
return bytes()
|
return bytes()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if swap_client.debug is True:
|
||||||
|
swap_client.log.error(str(e))
|
||||||
err_messages.append(str(e))
|
err_messages.append(str(e))
|
||||||
|
|
||||||
template = server.env.get_template('unlock.html')
|
template = server.env.get_template('unlock.html')
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
0.12.5
|
||||||
|
==============
|
||||||
|
|
||||||
|
- Unlock wallets logs an error when failing to unlock a wallet.
|
||||||
|
- Fixed bug where failed unlock prevents processing incoming smsg messages.
|
||||||
|
|
||||||
|
|
||||||
0.12.4
|
0.12.4
|
||||||
==============
|
==============
|
||||||
|
Loading…
Reference in New Issue
Block a user