Skip to content

Commit

Permalink
Merge pull request #15 from MAGICGrants/scripts
Browse files Browse the repository at this point in the history
fix: only attempt to open monero wallet when necessary
  • Loading branch information
SamsungGalaxyPlayer authored Oct 15, 2024
2 parents e75deb0 + 7541f3f commit 4d48a64
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ast
from requests.auth import HTTPDigestAuth
from datetime import datetime
import urllib.parse
Expand Down Expand Up @@ -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...')
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 4d48a64

Please sign in to comment.