2020-05-10 21:11:21 -03:00
#Developer: Curly60e
2020-05-25 19:35:24 -03:00
#PyBLOCK its a clock of the Bitcoin blockchain.
2020-05-30 21:46:11 -03:00
#Version: 0.3.0
2020-05-10 21:11:21 -03:00
2020-05-06 16:34:55 -03:00
import os
2020-05-16 00:21:47 -03:00
import os . path
2020-05-06 16:34:55 -03:00
import time as t
2020-05-16 00:21:47 -03:00
import pickle
2020-05-25 19:35:24 -03:00
import psutil
2020-05-29 11:52:29 -03:00
import qrcode
2020-05-23 08:50:38 -03:00
from clone import *
2020-05-20 20:32:31 -03:00
from donation import *
2020-05-23 08:50:38 -03:00
from feed import *
2020-05-08 08:37:26 -03:00
from art import *
2020-05-18 22:25:55 -03:00
from logos import *
2020-05-25 19:35:24 -03:00
from sysinf import *
from pblogo import *
from apisnd import *
2020-05-30 21:46:11 -03:00
from nodeconnection import *
2020-05-29 11:52:29 -03:00
from terminal_matrix . matrix import *
2020-05-06 16:34:55 -03:00
2020-05-09 18:22:43 -03:00
2020-05-30 21:46:11 -03:00
def sysinfo ( ) : #Cpu and memory usage
print ( " \033 [0;37;40m---------------------- " )
print ( " \033 [3;33;40mCPU Usage: \033 [1;32;40m " + str ( psutil . cpu_percent ( ) ) + " % \033 [0;37;40m " )
print ( " \033 [3;33;40mMemory Usage: \033 [1;32;40m " " {} % \033 [0;37;40m " . format ( int ( psutil . virtual_memory ( ) . percent ) ) )
print ( " \033 [0;37;40m---------------------- " )
def getblock ( ) : # get access to bitcoin-cli with the command getblockchaininfo
bitcoincli = " getblockchaininfo "
os . system ( path + bitcoincli )
def getblockcount ( ) : # get access to bitcoin-cli with the command getblockcount
bitcoincli = " getblockcount "
os . system ( path + bitcoincli )
def clear ( ) : # clear the screen
os . system ( ' cls ' if os . name == ' nt ' else ' clear ' )
def getgenesis ( ) : # get and decode Genesis block
bitcoincli = " getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f 0 | xxd -r -p | hexyl -n 256 "
os . system ( path + bitcoincli )
def close ( ) :
print ( " <<< Back to the Main Menu Press Control + C. \n \n " )
def readHexBlock ( ) : # Hex Decoder using Hexyl on local node
hexa = input ( " Add the Block Hash you want to decode: " )
blocknumber = input ( " Add the Block number: " )
decodeBlock = path + " getblock {} {} " . format ( hexa , blocknumber ) + " | xxd -r -p | hexyl -n 256 "
os . system ( decodeBlock )
def readHexTx ( ) : # Hex Decoder using Hexyl on an external node
hexa = input ( " Add the Transaction ID. you want to decode: " )
decodeTX = path + " getrawtransaction {} " . format ( hexa ) + " | xxd -r -p | hexyl -n 256 "
os . system ( decodeTX )
def prt ( ) :
print ( " \033 [1;32;40m " )
blogo ( )
#tprint("PyBLOCK", font="rnd-large") # random title design
print ( " \033 [0;37;40m " )
def tmp ( ) :
t . sleep ( 15 )
#-----
2020-05-25 19:35:24 -03:00
2020-05-18 22:25:55 -03:00
def console ( ) : # get into the console from bitcoin-cli
2020-05-25 19:35:24 -03:00
print ( " \t \033 [0;37;40mThis is \033 [1;33;40mBitcoin-cli ' s \033 [0;37;40mconsole. Type your respective commands you want to display. \n \n " )
2020-05-18 22:25:55 -03:00
while True :
2020-05-25 19:35:24 -03:00
cle = input ( " \033 [1;32;40mconsole $>: \033 [0;37;40m " )
2020-05-27 08:59:36 -03:00
lsd = os . popen ( path + " " + cle )
lsd0 = lsd . read ( )
lsd1 = str ( lsd0 )
print ( lsd1 )
lsd . close ( )
2020-05-29 11:52:29 -03:00
def screensv ( ) :
try :
doit ( )
except ( KeyboardInterrupt , SystemExit ) :
matrix . close ( )
clear ( )
ptr ( )
menu ( )
#-------------------Lighitning network-------------------------------------
def LNInvoice ( ) :
2020-05-30 21:46:11 -03:00
clear ( )
prt ( )
getnewinvoice ( )
2020-06-01 09:25:57 -03:00
2020-05-29 16:06:45 -03:00
def payinvoice ( ) :
2020-06-01 22:38:56 -03:00
lncli = " lncli payinvoice "
2020-05-29 16:06:45 -03:00
invoice = input ( " Pay Invoice: " )
#----------decode invoice-----
2020-06-01 22:38:56 -03:00
lnclideq = " lncli decodepayreq "
sh = os . popen ( lnclideq + invoice )
2020-05-29 16:06:45 -03:00
shh = sh . read ( )
shh0 = str ( shh )
shh1 = shh0 . split ( ' , ' )
shh2 = shh1 [ 2 ]
#----amount----
lnbc1R = shh2 . split ( ' : ' )
lnbc1W = lnbc1R [ 1 ]
ln = str ( lnbc1W )
ln1 = ln . split ( ' " ' )
ln3 = ln1 [ 1 ]
2020-05-29 11:52:29 -03:00
2020-05-29 16:06:45 -03:00
if ln3 == " 0 " :
amt = " --amt "
amount = input ( " Amount in satoshis: " )
2020-06-01 22:38:56 -03:00
os . system ( lncli + invoice + amt + amount )
2020-05-29 16:06:45 -03:00
else :
2020-06-01 22:38:56 -03:00
os . system ( lncli + invoice )
2020-05-29 16:06:45 -03:00
2020-05-29 11:52:29 -03:00
tmp ( )
2020-05-29 16:06:45 -03:00
2020-05-10 21:11:21 -03:00
#-------------------From this line the program starts----------------------
2020-05-06 17:04:20 -03: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 " :
2020-05-13 19:47:58 -03:00
clear ( )
prt ( )
print ( " \n Add your node information \n " )
2020-05-15 07:41:42 -03:00
menuUserConn ( )
2020-05-09 18:22:43 -03:00
else :
2020-05-13 19:47:58 -03:00
menu ( )
2020-05-24 14:15:12 -03:00
2020-05-16 00:21:47 -03:00
def nodeinfo ( ) :
2020-05-25 19:35:24 -03:00
print ( " \n \033 [1;31;40mWARNING! This is not a safe method of connection. The best method is doing this locally. \n " )
connected ( input ( " WARNING! Are you sure you want to connect to a node? Y/n: \033 [0;37;40m " ) ) # call 'connected' function to make the connection with the node information
2020-05-24 14:15:12 -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
custom = input ( " Do you want random designs? Y/n: " )
if custom == " Y " or custom == " y " :
while True :
2020-05-16 12:51:30 -03:00
try :
clear ( )
close ( )
design ( )
tmp ( )
except ( KeyboardInterrupt , SystemExit ) :
menu ( )
raise
2020-05-07 10:59:47 -03:00
else :
2020-05-09 18:22:43 -03:00
while True :
2020-05-16 12:51:30 -03:00
try :
clear ( )
close ( )
getblockcount ( )
tmp ( )
except ( KeyboardInterrupt , SystemExit ) :
menu ( )
raise
2020-05-10 21:11:21 -03:00
def design ( ) :
bitcoinclient = path + " getblockcount "
block = os . popen ( str ( bitcoinclient ) ) . read ( ) # 'getblockcount' convert to string
2020-05-24 14:15:12 -03:00
b = block
2020-05-25 19:35:24 -03:00
print ( " \033 [1;32;40m " )
2020-05-15 07:41:42 -03:00
tprint ( b , font = " rnd-large " )
2020-05-25 19:35:24 -03:00
print ( " \033 [0;37;40m " )
2020-05-16 00:21:47 -03:00
#------------------------------------------- SSH connection external node --------------------------------------------
def userconn ( ) : # All the connection to a remote node
2020-05-25 19:35:24 -03:00
option = input ( " \033 [1;32;40mSelect option: \033 [0;37;40m " )
2020-05-16 00:21:47 -03:00
if option == " A " or option == " a " : # Execution of the secondary Menu menuUserConn
2020-05-25 19:35:24 -03:00
user = input ( " \033 [1;36;40mUSER \033 [0;37;40m@ \033 [1;33;40mNODE: \033 [0;37;40m " )
2020-05-15 07:41:42 -03:00
s = input ( " Do you want to continue Y/n: " )
if s == " Y " or s == " y " :
clear ( )
c = input ( " Do you want to see custom design? Y/n: " )
2020-05-24 14:15:12 -03:00
if c == " Y " or c == " y " :
2020-05-16 12:51:30 -03:00
while True : # connection via ssh
try :
clear ( )
close ( )
sshb = " ssh " + user + " ' " + " {} " . format ( path ) + " ' " + " getblockcount "
2020-05-27 08:59:36 -03:00
sshc = os . popen ( sshb )
lsd0 = sshc . read ( )
lsd1 = str ( lsd0 )
sshd = lsd1
2020-05-25 19:35:24 -03:00
print ( " \033 [1;32;40m " )
2020-05-16 12:51:30 -03:00
tprint ( sshd , font = " rnd-large " )
2020-05-25 19:35:24 -03:00
print ( " \033 [0;37;40m " )
2020-05-16 12:51:30 -03:00
tmp ( )
2020-05-27 08:59:36 -03:00
sshc . close ( )
2020-05-16 12:51:30 -03:00
except ( KeyboardInterrupt , SystemExit ) :
menuUserConn ( )
raise
2020-05-15 07:41:42 -03:00
else :
2020-05-24 14:15:12 -03:00
menu ( )
2020-05-15 07:41:42 -03:00
else :
while True : # connection via ssh
2020-05-16 12:51:30 -03:00
try :
clear ( )
close ( )
sshb = " ssh " + user + " ' " + " {} " . format ( path ) + " ' " + " getblockchaininfo "
os . system ( sshb )
tmp ( )
except ( KeyboardInterrupt , SystemExit ) :
menuUserConn ( )
raise
2020-05-10 21:11:21 -03:00
else :
2020-05-24 14:15:12 -03:00
menu ( )
2020-05-16 00:21:47 -03:00
elif option == " B " or option == " b " : # Decode Block 0 on HEX for external node
2020-05-25 19:35:24 -03:00
user = input ( " \033 [1;36;40mUSER \033 [0;37;40m@ \033 [1;33;40mNODE: \033 [0;37;40m " )
2020-05-15 07:41:42 -03:00
while True :
2020-05-13 19:47:58 -03:00
clear ( )
2020-05-15 07:41:42 -03:00
prt ( )
sshb = " ssh " + user + " ' " + " {} " . format ( path ) + " ' " + " getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f 0 | xxd -r -p | hexyl -n 256 "
2020-05-13 19:47:58 -03:00
os . system ( sshb )
2020-05-15 07:41:42 -03:00
a = input ( " Do you want to return to the Node Connection Menu? Y/n: " )
if a == " Y " or a == " y " :
menuUserConn ( )
else :
b = input ( " Do you want to exit? Y/n: " )
if b == " Y " or b == " y " :
exit ( )
else :
2020-05-24 14:15:12 -03:00
menuUserConn ( )
2020-05-13 19:47:58 -03:00
tmp ( )
2020-05-16 00:21:47 -03:00
elif option == " C " or option == " c " : # Block decoder to HEX for external node
readHexBlockSsh ( )
while True :
m = input ( " Do you want to continue decoding? Y/n: " )
if m == " Y " or m == " y " :
readHexBlockSsh ( )
else :
2020-05-24 14:15:12 -03:00
menuUserConn ( )
2020-05-16 00:21:47 -03:00
elif option == " D " or option == " d " :
2020-05-16 12:51:30 -03:00
readHexTXSsh ( )
while True :
m = input ( " Do you want to continue decoding? Y/n: " )
if m == " Y " or m == " y " :
readHexTXSsh ( )
else :
menuUserConn ( )
2020-05-18 22:25:55 -03:00
elif option == " R " or option == " r " :
2020-05-15 07:41:42 -03:00
menu ( )
2020-05-24 14:15:12 -03:00
2020-05-16 00:21:47 -03:00
#------------------------------------------- End SSH connection external node --------------------------------------------
2020-05-07 10:59:47 -03:00
2020-05-16 00:21:47 -03:00
#--------------------------------- Hex Block Decoder Functions -------------------------------------
def readHexBlockSsh ( ) : # Hex Decoder using Hexyl on an external node
2020-05-25 19:35:24 -03:00
user = input ( " \033 [1;36;40mUSER \033 [0;37;40m@ \033 [1;33;40mNODE: \033 [0;37;40m " )
2020-05-16 00:21:47 -03:00
clear ( )
prt ( )
hexa = input ( " Add the Block Hash you want to decode: " )
blocknumber = input ( " Add the Block number: " )
decodeBlock = " ssh " + user + " ' " + " {} " . format ( path ) + " ' " + " getblock {} {} " . format ( hexa , blocknumber ) + " | xxd -r -p | hexyl -n 256 "
clear ( )
prt ( )
os . system ( decodeBlock )
2020-05-24 14:15:12 -03:00
2020-05-16 12:51:30 -03:00
def readHexTXSsh ( ) : # Hex Decoder using Hexyl on an external node
2020-05-25 19:35:24 -03:00
user = input ( " \033 [1;36;40mUSER \033 [0;37;40m@ \033 [1;33;40mNODE: \033 [0;37;40m " )
2020-05-16 12:51:30 -03:00
clear ( )
prt ( )
hexa = input ( " Add the Transaction ID. you want to decode: " )
decodeTX = " ssh " + user + " ' " + " {} " . format ( path ) + " ' " + " getrawtransaction {} " . format ( hexa ) + " | xxd -r -p | hexyl -n 256 "
clear ( )
prt ( )
os . system ( decodeTX )
2020-05-25 19:35:24 -03:00
def getrawtx ( ) : # show confirmatins from transactions
tx = input ( " Insert your TxID: " )
while True :
try :
clear ( )
prt ( )
close ( )
bitcoincli = " getrawtransaction "
2020-05-27 17:34:26 -03:00
if tx == " 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b " :
print ( """ \t \t \n \033 [1;35;40mThis transaction it ' s the first one of the Bitcoin Blockchain on Block 0 by Satoshi Nakamoto.
You can decode that block in HEX and see what ' s inside. \033 [0;37;40m " " " )
t . sleep ( 10 )
else :
lsd = os . popen ( path + bitcoincli + tx + " 1 " )
lsd0 = lsd . read ( )
lsd1 = str ( lsd0 )
lsda = lsd1 . split ( ' , ' )
lsdb = lsda [ - 3 ]
lsdc = str ( lsdb )
print ( " \033 [0;37;40mTransaction " + " \033 [1;31;40m {} \033 [0;37;40m " . format ( tx ) + " has: \n " + " \033 [1;31;40m {} \033 [0;37;40m " . format ( lsdc ) )
tmp ( )
lsd . close ( )
2020-05-25 19:35:24 -03:00
except ( KeyboardInterrupt , SystemExit ) :
menu ( )
2020-05-16 00:21:47 -03:00
#--------------------------------- End Hex Block Decoder Functions -------------------------------------
2020-05-24 14:15:12 -03:00
2020-05-16 00:21:47 -03:00
#--------------------------------- Menu section -----------------------------------
def menu ( ) : #Main Menu
2020-05-13 19:47:58 -03:00
clear ( )
prt ( )
2020-05-25 19:35:24 -03:00
sysinfo ( )
2020-05-13 19:47:58 -03:00
print ( """ \t \t
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 31 ; 40 mPyBLOCK \033 [ 0 ; 37 ; 40 m Menu
2020-05-30 21:46:11 -03:00
Version 0.3 .0
2020-05-25 19:35:24 -03:00
2020-05-26 14:20:20 -03:00
\033 [ 1 ; 31 ; 40 mA . \033 [ 0 ; 37 ; 40 m Run PyBLOCK in your own node
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 32 ; 40 mB . \033 [ 0 ; 37 ; 40 m Show Blockchain information in your own node
\033 [ 1 ; 32 ; 40 mC . \033 [ 0 ; 37 ; 40 m Show the Genesis Block
\033 [ 1 ; 32 ; 40 mD . \033 [ 0 ; 37 ; 40 m Decode in HEX any block
\033 [ 1 ; 32 ; 40 mE . \033 [ 0 ; 37 ; 40 m Decode in HEX any transaction
\033 [ 1 ; 32 ; 40 mF . \033 [ 0 ; 37 ; 40 m Show confirmations from a transaction
\033 [ 1 ; 32 ; 40 mG . \033 [ 0 ; 37 ; 40 m Connect to an external node through SSH
\033 [ 1 ; 32 ; 40 mH . \033 [ 0 ; 37 ; 40 m Advanced
2020-05-29 11:52:29 -03:00
\033 [ 1 ; 33 ; 40 mL . \033 [ 0 ; 37 ; 40 m Lightning Network
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 34 ; 40 mS . \033 [ 0 ; 37 ; 40 m SatNode
\033 [ 1 ; 35 ; 40 mX . \033 [ 0 ; 37 ; 40 m Donate
\033 [ 1 ; 33 ; 40 mQ . \033 [ 0 ; 37 ; 40 m Exit
2020-05-13 19:47:58 -03:00
\n \n """ )
2020-05-25 19:35:24 -03:00
menuA ( input ( " \033 [1;32;40mSelect option: \033 [0;37;40m " ) )
2020-05-24 14:15:12 -03:00
2020-05-16 00:21:47 -03:00
def menuUserConn ( ) : #Menu before connection over ssh
2020-05-15 07:41:42 -03:00
clear ( )
prt ( )
2020-05-25 19:35:24 -03:00
sysinfo ( )
2020-05-15 07:41:42 -03:00
print ( """ \t \t
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 31 ; 40 mPyBLOCK \033 [ 0 ; 37 ; 40 m Menu
2020-05-30 21:46:11 -03:00
Version 0.3 .0
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 32 ; 40 mA . \033 [ 0 ; 37 ; 40 m Run PyBLOCK in this external node
\033 [ 1 ; 32 ; 40 mB . \033 [ 0 ; 37 ; 40 m Show the Genesis Block
\033 [ 1 ; 32 ; 40 mC . \033 [ 0 ; 37 ; 40 m Decode in HEX any block
\033 [ 1 ; 32 ; 40 mD . \033 [ 0 ; 37 ; 40 m Decode in HEX any transaction
\033 [ 1 ; 36 ; 40 mR . \033 [ 0 ; 37 ; 40 m Return Main Menu
2020-05-15 07:41:42 -03:00
\n \n """ )
userconn ( )
2020-05-24 14:15:12 -03:00
2020-05-25 19:35:24 -03:00
def advanceMenu ( ) : # Advanced Menu
2020-05-18 22:25:55 -03:00
clear ( )
prt ( )
2020-05-25 19:35:24 -03:00
sysinfo ( )
2020-05-18 22:25:55 -03:00
print ( """ \t \t
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 31 ; 40 mPyBLOCK \033 [ 0 ; 37 ; 40 m Menu
2020-05-30 21:46:11 -03:00
Version 0.3 .0
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 32 ; 40 mA . \033 [ 0 ; 37 ; 40 m Bitconi - cli Console
\033 [ 1 ; 32 ; 40 mB . \033 [ 0 ; 37 ; 40 m FunB
\033 [ 1 ; 32 ; 40 mC . \033 [ 0 ; 37 ; 40 m Show QR from a Bitcoin Address
\033 [ 1 ; 32 ; 40 mS . \033 [ 0 ; 37 ; 40 m Sysinfo
\033 [ 1 ; 36 ; 40 mR . \033 [ 0 ; 37 ; 40 m Return Main Menu
2020-05-18 22:25:55 -03:00
\n \n """ )
2020-05-25 19:35:24 -03:00
menuB ( input ( " \033 [1;32;40mSelect option: \033 [0;37;40m " ) )
2020-05-15 07:41:42 -03:00
2020-05-25 19:35:24 -03:00
def dnt ( ) : # Donation selection menu
2020-05-20 20:32:31 -03:00
clear ( )
prt ( )
2020-05-25 19:35:24 -03:00
sysinfo ( )
2020-05-20 20:32:31 -03:00
print ( """ \t \t
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 31 ; 40 mPyBLOCK \033 [ 0 ; 37 ; 40 m Menu
2020-05-30 21:46:11 -03:00
Version 0.3 .0
2020-05-24 14:15:12 -03:00
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 32 ; 40 mA . \033 [ 0 ; 37 ; 40 m Developers Donation
\033 [ 1 ; 32 ; 40 mB . \033 [ 0 ; 37 ; 40 m Testers Donation
\033 [ 1 ; 36 ; 40 mR . \033 [ 0 ; 37 ; 40 m Return Main Menu
2020-05-23 08:50:38 -03:00
\n \n """ )
2020-05-25 19:35:24 -03:00
menuC ( input ( " \033 [1;32;40mSelect option: \033 [0;37;40m " ) )
2020-05-24 14:15:12 -03:00
2020-05-25 19:35:24 -03:00
def dntDev ( ) : # Dev Donation Menu
2020-05-23 08:50:38 -03:00
clear ( )
prt ( )
2020-05-25 19:35:24 -03:00
sysinfo ( )
2020-05-23 08:50:38 -03:00
print ( """ \t \t
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 31 ; 40 mPyBLOCK \033 [ 0 ; 37 ; 40 m Menu
2020-05-30 21:46:11 -03:00
Version 0.3 .0
2020-05-24 14:15:12 -03:00
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 32 ; 40 mA . \033 [ 0 ; 37 ; 40 m PayNym
\033 [ 1 ; 32 ; 40 mB . \033 [ 0 ; 37 ; 40 m Bitcoin Address
\033 [ 1 ; 32 ; 40 mC . \033 [ 0 ; 37 ; 40 m Lightning Network
\033 [ 1 ; 36 ; 40 mR . \033 [ 0 ; 37 ; 40 m Return Main Menu
2020-05-20 20:32:31 -03:00
\n \n """ )
2020-05-25 19:35:24 -03:00
menuE ( input ( " \033 [1;32;40mSelect option: \033 [0;37;40m " ) )
2020-05-24 14:15:12 -03:00
2020-05-25 19:35:24 -03:00
def dntTst ( ) : # Tester Donation Menu
2020-05-23 08:50:38 -03:00
clear ( )
prt ( )
2020-05-25 19:35:24 -03:00
sysinfo ( )
2020-05-23 08:50:38 -03:00
print ( """ \t \t
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 31 ; 40 mPyBLOCK \033 [ 0 ; 37 ; 40 m Menu
2020-05-30 21:46:11 -03:00
Version 0.3 .0
2020-05-24 14:15:12 -03:00
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 32 ; 40 mA . \033 [ 0 ; 37 ; 40 m Bitcoin Address
\033 [ 1 ; 32 ; 40 mB . \033 [ 0 ; 37 ; 40 m Lightning Network
\033 [ 1 ; 36 ; 40 mR . \033 [ 0 ; 37 ; 40 m Return Main Menu
2020-05-23 08:50:38 -03:00
\n \n """ )
2020-05-25 19:35:24 -03:00
menuF ( input ( " \033 [1;32;40mSelect option: \033 [0;37;40m " ) )
2020-05-24 14:15:12 -03:00
2020-05-25 19:35:24 -03:00
def satnodeMenu ( ) : # Satnode Menu
2020-05-23 08:50:38 -03:00
clear ( )
prt ( )
2020-05-25 19:35:24 -03:00
sysinfo ( )
2020-05-23 08:50:38 -03:00
print ( """ \t \t
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 31 ; 40 mPyBLOCK \033 [ 0 ; 37 ; 40 m Menu
2020-05-30 21:46:11 -03:00
Version 0.3 .0
2020-05-25 19:35:24 -03:00
\033 [ 1 ; 32 ; 40 mA . \033 [ 0 ; 37 ; 40 m Start SatNode
\033 [ 1 ; 32 ; 40 mB . \033 [ 0 ; 37 ; 40 m Feed
\033 [ 1 ; 32 ; 40 mC . \033 [ 0 ; 37 ; 40 m Setup
\033 [ 1 ; 34 ; 40 mS . \033 [ 0 ; 37 ; 40 m Send a Message to Space
\033 [ 1 ; 36 ; 40 mD . \033 [ 0 ; 37 ; 40 m Return Main Menu
2020-05-23 08:50:38 -03:00
\n \n """ )
2020-05-25 19:35:24 -03:00
menuD ( input ( " \033 [1;32;40mSelect option: \033 [0;37;40m " ) )
2020-05-20 20:32:31 -03:00
2020-05-29 11:52:29 -03:00
def menuLND ( ) :
clear ( )
prt ( )
sysinfo ( )
print ( """ \t \t
2020-05-29 16:06:45 -03:00
\033 [ 1 ; 31 ; 40 mPyBLOCK \033 [ 0 ; 37 ; 40 m Lightning Network Menu
2020-06-01 22:38:56 -03:00
Remote node connection
2020-05-30 21:46:11 -03:00
Version 0.3 .0
2020-05-29 11:52:29 -03:00
2020-05-29 16:06:45 -03:00
\033 [ 1 ; 32 ; 40 mI . \033 [ 0 ; 37 ; 40 m New Invoice
2020-05-29 11:52:29 -03:00
\033 [ 1 ; 31 ; 40 mP . \033 [ 0 ; 37 ; 40 m Pay Invoice
2020-06-01 22:38:56 -03:00
\033 [ 1 ; 33 ; 40 mB . \033 [ 0 ; 37 ; 40 m New Bitcoin Address
\033 [ 1 ; 32 ; 40 mL . \033 [ 0 ; 37 ; 40 m List Invoices
\033 [ 1 ; 32 ; 40 mT . \033 [ 0 ; 37 ; 40 m List Onchain TXS
\033 [ 1 ; 32 ; 40 mS . \033 [ 0 ; 37 ; 40 m Check if invoice was paid
\033 [ 1 ; 31 ; 40 mN . \033 [ 0 ; 37 ; 40 m Get Node Info
\033 [ 1 ; 31 ; 40 mC . \033 [ 0 ; 37 ; 40 m Channels
2020-05-29 11:52:29 -03:00
\033 [ 1 ; 36 ; 40 mR . \033 [ 0 ; 37 ; 40 m Return Main Menu
\n \n """ )
menuLN ( input ( " \033 [1;32;40mSelect option: \033 [0;37;40m " ) )
2020-05-16 00:21:47 -03:00
#--------------------------------- End Menu section -----------------------------------
2020-05-29 11:52:29 -03:00
2020-05-24 14:15:12 -03:00
2020-05-16 12:51:30 -03:00
#--------------------------------- Main Menu execution --------------------------------
2020-05-16 00:21:47 -03:00
def menuA ( menuS ) : #Execution of the Main Menu options
2020-05-15 07:41:42 -03:00
if menuS == " A " or menuS == " a " :
2020-05-16 12:51:30 -03:00
artist ( )
2020-05-15 07:41:42 -03:00
elif menuS == " B " or menuS == " b " :
2020-05-13 19:47:58 -03:00
while True :
2020-05-16 12:51:30 -03:00
try :
clear ( )
close ( )
getblock ( )
tmp ( )
except ( KeyboardInterrupt , SystemExit ) :
menu ( )
raise
2020-05-15 07:41:42 -03:00
elif menuS == " C " or menuS == " c " :
clear ( )
prt ( )
getgenesis ( )
a = input ( " Do you want to return to the Main Menu? Y/n: " )
if a == " Y " or a == " y " :
menu ( )
else :
b = input ( " Do you want to exit? Y/n: " )
if b == " Y " or b == " y " :
2020-05-27 08:59:36 -03:00
os . _exit ( 0 )
apisnd . close ( )
donation . close ( )
clone . close ( )
logos . close ( )
feed . close ( )
2020-05-27 11:01:03 -03:00
sysinf . close ( )
2020-06-01 09:25:57 -03:00
nodeconnection . close ( )
2020-05-15 07:41:42 -03:00
exit ( )
else :
menu ( )
2020-05-16 12:51:30 -03:00
elif menuS == " D " or menuS == " d " :
2020-05-16 00:21:47 -03:00
clear ( )
prt ( )
readHexBlock ( )
while True :
r = input ( " Do you want to continue decoding? Y/n: " )
if r == " Y " or r == " y " :
clear ( )
prt ( )
readHexBlock ( )
else :
2020-05-24 14:15:12 -03:00
menu ( )
2020-05-16 12:51:30 -03:00
elif menuS == " E " or menuS == " e " :
clear ( )
prt ( )
readHexTx ( )
while True :
r = input ( " Do you want to continue decoding? Y/n: " )
if r == " Y " or r == " y " :
clear ( )
prt ( )
2020-05-25 19:35:24 -03:00
sysinfo ( )
2020-05-16 12:51:30 -03:00
readHexTx ( )
else :
2020-05-24 14:15:12 -03:00
menu ( )
2020-05-16 00:21:47 -03:00
elif menuS == " F " or menuS == " f " :
2020-05-25 19:35:24 -03:00
getrawtx ( )
elif menuS == " H " or menuS == " h " :
advanceMenu ( )
2020-05-29 11:52:29 -03:00
elif menuS == " L " or menuS == " l " :
clear ( )
prt ( )
menuLND ( )
2020-05-18 22:25:55 -03:00
elif menuS == " Q " or menuS == " q " :
2020-05-27 08:59:36 -03:00
os . _exit ( 0 )
apisnd . close ( )
donation . close ( )
clone . close ( )
logos . close ( )
feed . close ( )
2020-05-27 11:01:03 -03:00
sysinf . close ( )
2020-06-01 09:25:57 -03:00
nodeconnection . close ( )
2020-05-15 07:41:42 -03:00
exit ( )
2020-05-25 19:35:24 -03:00
elif menuS == " S " or menuS == " s " :
clear ( )
prt ( )
satnodeMenu ( )
2020-05-18 22:25:55 -03:00
elif menuS == " G " or menuS == " g " :
2020-05-25 19:35:24 -03:00
nodeinfo ( )
2020-05-20 20:32:31 -03:00
elif menuS == " X " or menuS == " x " :
dnt ( )
2020-05-25 19:35:24 -03:00
elif menuS == " T " or menuS == " t " : #Test feature fast access
2020-05-26 14:20:20 -03:00
print ( " This is a test access. \n " )
2020-05-29 11:52:29 -03:00
screensv ( )
#------------------------------------------
def menuLN ( menuLL ) :
2020-05-29 16:06:45 -03:00
if menuLL == " I " or menuLL == " i " :
2020-05-29 11:52:29 -03:00
clear ( )
prt ( )
LNInvoice ( )
2020-05-29 16:06:45 -03:00
elif menuLL == " P " or menuLL == " p " :
2020-05-29 11:52:29 -03:00
clear ( )
prt ( )
2020-05-29 16:06:45 -03:00
payinvoice ( )
2020-06-01 22:38:56 -03:00
elif menuLL == " B " or menuLL == " b " :
clear ( )
prt ( )
getnewaddress ( )
elif menuLL == " L " or menuLL == " l " :
clear ( )
prt ( )
listinvoice ( )
elif menuLL == " T " or menuLL == " t " :
clear ( )
prt ( )
listchaintxns ( )
elif menuLL == " S " or menuLL == " s " :
clear ( )
prt ( )
invoicesettle ( )
elif menuLL == " N " or menuLL == " n " :
clear ( )
prt ( )
getinfo ( )
elif menuLL == " C " or menuLL == " c " :
clear ( )
prt ( )
channels ( )
2020-05-29 11:52:29 -03:00
elif menuLL == " R " or menuLL == " r " :
menu ( )
#------------------------------------------
2020-05-25 19:35:24 -03:00
def menuB ( menuR ) : # Advanced access Menu
2020-05-18 22:25:55 -03:00
if menuR == " A " or menuR == " a " :
while True :
try :
clear ( )
prt ( )
2020-05-25 19:35:24 -03:00
sysinfo ( )
2020-05-18 22:25:55 -03:00
close ( )
console ( )
t . sleep ( 5 )
except ( KeyboardInterrupt , SystemExit ) :
advanceMenu ( )
raise
elif menuR == " B " or menuR == " b " :
while True :
try :
clear ( )
prt ( )
close ( )
logoA ( )
tmp ( )
clear ( )
prt ( )
close ( )
logoB ( )
tmp ( )
clear ( )
prt ( )
close ( )
logoC ( )
tmp ( )
except ( KeyboardInterrupt , SystemExit ) :
advanceMenu ( )
raise
2020-05-20 20:32:31 -03:00
elif menuR == " C " or menuR == " c " :
while True :
try :
clear ( )
prt ( )
2020-05-25 19:35:24 -03:00
sysinfo ( )
2020-05-20 20:32:31 -03:00
close ( )
decodeQR ( )
t . sleep ( 50 )
except ( KeyboardInterrupt , SystemExit ) :
advanceMenu ( )
2020-05-23 08:50:38 -03:00
raise
elif menuR == " S " or menuR == " s " :
2020-05-25 19:35:24 -03:00
while True :
try :
clear ( )
prt ( )
close ( )
sysinfoDetail ( )
t . sleep ( 1 )
except ( KeyboardInterrupt , SystemExit ) :
advanceMenu ( )
raise
2020-05-18 22:25:55 -03:00
elif menuR == " R " or menuR == " r " :
2020-05-27 16:19:42 -03:00
try :
menu ( )
except ( KeyboardInterrupt , SystemExit ) :
os . _exit ( 0 )
apisnd . close ( )
donation . close ( )
clone . close ( )
logos . close ( )
feed . close ( )
sysinf . close ( )
exit ( )
2020-05-25 19:35:24 -03:00
def menuC ( menuO ) : # Donation access Menu
2020-05-24 14:15:12 -03:00
if menuO == " A " or menuO == " a " :
2020-05-23 08:50:38 -03:00
dntDev ( )
elif menuO == " B " or menuO == " b " :
dntTst ( )
2020-05-25 19:35:24 -03:00
elif menuO == " R " or menuO == " r " :
2020-05-23 08:50:38 -03:00
menu ( )
2020-05-24 14:15:12 -03:00
2020-05-25 19:35:24 -03:00
def menuD ( menuN ) : # Satnode access Menu
2020-05-23 08:50:38 -03:00
if menuN == " A " or menuN == " a " :
satnode ( )
elif menuN == " B " or menuN == " b " :
readFile ( )
2020-05-25 19:35:24 -03:00
elif menuN == " S " or menuN == " s " :
try :
close ( )
2020-05-26 14:20:20 -03:00
message = input ( " \n \033 [0;37;40mYour message it ' s a \033 [1;34;40mF \033 [0;37;40mile or a plain \033 [1;32;40mT \033 [0;37;40mext? \033 [1;34;40mF \033 [0;37;40m/ \033 [1;32;40mT \033 [0;37;40m: " )
if message == " F " or message == " f " :
try :
clear ( )
prt ( )
close ( )
apisenderFile ( )
2020-05-26 20:48:23 -03:00
t . sleep ( 30 )
2020-05-26 14:20:20 -03:00
menu ( )
except ( KeyboardInterrupt , SystemExit ) :
menu ( )
raise
elif message == " T " or message == " t " :
try :
clear ( )
prt ( )
close ( )
apisender ( )
2020-05-26 20:48:23 -03:00
t . sleep ( 30 )
2020-05-26 14:20:20 -03:00
menu ( )
except ( KeyboardInterrupt , SystemExit ) :
menu ( )
raise
2020-05-25 19:35:24 -03:00
except ( KeyboardInterrupt , SystemExit ) :
menu ( )
2020-05-26 14:20:20 -03:00
raise
2020-05-23 08:50:38 -03:00
elif menuN == " C " or menuN == " c " :
print ( " \n \t This only will work on Linux or Unix systems. \n " )
a = input ( " Do we continue? Y/n: " )
if a == " Y " or a == " y " :
gitclone ( )
else :
2020-05-25 19:35:24 -03:00
menu ( )
2020-05-24 14:15:12 -03:00
2020-05-25 19:35:24 -03:00
def menuE ( menuQ ) : # Dev Donation access Menu
2020-05-24 14:15:12 -03:00
if menuQ == " A " or menuQ == " a " :
2020-05-20 20:32:31 -03:00
try :
clear ( )
prt ( )
close ( )
donationPN ( )
t . sleep ( 50 )
2020-05-20 21:07:35 -03:00
menu ( )
2020-05-20 20:32:31 -03:00
except ( KeyboardInterrupt , SystemExit ) :
menu ( )
raise
2020-05-23 08:50:38 -03:00
elif menuQ == " B " or menuQ == " b " :
2020-05-20 20:32:31 -03:00
try :
clear ( )
prt ( )
close ( )
donationAddr ( )
t . sleep ( 50 )
2020-05-20 21:07:35 -03:00
menu ( )
2020-05-20 20:32:31 -03:00
except ( KeyboardInterrupt , SystemExit ) :
menu ( )
raise
2020-05-23 08:50:38 -03:00
elif menuQ == " C " or menuQ == " c " :
2020-05-20 20:32:31 -03:00
try :
clear ( )
prt ( )
close ( )
donationLN ( )
t . sleep ( 50 )
2020-05-20 21:07:35 -03:00
menu ( )
2020-05-20 20:32:31 -03:00
except ( KeyboardInterrupt , SystemExit ) :
menu ( )
raise
2020-05-25 19:35:24 -03:00
elif menuQ == " R " or menuQ == " r " :
2020-05-23 08:50:38 -03:00
menu ( )
2020-05-24 14:15:12 -03:00
2020-05-25 19:35:24 -03:00
def menuF ( menuV ) : # Tester Donation access Menu
2020-05-23 08:50:38 -03:00
if menuV == " A " or menuV == " a " :
try :
clear ( )
prt ( )
close ( )
donationAddrTst ( )
t . sleep ( 50 )
menu ( )
except ( KeyboardInterrupt , SystemExit ) :
menu ( )
raise
elif menuV == " B " or menuV == " b " :
try :
clear ( )
prt ( )
close ( )
donationLNTst ( )
t . sleep ( 50 )
menu ( )
except ( KeyboardInterrupt , SystemExit ) :
menu ( )
raise
2020-05-25 19:35:24 -03:00
elif menuV == " R " or menuV == " r " :
2020-05-20 20:32:31 -03:00
menu ( )
2020-05-23 08:50:38 -03:00
2020-05-16 12:51:30 -03:00
#--------------------------------- End Main Menu execution --------------------------------
2020-05-24 14:15:12 -03:00
2020-05-30 21:46:11 -03:00
def conf ( ) :
2020-05-29 11:52:29 -03:00
if os . path . isfile ( ' bclock.conf ' ) or os . path . isfile ( ' blnclock.conf ' ) : # Check if the file 'bclock.conf' is in the same folder
2020-05-16 00:21:47 -03:00
pathv = pickle . load ( open ( " bclock.conf " , " rb " ) ) # Load the file 'bclock.conf'
path = pathv # Copy the variable pathv to 'path'
menu ( )
else :
prt ( )
2020-05-25 19:35:24 -03:00
print ( " Welcome to \033 [1;31;40mPyBLOCK \033 [0;37;40m \n \n " )
2020-05-29 11:52:29 -03:00
path = input ( " Insert the Path to Bitcoin-Cli: " )
pickle . dump ( path , open ( " bclock.conf " , " wb " ) )
2020-05-16 00:21:47 -03:00
menu ( )
2020-05-29 16:06:45 -03:00
2020-05-30 21:46:11 -03:00
while True : # Loop
clear ( )
path = " "
conf ( )