2020-05-06 16:34:55 -03:00
|
|
|
import os
|
|
|
|
|
import time as t
|
2020-05-08 08:37:26 -03:00
|
|
|
from art import *
|
2020-05-06 16:34:55 -03:00
|
|
|
|
2020-05-09 18:22:43 -03:00
|
|
|
|
|
|
|
|
#/home/pi/Documents/bitcoin-0.19.1/bin/./bitcoin-cli -datadir=/mnt/royal/Bitcoin
|
|
|
|
|
|
2020-05-08 08:37:26 -03:00
|
|
|
def getblock(): # get access to bitcoin-cli with the command getblockchaininfo
|
2020-05-07 10:59:47 -03:00
|
|
|
bitcoincli = " getblockchaininfo"
|
|
|
|
|
os.system(path + bitcoincli)
|
|
|
|
|
|
2020-05-09 18:22:43 -03:00
|
|
|
|
2020-05-08 08:37:26 -03:00
|
|
|
def getblockcount(): # get access to bitcoin-cli with the command getblockcount
|
2020-05-07 10:59:47 -03:00
|
|
|
bitcoincli = " getblockcount"
|
2020-05-06 17:04:20 -03:00
|
|
|
os.system(path + bitcoincli)
|
|
|
|
|
|
2020-05-08 08:37:26 -03:00
|
|
|
def clear(): # clear the screen
|
2020-05-06 16:34:55 -03:00
|
|
|
os.system('cls' if os.name=='nt' else 'clear')
|
2020-05-09 18:22:43 -03:00
|
|
|
|
2020-05-06 17:04:20 -03:00
|
|
|
|
2020-05-09 18:22:43 -03:00
|
|
|
def connection(conn): # here we initiate the connection function
|
|
|
|
|
if conn == "Y" or conn == "y":
|
|
|
|
|
nodeinfo() # call 'nodeinfo' function that makes the connection to an external node
|
|
|
|
|
else:
|
|
|
|
|
a = input("Do you want to see just Block height? 'Yes', for just Block Height. 'No', for full blockchain data. Y/n: ")
|
|
|
|
|
if a == "y" or a == "Y":
|
|
|
|
|
while True:
|
|
|
|
|
clear()
|
|
|
|
|
artist()
|
|
|
|
|
getblockcount()
|
|
|
|
|
tmp()
|
|
|
|
|
else:
|
|
|
|
|
while True:
|
|
|
|
|
clear()
|
|
|
|
|
getblock()
|
|
|
|
|
tmp()
|
2020-05-08 19:20:11 +02:00
|
|
|
|
2020-05-09 18:22:43 -03:00
|
|
|
def connected(info): # here we complete the connection to the external node
|
|
|
|
|
if info == "Y" or info == "y":
|
|
|
|
|
user = input("USER@NODE: ")
|
|
|
|
|
s = input("Do you want to see the blockheight? Y/n: ")
|
|
|
|
|
if s == "Y" or s == "y":
|
|
|
|
|
c = input("Do you want to see custom design? Y/n: ")
|
|
|
|
|
if c == "Y" or c == "y":
|
|
|
|
|
while True: # connection via ssh
|
|
|
|
|
clear()
|
|
|
|
|
sshb = "ssh " + user + " '" + "{}".format(path) + "'" + " getblockcount"
|
|
|
|
|
os.system(sshb)
|
|
|
|
|
sshc = os.popen(str(sshb)).read()
|
|
|
|
|
sshd = sshc
|
|
|
|
|
tprint(sshd, font="rnd-large")
|
|
|
|
|
tmp()
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
while True: # connection via ssh
|
|
|
|
|
clear()
|
|
|
|
|
sshb = "ssh " + user + " '" + "{}".format(path) + "'" + " getblockchaininfo"
|
|
|
|
|
os.system(sshb)
|
|
|
|
|
sshc = os.popen(str(sshb)).read()
|
|
|
|
|
sshd = sshc
|
|
|
|
|
tmp()
|
|
|
|
|
else:
|
|
|
|
|
connection(input("Are you going to connect to an external node? Y/n: "))
|
2020-05-06 17:04:20 -03:00
|
|
|
|
2020-05-09 18:22:43 -03:00
|
|
|
|
|
|
|
|
def nodeinfo():
|
|
|
|
|
print("\nAdd your node information\n")
|
|
|
|
|
connected(input("Are you sure you want to connect to a node? Y/n: ")) # call 'connected' function to make the connection with the node information
|
|
|
|
|
|
2020-05-07 10:59:47 -03:00
|
|
|
|
2020-05-09 18:22:43 -03:00
|
|
|
def artist(): # here we convert the result of the command 'getblockcount' on a random art design
|
2020-05-08 08:37:26 -03:00
|
|
|
bitcoinclient = path + " getblockcount"
|
2020-05-09 18:22:43 -03:00
|
|
|
custom = input("Do you want random designs? Y/n: ")
|
2020-05-08 08:37:26 -03:00
|
|
|
block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string
|
|
|
|
|
b = block # copy the result in the variable 'b'
|
2020-05-09 18:22:43 -03:00
|
|
|
if custom == "Y" or custom == "y":
|
|
|
|
|
while True:
|
|
|
|
|
clear()
|
|
|
|
|
tprint(b, font="rnd-large")
|
|
|
|
|
tmp()
|
2020-05-07 10:59:47 -03:00
|
|
|
else:
|
2020-05-09 18:22:43 -03:00
|
|
|
while True:
|
|
|
|
|
clear()
|
|
|
|
|
getblockcount()
|
|
|
|
|
tmp()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tmp():
|
|
|
|
|
t.sleep(20)
|
2020-05-07 10:59:47 -03:00
|
|
|
|
|
|
|
|
|
2020-05-09 18:22:43 -03:00
|
|
|
while True: # Loop
|
|
|
|
|
clear() # call clear function that clears the screen
|
|
|
|
|
tprint("BlockClock", font="rnd-large") # random title design
|
|
|
|
|
print("Welcome to Python BlockClock\n\n")
|
|
|
|
|
path = input("Insert the Path to Bitcoin-Cli: ") # path to the bitcoin-cli
|
|
|
|
|
connection(input("Are you going to connect to an external node? Y/n: ")) # access to 'connection' function
|
2020-05-07 10:59:47 -03:00
|
|
|
|