diff --git a/pybitblock/SPV/clockscript.py b/pybitblock/SPV/clockscript.py index 5f90a25..49315ff 100644 --- a/pybitblock/SPV/clockscript.py +++ b/pybitblock/SPV/clockscript.py @@ -2,9 +2,11 @@ import pickle import os import sys import base64, codecs, json, requests +import time as t from cfonts import render, say + def clear(): # clear the screen os.system('cls' if os.name=='nt' else 'clear') @@ -22,7 +24,7 @@ def rectangle(n): f'{""*n}{"|"*n}{""*n}' if i >= (n+1)/2 and i <= (1*n)/2 else - f'\u001b[38;5;27m{"■"*(x-1)}' + f'\033[A\u001b[38;5;27m{"■"*(x-1)}\033[A' ) for i in range(y) ) @@ -52,6 +54,12 @@ def artist(): # here we convert the result of the command 'getblockcount' on a r except: break +def pathexec(): + global path + path = {"ip_port":"", "rpcuser":"", "rpcpass":"", "bitcoincli":""} + pathv = pickle.load(open("config/bclock.conf", "rb")) # Load the file 'bclock.conf' + path = pathv # Copy the variable pathv to 'path' + def design(): while True: if os.path.isfile('config/pyblocksettingsClock.conf') or os.path.isfile('config/pyblocksettingsClock.conf'): # Check if the file 'bclock.conf' is in the same folder @@ -122,8 +130,6 @@ def design(): output = render(str(b), colors=[settingsClock['colorA'], settingsClock['colorB']], align='center') print("\x1b[?25l" + output) - - settings = {"gradient":"", "design":"block", "colorA":"green", "colorB":"yellow"} settingsClock = {"gradient":"", "colorA":"green", "colorB":"yellow"} while True: # Loop @@ -144,7 +150,6 @@ while True: # Loop print("\n\tLocal Bitcoin Core Node connection.\n") path['bitcoincli']= input("Insert the Path to Bitcoin-Cli: ") pickle.dump(path, open("config/bclock.conf", "wb")) - artist() diff --git a/pybitblock/SPV/mempoolclock.py b/pybitblock/SPV/mempoolclock.py new file mode 100644 index 0000000..38ce07c --- /dev/null +++ b/pybitblock/SPV/mempoolclock.py @@ -0,0 +1,85 @@ +import pickle +import os +import sys +import base64, codecs, json, requests +import time as t +from cfonts import render, say + + + +def clear(): # clear the screen + os.system('cls' if os.name=='nt' else 'clear') + +def rectangle(n): + x = n - 3 + y = n - x + [ + print(''.join(i)) + for i in + ( + ''*x + if i in (0,y-1) + else + ( + f'{""*n}{"|"*n}{""*n}' + if i >= (n+1)/2 and i <= (1*n)/2 + else + f'\033[A\u001b[38;5;27m{"■"*(x-1)}\033[A' + ) + for i in range(y) + ) + ] + +def pathexec(): + global path + path = {"ip_port":"", "rpcuser":"", "rpcpass":"", "bitcoincli":""} + pathv = pickle.load(open("config/bclock.conf", "rb")) # Load the file 'bclock.conf' + path = pathv # Copy the variable pathv to 'path' + +def counttxs(): + while True: + try: + pathexec() + clear() + getrawmempool = " getrawmempool" + gna = os.popen(path['bitcoincli'] + getrawmempool) + gnaa = gna.read() + gna1 = str(gnaa) + d = json.loads(gna1) + e = len(d) + n = e / 10 + outputtxs = render(str(e) + " txs", colors=[settingsClock['colorA'], settingsClock['colorB']], align='center', font='tiny') + print("\x1b[?25l" + outputtxs) + shq = int(n) + ss = str(rectangle(shq)) + qq = ss.replace("None","") + print(f"\033[A{qq}\033[A") + t.sleep(10) + except: + break +settings = {"gradient":"", "design":"block", "colorA":"green", "colorB":"yellow"} +settingsClock = {"gradient":"", "colorA":"green", "colorB":"yellow"} +while True: # Loop + try: + clear() + path = {"ip_port":"", "rpcuser":"", "rpcpass":"", "bitcoincli":""} + + if os.path.isfile('config/bclock.conf') or os.path.isfile('config/blnclock.conf'): # Check if the file 'bclock.conf' is in the same folder + pathv = pickle.load(open("config/bclock.conf", "rb")) # Load the file 'bclock.conf' + path = pathv # Copy the variable pathv to 'path' + else: + blogo() + print("Welcome to \033[1;31;40mPyBLOCK\033[0;37;40m\n\n") + print("\n\tIf you are going to use your local node leave IP:PORT/USER/PASSWORD in blank.\n") + path['ip_port'] = "http://{}".format(input("Insert IP:PORT to access your remote Bitcoin-Cli node: ")) + path['rpcuser'] = input("RPC User: ") + path['rpcpass'] = input("RPC Password: ") + print("\n\tLocal Bitcoin Core Node connection.\n") + path['bitcoincli']= input("Insert the Path to Bitcoin-Cli: ") + pickle.dump(path, open("config/bclock.conf", "wb")) + artist() + + + except: + print("\n") + sys.exit(101)