friendspool
unknown
python
a year ago
2.8 kB
1
Indexable
Never
from os import system from time import sleep from json import loads from datetime import datetime from urllib.request import urlopen urlBase = 'http://etc.friendspool.net' def convertHashrate(hashrate): match len(str(hashrate)): case 4: return round(hashrate / 1000), 'KH/s' case 5 | 6 | 7 | 8 | 9: return round(hashrate / 1e6, 2), 'MH/s' case 10 | 11 | 12: return round(hashrate / 1e9, 2), 'GH/s' def convertUnixTime(unixtime): utctime = datetime.utcfromtimestamp(unixtime) return utctime.strftime('%d/%m/%Y %H:%M:%S') def getPoolNewBlock(): request = urlopen('%s/api/stats' %urlBase) textObj = request.read() jsonObj = loads(textObj) if jsonObj['immatureTotal'] > 0: for key in jsonObj['immature']: return round(key['reward'] / 1e9, 8) else: return None def getPoolHashrate(): request = urlopen('%s/api/stats' %urlBase) textObj = request.read() jsonObj = loads(textObj) return convertHashrate(jsonObj['hashrate']) def getMyHashrate(wallet): request = urlopen('%s/api/accounts/%s' %(urlBase, wallet)) textObj = request.read() jsonObj = loads(textObj) return convertHashrate(jsonObj['currentHashrate']) def totalPaid(wallet): request = urlopen('%s/api/accounts/%s' %(urlBase, wallet)) textObj = request.read() jsonObj = loads(textObj) return round(jsonObj['stats']['paid'] / 1e9, 8) def totalPayments(wallet): request = urlopen('%s/api/accounts/%s' %(urlBase, wallet)) textObj = request.read() jsonObj = loads(textObj) payments = [] for key in jsonObj['payments']: txhash = key['tx'] amount = round(key['amount'] / 1e9, 8) localtime = convertUnixTime(key['timestamp']) payments.append('%s %s ETC' %(localtime, amount)) return '\n'.join(list(set(payments))) def main(wallet='0xc4ebb5469a9baf0b65a14005bb17c7ec1523793b'): while True: system('clear') try: print('~' * 41) print('\t\tHASHRATE\n') print('\t• POOL : %s %s' %getPoolHashrate()) print('\t• MINERADOR: %s %s\n' %getMyHashrate(wallet)) print('~' * 41) print('\t\tSALDO\n') print('\t • %s ETC\n' %totalPaid(wallet)) print('~' * 41) print('\t\tPAGAMENTOS\n') print(' • %s\n' %totalPayments(wallet)) newblock = getPoolNewBlock() if newblock != None: print('~' * 41) print('\t\tNOVO BLOCO ENCONTRADO!\n') print('\t• RECOMPENSA: %s ETC' %newblock) except: pass sleep(10) if __name__ == '__main__': main()