Merge pull request #544 from NebulousLabs/print-wallet-address-on-low-funds

Add wallet address to funds check message when funds are low
This commit is contained in:
Karol Wypchło 2020-11-30 11:09:06 +01:00 committed by GitHub
commit 43f535c82b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -161,6 +161,14 @@ class siad:
def load_json(resp): def load_json(resp):
return json.loads(resp.decode("utf-8")) return json.loads(resp.decode("utf-8"))
@staticmethod
def get(endpoint):
if not setup_done:
setup()
resp = urllib.request.urlopen(api_endpoint + endpoint).read()
return siad.load_json(resp)
@staticmethod @staticmethod
def get_wallet(): def get_wallet():
if not setup_done: if not setup_done:

View File

@ -64,7 +64,9 @@ async def check_funds():
# Send an alert if there is less than 1 allowance worth of money left. # Send an alert if there is less than 1 allowance worth of money left.
if balance < allowance_funds: if balance < allowance_funds:
message = "__Wallet balance running low!__ {}".format(balance_msg) wallet_address_res = siad.get("/wallet/address")
wallet_msg = "Address: {}".format(wallet_address_res["address"])
message = "__Wallet balance running low!__ {} {}".format(balance_msg, wallet_msg)
return await send_msg(client, message, force_notify=True) return await send_msg(client, message, force_notify=True)
# Alert devs when only a fraction of the allowance is remaining. # Alert devs when only a fraction of the allowance is remaining.