diff --git a/src/util.py b/src/util.py index 17dab1d..8f03ef1 100644 --- a/src/util.py +++ b/src/util.py @@ -1,3 +1,4 @@ +import ast from requests.auth import HTTPDigestAuth from datetime import datetime import urllib.parse @@ -70,7 +71,7 @@ def open_bitcoin_wallet(): def open_monero_wallet() -> None: params = {'filename': 'wallet', 'password': env.MONERO_WALLET_PASSWORD} - print(request_monero_rpc('open_wallet', params)) + request_monero_rpc('open_wallet', params) def wait_for_rpc(): print('Waiting for Electrum RPC...') @@ -105,10 +106,17 @@ def wait_for_wallets(): while 1: try: - open_monero_wallet() + request_monero_rpc('get_balance', {'account_index': 0}) break except Exception as e: - print(e) + error = ast.literal_eval(str(e)) + if not (isinstance(error, dict) and error.get('error', {}).get('message')): + raise e + + try: + open_monero_wallet() + break + except: time.sleep(10) def get_kraken_signature(url: str, payload: dict):