From 1bb0b33aae2ccb54f0ee113ea56a7d465a9e20bf Mon Sep 17 00:00:00 2001 From: Sourcery AI <> Date: Wed, 24 Nov 2021 10:49:20 +0000 Subject: [PATCH] 'Refactored by Sourcery' --- PyBlock.py | 202 ++++++++++++++++++++++++++--------------------------- 1 file changed, 98 insertions(+), 104 deletions(-) diff --git a/PyBlock.py b/PyBlock.py index 912e80c..7cfc680 100644 --- a/PyBlock.py +++ b/PyBlock.py @@ -89,74 +89,74 @@ def getblock(): # get access to bitcoin-cli with the command getblockchaininfo def getnewaddressOnchain(): #try: - clear() - blogo() - close() - qr = qrcode.QRCode( - version=1, - error_correction=qrcode.constants.ERROR_CORRECT_L, - box_size=10, - border=4, - ) - getadd = " getnewaddress" - getbal = " getbalance" - getfeemempool = " getmempoolinfo" - gna = os.popen(path['bitcoincli'] + getadd) - gnaa = gna.read() - gna1 = str(gnaa) + clear() + blogo() + close() + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + getadd = " getnewaddress" + getbal = " getbalance" + getfeemempool = " getmempoolinfo" + gna = os.popen(path['bitcoincli'] + getadd) + gnaa = gna.read() + gna1 = str(gnaa) + gnb = os.popen(path['bitcoincli'] + getbal) + gnbb= gnb.read() + gnb1 = str(gnbb) + output = render(str("BTC: " + gnb1), colors=['yellow'], align='left', font='tiny') + print("""--------------------------------------------------------------- + {} +---------------------------------------------------------------""".format(output)) + print("\033[1;30;47m") + qr.add_data(gna1) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("\x1b[?25l" + "Bitcoin Address: " + gna1) + gna.close() + a = gnb1 + getbal = " getbalance" + while True: + x = a gnb = os.popen(path['bitcoincli'] + getbal) gnbb= gnb.read() gnb1 = str(gnbb) - output = render(str("BTC: " + gnb1), colors=['yellow'], align='left', font='tiny') - print("""--------------------------------------------------------------- - {} + gnaq = os.popen(path['bitcoincli'] + getfeemempool) + gnaaq = gnaq.read() + gna1q = str(gnaaq) + d = json.loads(gna1q) + nn = d['total_fee'] / d['bytes'] * 100000000 + print("\n\033[ALive Fee: ~{} sats/byte \033[A".format(str(nn))) + if gnb1 > a: + clear() + blogo() + close() + getadd = " getnewaddress" + gna = os.popen(path['bitcoincli'] + getadd) + gnaa = gna.read() + gna1 = str(gnaa) + output = render(str("BTC: " + gnb1), colors=['yellow'], align='left', font='tiny') + print("""--------------------------------------------------------------- + {} ---------------------------------------------------------------""".format(output)) - print("\033[1;30;47m") - qr.add_data(gna1) - qr.print_ascii() - print("\033[0;37;40m") - qr.clear() - print("\x1b[?25l" + "Bitcoin Address: " + gna1) - gna.close() - a = gnb1 - while True: - x = a - getbal = " getbalance" - gnb = os.popen(path['bitcoincli'] + getbal) - gnbb= gnb.read() - gnb1 = str(gnbb) + getfeemempool = " getmempoolinfo" gnaq = os.popen(path['bitcoincli'] + getfeemempool) gnaaq = gnaq.read() gna1q = str(gnaaq) d = json.loads(gna1q) - nn = d['total_fee'] / d['bytes'] * 100000000 - print("\n\033[ALive Fee: ~{} sats/byte \033[A".format(str(nn))) - if gnb1 > a: - clear() - blogo() - close() - getadd = " getnewaddress" - gna = os.popen(path['bitcoincli'] + getadd) - gnaa = gna.read() - gna1 = str(gnaa) - output = render(str("BTC: " + gnb1), colors=['yellow'], align='left', font='tiny') - print("""--------------------------------------------------------------- - {} ----------------------------------------------------------------""".format(output)) - getfeemempool = " getmempoolinfo" - gnaq = os.popen(path['bitcoincli'] + getfeemempool) - gnaaq = gnaq.read() - gna1q = str(gnaaq) - d = json.loads(gna1q) - print("Total Fee: " + str(d['total_fee'])) - print("\033[1;30;47m") - qr.add_data(gna1) - qr.print_ascii() - print("\033[0;37;40m") - qr.clear() - print("\x1b[?25l" + "Bitcoin Address: " + gna1) - gna.close() - a = gnb1 + print("Total Fee: " + str(d['total_fee'])) + print("\033[1;30;47m") + qr.add_data(gna1) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("\x1b[?25l" + "Bitcoin Address: " + gna1) + gna.close() + a = gnb1 #except: # walletmenuLOCALOnchainONLY() @@ -2932,10 +2932,10 @@ def menuSelection(): else: if os.path.isfile('blndconnect.conf'): chln['offchain'] = "offchain" - pickle.dump(chln, open("selection.conf", "wb")) else: chln['onchain'] = "onchain" - pickle.dump(chln, open("selection.conf", "wb")) + + pickle.dump(chln, open("selection.conf", "wb")) def menuSelectionLN(): @@ -5100,50 +5100,44 @@ 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('bclock.conf') or os.path.isfile('blnclock.conf'): # Check if the file 'bclock.conf' is in the same folder + pathv = pickle.load(open("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("bclock.conf", "wb")) + + if os.path.isfile('blndconnect.conf'): # Check if the file 'bclock.conf' is in the same folder + lndconnectData= pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + else: clear() - path = {"ip_port":"", "rpcuser":"", "rpcpass":"", "bitcoincli":""} - - if os.path.isfile('bclock.conf') or os.path.isfile('blnclock.conf'): # Check if the file 'bclock.conf' is in the same folder - pathv = pickle.load(open("bclock.conf", "rb")) # Load the file 'bclock.conf' - path = pathv # Copy the variable pathv to 'path' + blogo() + if os.path.isfile('init.conf'): + pqr = pickle.load(open("init.conf", "rb")) + yesno = pqr 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("bclock.conf", "wb")) - - if os.path.isfile('blndconnect.conf'): # Check if the file 'bclock.conf' is in the same folder - lndconnectData= pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' - lndconnectload = lndconnectData # Copy the variable pathv to 'path' - else: - clear() - blogo() - if os.path.isfile('init.conf'): - pqr = pickle.load(open("init.conf", "rb")) - yesno = pqr - if yesno in ["NO", "no", "No", "nO"]: - pass - else: - yesno = input("Do you want to connect your Lightning Node? yes/no: ") - pickle.dump(yesno, open("init.conf", "wb")) - if yesno in ["YES", "yes", "yES", "yeS", "Yes", "YEs"]: - print("\n\tIf you are going to use your local node leave IP:PORT/CERT/MACAROONS in blank.\n") - lndconnectload["ip_port"] = input("Insert IP:PORT to your node: ") # path to the bitcoin-cli - lndconnectload["tls"] = input("Insert the path to tls.cert file: ") - lndconnectload["macaroon"] = input("Insert the path to admin.macaroon: ") - print("\n\tLocal Lightning Node connection.\n") - lndconnectload["ln"] = input("Insert the path to lncli: ") - pickle.dump(lndconnectload, open("blndconnect.conf", "wb")) # Save the file 'bclock.conf' - elif yesno in ["NO", "no", "No", "nO"]: - pass - - - menuSelection() + yesno = input("Do you want to connect your Lightning Node? yes/no: ") + pickle.dump(yesno, open("init.conf", "wb")) + if yesno in ["YES", "yes", "yES", "yeS", "Yes", "YEs"]: + print("\n\tIf you are going to use your local node leave IP:PORT/CERT/MACAROONS in blank.\n") + lndconnectload["ip_port"] = input("Insert IP:PORT to your node: ") # path to the bitcoin-cli + lndconnectload["tls"] = input("Insert the path to tls.cert file: ") + lndconnectload["macaroon"] = input("Insert the path to admin.macaroon: ") + print("\n\tLocal Lightning Node connection.\n") + lndconnectload["ln"] = input("Insert the path to lncli: ") + pickle.dump(lndconnectload, open("blndconnect.conf", "wb")) # Save the file 'bclock.conf' + menuSelection() #except: