diff --git a/pybitblock/PyBlock.py b/pybitblock/PyBlock.py index 24925d39..a59fbf87 100644 --- a/pybitblock/PyBlock.py +++ b/pybitblock/PyBlock.py @@ -1,6 +1,6 @@ #Developer: Curly60e #Tester: __B__T__C__ -#ℙ𝕪𝔹𝕃𝕆ℂ𝕂 𝕚𝕥𝕤 𝕒 𝔹𝕚𝕥𝕔𝕠𝕚𝕟 𝔻𝕒𝕤𝕙𝕓𝕠𝕒𝕣𝕕 𝕨𝕚𝕥𝕙 ℂ𝕪𝕡𝕙𝕖𝕣𝕡𝕦𝕟𝕜 𝕖𝕤𝕥𝕙𝕖𝕥𝕚𝕔. +#ℙ𝕪𝔹𝕃𝕆ℂ𝕂 𝕚𝕥𝕤 𝕒 𝔹𝕚𝕥𝕔𝕠𝕚𝕟 𝔻𝕒𝕤𝕙𝕓𝕠𝕒𝕣𝕕 𝕨𝕚𝕥𝕙 ℂ𝕪𝕡𝕙𝕖𝕣𝕡𝕦𝕟𝕜 𝕒𝕖𝕤𝕥𝕙𝕖𝕥𝕚𝕔. import os import os.path @@ -33,7 +33,7 @@ from robohash import Robohash -version = "1.1.9.1" +version = "1.1.9.2" def close(): print("<<< Back Control + C.\n\n") @@ -184,7 +184,10 @@ def getnewaddressOnchain(): gnu = os.popen(path['bitcoincli'] + getunconfirm) gnua= gnu.read() gnub = str(gnua) - output = render(str(gnb1 + " BTC"), colors=['yellow'], align='left', font='tiny') + output = render( + str(f'{gnb1} BTC'), colors=['yellow'], align='left', font='tiny' + ) + print("""--------------------------------------------------------------- {} ---------------------------------------------------------------""".format(output)) @@ -221,7 +224,13 @@ def getnewaddressOnchain(): gna = os.popen(path['bitcoincli'] + getadd) gnaa = gna.read() gna1 = str(gnaa) - output = render(str(gnb1 + " BTC"), colors=['yellow'], align='left', font='tiny') + output = render( + str(f'{gnb1} BTC'), + colors=['yellow'], + align='left', + font='tiny', + ) + print("""--------------------------------------------------------------- {} ---------------------------------------------------------------""".format(output)) @@ -285,7 +294,7 @@ def clear(): # clear the screen os.system('cls' if os.name=='nt' else 'clear') def getgenesis(): # get and decode Genesis block - output = render(str("satoshis 0 block"), colors=['yellow'], align='left', font='tiny') + output = render(str("genesis"), colors=['yellow'], align='left', font='tiny') print(output) bitcoincli = " getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f 0 | xxd -r -p | hexyl -n 256" os.system(path['bitcoincli'] + bitcoincli) @@ -314,7 +323,7 @@ def console(): # get into the console from bitcoin-cli sysinfo() close() console() - lsd = os.popen(path['bitcoincli'] + " " + cle) + lsd = os.popen(f'{path["bitcoincli"]} {cle}') lsd0 = lsd.read() lsd1 = str(lsd0) print(lsd1) @@ -352,7 +361,7 @@ def design(): else: settingsClock = {"gradient":"", "design":"block", "colorA":"green", "colorB":"yellow"} pickle.dump(settingsClock, open("config/pyblocksettingsClock.conf", "wb")) - bitcoinclient = path['bitcoincli'] + " getblockcount" + bitcoinclient = f'{path["bitcoincli"]} getblockcount' block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string b = block a = b @@ -360,7 +369,7 @@ def design(): print("\x1b[?25l" + output) while True: x = a - bitcoinclient = path['bitcoincli'] + " getblockcount" + bitcoinclient = f'{path["bitcoincli"]} getblockcount' block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string b = block if b > a: @@ -368,10 +377,10 @@ def design(): close() output = render(str(b), colors=[settingsClock['colorA'], settingsClock['colorB']], align='center') print("\a\x1b[?25l" + output) - bitcoinclient = path['bitcoincli'] + " getbestblockhash" + bitcoinclient = f'{path["bitcoincli"]} getbestblockhash' bb = os.popen(str(bitcoinclient)).read() ll = bb - bitcoinclientgetblock = path['bitcoincli'] + " getblock " + ll + bitcoinclientgetblock = f'{path["bitcoincli"]} getblock {ll}' qq = os.popen(bitcoinclientgetblock).read() yy = json.loads(qq) mm = yy @@ -420,7 +429,7 @@ def runthenumbers(): input("\nContinue...") def countdownblock(): - bitcoinclient = path['bitcoincli'] + " getblockcount" + bitcoinclient = f'{path["bitcoincli"]} getblockcount' block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string b = block try: @@ -437,7 +446,7 @@ def countdownblock(): print("Remaining: " + str(q) + " Blocks\n") while a > b: try: - bitcoinclient = path['bitcoincli'] + " getblockcount" + bitcoinclient = f'{path["bitcoincli"]} getblockcount' block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string b = block if a == b: @@ -489,7 +498,7 @@ def countdownblockConn(): def localHalving(): - bitcoinclient = path['bitcoincli'] + " getblockcount" + bitcoinclient = f'{path["bitcoincli"]} getblockcount' block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string b = block c = b @@ -580,7 +589,7 @@ def pdfconvert(): #--------------------------------- NYMs ----------------------------------- def get_ansi_color_code(r, g, b): - if r == g and g == b: + if r == g == b: if r < 8: return 16 if r > 248: diff --git a/pybitblock/ppi.py b/pybitblock/ppi.py index 558f44da..77200cde 100644 --- a/pybitblock/ppi.py +++ b/pybitblock/ppi.py @@ -56,14 +56,14 @@ def opreturnOnchainONLY(): qr.add_data(b) qr.print_ascii() print("\033[0;37;40m") - print("LND Invoice: " + b) + print(f'LND Invoice: {b}') qr.clear() input("\nContinue...") if lndconnectload['ln']: invoiceN = b invoice = invoiceN.lower() lncli = " payinvoice " - lsd = os.popen(lndconnectload['ln'] + " decodepayreq " + invoice).read() + lsd = os.popen(f'{lndconnectload["ln"]} decodepayreq {invoice}').read() lsd0 = str(lsd) d = json.loads(lsd0) url = 'http://opreturnbot.com/api/status/{}'.format(d['payment_hash']) @@ -167,7 +167,7 @@ def opreturn(): invoiceN = b invoice = invoiceN.lower() lncli = " payinvoice " - lsd = os.popen(lndconnectload['ln'] + " decodepayreq " + invoice).read() + lsd = os.popen(f'{lndconnectload["ln"]} decodepayreq {invoice}').read() lsd0 = str(lsd) d = json.loads(lsd0) url = 'http://opreturnbot.com/api/status/{}'.format(d['payment_hash']) @@ -185,14 +185,14 @@ def opreturn(): qr.add_data(b) qr.print_ascii() print("\033[0;37;40m") - print("LND Invoice: " + b) + print(f'LND Invoice: {b}') qr.clear() input("\nContinue...") if lndconnectload['ln']: invoiceN = b invoice = invoiceN.lower() lncli = " payinvoice " - lsd = os.popen(lndconnectload['ln'] + " decodepayreq " + invoice).read() + lsd = os.popen(f'{lndconnectload["ln"]} decodepayreq {invoice}').read() lsd0 = str(lsd) d = json.loads(lsd0) url = 'http://opreturnbot.com/api/status/{}'.format(d['payment_hash']) @@ -229,7 +229,7 @@ def opreturn_view(): clear() blogo() print("\nTransaction ID: " + responseC) - print("OP_RETURN Message: " + r3) + print(f'OP_RETURN Message: {r3}') input("\nContinue...") except: pass @@ -273,7 +273,7 @@ def gameroom(): def statsConn(): try: - conn = """curl -s https://www.bitcoinblockhalf.com/ | html2text | grep -E "Total" -A 10 | grep -v -E "\--" | tr -d '*' | jq -R | tr -d '"' """ + conn = """curl -s https://www.bitcoinblockhalf.com/ | html2text | grep -E "Total" -A 10 | grep -v -E "\--" | tr -d '*' | tr -d '"' """ a = os.popen(conn).read() clear() blogo() @@ -322,7 +322,7 @@ def bwtConn(): def datesConn(): try: - conn = """curl -s "https://bitcoinexplorer.org/fun" | html2text | grep "20" | grep -v -E "https" | grep -E " " | head -n 46 | tr -d '[' | tr -d ',' | jq -R""" + conn = """curl -s "https://bitcoinexplorer.org/fun" | html2text | grep "20" | grep -v -E "https" | grep -E " " | head -n 46 | tr -d '[' | tr -d ','""" a = os.popen(conn).read() clear() blogo() @@ -372,7 +372,7 @@ def miningConn(): def stalnConn(): try: - conn = """curl -s 'https://1ml.com' | html2text | xargs -L 1 | grep -E "Number" -A 8 | jq -R""" + conn = """curl -s 'https://1ml.com' | html2text | xargs -L 1 | grep -E "Number" -A 8""" a = os.popen(conn).read() clear() blogo() @@ -477,7 +477,7 @@ def wttrDataV1(): unit = input("Insert your metric units: ") list = "curl '" + lang + ".wttr.in/" + selectData2 + "?F&" + unit + "'" else: - list = "curl wttr.in/" + selectData + "?F" + list = f'curl wttr.in/{selectData}?F' a = os.popen(list).read() clear() blogo() @@ -536,7 +536,7 @@ def wttrDataV2(): list = "curl 'v2.wttr.in/" + selectData2 + "?" + unit + "&F&lang=" + lang + "'" else: - list = "curl v2.wttr.in/" + selectData + "?F" + list = f'curl v2.wttr.in/{selectData}?F' a = os.popen(list).read() clear() blogo() @@ -726,8 +726,6 @@ def loadFileConnLNBits(lnbitLoad): return lnbitLoad def createFileConnLNBits(): - lnbitLoad = {"wallet_name":"", "wallet_id":"", "admin_key":"", "invoice_read_key":""} - clear() blogo() print("""\n\t \033[1;33;40mATENTION\033[0;37;40m: YOU ARE GOING TO CREATE A FILE WITH YOUR INFORMATION OF CONNECTION TO LNBITS.COM. @@ -735,7 +733,13 @@ def createFileConnLNBits(): IF YOU DELETE THIS FILE YOU WILL NEED TO PAY AGAIN TO GET ACCESS FROM PyBLOCK. SAVE THE FILE '\033[1;33;40mlnbitSN.conf\033[0;37;40m' IN A SAFE PLACE.\n """) - lnbitLoad["wallet_name"] = input("Wallet name: ") # path to the bitcoin-cli + lnbitLoad = { + 'wallet_id': '', + 'admin_key': '', + 'invoice_read_key': '', + 'wallet_name': input("Wallet name: "), + } + lnbitLoad["wallet_id"] = input("Wallet ID: ") lnbitLoad["admin_key"] = input("Admin key: ") lnbitLoad["invoice_read_key"] = input("Invoice/read key: ") @@ -782,10 +786,16 @@ def lnbitCreateNewInvoice(): qr.print_ascii() print("\033[0;37;40m") qr.clear() - print("Lightning Invoice: " + c) + print(f'Lightning Invoice: {c}') t.sleep(10) dn = str(d['checking_id']) - checkcurl = 'curl -X GET https://lnbits.com/api/v1/payments/' + dn + """ -H "X-Api-Key: {}" -H "Content-type: application/json" """.format(b) + checkcurl = ( + f'curl -X GET https://lnbits.com/api/v1/payments/{dn}' + + """ -H "X-Api-Key: {}" -H "Content-type: application/json" """.format( + b + ) + ) + rsh = os.popen(checkcurl).read() clear() blogo() @@ -815,7 +825,13 @@ def lnbitPayInvoice(): a = loadFileConnLNBits(['invoice_read_key']) b = str(a['invoice_read_key']) while True: - checkcurl = 'curl -X GET https://lnbits.com/api/v1/payments/' + dn + """ -H "X-Api-Key: {}" -H "Content-type: application/json" """.format(b) + checkcurl = ( + f'curl -X GET https://lnbits.com/api/v1/payments/{dn}' + + """ -H "X-Api-Key: {}" -H "Content-type: application/json" """.format( + b + ) + ) + rsh = os.popen(checkcurl).read() clear() blogo() @@ -865,7 +881,7 @@ def lnbitCreatePayWall(): print("\n\tLNBITS PAYWALL LIST\n") for item_ in d: s = item_ - print("ID: " + s['id']) + print(f'ID: {s["id"]}') nd = input("\nSelect ID: ") for item in d: s = item @@ -905,7 +921,7 @@ def lnbitListPawWall(): try: for item_ in d: s = item_ - print("ID: " + s['id']) + print(f'ID: {s["id"]}') nd = input("\nSelect ID: ") for item in d: s = item @@ -947,7 +963,7 @@ def lnbitDeletePayWall(): try: for item_ in d: s = item_ - print("ID: " + s['id']) + print(f'ID: {s["id"]}') nd = input("\nSelect ID: ") for item in d: s = item @@ -1021,7 +1037,7 @@ def lnbitsLNURLw(): print("\n\tLNBITS LNURLW LIST\n") for item_ in d: s = item_ - print("ID: " + s['id'] + " Uses: " + str(s['uses']) + " Used: " + str(s['used'])) + print(f'ID: {s["id"]} Uses: ' + str(s['uses']) + " Used: " + str(s['used'])) nd = input("\nSelect ID: ") for item in d: s = item @@ -1060,7 +1076,7 @@ def lnbitsLNURLwList(): print("\n\tLNBITS LNURLW LIST\n") for item_ in d: s = item_ - print("ID: " + s['id'] + " Uses: " + str(s['uses']) + " Used: " + str(s['used'])) + print(f'ID: {s["id"]} Uses: ' + str(s['uses']) + " Used: " + str(s['used'])) nd = input("\nSelect ID: ") for item in d: s = item @@ -1159,10 +1175,7 @@ def lnpayCreateInvoice(): my_wallet = LNPayWallet(q) amt = input("\nAmount in Sats: ") memo = input("Memo: ") - invoice_params = { - 'num_satoshis': amt, - 'memo': memo + ' -PyBLOCK' - } + invoice_params = {'num_satoshis': amt, 'memo': f'{memo} -PyBLOCK'} try: invoice = my_wallet.create_invoice(invoice_params) clear() @@ -1185,9 +1198,10 @@ def lnpayCreateInvoice(): qr.print_ascii() print("\033[0;37;40m") qr.clear() - print("Lightning Invoice: " + invoice['payment_request']) + print(f'Lightning Invoice: {invoice["payment_request"]}') t.sleep(10) - curl = 'curl -u ' + b + ': https://api.lnpay.co/v1/lntx/' + invoice['id'] + '?fields=settled,num_satoshis' + curl = f'curl -u {b}: https://api.lnpay.co/v1/lntx/{invoice["id"]}?fields=settled,num_satoshis' + rsh = os.popen(curl).read() clear() blogo() @@ -1228,7 +1242,7 @@ def lnpayGetTransactions(): s = transaction_ q = s['lnTx'] - print("ID: " + s['id']) + print(f'ID: {s["id"]}') nd = input("\nSelect ID: ") for transaction in transactions: s = transaction @@ -1271,7 +1285,8 @@ def lnpayPayInvoice(): try: print("\n\tLNPAY PAY INVOICE\n") inv = input("\nInvoice: ") - curl = 'curl -u' + b +': https://api.lnpay.co/v1/node/default/payments/decodeinvoice?payment_request=' + inv + curl = f'curl -u{b}: https://api.lnpay.co/v1/node/default/payments/decodeinvoice?payment_request={inv}' + clear() rsh = os.popen(curl).read() nn = str(rsh) @@ -1364,8 +1379,6 @@ def loadFileConnOpenNode(opennodeLoad): return opennodeLoad def createFileConnOpenNode(): - opennodeLoad = {"key":"","wdr":"","inv":""} - clear() blogo() print("""\n\t \033[1;33;40mATENTION\033[0;37;40m: YOU ARE GOING TO CREATE A FILE WITH YOUR INFORMATION OF CONNECTION TO OPENNODE.COM. @@ -1373,7 +1386,7 @@ def createFileConnOpenNode(): IF YOU DELETE THIS FILE YOU WILL NEED TO PAY AGAIN TO GET ACCESS FROM PyBLOCK. SAVE THE FILE '\033[1;33;40mopennodeSN.conf\033[0;37;40m' IN A SAFE PLACE.\n """) - opennodeLoad["key"] = input("API Read Only Key: ") + opennodeLoad = {'wdr': '', 'inv': '', 'key': input("API Read Only Key: ")} opennodeLoad["wdr"] = input("API Withdrawall Key: ") opennodeLoad["inv"] = input("API Invoices Key: ") pickle.dump(opennodeLoad, open("opennode.conf", "wb")) @@ -1689,7 +1702,7 @@ def OpenNodeListPayments(): s = item_ n = s['status'] q = str(n) - print("ID: " + s['id'] + " " + q) + print(f'ID: {s["id"]} {q}') nd = input("\nSelect ID: ") for item in da: s = item @@ -1739,13 +1752,12 @@ def loadFileTippinMe(tippinmeLoad): return tippinmeLoad def createFileTippinMe(): - tippinmeLoad = {"key":""} clear() blogo() print("""\n\t \033[1;33;40mATENTION\033[0;37;40m: YOUR CONFIGURATION INFORMATION WILL BE SAVE IN '\033[1;33;40mtippinme.conf\033[0;37;40m' IF YOU NEED TO START AGAIN, DELETE IT.\n """) - tippinmeLoad["key"] = input("Twitter @user: ") + tippinmeLoad = {'key': input("Twitter @user: ")} pickle.dump(tippinmeLoad, open("tippinme.conf", "wb")) def tippinmeGetInvoice(): @@ -1789,7 +1801,7 @@ def tippinmeGetInvoice(): qr.add_data(ln1) qr.print_ascii() print("\033[0;37;40m") - print("LND Invoice: " + ln1) + print(f'LND Invoice: {ln1}') response.close() input("Continue...") except: @@ -1819,8 +1831,6 @@ def loadFileConnTallyCo(tallycoLoad): return tallycoLoad def createFileConnTallyCo(): - tallycoLoad = {"fundraiser_id":"","id":""} - clear() blogo() print("""\n\t \033[1;33;40mATENTION\033[0;37;40m: YOU ARE GOING TO CREATE A FILE WITH YOUR INFORMATION OF CONNECTION TO TALLYCO.IN. @@ -1829,7 +1839,7 @@ def createFileConnTallyCo(): SAVE THE FILE '\033[1;33;40mtallycoSN.conf\033[0;37;40m' IN A SAFE PLACE.\n """) print("\nEXAMPLE: https://tallyco.in/s/{fundraiser_id}/\n") - tallycoLoad["id"] = input("User ID or Twitter @USER: ") + tallycoLoad = {'fundraiser_id': '', 'id': input("User ID or Twitter @USER: ")} pickle.dump(tallycoLoad, open("tallyco.conf", "wb")) def tallycoGetPayment(): @@ -1861,7 +1871,7 @@ def tallycoGetPayment(): qr.add_data(f) qr.print_ascii() print("\033[0;37;40m") - print("LND Invoice: " + f) + print(f'LND Invoice: {f}') qr.clear() input("\nContinue...") elif lnd_onchain == "btc": @@ -1870,8 +1880,8 @@ def tallycoGetPayment(): qr.add_data(e) qr.print_ascii() print("\033[0;37;40m") - print("Amount: " + d['cost']) - print("Bitcoin Address: " + e) + print(f'Amount: {d["cost"]}') + print(f'Bitcoin Address: {e}') qr.clear() input("\nContinue...") except: @@ -1924,7 +1934,7 @@ def tallycoDonateid(): qr.add_data(f) qr.print_ascii() print("\033[0;37;40m") - print("LND Invoice: " + f) + print(f'LND Invoice: {f}') qr.clear() input("\nContinue...") elif lnd_onchain in ["btc", "bTC", "BtC", "BTC", "BTc", "btC"]: @@ -1933,8 +1943,8 @@ def tallycoDonateid(): qr.add_data(e) qr.print_ascii() print("\033[0;37;40m") - print("Amount: " + d['cost']) - print("Bitcoin Address: " + e) + print(f'Amount: {d["cost"]}') + print(f'Bitcoin Address: {e}') qr.clear() input("\nContinue...") except: