diff --git a/pybitblock/SPV/PyBlock-SPV.py b/pybitblock/SPV/PyBlock-SPV.py new file mode 100644 index 0000000..d96ed30 --- /dev/null +++ b/pybitblock/SPV/PyBlock-SPV.py @@ -0,0 +1,6462 @@ +#Developer: Curly60e +#Tester: __B__T__C__ +#ℙ𝕪𝔹𝕃𝕆ℂ𝕂 𝕚𝕥𝕤 𝕒 𝔹𝕚𝕥𝕔𝕠𝕚𝕟 𝔻𝕒𝕤𝕙𝕓𝕠𝕒𝕣𝕕 𝕨𝕚𝕥𝕙 ℂ𝕪𝕡𝕙𝕖𝕣𝕡𝕦𝕟𝕜 𝕒𝕖𝕤𝕥𝕙𝕖𝕥𝕚𝕔. + +import os +import os.path +import time as t +import pickle +import psutil +import qrcode +import random +import xmltodict +import sys +import subprocess +import requests +import json +import simplejson as json +import numpy as np +from cfonts import render, say +from clone import * +from donation import * +from feed import * +from art import * +from logos import * +from sysinf import * +from pblogo import * +from apisnd import * +from ppi import * +from termcolor import colored, cprint +from nodeconnection import * +from terminal_matrix.matrix import * +from PIL import Image +from robohash import Robohash + + +version = "1.1.14-alpha12" + +def close(): + print("<<< Ctrl + C.\n\n") + +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 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'\u001b[38;5;27m{"■"*(x-1)}' + ) + for i in range(y) + ) + ] + +def rpc(method, params=[]): + payload = json.dumps({ + "jsonrpc": "2.0", + "id": "minebet", + "method": method, + "params": params + }) + path = {"ip_port":"", "rpcuser":"", "rpcpass":"", "bitcoincli":""} + if os.path.isfile('config/bclock.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' + return requests.post(path['ip_port'], auth=(path['rpcuser'], path['rpcpass']), data=payload).json()['result'] + + +#-----------------------------Slush-------------------------------- + +def slDIFFConn(): + try: + conn = """curl -s https://insights.braiins.com/api/v1.0/difficulty-stats""" + a = os.popen(conn).read() + clear() + blogo() + closed() + output = render("difficulty", colors=['yellow'], align='left', font='tiny') + print(output) + b = json.loads(a) + print(f"""\n + + Block epoch: {b['blocks_epoch']} + Difficulty: {b['difficulty']} + Epoch block time: {b['epoch_block_time']} + Estimated adjustment: {b['estimated_adjustment']} + Estimated adjustemnt date: {b['estimated_adjustment_date']} + Estimated next differece: {b['estimated_next_diff']} + Previous adjustment: {b['previous_adjustment']} + + """) + input("\a\nContinue...") + except: + pass + +def slHASHConn(): + try: + conn = """curl -s https://insights.braiins.com/api/v1.0/hash-rate-stats""" + a = os.popen(conn).read() + clear() + blogo() + closed() + output = render("hash rate", colors=['yellow'], align='left', font='tiny') + print(output) + b = json.loads(a) + print(f"""\n + + Averiage fees per block: {b['avg_fees_per_block']} + Current hashrate: {b['current_hashrate']} + Fees percent: {b['fees_percent']} + Hash price: {b['hash_price']} + Hash rate 30: {b['hash_rate_30']} + Hash value: {b['hash_value']} + Rev. USD: {b['rev_usd']} + + """) + input("\a\nContinue...") + except: + pass + +def slPOOLConn(): + try: + conn = """curl -s https://insights.braiins.com/api/v1.0/pool-stats?json=1 | jq -C '.[]' | tr -d '{|}|]|,' | xargs -L 1 | grep -E " " """ + a = os.popen(conn).read() + clear() + blogo() + closed() + output = render("pool", colors=['yellow'], align='left', font='tiny') + print(output) + print(a) + input("\a\nContinue...") + except: + pass + +def slHISTConn(): + try: + conn = """curl -s https://insights.braiins.com/api/v1.0/hashrate-and-difficulty-history?json=1 | jq -C '.[]' | tr -d '{|}|]|,' | xargs -L 1 | grep -E " " """ + a = os.popen(conn).read() + clear() + blogo() + closed() + output = render("history", colors=['yellow'], align='left', font='tiny') + print(output) + print(a) + input("\a\nContinue...") + except: + pass + +def getPoolSlushCheck(): + + s = "" + sq = s + + api = "" + try: + if os.path.isfile("config/slushAPI.conf"): + apiv = pickle.load(open("config/slushAPI.conf", "rb")) + api = apiv + else: + clear() + blogo() + api = input("Insert Slush API KEY: ") + pickle.dump(api, open("config/slushAPI.conf", "wb")) + except: + pass + + while True: + try: + slushpoolbtc = f"curl https://slushpool.com/accounts/profile/json/btc/ -H 'SlushPool-Auth-Token: {api}' 2>/dev/null" + + slushpoolbtcblock = f"curl https://slushpool.com/stats/json/btc/ -H 'SlushPool-Auth-Token: {api}' 2>/dev/null" + + + b = os.popen(slushpoolbtc) + c = b.read() + d = json.loads(c) + f = d['btc'] + + bblock = os.popen(slushpoolbtcblock) + cblock = bblock.read() + dblock = json.loads(cblock) + fblock = dblock['btc'] + eblock = fblock['blocks'] + for i in eblock: + qnq = sorted(eblock) + for n in qnq: + s = n + + if s > sq: + newblock = "\a\n\n\t\t\u001b[31;1m New Block Mined \u001b[38;5;27m{}\u001b[31;1m! \u001b[38;5;202mFresh sats for you!\033[0;37;40m".format(s) + sq = s + else: + newblock = s + + clear() + blogo() + print("""\033[A + + -------------------------------------------------------------------------------------------- + + \033[0;37;40mSlushPool BTC + + Username: {} + Confirmed reward: \u001b[38;5;40m{}\033[0;37;40m BTC + Unconfirmed reward: \u001b[33;1m{}\033[0;37;40m BTC + Estimated reward: {} BTC + All Time reward: {} BTC + Hash Rate 5m: {} Gh/s + Hash Rate 60m: {} Gh/s + Hash Rate 24h: {} Gh/s + Hash Rate Scoring: \u001b[38;5;27m{}\033[0;37;40m Gh/s + Hash Rate Yesterday: {} Gh/s + Connected Workers: {} + Disconnected Workers: {} + Last Block discovered: {} + + -------------------------------------------------------------------------------------------- + + \033[A""".format(d['username'], f['confirmed_reward'], f['unconfirmed_reward'], f['estimated_reward'], f['all_time_reward'], f['hash_rate_5m'], f['hash_rate_60m'], f['hash_rate_24h'], f['hash_rate_scoring'], f['hash_rate_yesterday'], f['ok_workers'], f['off_workers'],newblock)) + + t.sleep(10) + + except: + break + + +#-----------------------------END Slush-------------------------------- + + +def getblock(): # get access to bitcoin-cli with the command getblockchaininfo + while True: + try: + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + print(d) + clear() + blogo() + close() + output = render("CHAIN INFO", colors=['yellow'], align='left', font='tiny') + print(output) + print(""" + ---------------------------------------------------------------------------- + Chain: {} + Blocks: {} + Best BlockHash: {} + Difficulty: {} + Verification Progress: {} + Size on Disk: {} + Pruned: {} + ---------------------------------------------------------------------------- + """.format(d['chain'], d['blocks'], d['bestblockhash'], d['difficulty'], d['verificationprogress'], d['size_on_disk'], d['pruned'])) + t.sleep(10) + except: + break + +def searchTXS(): + try: + while True: + clear() + blogo() + closed() + output = render("search txs", colors=['yellow'], align='left', font='tiny') + print(output) + tx = input("Search Tx ID: ") + gettxout = " gettxout " + + gnt = os.popen(path['bitcoincli'] + gettxout + tx + " 1") + gnta = gnt.read() + gnt1 = str(gnta) + gnt2 = json.loads(gnt1) + scriptPubKey = gnt2['scriptPubKey'] + if gnt2['bestblock']: + clear() + blogo() + closed() + output = render("search txs", colors=['yellow'], align='left', font='tiny') + print(output) + print(""" + ------------------------------------------------------------------------------- + Tx: \u001b[38;5;40m{} \033[0;37;40m + ------------------------------------------------------------------------------- + \u001b[31;1mBestblockhash: \u001b[31;1m{} + \u001b[31;1mConfirmations: \u001b[38;5;27m{} + \u001b[31;1mAmount: \u001b[38;5;202m{} BTC + \u001b[31;1mAddress: \u001b[33;1m{}\033[0;37;40m + ------------------------------------------------------------------------------- + """.format(tx, gnt2['bestblock'], gnt2['confirmations'], gnt2['value'], scriptPubKey['address'])) + else: + print("Is this a \u001b[38;5;40m Coinbase\033[0;37;40m tx?") + + input("\n\033[?25l\033[0;37;40m\n\033[AContinue...\033[A") + except: + pass + +def untxsConn(): + try: + while True: + clear() + blogo() + closed() + output = render( + "unconfirmed txs", colors=['yellow'], align='left', font='tiny' + ) + + print(output) + getrawmempool = " getrawmempool" + gna = os.popen(path['bitcoincli'] + getrawmempool) + gnaa = gna.read() + gna1 = str(gnaa) + d = json.loads(gna1) + getrawtrans = " getrawtransaction " + for b in d: + n = "".join(map(str, b)) + m = getrawtrans + n + " 1" + gnb = os.popen(path['bitcoincli'] + m) + gnba = gnb.read() + gnb1 = str(gnba) + abc = json.loads(gnb1) + ab = abc['vout'] + knz = 'address' + for value in ab: + knx = value['scriptPubKey'] + if knz in knx: + print("TxID: \u001b[38;5;40m{} \033[0;37;40m| \u001b[31;1mAmount: \u001b[38;5;202m{} BTC \033[0;37;40m| \u001b[31;1mAddress: \u001b[33;1m{}\033[0;37;40m | \u001b[31;1mType: \u001b[31;1m{}\u001b[33;1m".format(b,value['value'],knx['address'],knx['type'])) + else: + print("TxID: \u001b[38;5;40m{} \033[0;37;40m| \u001b[31;1mAmount: \u001b[38;5;202m{} BTC \033[0;37;40m| \u001b[31;1mOP_RETURN: \u001b[38;5;27m{}\033[0;37;40m | \u001b[31;1mType: \u001b[31;1m{}\u001b[33;1m".format(b,value['value'],knx['asm'],knx['type'])) + decodeTX = ( + path['bitcoincli'] + + f" getrawtransaction {b}" + + " | xxd -r -p | hexyl -n 256" + ) + + print("OP_RETURN Hex: ") + os.system(decodeTX) + input("\n\033[?25l\033[0;37;40m\n\033[AContinue...\033[A") + except: + pass + +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" + getunconfirm = " getunconfirmedbalance" + gna = os.popen(path['bitcoincli'] + getadd) + gnaa = gna.read() + gna1 = str(gnaa) + gnb = os.popen(path['bitcoincli'] + getbal) + gnbb= gnb.read() + gnb1 = str(gnbb) + gnu = os.popen(path['bitcoincli'] + getunconfirm) + gnua= gnu.read() + gnub = str(gnua) + output = render( + str(f'{gnb1} BTC'), colors=['yellow'], align='left', font='tiny' + ) + + print("""--------------------------------------------------------------- + {} +---------------------------------------------------------------""".format(output)) + print("Unconfrmed: \u001b[31;1m{} BTC\033[0;37;40m".format(gnub.replace("\n",""))) + print("---------------------------------------------------------------") + print("\033[1;30;47m") + qr.add_data(gna1.replace("\n","")) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("\x1b[?25l" + "Bitcoin Address: " + gna1) + gna.close() + a = gnub + b = gnb1 + getbal = " getbalance" + while True: + x = a + z = b + gnb = os.popen(path['bitcoincli'] + getbal) + gnbb= gnb.read() + gnb1 = str(gnbb) + gnaq = os.popen(path['bitcoincli'] + getfeemempool) + gnaaq = gnaq.read() + gna1q = str(gnaaq) + gnu = os.popen(path['bitcoincli'] + getunconfirm) + gnua= gnu.read() + gnub = str(gnua) + d = json.loads(gna1q) + if gnub > a or gnb1 > b: + clear() + blogo() + close() + getadd = " getnewaddress" + gna = os.popen(path['bitcoincli'] + getadd) + gnaa = gna.read() + gna1 = str(gnaa) + output = render( + str(f'{gnb1} BTC'), + colors=['yellow'], + align='left', + font='tiny', + ) + + print("""--------------------------------------------------------------- + {} +---------------------------------------------------------------""".format(output)) + print("Unconfrmed: \u001b[31;1m{} BTC\033[0;37;40m".format(gnub.replace("\n",""))) + print("---------------------------------------------------------------") + getfeemempool = " getmempoolinfo" + gnaq = os.popen(path['bitcoincli'] + getfeemempool) + gnaaq = gnaq.read() + gna1q = str(gnaaq) + d = json.loads(gna1q) + print("\033[1;30;47m") + qr.add_data(gna1.replace("\n","")) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("\x1b[?25l" + "Bitcoin Address: " + gna1) + gna.close() + a = gnub + b = gnb1 + nn = float(d['total_fee']) / float(d['bytes']) * float(100000000) + print("\n\033[ALive Fee: ~{} sat/vB \033[A".format(nn)) + t.sleep(10) + except: + walletmenuLOCALOnchainONLY() + +def gettransactionsOnchain(): + try: + listtxs = " listunspent" + while True: + clear() + blogo() + close() + gna = os.popen(path['bitcoincli'] + listtxs) + gnaa = gna.read() + gna1 = str(gnaa) + d = json.loads(gna1) + gnb = os.popen(path['bitcoincli'] + " getbalance") + gnbb= gnb.read() + gnb1 = str(gnbb) + sort_order = sorted(d, key=lambda x:x['confirmations'], reverse=True) + output = render("transactions", colors=['yellow'], align='left', font='tiny') + print(output) + for q in sort_order: + print( + "TxID: " + + "\u001b[38;5;40m{}\033[0;37;40m".format(str(q['txid'])) + + " | " + + "Amount: " + + "\u001b[38;5;202m{} BTC\033[0;37;40m".format( + str(q['amount']) + ) + + " | " + + "Conf: " + + "\u001b[33;1m{}\033[0;37;40m".format( + str(q['confirmations']) + ) + ) + + + print("\nTotal Balance: \u001b[38;5;202m{} BTC \033[0;37;40m".format(gnb1.replace("\n", ""))) + input("\nRefresh...") + except: + walletmenuLOCALOnchainONLY() + +def getblockcount(): # get access to bitcoin-cli with the command getblockcount + bitcoincli = " getblockcount" + os.system(path['bitcoincli'] + bitcoincli) + +def getbestblockhash(): # get access to bitcoin-cli with the command getblockcount + bitcoincli = " getbestblockhash" + os.system(path['bitcoincli'] + bitcoincli) + +def clear(): # clear the screen + os.system('cls' if os.name=='nt' else 'clear') + +def getgenesis(): # get and decode Genesis block + output = render("genesis", colors=['yellow'], align='left', font='tiny') + print(output) + bitcoincli = " getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f 0 | xxd -r -p | hexyl -n 256" + os.system(path['bitcoincli'] + bitcoincli) + +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['bitcoincli'] + + f" getblock {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['bitcoincli'] + + f" getrawtransaction {hexa}" + + " | xxd -r -p | hexyl -n 256" + ) + + os.system(decodeTX) + +def tmp(): + t.sleep(15) + +def console(): # get into the console from bitcoin-cli + print("\t\033[0;37;40mThis is \033[1;33;40mBitcoin-cli's \033[0;37;40mconsole. Type 'help' for more information.\n\n") + while True: + cle = input("\u001b[38;5;202m₿ console >: \033[0;37;40m") + if cle == "clear": + clear() + blogo() + sysinfo() + close() + console() + lsd = os.popen(f'{path["bitcoincli"]} {cle}') + lsd0 = lsd.read() + lsd1 = str(lsd0) + print(lsd1) + lsd.close() + +def screensv(): + try: + doit() + except (KeyboardInterrupt, SystemExit): + matrix.close() + clear() + blogo() + menu() + +def delay_print(s): + for c in s: + sys.stdout.write(c) + sys.stdout.flush() + time.sleep(0.25) +#------------------------------------------------------ + +def artist(): # here we convert the result of the command 'getblockcount' on a random art design + while True: + try: + clear() + close() + design() + except: + break + +def design(): + 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 + settingsv = pickle.load(open("config/pyblocksettingsClock.conf", "rb")) # Load the file 'bclock.conf' + settingsClock = settingsv # Copy the variable pathv to 'path' + else: + settingsClock = {"gradient":"", "design":"block", "colorA":"green", "colorB":"yellow"} + pickle.dump(settingsClock, open("config/pyblocksettingsClock.conf", "wb")) + bitcoinclient = f'{path["bitcoincli"]} getblockcount' + block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string + b = block + a = b + output = render(str(b), colors=[settingsClock['colorA'], settingsClock['colorB']], align='center') + print("\033[0;37;40m\x1b[?25l" + output) + while True: + x = a + bitcoinclient = f'{path["bitcoincli"]} getblockcount' + block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string + b = block + if b > a: + clear() + close() + output = render(str(b), colors=[settingsClock['colorA'], settingsClock['colorB']], align='center') + print("\a\x1b[?25l" + output) + bitcoinclient = f'{path["bitcoincli"]} getbestblockhash' + bb = os.popen(str(bitcoinclient)).read() + ll = bb + bitcoinclientgetblock = f'{path["bitcoincli"]} getblock {ll}' + qq = os.popen(bitcoinclientgetblock).read() + yy = json.loads(qq) + mm = yy + outputsize = render(str(mm['size']) + " bytes", colors=[settingsClock['colorA'], settingsClock['colorB']], align='center', font='tiny') + print("\x1b[?25l" + outputsize) + outputtxs = render(str(mm['nTx']) + " txs", colors=[settingsClock['colorA'], settingsClock['colorB']], align='center', font='tiny') + print("\x1b[?25l" + outputtxs) + sh = int(mm['nTx']) / 4 + shq = int(sh) + ss = str(rectangle(shq)) + print(ss.replace("None","")) + t.sleep(10) + txs = str(mm['nTx']) + if txs == "1": + try: + p = subprocess.Popen(['curl', 'https://poptart.spinda.net']) + p.wait(5) + except subprocess.TimeoutExpired: + p.kill() + print("\033[0;37;40m\x1b[?25l") + clear() + close() + a = b + output = render(str(b), colors=[settingsClock['colorA'], settingsClock['colorB']], align='center') + print("\x1b[?25l" + output) + + +#--------------------------------- Hex Block Decoder Functions ------------------------------------- + +def getrawtx(): # show confirmatins from transactions + while True: + try: + clear() + blogo() + close() + tx = input("Insert your TxID: ") + 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""") + else: + bitcoincli = " getrawtransaction " + lsd = os.popen(path['bitcoincli'] + 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() + input("Continue...") + except: + break + +def runthenumbers(): + bitcoincli = " gettxoutsetinfo" + os.system(path['bitcoincli'] + bitcoincli) + input("\nContinue...") + +def countdownblock(): + bitcoinclient = f'{path["bitcoincli"]} getblockcount' + block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string + b = block + try: + a = input("Insert your block target: ") + clear() + blogo() + print(""" + --------------------- BLOCK {} COUNTDOWN --------------------- + + """.format(a)) + n = int(b) + print("\nCountDown:", b) + q = int(a) - int(b) + print(f'Remaining: {str(q)}' + " Blocks\n") + while a > b: + try: + bitcoinclient = f'{path["bitcoincli"]} getblockcount' + block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string + b = block + if a == b: + break + elif n != int(b): + print("CountDown: ", b) + q = int(a) - int(b) + print(f'Remaining: {str(q)}' + " Blocks\n") + n = int(b) + except: + break + print(f'#RunTheNumbers {str(a)} PyBLOCK') + input("\nContinue...") + except: + menuSelection() + +def countdownblockConn(): + b = rpc('getblockcount') + c = str(b) + try: + a = int(input("Insert your block target: ")) + clear() + blogo() + print(""" + --------------------- BLOCK {} COUNTDOWN --------------------- + + """.format(a)) + print("\nCountDown:", int(c)) + n = int(c) + q = a - int(c) + print(f'Remaining: {str(q)}' + " Blocks\n") + while a > int(c): + try: + b = rpc('getblockcount') + c = str(b) + if a == c: + break + elif n != int(c): + print("CountDown: ", c) + q = a - int(c) + print(f'Remaining: {str(q)}' + " Blocks\n") + n = int(c) + except: + break + print(f'#RunTheNumbers {a} PyBLOCK') + input("\nContinue...") + except: + menuSelection() + + +def localHalving(): + bitcoinclient = f'{path["bitcoincli"]} getblockcount' + block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string + b = block + c = b + oneh = 0 - int(c) + 210000 + twoh = 210000 - int(c) + 210000 + thrh = 420000 - int(c) + 210000 + forh = 630000 - int(c) + 210000 + fifh = 840000 - int(c) + 210000 + sixh = 1050000 - int(c) + 210000 + sevh = 1260000 - int(c) + 210000 + eith = 1470000 - int(c) + 210000 + ninh = 1680000 - int(c) + 210000 + tenh = 1890000 - int(c) + 210000 + + q = """ + \033[0;37;40m------------------- HALVING CLOCK ------------------- + + 1st Halving: in {} Blocks {} + 2nd Halving: in {} Blocks {} + 3rd Halving: in {} Blocks {} + 4th Halving: in {} Blocks {} + 5th Halving: in {} Blocks {} + 6th Halving: in {} Blocks {} + 7th Halving: in {} Blocks {} + 8th Halving: in {} Blocks {} + 9th Halving: in {} Blocks {} + 10th Halving: in {} Blocks {} + + ------------------------------------------------------- + """.format("0" if int(c) == 210000 else oneh,"\033[1;32;40mCOMPLETE\033[0;37;40m","0" if int(c) == 420000 else twoh,"\033[1;32;40mCOMPLETE\033[0;37;40m", "0" if int(c) == 630000 else thrh,"\033[1;32;40mCOMPLETE\033[0;37;40m","0" if int(c) == 840000 else forh,"\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 840000 else "\033[1;35;40mPENDING\033[0;37;40m", "0" if int(c) >= 1050000 else fifh , "\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 1050000 else "\033[1;35;40mPENDING\033[0;37;40m", sixh, "\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 1260000 else "\033[1;35;40mPENDING\033[0;37;40m", sevh,"\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 1470000 else "\033[1;35;40mPENDING\033[0;37;40m", eith,"\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 1680000 else "\033[1;35;40mPENDING\033[0;37;40m", ninh, "\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 1890000 else "\033[1;35;40mPENDING\033[0;37;40m", tenh, "\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 1890000 else "\033[1;35;40mPENDING\033[0;37;40m") + print(q) + input("\nContinue...") +#--------------------------------- End Hex Block Decoder Functions ------------------------------------- + +def pdfconvert(): + 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' + if not os.path.isfile("config/bitcoin.pdf"): + clear() + blogo() + close() + print(""" + ----------------------------------------- + + The Bitcoin Whitepaper + is not in this + directory + + ----------------------------------------- + + """) + a = input("Do you want to download it from the Blockchain? Y/n: ") + if a in ["y", "Y"]: + clear() + blogo() + close() + print(""" + --------------------------------- + + You are going to + download the + Whitepaper from + the Blockchain + + This file will + be save in the + main PyBLOCK + folder as + bitcoin.pdf + + --------------------------------- + """) + input("Continue...") + bitcoincli = """ getblock 00000000000000ecbbff6bafb7efa2f7df05b227d5c73dca8f2635af32a2e949 0 | tail -c+92167 | for ((o=0;o<946;++o)) ; do read -rN420 x ; echo -n ${x::130}${x:132:130}${x:264:130} ; done | xxd -r -p | tail -c+9 | head -c184292 > bitcoin.pdf """ + os.system(path['bitcoincli'] + bitcoincli) + clear() + blogo() + close() + os.system("pdf2txt.py bitcoin.pdf") + input("Continue...") + else: + clear() + blogo() + close() + os.system("pdf2txt.py bitcoin.pdf") + input("Continue...") +#--------------------------------- NYMs ----------------------------------- + +def get_ansi_color_code(r, g, b): + if r == g == b: + if r < 8: + return 16 + if r > 248: + return 231 + return round(((r - 8) / 247) * 24) + 232 + return 16 + (36 * round(r / 255 * 5)) + (6 * round(g / 255 * 5)) + round(b / 255 * 5) + + +def get_color(r, g, b): + return "\x1b[48;5;{}m \x1b[0m".format(int(get_ansi_color_code(r,g,b))) + + +def robotNym(): + try: + if path['bitcoincli']: + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + + hash = alias['identity_pubkey'] + rh = Robohash(hash) + rh.assemble(roboset='set1') + with open("file.png", "wb") as f: + rh.img.save(f, format="png") + + img_path = open("file.png", "rb") + img = Image.open(img_path) + + h = 40 + w = int((img.width / img.height) * 90) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + for x in range(h): + for y in range(w): + pix = img_arr[x][y] + print(get_color(pix[0], pix[1], pix[2]), sep='', end='') + print() + image = "\n\t\t\t\t\t \u001b[31;1mNode\u001b[38;5;93mNym\033[0;37;40m\n"+ "\n\t \u001b[33;1m" + alias['identity_pubkey'] + "\033[0;37;40m" + print(image) + input("\n\nContinue...") + except: + menuSelection() + + +#---------------------------------Warden Terminal---------------------------------- +def callGitWardenTerminal(): + if not os.path.isdir('warden_terminal'): + git = "git clone https://github.com/pxsocs/warden_terminal.git" + os.system(git) + os.system("cd warden_terminal && python3 node_warden.py") + +#---------------------------------ColdCore----------------------------------------- +def callColdCore(): + clear() + blogo() + close() + try: + if not os.path.isfile('$HOME/.pyblock/public.txt'): + msg = """ + \033[0;37;40m-------------------------\a\u001b[31;1mFILE NOT FOUND\033[0;37;40m---------------------------- + To ColdCore works it needs to import your wallet's + public information on your coldcard, go to + ----------------------------------------- + | | + | \033[1;37;40mAdvanced > MicroSD > Dump Summary\033[0;37;40m | + | | + ----------------------------------------- + Copy the file \033[1;37;40mpublic.txt\033[0;37;40m inside + the main \u001b[31;1mpyblock\033[0;37;40m folder + (see: https://coldcardwallet.com/docs/microsd#dump-summary-file) + -------------------------------------------------------------------""" + print(msg) + input("\nContinue...") + else: + if not os.path.isdir('$HOME/.pyblock/coldcore'): + git = "git clone https://github.com/jamesob/coldcore.git" + install = "cd coldcore && chmod +x coldcore && cp coldcore ~/.local/bin/coldcore" + os.system(git) + os.system(install) + os.system("coldcore") + except: + menuSelection() + +#--------------------------------- Menu section ----------------------------------- + +def MainMenuLOCAL(): #Main Menu + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m\a + \033[1;37;40mVersion\033[0;37;40m: {} + + + \u001b[31;1mA.\033[0;37;40m PyBLOCK + \u001b[38;5;202mB.\033[0;37;40m Bitcoin Core + \u001b[33;1mL.\033[0;37;40m Lightning Network + \u001b[38;5;40mP.\033[0;37;40m Platforms + \u001b[38;5;27mS.\033[0;37;40m Settings + \u001b[38;5;15mX.\033[0;37;40m Donate + \u001b[38;5;93mQ.\033[0;37;40m Exit + \n\n\x1b[?25h""".format(n, alias['alias'], d['blocks'], version, checkupdate())) + mainmenuLOCALcontrol(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def MainMenuLOCALChainONLY(): #Main Menu + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m\a + \033[1;37;40mVersion\033[0;37;40m: {} + + + \u001b[31;1mA.\033[0;37;40m PyBLOCK + \u001b[38;5;202mB.\033[0;37;40m Bitcoin Core + \u001b[38;5;40mP.\033[0;37;40m Platforms + \u001b[38;5;27mS.\033[0;37;40m Settings + \u001b[38;5;15mX.\033[0;37;40m Donate + \u001b[38;5;93mQ.\033[0;37;40m Exit + \n\n\x1b[?25h""".format(n,d['blocks'], version, checkupdate())) + mainmenuLOCALcontrolOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def MainMenuREMOTE(): #Main Menu + clear() + blogo() + sysinfo() + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m\a + \033[1;37;40mVersion\033[0;37;40m: {} + + + \u001b[31;1mA.\033[0;37;40m PyBLOCK + \u001b[38;5;202mB.\033[0;37;40m Bitcoin Core + \u001b[33;1mL.\033[0;37;40m Lightning Network + \u001b[38;5;40mP.\033[0;37;40m Platforms + \u001b[38;5;27mS.\033[0;37;40m Settings + \u001b[38;5;15mX.\033[0;37;40m Donate + \u001b[38;5;93mQ.\033[0;37;40m Exit + \n\n\x1b[?25h""".format(a, alias['alias'], d['blocks'], version, checkupdate())) + mainmenuREMOTEcontrol(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def bitcoincoremenuLOCAL(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Bitcoin-cli Console + \u001b[38;5;202mB.\033[0;37;40m Show Genesis Block + \u001b[38;5;202mC.\033[0;37;40m Show Blockchain Information + \u001b[38;5;202mD.\033[0;37;40m Run the Numbers + \u001b[38;5;202mE.\033[0;37;40m Decode in HEX + \u001b[38;5;202mF.\033[0;37;40m Show QR from a Bitcoin Address + \u001b[38;5;202mG.\033[0;37;40m Show confirmations from a transaction + \u001b[38;5;202mH.\033[0;37;40m Miscellaneous + \u001b[38;5;202mI.\033[0;37;40m ColdCore + \u001b[38;5;202mJ.\033[0;37;40m Whitepaper + \u001b[38;5;202mO.\033[0;37;40m OP_RETURN + \u001b[38;5;202mZ.\033[0;37;40m Stats + \u001b[38;5;202mM.\033[0;37;40m Hashrate + \u001b[38;5;202mU.\033[0;37;40m Unconfirmed Txs + \u001b[33;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n, alias['alias'], d['blocks'], version, checkupdate())) + bitcoincoremenuLOCALcontrolA(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def bitcoincoremenuLOCALOnchainONLY(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Bitcoin-cli Console + \u001b[38;5;202mB.\033[0;37;40m Show Genesis Block + \u001b[38;5;202mC.\033[0;37;40m Show Blockchain Information + \u001b[38;5;202mD.\033[0;37;40m Run the Numbers + \u001b[38;5;202mE.\033[0;37;40m Decode in HEX + \u001b[38;5;202mF.\033[0;37;40m Show QR from a Bitcoin Address + \u001b[38;5;202mG.\033[0;37;40m Show confirmations from a transaction + \u001b[38;5;202mH.\033[0;37;40m Miscellaneous + \u001b[38;5;202mI.\033[0;37;40m ColdCore + \u001b[38;5;202mJ.\033[0;37;40m Whitepaper + \u001b[38;5;202mO.\033[0;37;40m OP_RETURN + \u001b[38;5;202mW.\033[0;37;40m Wallet + \u001b[38;5;202mZ.\033[0;37;40m Stats + \u001b[38;5;202mM.\033[0;37;40m Hashrate + \u001b[38;5;202mU.\033[0;37;40m Unconfirmed Txs + \u001b[33;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n,d['blocks'], version, checkupdate())) + bitcoincoremenuLOCALcontrolAOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def walletmenuLOCALOnchainONLY(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Deposit + \u001b[38;5;202mB.\033[0;37;40m Show transactions + \u001b[33;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n,d['blocks'], version, checkupdate())) + walletmenuLOCALcontrolAOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def bitcoincoremenuLOCALOPRETURN(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Send OP_RETURN + \u001b[38;5;202mB.\033[0;37;40m View OP_RETURN + \u001b[38;5;202mC.\033[0;37;40m View Decoded Coinbase + \u001b[33;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n, alias['alias'], d['blocks'], version, checkupdate())) + bitcoincoremenuLOCALcontrolO(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def bitcoincoremenuLOCALOPRETURNOnchainONLY(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Send OP_RETURN + \u001b[38;5;202mB.\033[0;37;40m View OP_RETURN + \u001b[38;5;202mC.\033[0;37;40m View Decoded Coinbase + \u001b[33;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n, d['blocks'], version, checkupdate())) + bitcoincoremenuLOCALcontrolOOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def bitcoincoremenuREMOTE(): + clear() + blogo() + sysinfo() + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Bitcoin-cli Console + \u001b[38;5;202mB.\033[0;37;40m Show Blockchain Information + \u001b[38;5;202mC.\033[0;37;40m Run the Numbers + \u001b[38;5;202mD.\033[0;37;40m Show QR from a Bitcoin Address + \u001b[38;5;202mE.\033[0;37;40m Miscellaneous + \u001b[38;5;202mO.\033[0;37;40m OP_RETURN + \u001b[38;5;202mM.\033[0;37;40m Hashrate + \u001b[33;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(a, alias['alias'], d['blocks'], version, checkupdate())) + bitcoincoremenuREMOTEcontrol(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def bitcoincoremenuREMOTEOPRETURN(): + clear() + blogo() + sysinfo() + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Send OP_RETURN + \u001b[38;5;202mB.\033[0;37;40m View OP_RETURN + \u001b[38;5;202mC.\033[0;37;40m View Decoded Coinbase + \u001b[33;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(a, alias['alias'], d['blocks'], version, checkupdate())) + bitcoincoremenuREMOTEcontrolO(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def lightningnetworkLOCAL(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[33;1mA.\033[0;37;40m Lncli Console + \u001b[33;1mB.\033[0;37;40m New Invoice + \u001b[33;1mC.\033[0;37;40m Pay Invoice + \u001b[33;1mD.\033[0;37;40m Make a KeySend Payment + \u001b[33;1mE.\033[0;37;40m New Bitcoin Address + \u001b[33;1mF.\033[0;37;40m List Invoices + \u001b[33;1mG.\033[0;37;40m Channel Balance + \u001b[33;1mH.\033[0;37;40m Show Channels + \u001b[33;1mI.\033[0;37;40m Rebalance Channel + \u001b[33;1mJ.\033[0;37;40m Show Peers + \u001b[33;1mK.\033[0;37;40m Connect Peers + \u001b[33;1mL.\033[0;37;40m Onchain Balance + \u001b[33;1mM.\033[0;37;40m List Onchain Transactions + \u001b[33;1mN.\033[0;37;40m Get Node Info + \u001b[33;1mO.\033[0;37;40m Get Network Information + \u001b[33;1mP.\033[0;37;40m PyChat + \u001b[33;1mZ.\033[0;37;40m Stats + \u001b[33;1mT.\033[0;37;40m Ranking + \u001b[33;1mQ.\033[0;37;40m LNBits List LNURL \033[3;35;40m{lnbitspaid}\033[0;37;40m + \u001b[33;1mS.\033[0;37;40m LNBits Create LNURL \033[3;35;40m{lnbitspaid}\033[0;37;40m + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n, alias['alias'], d['blocks'], version, checkupdate(), lnbitspaid = "UNLOCKED" if os.path.isfile("lnbitSN.conf") else "LOCKED")) + lightningnetworkLOCALcontrol(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def chatConn(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Open + \u001b[38;5;202mB.\033[0;37;40m Close + \u001b[38;5;202mC.\033[0;37;40m Hidden + \u001b[31;1mQ.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n, d['blocks'], version, checkupdate())) + chatConnA(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def pyCHATA(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Write + \u001b[38;5;202mB.\033[0;37;40m Read + \u001b[38;5;202mC.\033[0;37;40m List + \u001b[31;1mQ.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n, d['blocks'], version, checkupdate())) + chatConnB(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def pyCHATB(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Write + \u001b[38;5;202mB.\033[0;37;40m Read + \u001b[38;5;202mC.\033[0;37;40m List + \u001b[31;1mQ.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n, d['blocks'], version, checkupdate())) + chatConnC(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def pyCHATC(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Write + \u001b[38;5;202mB.\033[0;37;40m Read + \u001b[38;5;202mC.\033[0;37;40m List + \u001b[31;1mQ.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n, d['blocks'], version, checkupdate())) + chatConnD(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def lightningnetworkREMOTE(): + clear() + blogo() + sysinfo() + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[33;1mA.\033[0;37;40m New Invoice + \u001b[33;1mB.\033[0;37;40m Pay Invoice + \u001b[33;1mC.\033[0;37;40m New Bitcoin Address + \u001b[33;1mD.\033[0;37;40m List Invoices + \u001b[33;1mE.\033[0;37;40m Channel Balance + \u001b[33;1mF.\033[0;37;40m Show Channels + \u001b[33;1mG.\033[0;37;40m Onchain Balance + \u001b[33;1mH.\033[0;37;40m List Onchain Transactions + \u001b[33;1mI.\033[0;37;40m Get Node Info + \u001b[33;1mZ.\033[0;37;40m Stats + \u001b[33;1mT.\033[0;37;40m Ranking + \u001b[33;1mQ.\033[0;37;40m LNBits List LNURL \033[3;35;40m{lnbitspaid}\033[0;37;40m + \u001b[33;1mS.\033[0;37;40m LNBits Create LNURL \033[3;35;40m{lnbitspaid}\033[0;37;40m + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(a, alias['alias'], d['blocks'], version, checkupdate(), lnbitspaid = "UNLOCKED" if os.path.isfile("lnbitSN.conf") else "LOCKED")) + lightningnetworkREMOTEcontrol(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def APIMenuLOCAL(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m TippinMe FREE + \033[1;32;40mB.\033[0;37;40m Tallycoin FREE + \033[1;32;40mC.\033[0;37;40m Mempool FREE + \033[1;32;40mD.\033[0;37;40m CoinGecko FREE + \033[1;32;40mE.\033[0;37;40m Rate.sx FREE + \033[1;32;40mF.\033[0;37;40m BWT FREE + \033[1;32;40mG.\033[0;37;40m LNBits \033[3;35;40m{lnbitspaid}\033[0;37;40m + \033[1;32;40mH.\033[0;37;40m LNPay \033[3;35;40m{lnpaypaid}\033[0;37;40m + \033[1;32;40mI.\033[0;37;40m OpenNode \033[3;35;40m{opennodepaid}\033[0;37;40m + \033[1;32;40mJ.\033[0;37;40m SatNode FREE + \033[1;32;40mK.\033[0;37;40m Weather FREE + \033[1;32;40mL.\033[0;37;40m Arcade FREE + \033[1;32;40mM.\033[0;37;40m Whale Alert FREE + \033[1;32;40mS.\033[0;37;40m Slush Pool FREE + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate(),lnbitspaid = "PAID" if os.path.isfile("lnbitSN.conf") else "PREMIUM", lnpaypaid = "PAID" if os.path.isfile("lnpaySN.conf") else "PREMIUM", opennodepaid = "PAID" if os.path.isfile("opennodeSN.conf") else "PREMIUM")) + platfformsLOCALcontrol(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def APIMenuLOCALOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m TippinMe FREE + \033[1;32;40mB.\033[0;37;40m Tallycoin FREE + \033[1;32;40mC.\033[0;37;40m Mempool FREE + \033[1;32;40mD.\033[0;37;40m CoinGecko FREE + \033[1;32;40mE.\033[0;37;40m Rate.sx FREE + \033[1;32;40mF.\033[0;37;40m BWT FREE + \033[1;32;40mG.\033[0;37;40m LNBits \033[3;35;40m{lnbitspaid}\033[0;37;40m + \033[1;32;40mH.\033[0;37;40m LNPay \033[3;35;40m{lnpaypaid}\033[0;37;40m + \033[1;32;40mI.\033[0;37;40m OpenNode \033[3;35;40m{opennodepaid}\033[0;37;40m + \033[1;32;40mJ.\033[0;37;40m SatNode FREE + \033[1;32;40mK.\033[0;37;40m Weather FREE + \033[1;32;40mL.\033[0;37;40m Arcade FREE + \033[1;32;40mM.\033[0;37;40m Whale Alert FREE + \033[1;32;40mS.\033[0;37;40m Slush Pool FREE + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate(),lnbitspaid = "PAID" if os.path.isfile("lnbitSN.conf") else "PREMIUM", lnpaypaid = "PAID" if os.path.isfile("lnpaySN.conf") else "PREMIUM", opennodepaid = "PAID" if os.path.isfile("opennodeSN.conf") else "PREMIUM")) + platfformsLOCALcontrolOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def decodeHex(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Decode Blocks in HEX + \u001b[38;5;202mB.\033[0;37;40m Decode Transactions in HEX + \u001b[31;1mQ.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n, alias['alias'], d['blocks'], version, checkupdate())) + decodeHexLOCAL(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def decodeHexOnchainONLY(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Decode Blocks in HEX + \u001b[38;5;202mB.\033[0;37;40m Decode Transactions in HEX + \u001b[31;1mQ.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n, d['blocks'], version, checkupdate())) + decodeHexLOCALOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def miscellaneousLOCAL(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Ascii ₿ + \u001b[38;5;202mB.\033[0;37;40m System + \u001b[38;5;202mC.\033[0;37;40m Dates + \u001b[38;5;202mD.\033[0;37;40m Quotes + \u001b[38;5;202mP.\033[0;37;40m PGP + \u001b[38;5;202mS.\033[0;37;40m Satoshi Nakamoto + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + miscellaneousLOCALmenu(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def miscellaneousLOCALOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Ascii ₿ + \u001b[38;5;202mB.\033[0;37;40m System + \u001b[38;5;202mC.\033[0;37;40m Dates + \u001b[38;5;202mD.\033[0;37;40m Quotes + \u001b[38;5;202mP.\033[0;37;40m PGP + \u001b[38;5;202mS.\033[0;37;40m Satoshi Nakamoto + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + miscellaneousLOCALmenuOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def slushpoolREMOTEOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Difficulty + \u001b[38;5;202mB.\033[0;37;40m Hash Rate + \u001b[38;5;202mC.\033[0;37;40m Pool + \u001b[38;5;202mD.\033[0;37;40m History + \u001b[38;5;202mE.\033[0;37;40m Miner + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + slushpoolLOCALOnchainONLYMenu(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def slushpoolLOCALOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Difficulty + \u001b[38;5;202mB.\033[0;37;40m Hash Rate + \u001b[38;5;202mC.\033[0;37;40m Pool + \u001b[38;5;202mD.\033[0;37;40m History + \u001b[38;5;202mE.\033[0;37;40m Miner + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + slushpoolLOCALOnchainONLYMenu(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def runTheNumbersMenu(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Countdown Block + \033[1;32;40mB.\033[0;37;40m Countdown Halving + \033[1;32;40mC.\033[0;37;40m Audit + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + runTheNumbersControl(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def runTheNumbersMenuOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Countdown Block + \033[1;32;40mB.\033[0;37;40m Countdown Halving + \033[1;32;40mC.\033[0;37;40m Audit + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + runTheNumbersControlOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def runTheNumbersMenuConn(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Countdown Block + \033[1;32;40mB.\033[0;37;40m Countdown Halving + \033[1;32;40mC.\033[0;37;40m Audit + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + runTheNumbersControlConn(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def weatherMenuOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Version 1 + \033[1;32;40mB.\033[0;37;40m Version 2 + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + menuWeatherOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def weatherMenu(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Version 1 + \033[1;32;40mB.\033[0;37;40m Version 2 + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuWeather(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def dnt(): # Donation selection menu + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;15mA.\033[0;37;40m Developers Donation + \u001b[38;5;15mB.\033[0;37;40m Testers Donation + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuC(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def dntOnchainONLY(): # Donation selection menu + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;15mA.\033[0;37;40m Developers Donation + \u001b[38;5;15mB.\033[0;37;40m Testers Donation + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + menuCOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + + +def dntDev(): # Dev Donation Menu + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Samourai PayNym + \u001b[38;5;202mB.\033[0;37;40m Bitcoin Address + \u001b[33;1mC.\033[0;37;40m Lightning Network + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuE(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def dntDevOnchainONLY(): # Dev Donation Menu + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Samourai PayNym + \u001b[38;5;202mB.\033[0;37;40m Bitcoin Address + \u001b[33;1mC.\033[0;37;40m Lightning Network + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + menuEOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def dntTst(): # Tester Donation Menu + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Bitcoin Address + \u001b[33;1mB.\033[0;37;40m Lightning Network + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuF(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def dntTstOnchainONLY(): # Tester Donation Menu + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;202mA.\033[0;37;40m Bitcoin Address + \u001b[33;1mB.\033[0;37;40m Lightning Network + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + menuFOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + + +def satnodeMenu(): # Satnode Menu + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Start SatNode + \033[1;32;40mB.\033[0;37;40m Feed + \033[1;32;40mC.\033[0;37;40m Setup + \033[1;34;40mS.\033[0;37;40m Send a Message to Space + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuD(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def satnodeMenuOnchainONLY(): # Satnode Menu + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Start SatNode + \033[1;32;40mB.\033[0;37;40m Feed + \033[1;32;40mC.\033[0;37;40m Setup + \033[1;34;40mS.\033[0;37;40m Send a Message to Space + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + menuD(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def rateSX(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Rate + \033[1;32;40mB.\033[0;37;40m Chart + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + rateSXMenu(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def rateSXOncainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/getinfo' + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Rate + \033[1;32;40mB.\033[0;37;40m Chart + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + rateSXMenuOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def mempoolmenu(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Blocks + \033[1;32;40mB.\033[0;37;40m Recommended Fee + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + mempoolmenuS(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def mempoolmenuOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Blocks + \033[1;32;40mB.\033[0;37;40m Recommended Fee + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + mempoolmenuSOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + + +def APILnbit(): + bitLN = {"NN":"","pd":""} + if os.path.isfile('lnbitSN.conf'): # Check if the file 'bclock.conf' is in the same folder + bitData= pickle.load(open("lnbitSN.conf", "rb")) # Load the file 'bclock.conf' + bitLN = bitData # Copy the variable pathv to 'path' + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[0;37;40mLNBits SN:{} \033[1;34;40mPremium\033[0;37;40m + + \033[1;32;40mA.\033[0;37;40m New Invoice + \033[1;32;40mB.\033[0;37;40m Pay Invoice + \033[1;32;40mC.\033[0;37;40m New PayWall + \033[1;32;40mD.\033[0;37;40m Delete PayWall + \033[1;32;40mE.\033[0;37;40m List PayWalls + \033[1;32;40mF.\033[0;37;40m Create LNURL + \033[1;32;40mG.\033[0;37;40m List LNURL + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, bitLN['NN'], checkupdate())) + menuLNBPI(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def APILnbitOnchainONLY(): + bitLN = {"NN":"","pd":""} + if os.path.isfile('lnbitSN.conf'): # Check if the file 'bclock.conf' is in the same folder + bitData= pickle.load(open("lnbitSN.conf", "rb")) # Load the file 'bclock.conf' + bitLN = bitData # Copy the variable pathv to 'path' + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[0;37;40mLNBits SN:{} \033[1;34;40mPremium\033[0;37;40m + + \033[1;32;40mA.\033[0;37;40m New Invoice + \033[1;32;40mB.\033[0;37;40m Pay Invoice + \033[1;32;40mC.\033[0;37;40m New PayWall + \033[1;32;40mD.\033[0;37;40m Delete PayWall + \033[1;32;40mE.\033[0;37;40m List PayWalls + \033[1;32;40mF.\033[0;37;40m Create LNURL + \033[1;32;40mG.\033[0;37;40m List LNURL + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, bitLN['NN'], checkupdate())) + menuLNBPIOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def APILnPay(): + bitLN = {"NN":"","pd":""} + if os.path.isfile('lnpaySN.conf'): # Check if the file 'bclock.conf' is in the same folder + bitData= pickle.load(open("lnpaySN.conf", "rb")) # Load the file 'bclock.conf' + bitLN = bitData # Copy the variable pathv to 'path' + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[0;37;40mLNPay SN:{} \033[1;34;40mPremium\033[0;37;40m + + \033[1;32;40mA.\033[0;37;40m New Invoice + \033[1;32;40mB.\033[0;37;40m Pay Invoice + \033[1;32;40mC.\033[0;37;40m Wallet Balance + \033[1;32;40mD.\033[0;37;40m List Invoices + \033[1;32;40mE.\033[0;37;40m Transfer Between Wallets + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, bitLN['NN'], checkupdate())) + menuLNPAY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def APILnPayOnchainONLY(): + bitLN = {"NN":"","pd":""} + if os.path.isfile('lnpaySN.conf'): # Check if the file 'bclock.conf' is in the same folder + bitData= pickle.load(open("lnpaySN.conf", "rb")) # Load the file 'bclock.conf' + bitLN = bitData # Copy the variable pathv to 'path' + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[0;37;40mLNPay SN:{} \033[1;34;40mPremium\033[0;37;40m + + \033[1;32;40mA.\033[0;37;40m New Invoice + \033[1;32;40mB.\033[0;37;40m Pay Invoice + \033[1;32;40mC.\033[0;37;40m Wallet Balance + \033[1;32;40mD.\033[0;37;40m List Invoices + \033[1;32;40mE.\033[0;37;40m Transfer Between Wallets + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, bitLN['NN'], checkupdate())) + menuLNPAYOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def APIOpenNode(): + bitLN = {"NN":"","pd":""} + if os.path.isfile('opennodeSN.conf'): # Check if the file 'bclock.conf' is in the same folder + bitData= pickle.load(open("opennodeSN.conf", "rb")) # Load the file 'bclock.conf' + bitLN = bitData # Copy the variable pathv to 'path' + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[0;37;40mOpenNode SN:{} \033[1;34;40mPremium\033[0;37;40m + + \033[1;32;40mA.\033[0;37;40m New Invoice + \033[1;32;40mB.\033[0;37;40m Pay Invoice + \033[1;32;40mC.\033[0;37;40m Wallet Balance + \033[1;32;40mD.\033[0;37;40m List Payments + \033[1;32;40mS.\033[0;37;40m Status + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, bitLN['NN'], checkupdate())) + menuOpenNode(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def APIOpenNodeOnchainONLY(): + bitLN = {"NN":"","pd":""} + if os.path.isfile('opennodeSN.conf'): # Check if the file 'bclock.conf' is in the same folder + bitData= pickle.load(open("opennodeSN.conf", "rb")) # Load the file 'bclock.conf' + bitLN = bitData # Copy the variable pathv to 'path' + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[0;37;40mOpenNode SN:{} \033[1;34;40mPremium\033[0;37;40m + + \033[1;32;40mA.\033[0;37;40m New Invoice + \033[1;32;40mB.\033[0;37;40m Pay Invoice + \033[1;32;40mC.\033[0;37;40m Wallet Balance + \033[1;32;40mD.\033[0;37;40m List Payments + \033[1;32;40mS.\033[0;37;40m Status + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , d['blocks'], version, bitLN['NN'], checkupdate())) + menuOpenNodeOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def APITippinMe(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[0;37;40mTippinMe + + \033[1;32;40mA.\033[0;37;40m New Invoice + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuTippinMe(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def APITippinMeOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[0;37;40mTippinMe + + \033[1;32;40mA.\033[0;37;40m New Invoice + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + menuTippinMeOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def APITallyCo(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[0;37;40mTallyCoin + + \033[1;32;40mA.\033[0;37;40m Get Payment + \033[1;32;40mB.\033[0;37;40m Tip User + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuTallyCo(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def APITallyCoOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[0;37;40mTallyCoin + + \033[1;32;40mA.\033[0;37;40m Get Payment + \033[1;32;40mB.\033[0;37;40m Tip User + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , d['blocks'], version, checkupdate())) + menuTallyCoOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) +#-------------------------------- SETTINGS ----------------------------------------------- + + +def settings4Local(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;27mA.\033[0;37;40m Change Logo Design + \u001b[38;5;27mB.\033[0;37;40m Change Logo Colors + \u001b[38;5;27mC.\033[0;37;40m Change Clock Colors + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n, alias['alias'], d['blocks'], version, checkupdate())) + menuSettingsLocal(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def settings4LocalOnchainONLY(): + clear() + blogo() + sysinfo() + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;27mA.\033[0;37;40m Change Logo Design + \u001b[38;5;27mB.\033[0;37;40m Change Logo Colors + \u001b[38;5;27mC.\033[0;37;40m Change Clock Colors + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n, d['blocks'], version, checkupdate())) + menuSettingsLocalOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def settings4Remote(): + clear() + blogo() + sysinfo() + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \u001b[38;5;27mA.\033[0;37;40m Change Logo Design + \u001b[38;5;27mB.\033[0;37;40m Change Logo Colors + \u001b[38;5;27mC.\033[0;37;40m Change Clock Colors + \u001b[31;1mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(a, alias['alias'], d['blocks'], version, checkupdate())) + menuSettingsRemote(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def designQ(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Block + \033[1;31;40mB.\033[0;37;40m Slick + \033[1;31;40mC.\033[0;37;40m Tiny + \033[1;31;40mD.\033[0;37;40m Grid + \033[1;31;40mE.\033[0;37;40m Pallet + \033[1;31;40mF.\033[0;37;40m Shade + \033[1;31;40mG.\033[0;37;40m Chrome + \033[1;31;40mH.\033[0;37;40m Simple + \033[1;31;40mI.\033[0;37;40m Simple Block + \033[1;31;40mJ.\033[0;37;40m 3D + \033[1;31;40mK.\033[0;37;40m Simple 3D + \033[1;31;40mL.\033[0;37;40m Huge + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuDesign(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def designQOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Block + \033[1;31;40mB.\033[0;37;40m Slick + \033[1;31;40mC.\033[0;37;40m Tiny + \033[1;31;40mD.\033[0;37;40m Grid + \033[1;31;40mE.\033[0;37;40m Pallet + \033[1;31;40mF.\033[0;37;40m Shade + \033[1;31;40mG.\033[0;37;40m Chrome + \033[1;31;40mH.\033[0;37;40m Simple + \033[1;31;40mI.\033[0;37;40m Simple Block + \033[1;31;40mJ.\033[0;37;40m 3D + \033[1;31;40mK.\033[0;37;40m Simple 3D + \033[1;31;40mL.\033[0;37;40m Huge + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + menuDesignOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def designC(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Block + \033[1;31;40mB.\033[0;37;40m Slick + \033[1;31;40mC.\033[0;37;40m Tiny + \033[1;31;40mD.\033[0;37;40m Grid + \033[1;31;40mE.\033[0;37;40m Pallet + \033[1;31;40mF.\033[0;37;40m Shade + \033[1;31;40mG.\033[0;37;40m Chrome + \033[1;31;40mH.\033[0;37;40m Simple + \033[1;31;40mI.\033[0;37;40m Simple Block + \033[1;31;40mJ.\033[0;37;40m 3D + \033[1;31;40mK.\033[0;37;40m Simple 3D + \033[1;31;40mL.\033[0;37;40m Huge + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuDesignClock(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def designCOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Block + \033[1;31;40mB.\033[0;37;40m Slick + \033[1;31;40mC.\033[0;37;40m Tiny + \033[1;31;40mD.\033[0;37;40m Grid + \033[1;31;40mE.\033[0;37;40m Pallet + \033[1;31;40mF.\033[0;37;40m Shade + \033[1;31;40mG.\033[0;37;40m Chrome + \033[1;31;40mH.\033[0;37;40m Simple + \033[1;31;40mI.\033[0;37;40m Simple Block + \033[1;31;40mJ.\033[0;37;40m 3D + \033[1;31;40mK.\033[0;37;40m Simple 3D + \033[1;31;40mL.\033[0;37;40m Huge + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + menuDesignClockOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def designCRemote(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Block + \033[1;31;40mB.\033[0;37;40m Slick + \033[1;31;40mC.\033[0;37;40m Tiny + \033[1;31;40mD.\033[0;37;40m Grid + \033[1;31;40mE.\033[0;37;40m Pallet + \033[1;31;40mF.\033[0;37;40m Shade + \033[1;31;40mG.\033[0;37;40m Chrome + \033[1;31;40mH.\033[0;37;40m Simple + \033[1;31;40mI.\033[0;37;40m Simple Block + \033[1;31;40mJ.\033[0;37;40m 3D + \033[1;31;40mK.\033[0;37;40m Simple 3D + \033[1;31;40mL.\033[0;37;40m Huge + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuDesignClockRemote(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colors(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Front Color + \033[1;31;40mB.\033[0;37;40m Back Color + \033[1;31;40mC.\033[0;37;40m Rainbow + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuColors(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Front Color + \033[1;31;40mB.\033[0;37;40m Back Color + \033[1;31;40mC.\033[0;37;40m Rainbow + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + menuColorsOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsC(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Front Color + \033[1;31;40mB.\033[0;37;40m Back Color + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuColorsClock(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsCOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Front Color + \033[1;31;40mB.\033[0;37;40m Back Color + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + menuColorsClockOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsCRemote(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Front Color + \033[1;31;40mB.\033[0;37;40m Back Color + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuColorsClockRemote(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectFront(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuColorsSelectFront(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectFrontOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a ,d['blocks'], version, checkupdate())) + menuColorsSelectFrontOncainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectFrontClock(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuColorsSelectFrontClock(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectFrontClockOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , d['blocks'], version, checkupdate())) + menuColorsSelectFrontClockOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectFrontClockRemote(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuColorsSelectFrontClockRemote(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectBack(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuColorsSelectBack(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectBackOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "RemotcolorsCe" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a, d['blocks'], version, checkupdate())) + menuColorsSelectBackOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectBackClock(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuColorsSelectBackClock(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectBackClockOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , d['blocks'], version, checkupdate())) + menuColorsSelectBackClockOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectBackClockRemote(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuColorsSelectBackClockRemote(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectRainbow(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Start Color + \033[1;31;40mB.\033[0;37;40m End Color + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuColorsSelectRainbow(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectRainbowOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Start Color + \033[1;31;40mB.\033[0;37;40m End Color + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , d['blocks'], version, checkupdate())) + menuColorsSelectRainbowOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectRainbowStart(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuColorsSelectRainbowStart(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectRainbowStartOnchaiONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , d['blocks'], version, checkupdate())) + menuColorsSelectRainbowStartOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectRainbowEnd(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , alias['alias'], d['blocks'], version, checkupdate())) + menuColorsSelectRainbowEnd(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def colorsSelectRainbowEndOnchainONLY(): + clear() + blogo() + sysinfo() + if path['bitcoincli']: + n = "Local" if path['bitcoincli'] else "Remote" + bitcoincli = " getblockchaininfo" + a = os.popen(path['bitcoincli'] + bitcoincli).read() + b = json.loads(a) + d = b + + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + alias = json.loads(lsd0) + else: + a = "Local" if path['bitcoincli'] else "Remote" + blk = rpc('getblockchaininfo') + d = blk + + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + alias = r.json() + print("""\t\t + \033[1;37;40m{}\033[0;37;40m: \033[1;31;40mPyBLOCK\033[0;37;40m + \033[1;37;40mNode\033[0;37;40m: \033[1;33;40m{}\033[0;37;40m + \033[1;37;40mBlock\033[0;37;40m: \033[1;32;40m{}\033[0;37;40m + \033[1;37;40mVersion\033[0;37;40m: {} + + \033[1;32;40mA.\033[0;37;40m Black + \033[1;31;40mB.\033[0;37;40m Red + \033[1;31;40mC.\033[0;37;40m Green + \033[1;31;40mD.\033[0;37;40m Yellow + \033[1;31;40mE.\033[0;37;40m Blue + \033[1;31;40mF.\033[0;37;40m Magenta + \033[1;31;40mG.\033[0;37;40m Cyan + \033[1;31;40mH.\033[0;37;40m White + \033[1;31;40mI.\033[0;37;40m Gray + \033[1;36;40mR.\033[0;37;40m Return + \n\n\x1b[?25h""".format(n if path['bitcoincli'] else a , d['blocks'], version, checkupdate())) + menuColorsSelectRainbowEndOnchainONLY(input("\033[1;32;40mSelect option: \033[0;37;40m")) + +def menuSelection(): + 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' + chln = {"onchain":"", "offchain":""} + if os.path.isfile('config/selection.conf'): + chain = pickle.load(open("config/selection.conf", "rb")) + chln = chain + if path['bitcoincli']: + if chln ['onchain']: + MainMenuLOCALChainONLY() + else: + MainMenuLOCAL() + else: + MainMenuREMOTE() + else: + if os.path.isfile('config/blndconnect.conf'): + chln['offchain'] = "offchain" + else: + chln['onchain'] = "onchain" + + pickle.dump(chln, open("config/selection.conf", "wb")) + + +def menuSelectionLN(): + lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "lncli":""} + lndconnectData = pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + if lndconnectload['ln']: + menuLNDLOCAL() + else: + menuLND() + +def aaccPPiLNBits(): + try: + bitLN = {"NN":"","pd":""} + if os.path.isfile('config/lnbitSN.conf'): + bitData= pickle.load(open("config/lnbitSN.conf", "rb")) + bitLN = bitData + APILnbit() + else: + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + bitLN['NN'] = randrange(10000000) + curl = 'curl -X POST https://lnbits.com/api/v1/payments -d ' + "'{" + """"out": false, "amount": 1000, "memo": "LNBits on PyBLOCK {}" """.format(bitLN['NN']) + "}'" + """ -H "X-Api-Key: 1d646820055e4e2da218e801eaacfc94 " -H "Content-type: application/json" """ + sh = os.popen(curl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + q = d['payment_request'] + c = q.lower() + while True: + print("\033[1;30;47m") + qr.add_data(c) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("Lightning Invoice: " + c) + dn = str(d['checking_id']) + t.sleep(10) + checkcurl = 'curl -X GET https://lnbits.com/api/v1/payments/' + dn + """ -H "X-Api-Key: 1d646820055e4e2da218e801eaacfc94" -H "Content-type: application/json" """ + rsh = os.popen(checkcurl).read() + clear() + blogo() + nn = str(rsh) + dd = json.loads(nn) + db = dd['paid'] + if db is not True: + continue + + clear() + blogo() + tick() + bitLN['pd'] = "PAID" + pickle.dump(bitLN, open("config/lnbitSN.conf", "wb")) + createFileConnLNBits() + break + except: + clear() + blogo() + print("\n\tSERIAL NUMBER NOT FOUND\n") + input("Continue...") + +def aaccPPiLNPay(): + try: + bitLN = {"NN":"","pd":""} + if os.path.isfile('config/lnpaySN.conf'): # Check if the file 'bclock.conf' is in the same folder + bitData= pickle.load(open("config/lnpaySN.conf", "rb")) # Load the file 'bclock.conf' + bitLN = bitData # Copy the variable pathv to 'path' + APILnPay() + else: + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + bitLN['NN'] = randrange(10000000) + curl = 'curl -X POST https://lnbits.com/api/v1/payments -d ' + "'{" + """"out": false, "amount": 1000, "memo": "LNPay on PyBLOCK {}" """.format(bitLN['NN']) + "}'" + """ -H "X-Api-Key: 1d646820055e4e2da218e801eaacfc94 " -H "Content-type: application/json" """ + sh = os.popen(curl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + q = d['payment_request'] + c = q.lower() + while True: + print("\033[1;30;47m") + qr.add_data(c) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("Lightning Invoice: " + c) + dn = str(d['checking_id']) + t.sleep(10) + checkcurl = 'curl -X GET https://lnbits.com/api/v1/payments/' + dn + """ -H "X-Api-Key: 1d646820055e4e2da218e801eaacfc94" -H "Content-type: application/json" """ + rsh = os.popen(checkcurl).read() + clear() + blogo() + nn = str(rsh) + dd = json.loads(nn) + db = dd['paid'] + if db is not True: + continue + + clear() + blogo() + tick() + bitLN['pd'] = "PAID" + pickle.dump(bitLN, open("config/lnpaySN.conf", "wb")) + createFileConnLNPay() + break + + except: + clear() + blogo() + print("\n\tSERIAL NUMBER NOT FOUND\n") + input("Continue...") + +def aaccPPiOpenNode(): + try: + bitLN = {"NN":"","pd":""} + if os.path.isfile('config/opennodeSN.conf'): # Check if the file 'bclock.conf' is in the same folder + bitData= pickle.load(open("config/opennodeSN.conf", "rb")) # Load the file 'bclock.conf' + bitLN = bitData # Copy the variable pathv to 'path' + APIOpenNode() + else: + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + bitLN['NN'] = randrange(10000000) + curl = 'curl -X POST https://lnbits.com/api/v1/payments -d ' + "'{" + """"out": false, "amount": 1000, "memo": "OpenNode on PyBLOCK {}" """.format(bitLN['NN']) + "}'" + """ -H "X-Api-Key: 1d646820055e4e2da218e801eaacfc94 " -H "Content-type: application/json" """ + sh = os.popen(curl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + q = d['payment_request'] + c = q.lower() + while True: + print("\033[1;30;47m") + qr.add_data(c) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("Lightning Invoice: " + c) + dn = str(d['checking_id']) + t.sleep(10) + checkcurl = 'curl -X GET https://lnbits.com/api/v1/payments/' + dn + """ -H "X-Api-Key: 1d646820055e4e2da218e801eaacfc94" -H "Content-type: application/json" """ + rsh = os.popen(checkcurl).read() + clear() + blogo() + nn = str(rsh) + dd = json.loads(nn) + db = dd['paid'] + if db is not True: + continue + + clear() + blogo() + tick() + bitLN['pd'] = "PAID" + pickle.dump(bitLN, open("config/opennodeSN.conf", "wb")) + createFileConnOpenNode() + break + + except: + clear() + blogo() + print("\n\tSERIAL NUMBER NOT FOUND\n") + input("Continue...") + + +def aaccPPiTippinMe(): + if os.path.isfile('config/tippinme.conf'): # Check if the file 'bclock.conf' is in the same folder + APITippinMe() + else: + createFileTippinMe() + +def aaccPPiTallyCo(): + if os.path.isfile('config/tallyco.conf'): # Check if the file 'bclock.conf' is in the same folder + APITallyCo() + else: + createFileConnTallyCo() + +def checkupdate(): + r = requests.get('https://raw.githubusercontent.com/curly60e/pyblock/master/ver.txt') + r.headers['Content-Type'] + n = r.text + di = json.loads(n) + if di['version'] == version: + q = print(" ") + else: + print("\n ------------------------------------------") + q = print(" \033[1;31;40mNew version available\033[0;37;40m > Exit and $pip3 install pybitblock -U ") + print(" ------------------------------------------") + +def testlogo(): + output = render('PyBLOCK', colors=[settings['colorA'], settings['colorB']], align='left', font=settings['design']) + print(output) + print(""" + + ------------------------- + Design: {} + Front Color: {} + Back Color: {} + ------------------------- + + """.format(settings['design'], settings['colorA'], settings['colorB'])) + try: + print("<<< Cancel Control + C") + input("Enter To Apply...") + settings["gradient"] = "color" + pickle.dump(settings, open("config/pyblocksettings.conf", "wb")) + except: + pass + +def testlogoRB(): + output = render('PyBLOCK', gradient=[settings['colorA'], settings['colorB']], align='left', font=settings['design']) + print(output) + print(""" + + ------------------------- + Design: {} + Start Color: {} + End Color: {} + ------------------------- + + """.format(settings['design'], settings['colorA'], settings['colorB'])) + try: + print("<<< Cancel Control + C") + input("Enter To Apply...") + settings["gradient"] = "grd" + pickle.dump(settings, open("config/pyblocksettings.conf", "wb")) + except: + pass + +def testClock(): + bitcoinclient = path['bitcoincli'] + " getblockcount" + block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string + b = block + output = render(str(b), colors=[settingsClock['colorA'], settingsClock['colorB']], align='left') + print(output) + print(""" + + ------------------------- + Front Color: {} + Back Color: {} + ------------------------- + + """.format(settingsClock['colorA'], settingsClock['colorB'])) + try: + print("<<< Cancel Control + C") + input("Enter To Apply...") + settingsClock["gradient"] = "color" + pickle.dump(settingsClock, open("config/pyblocksettingsClock.conf", "wb")) + except: + pass + +#--------------------------------- End Menu section ----------------------------------- +#--------------------------------- Main Menu execution -------------------------------- + +def menuSettingsLocal(menuSTT): + if menuSTT in ["A", "a"]: + clear() + blogo() + designQ() + elif menuSTT in ["B", "b"]: + clear() + blogo() + colors() + elif menuSTT in ["C", "c"]: + clear() + blogo() + colorsC() + +def menuSettingsLocalOnchainONLY(menuSTT): + if menuSTT in ["A", "a"]: + clear() + blogo() + designQOnchainONLY() + elif menuSTT in ["B", "b"]: + clear() + blogo() + colorsOnchainONLY() + elif menuSTT in ["C", "c"]: + clear() + blogo() + colorsCOnchainONLY() + +def menuSettingsRemote(menuSTT): + if menuSTT in ["A", "a"]: + clear() + blogo() + designQ() + elif menuSTT in ["B", "b"]: + clear() + blogo() + colors() + elif menuSTT in ["C", "c"]: + clear() + blogo() + colorsCRemote() + +def menuColors(menuCLS): + if menuCLS in ["A", "a"]: + colorsSelectFront() + elif menuCLS in ["B", "b"]: + colorsSelectBack() + elif menuCLS in ["C", "c"]: + colorsSelectRainbow() + elif menuCLS in ["F", "f"]: + colors() + +def menuColorsOnchainONLY(menuCLS): + if menuCLS in ["A", "a"]: + colorsSelectFrontOnchainONLY() + elif menuCLS in ["B", "b"]: + colorsSelectBackOnchainONLY() + elif menuCLS in ["C", "c"]: + colorsSelectRainbowOnchainONLY() + elif menuCLS in ["F", "f"]: + colorsOnchainONLY() + +def menuColorsClock(menuCLS): + if menuCLS in ["A", "a"]: + colorsSelectFrontClock() + elif menuCLS in ["B", "b"]: + colorsSelectBackClock() + elif menuCLS in ["F", "f"]: + colors() + +def menuColorsClockOnchainONLY(menuCLS): + if menuCLS in ["A", "a"]: + colorsSelectFrontClockOnchainONLY() + elif menuCLS in ["B", "b"]: + colorsSelectBackClockOnchainONLY() + elif menuCLS in ["F", "f"]: + colorsOnchainONLY() + +def menuColorsClockRemote(menuCLS): + if menuCLS in ["A", "a"]: + colorsSelectFrontClockRemote() + elif menuCLS in ["B", "b"]: + colorsSelectBackClockRemote() + elif menuCLS in ["F", "f"]: + colors() + +def menuColorsSelectRainbow(menuRF): + if menuRF in ["A", "a"]: + colorsSelectRainbowStart() + elif menuRF in ["B", "b"]: + colorsSelectRainbowEnd() + elif menuRF in ["F", "f"]: + colors() + +def menuColorsSelectRainbowOnchainONLY(menuRF): + if menuRF in ["A", "a"]: + colorsSelectRainbowStartOnchaiONLY() + elif menuRF in ["B", "b"]: + colorsSelectRainbowEndOnchainONLY() + elif menuRF in ["F", "f"]: + colorsOnchainONLY() + +def menuColorsSelectRainbowEnd(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settings["colorB"] = "black" + testlogoRB() + elif menuCF in ["B", "b"]: + clear() + blogo() + settings["colorB"] = "red" + testlogoRB() + elif menuCF in ["C", "c"]: + clear() + blogo() + settings["colorB"] = "green" + testlogoRB() + elif menuCF in ["D", "d"]: + clear() + blogo() + settings["colorB"] = "yellow" + testlogo() + elif menuCF in ["E", "e"]: + clear() + blogo() + settings["colorB"] = "blue" + testlogoRB() + elif menuCF in ["F", "f"]: + clear() + blogo() + settings["colorB"] = "magenta" + testlogoRB() + elif menuCF in ["G", "g"]: + clear() + blogo() + settings["colorB"] = "cyan" + testlogoRB() + elif menuCF in ["H", "h"]: + clear() + blogo() + settings["colorB"] = "white" + testlogoRB() + elif menuCF in ["I", "i"]: + clear() + blogo() + settings["colorB"] = "gray" + testlogoRB() + elif menuCF in ["R", "r"]: + colors() + +def menuColorsSelectRainbowEndOnchainONLY(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settings["colorB"] = "black" + testlogoRB() + elif menuCF in ["B", "b"]: + clear() + blogo() + settings["colorB"] = "red" + testlogoRB() + elif menuCF in ["C", "c"]: + clear() + blogo() + settings["colorB"] = "green" + testlogoRB() + elif menuCF in ["D", "d"]: + clear() + blogo() + settings["colorB"] = "yellow" + testlogo() + elif menuCF in ["E", "e"]: + clear() + blogo() + settings["colorB"] = "blue" + testlogoRB() + elif menuCF in ["F", "f"]: + clear() + blogo() + settings["colorB"] = "magenta" + testlogoRB() + elif menuCF in ["G", "g"]: + clear() + blogo() + settings["colorB"] = "cyan" + testlogoRB() + elif menuCF in ["H", "h"]: + clear() + blogo() + settings["colorB"] = "white" + testlogoRB() + elif menuCF in ["I", "i"]: + clear() + blogo() + settings["colorB"] = "gray" + testlogoRB() + elif menuCF in ["R", "r"]: + colorsOnchainONLY() + +def menuColorsSelectRainbowStart(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settings["colorA"] = "black" + testlogoRB() + elif menuCF in ["B", "b"]: + clear() + blogo() + settings["colorA"] = "red" + testlogoRB() + elif menuCF in ["C", "c"]: + clear() + blogo() + settings["colorA"] = "green" + testlogoRB() + elif menuCF in ["D", "d"]: + clear() + blogo() + settings["colorA"] = "yellow" + testlogoRB() + elif menuCF in ["E", "e"]: + clear() + blogo() + settings["colorA"] = "blue" + testlogoRB() + elif menuCF in ["F", "f"]: + clear() + blogo() + settings["colorA"] = "magenta" + testlogoRB() + elif menuCF in ["G", "g"]: + clear() + blogo() + settings["colorA"] = "cyan" + testlogoRB() + elif menuCF in ["H", "h"]: + clear() + blogo() + settings["colorA"] = "white" + testlogoRB() + elif menuCF in ["I", "i"]: + clear() + blogo() + settings["colorA"] = "gray" + testlogoRB() + elif menuCF in ["R", "r"]: + colors() + +def menuColorsSelectRainbowStartOnchainONLY(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settings["colorA"] = "black" + testlogoRB() + elif menuCF in ["B", "b"]: + clear() + blogo() + settings["colorA"] = "red" + testlogoRB() + elif menuCF in ["C", "c"]: + clear() + blogo() + settings["colorA"] = "green" + testlogoRB() + elif menuCF in ["D", "d"]: + clear() + blogo() + settings["colorA"] = "yellow" + testlogoRB() + elif menuCF in ["E", "e"]: + clear() + blogo() + settings["colorA"] = "blue" + testlogoRB() + elif menuCF in ["F", "f"]: + clear() + blogo() + settings["colorA"] = "magenta" + testlogoRB() + elif menuCF in ["G", "g"]: + clear() + blogo() + settings["colorA"] = "cyan" + testlogoRB() + elif menuCF in ["H", "h"]: + clear() + blogo() + settings["colorA"] = "white" + testlogoRB() + elif menuCF in ["I", "i"]: + clear() + blogo() + settings["colorA"] = "gray" + testlogoRB() + elif menuCF in ["R", "r"]: + colorsOnchainONLY() + +def menuColorsSelectBack(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settings["colorB"] = "black" + testlogo() + elif menuCF in ["B", "b"]: + clear() + blogo() + settings["colorB"] = "red" + testlogo() + elif menuCF in ["C", "c"]: + clear() + blogo() + settings["colorB"] = "green" + testlogo() + elif menuCF in ["D", "d"]: + clear() + blogo() + settings["colorB"] = "yellow" + testlogo() + elif menuCF in ["E", "e"]: + clear() + blogo() + settings["colorB"] = "blue" + testlogo() + elif menuCF in ["F", "f"]: + clear() + blogo() + settings["colorB"] = "magenta" + testlogo() + elif menuCF in ["G", "g"]: + clear() + blogo() + settings["colorB"] = "cyan" + testlogo() + elif menuCF in ["H", "h"]: + clear() + blogo() + settings["colorB"] = "white" + testlogo() + elif menuCF in ["I", "i"]: + clear() + blogo() + settings["colorB"] = "gray" + testlogo() + elif menuCF in ["R", "r"]: + colors() + +def menuColorsSelectBackOnchainONLY(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settings["colorB"] = "black" + testlogo() + elif menuCF in ["B", "b"]: + clear() + blogo() + settings["colorB"] = "red" + testlogo() + elif menuCF in ["C", "c"]: + clear() + blogo() + settings["colorB"] = "green" + testlogo() + elif menuCF in ["D", "d"]: + clear() + blogo() + settings["colorB"] = "yellow" + testlogo() + elif menuCF in ["E", "e"]: + clear() + blogo() + settings["colorB"] = "blue" + testlogo() + elif menuCF in ["F", "f"]: + clear() + blogo() + settings["colorB"] = "magenta" + testlogo() + elif menuCF in ["G", "g"]: + clear() + blogo() + settings["colorB"] = "cyan" + testlogo() + elif menuCF in ["H", "h"]: + clear() + blogo() + settings["colorB"] = "white" + testlogo() + elif menuCF in ["I", "i"]: + clear() + blogo() + settings["colorB"] = "gray" + testlogo() + elif menuCF in ["R", "r"]: + colorsOnchainONLY() + +def menuColorsSelectFront(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settings["colorA"] = "black" + testlogo() + elif menuCF in ["B", "b"]: + clear() + blogo() + settings["colorA"] = "red" + testlogo() + elif menuCF in ["C", "c"]: + clear() + blogo() + settings["colorA"] = "green" + testlogo() + elif menuCF in ["D", "d"]: + clear() + blogo() + settings["colorA"] = "yellow" + testlogo() + elif menuCF in ["E", "e"]: + clear() + blogo() + settings["colorA"] = "blue" + testlogo() + elif menuCF in ["F", "f"]: + clear() + blogo() + settings["colorA"] = "magenta" + testlogo() + elif menuCF in ["G", "g"]: + clear() + blogo() + settings["colorA"] = "cyan" + testlogo() + elif menuCF in ["H", "h"]: + clear() + blogo() + settings["colorA"] = "white" + testlogo() + elif menuCF in ["I", "i"]: + clear() + blogo() + settings["colorA"] = "gray" + testlogo() + elif menuCF in ["R", "r"]: + colors() + +def menuColorsSelectFrontOncainONLY(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settings["colorA"] = "black" + testlogo() + elif menuCF in ["B", "b"]: + clear() + blogo() + settings["colorA"] = "red" + testlogo() + elif menuCF in ["C", "c"]: + clear() + blogo() + settings["colorA"] = "green" + testlogo() + elif menuCF in ["D", "d"]: + clear() + blogo() + settings["colorA"] = "yellow" + testlogo() + elif menuCF in ["E", "e"]: + clear() + blogo() + settings["colorA"] = "blue" + testlogo() + elif menuCF in ["F", "f"]: + clear() + blogo() + settings["colorA"] = "magenta" + testlogo() + elif menuCF in ["G", "g"]: + clear() + blogo() + settings["colorA"] = "cyan" + testlogo() + elif menuCF in ["H", "h"]: + clear() + blogo() + settings["colorA"] = "white" + testlogo() + elif menuCF in ["I", "i"]: + clear() + blogo() + settings["colorA"] = "gray" + testlogo() + elif menuCF in ["R", "r"]: + colorsOnchainONLY() + +def menuColorsSelectFrontClock(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settingsClock["colorA"] = "black" + testClock() + elif menuCF in ["B", "b"]: + clear() + blogo() + settingsClock["colorA"] = "red" + testClock() + elif menuCF in ["C", "c"]: + clear() + blogo() + settingsClock["colorA"] = "green" + testClock() + elif menuCF in ["D", "d"]: + clear() + blogo() + settingsClock["colorA"] = "yellow" + testClock() + elif menuCF in ["E", "e"]: + clear() + blogo() + settingsClock["colorA"] = "blue" + testClock() + elif menuCF in ["F", "f"]: + clear() + blogo() + settingsClock["colorA"] = "magenta" + testClock() + elif menuCF in ["G", "g"]: + clear() + blogo() + settingsClock["colorA"] = "cyan" + testClock() + elif menuCF in ["H", "h"]: + clear() + blogo() + settingsClock["colorA"] = "white" + testClock() + elif menuCF in ["I", "i"]: + clear() + blogo() + settingsClock["colorA"] = "gray" + testClock() + elif menuCF in ["R", "r"]: + colors() + +def menuColorsSelectFrontClockOnchainONLY(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settingsClock["colorA"] = "black" + testClock() + elif menuCF in ["B", "b"]: + clear() + blogo() + settingsClock["colorA"] = "red" + testClock() + elif menuCF in ["C", "c"]: + clear() + blogo() + settingsClock["colorA"] = "green" + testClock() + elif menuCF in ["D", "d"]: + clear() + blogo() + settingsClock["colorA"] = "yellow" + testClock() + elif menuCF in ["E", "e"]: + clear() + blogo() + settingsClock["colorA"] = "blue" + testClock() + elif menuCF in ["F", "f"]: + clear() + blogo() + settingsClock["colorA"] = "magenta" + testClock() + elif menuCF in ["G", "g"]: + clear() + blogo() + settingsClock["colorA"] = "cyan" + testClock() + elif menuCF in ["H", "h"]: + clear() + blogo() + settingsClock["colorA"] = "white" + testClock() + elif menuCF in ["I", "i"]: + clear() + blogo() + settingsClock["colorA"] = "gray" + testClock() + elif menuCF in ["R", "r"]: + colorsOnchainONLY() + +def menuColorsSelectBackClock(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settingsClock["colorB"] = "black" + testClock() + elif menuCF in ["B", "b"]: + clear() + blogo() + settingsClock["colorB"] = "red" + testClock() + elif menuCF in ["C", "c"]: + clear() + blogo() + settingsClock["colorB"] = "green" + testClock() + elif menuCF in ["D", "d"]: + clear() + blogo() + settingsClock["colorB"] = "yellow" + testClock() + elif menuCF in ["E", "e"]: + clear() + blogo() + settingsClock["colorB"] = "blue" + testClock() + elif menuCF in ["F", "f"]: + clear() + blogo() + settingsClock["colorB"] = "magenta" + testClock() + elif menuCF in ["G", "g"]: + clear() + blogo() + settingsClock["colorB"] = "cyan" + testClock() + elif menuCF in ["H", "h"]: + clear() + blogo() + settingsClock["colorB"] = "white" + testClock() + elif menuCF in ["I", "i"]: + clear() + blogo() + settingsClock["colorB"] = "gray" + testClock() + elif menuCF in ["R", "r"]: + colors() + +def menuColorsSelectBackClockOnchainONLY(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settingsClock["colorB"] = "black" + testClock() + elif menuCF in ["B", "b"]: + clear() + blogo() + settingsClock["colorB"] = "red" + testClock() + elif menuCF in ["C", "c"]: + clear() + blogo() + settingsClock["colorB"] = "green" + testClock() + elif menuCF in ["D", "d"]: + clear() + blogo() + settingsClock["colorB"] = "yellow" + testClock() + elif menuCF in ["E", "e"]: + clear() + blogo() + settingsClock["colorB"] = "blue" + testClock() + elif menuCF in ["F", "f"]: + clear() + blogo() + settingsClock["colorB"] = "magenta" + testClock() + elif menuCF in ["G", "g"]: + clear() + blogo() + settingsClock["colorB"] = "cyan" + testClock() + elif menuCF in ["H", "h"]: + clear() + blogo() + settingsClock["colorB"] = "white" + testClock() + elif menuCF in ["I", "i"]: + clear() + blogo() + settingsClock["colorB"] = "gray" + testClock() + elif menuCF in ["R", "r"]: + colorsOnchainONLY() + +def menuColorsSelectFrontClockRemote(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settingsClock["colorA"] = "black" + testClockRemote() + elif menuCF in ["B", "b"]: + clear() + blogo() + settingsClock["colorA"] = "red" + testClockRemote() + elif menuCF in ["C", "c"]: + clear() + blogo() + settingsClock["colorA"] = "green" + testClockRemote() + elif menuCF in ["D", "d"]: + clear() + blogo() + settingsClock["colorA"] = "yellow" + testClockRemote() + elif menuCF in ["E", "e"]: + clear() + blogo() + settingsClock["colorA"] = "blue" + testClockRemote() + elif menuCF in ["F", "f"]: + clear() + blogo() + settingsClock["colorA"] = "magenta" + testClockRemote() + elif menuCF in ["G", "g"]: + clear() + blogo() + settingsClock["colorA"] = "cyan" + testClockRemote() + elif menuCF in ["H", "h"]: + clear() + blogo() + settingsClock["colorA"] = "white" + testClockRemote() + elif menuCF in ["I", "i"]: + clear() + blogo() + settingsClock["colorA"] = "gray" + testClockRemote() + elif menuCF in ["R", "r"]: + colors() + +def menuColorsSelectBackClockRemote(menuCF): + if menuCF in ["A", "a"]: + clear() + blogo() + settingsClock["colorB"] = "black" + testClockRemote() + elif menuCF in ["B", "b"]: + clear() + blogo() + settingsClock["colorB"] = "red" + testClockRemote() + elif menuCF in ["C", "c"]: + clear() + blogo() + settingsClock["colorB"] = "green" + testClockRemote() + elif menuCF in ["D", "d"]: + clear() + blogo() + settingsClock["colorB"] = "yellow" + testClockRemote() + elif menuCF in ["E", "e"]: + clear() + blogo() + settingsClock["colorB"] = "blue" + testClockRemote() + elif menuCF in ["F", "f"]: + clear() + blogo() + settingsClock["colorB"] = "magenta" + testClockRemote() + elif menuCF in ["G", "g"]: + clear() + blogo() + settingsClock["colorB"] = "cyan" + testClockRemote() + elif menuCF in ["H", "h"]: + clear() + blogo() + settingsClock["colorB"] = "white" + testClockRemote() + elif menuCF in ["I", "i"]: + clear() + blogo() + settingsClock["colorB"] = "gray" + testClockRemote() + elif menuCF in ["R", "r"]: + colors() + +def menuDesign(menuDSN): + if menuDSN in ["A", "a"]: + clear() + blogo() + settings["design"] = "block" + testlogo() + elif menuDSN in ["B", "b"]: + clear() + blogo() + settings['design'] = "slick" + testlogo() + elif menuDSN in ["C", "c"]: + clear() + blogo() + settings['design'] = "tiny" + testlogo() + elif menuDSN in ["D", "d"]: + clear() + blogo() + settings['design'] = "grid" + testlogo() + elif menuDSN in ["E", "e"]: + clear() + blogo() + settings['design'] = "pallet" + testlogo() + elif menuDSN in ["F", "f"]: + clear() + blogo() + settings['design'] = "shade" + testlogo() + elif menuDSN in ["G", "g"]: + clear() + blogo() + settings['design'] = "chrome" + testlogo() + elif menuDSN in ["H", "h"]: + clear() + blogo() + settings['design'] = "simple" + testlogo() + elif menuDSN in ["I", "i"]: + clear() + blogo() + settings['design'] = "simpleBlock" + testlogo() + elif menuDSN in ["J", "j"]: + clear() + blogo() + settings['design'] = "3d" + testlogo() + elif menuDSN in ["K", "k"]: + clear() + blogo() + settings['design'] = "simple3d" + testlogo() + elif menuDSN in ["L", "l"]: + clear() + blogo() + settings['design'] = "huge" + testlogo() + +def menuDesignOnchainONLY(menuDSN): + if menuDSN in ["A", "a"]: + clear() + blogo() + settings["design"] = "block" + testlogo() + elif menuDSN in ["B", "b"]: + clear() + blogo() + settings['design'] = "slick" + testlogo() + elif menuDSN in ["C", "c"]: + clear() + blogo() + settings['design'] = "tiny" + testlogo() + elif menuDSN in ["D", "d"]: + clear() + blogo() + settings['design'] = "grid" + testlogo() + elif menuDSN in ["E", "e"]: + clear() + blogo() + settings['design'] = "pallet" + testlogo() + elif menuDSN in ["F", "f"]: + clear() + blogo() + settings['design'] = "shade" + testlogo() + elif menuDSN in ["G", "g"]: + clear() + blogo() + settings['design'] = "chrome" + testlogo() + elif menuDSN in ["H", "h"]: + clear() + blogo() + settings['design'] = "simple" + testlogo() + elif menuDSN in ["I", "i"]: + clear() + blogo() + settings['design'] = "simpleBlock" + testlogo() + elif menuDSN in ["J", "j"]: + clear() + blogo() + settings['design'] = "3d" + testlogo() + elif menuDSN in ["K", "k"]: + clear() + blogo() + settings['design'] = "simple3d" + testlogo() + elif menuDSN in ["L", "l"]: + clear() + blogo() + settings['design'] = "huge" + testlogo() + +#------------API--------------------- + +def mempoolmenuS(menuMem): + if menuMem in ["A", "a"]: + blocks() + elif menuMem in ["B", "b"]: + fee() + elif menuMem in ["R", "r"]: + menuSelection() + +def mempoolmenuSOnchainONLY(menuMem): + if menuMem in ["A", "a"]: + blocks() + elif menuMem in ["B", "b"]: + fee() + elif menuMem in ["R", "r"]: + menuSelection() + +def menuTallyCo(menuTLC): + if menuTLC in ["A", "a"]: + tallycoGetPayment() + elif menuTLC in ["B", "b"]: + tallycoDonateid() + elif menuTLC in ["R", "r"]: + menuSelection() + +def menuTallyCoOnchainONLY(menuTLC): + if menuTLC in ["A", "a"]: + tallycoGetPayment() + elif menuTLC in ["B", "b"]: + tallycoDonateid() + elif menuTLC in ["R", "r"]: + menuSelection() + +def menuTippinMe(menuTM): + if menuTM in ["A", "a"]: + tippinmeGetInvoice() + elif menuTM in ["R", "r"]: + menuSelection() + +def menuTippinMeOnchainONLY(menuTM): + if menuTM in ["A", "a"]: + tippinmeGetInvoice() + elif menuTM in ["R", "r"]: + menuSelection() + +def menuOpenNode(menuOP): + if menuOP in ["A", "a"]: + clear() + blogo() + OpenNodecreatecharge() + elif menuOP in ["B", "b"]: + clear() + blogo() + OpenNodeiniciatewithdrawal() + elif menuOP in ["C", "c"]: + clear() + blogo() + OpenNodelistfunds() + elif menuOP in ["D", "d"]: + clear() + blogo() + OpenNodeListPayments() + elif menuOP in ["S", "s"]: + clear() + blogo() + OpenNodeCheckStatus() + elif menuOP in ["R", "r"]: + menuSelection() + +def menuOpenNodeOnchainONLY(menuOP): + if menuOP in ["A", "a"]: + clear() + blogo() + OpenNodecreatecharge() + elif menuOP in ["B", "b"]: + clear() + blogo() + OpenNodeiniciatewithdrawal() + elif menuOP in ["C", "c"]: + clear() + blogo() + OpenNodelistfunds() + elif menuOP in ["D", "d"]: + clear() + blogo() + OpenNodeListPayments() + elif menuOP in ["S", "s"]: + clear() + blogo() + OpenNodeCheckStatus() + elif menuOP in ["R", "r"]: + menuSelection() + +def menuLNPAY(menuNW): + if menuNW in ["A", "a"]: + clear() + blogo() + lnpayCreateInvoice() + elif menuNW in ["B", "b"]: + clear() + blogo() + lnpayPayInvoice() + elif menuNW in ["C", "c"]: + clear() + blogo() + lnpayGetBalance() + elif menuNW in ["D", "d"]: + clear() + blogo() + lnpayGetTransactions() + elif menuNW in ["E", "e"]: + clear() + blogo() + lnpayTransBWallets() + elif menuNW in ["R", "r"]: + menuSelection() + +def menuLNPAYOnchainONLY(menuNW): + if menuNW in ["A", "a"]: + clear() + blogo() + lnpayCreateInvoice() + elif menuNW in ["B", "b"]: + clear() + blogo() + lnpayPayInvoice() + elif menuNW in ["C", "c"]: + clear() + blogo() + lnpayGetBalance() + elif menuNW in ["D", "d"]: + clear() + blogo() + lnpayGetTransactions() + elif menuNW in ["E", "e"]: + clear() + blogo() + lnpayTransBWallets() + elif menuNW in ["R", "r"]: + menuSelection() + +def menuLNBPI(menuLNQ): + if menuLNQ in ["A", "a"]: + clear() + blogo() + lnbitCreateNewInvoice() + elif menuLNQ in ["B", "b"]: + clear() + blogo() + lnbitPayInvoice() + elif menuLNQ in ["C", "c"]: + clear() + blogo() + lnbitCreatePayWall() + elif menuLNQ in ["D", "d"]: + clear() + blogo() + lnbitDeletePayWall() + elif menuLNQ in ["E", "e"]: + clear() + blogo() + lnbitListPawWall() + elif menuLNQ in ["F", "f"]: + clear() + blogo() + lnbitsLNURLw() + elif menuLNQ in ["G", "g"]: + clear() + blogo() + lnbitsLNURLwList() + elif menuLNQ in ["R", "r"]: + menuSelection() + +def menuLNBPIOnchainONLY(menuLNQ): + if menuLNQ in ["A", "a"]: + clear() + blogo() + lnbitCreateNewInvoice() + elif menuLNQ in ["B", "b"]: + clear() + blogo() + lnbitPayInvoice() + elif menuLNQ in ["C", "c"]: + clear() + blogo() + lnbitCreatePayWall() + elif menuLNQ in ["D", "d"]: + clear() + blogo() + lnbitDeletePayWall() + elif menuLNQ in ["E", "e"]: + clear() + blogo() + lnbitListPawWall() + elif menuLNQ in ["F", "f"]: + clear() + blogo() + lnbitsLNURLw() + elif menuLNQ in ["G", "g"]: + clear() + blogo() + lnbitsLNURLwList() + elif menuLNQ in ["R", "r"]: + menuSelection() + +def rateSXMenu(menuSX): + if menuSX in ["A", "a"]: + clear() + blogo() + rateSXList() + elif menuSX in ["B", "b"]: + clear() + blogo() + rateSXGraph() + elif menuSX in ["R", "r"]: + menuSelection() + +def rateSXMenuOnchainONLY(menuSX): + if menuSX in ["A", "a"]: + clear() + blogo() + rateSXList() + elif menuSX in ["B", "b"]: + clear() + blogo() + rateSXGraph() + elif menuSX in ["R", "r"]: + menuSelection() + +#---------------END API----------- + + +def runTheNumbersControl(menuNumbers): + if menuNumbers in ["A", "a"]: + clear() + blogo() + countdownblock() + elif menuNumbers in ["B", "b"]: + clear() + blogo() + localHalving() + elif menuNumbers in ["C", "c"]: + clear() + blogo() + calc = """ + ---------------------------- + PROCESSING + THE NUMBERS + ---------------------------- + """ + comeback = """ + ---------------------------- + MAKE YOURSELF A COFFEE + AND COME BACK IN A + MOMENT + ---------------------------- + """ + cprint(comeback, 'yellow') + cprint(calc, 'red', attrs=['blink']) + runthenumbers() + +def runTheNumbersControlOnchainONLY(menuNumbers): + if menuNumbers in ["A", "a"]: + clear() + blogo() + countdownblock() + elif menuNumbers in ["B", "b"]: + clear() + blogo() + localHalving() + elif menuNumbers in ["C", "c"]: + clear() + blogo() + calc = """ + ---------------------------- + PROCESSING + THE NUMBERS + ---------------------------- + """ + comeback = """ + ---------------------------- + MAKE YOURSELF A COFFEE + AND COME BACK IN A + MOMENT + ---------------------------- + """ + cprint(comeback, 'yellow') + cprint(calc, 'red', attrs=['blink']) + runthenumbers() + +def runTheNumbersControlConn(menuNumbersconn): + if menuNumbersconn in ["A", "a"]: + clear() + blogo() + countdownblockConn() + elif menuNumbersconn in ["B", "b"]: + clear() + blogo() + remoteHalving() + elif menuNumbersconn in ["C", "c"]: + clear() + blogo() + calc = """ + ---------------------------- + PROCESSING + THE NUMBERS + ---------------------------- + """ + comeback = """ + ---------------------------- + MAKE YOURSELF A COFFEE + AND COME BACK IN A + MOMENT + ---------------------------- + """ + cprint(comeback, 'yellow') + cprint(calc, 'red', attrs=['blink']) + runthenumbersConn() + +def menuWeather(menuWD): + if menuWD in ["A", "a"]: + wttrDataV1() + elif menuWD in ["B", "b"]: + wttrDataV2() + +def menuWeatherOnchainONLY(menuWD): + if menuWD in ["A", "a"]: + wttrDataV1() + elif menuWD in ["B", "b"]: + wttrDataV2() + +def mainmenuLOCALcontrol(menuS): #Execution of the Main Menu options + if menuS in ["A", "a"]: + artist() + elif menuS in ["B", "b"]: + bitcoincoremenuLOCAL() + elif menuS in ["L", "l"]: + lightningnetworkLOCAL() + elif menuS in ["S", "s"]: + settings4Local() + elif menuS in ["P", "p"]: + APIMenuLOCAL() + elif menuS in ["X", "x"]: + dnt() + elif menuS in ["Q", "q"]: + os._exit(0) + apisnd.close() + donation.close() + clone.close() + logos.close() + feed.close() + sysinf.close() + nodeconnection.close() + exit() + elif menuS in ["T", "t"]: + clear() + delay_print("\033[1;32;40mWake up, Neo...") + t.sleep(2) + clear() + delay_print("The Matrix has you...") + t.sleep(2) + clear() + delay_print("Follow the white rabbit.") + t.sleep(3) + clear() + print("Knock, knock, Neo.\033[0;37;40m\n") + t.sleep(2) + clear() + t.sleep(3) + screensv() + elif menuS in ["nym", "Nym", "NYM", "nYm", "nyM", "NYm", "NyM", "nYM"]: + clear() + blogo() + robotNym() + elif menuS in ["wt", "WT", "Wt", "wT"]: + clear() + blogo() + callGitWardenTerminal() + +def mainmenuLOCALcontrolOnchainONLY(menuS): #Execution of the Main Menu options + if menuS in ["A", "a"]: + artist() + elif menuS in ["B", "b"]: + bitcoincoremenuLOCALOnchainONLY() + elif menuS in ["S", "s"]: + settings4LocalOnchainONLY() + elif menuS in ["P", "p"]: + APIMenuLOCALOnchainONLY() + elif menuS in ["X", "x"]: + dntOnchainONLY() + elif menuS in ["Q", "q"]: + os._exit(0) + apisnd.close() + donation.close() + clone.close() + logos.close() + feed.close() + sysinf.close() + nodeconnection.close() + exit() + elif menuS in ["T", "t"]: + clear() + delay_print("\033[1;32;40mWake up, Neo...") + t.sleep(2) + clear() + delay_print("The Matrix has you...") + t.sleep(2) + clear() + delay_print("Follow the white rabbit.") + t.sleep(3) + clear() + print("Knock, knock, Neo.\033[0;37;40m\n") + t.sleep(2) + clear() + t.sleep(3) + screensv() + elif menuS in ["nym", "Nym", "NYM", "nYm", "nyM", "NYm", "NyM", "nYM"]: + clear() + blogo() + robotNym() + elif menuS in ["wt", "WT", "Wt", "wT"]: + clear() + blogo() + callGitWardenTerminal() + +def slushpoolLOCALOnchainONLYMenu(slush): + if slush in ["A", "a"]: + clear() + blogo() + slDIFFConn() + elif slush in ["B", "b"]: + clear() + blogo() + slHASHConn() + elif slush in ["C", "c"]: + clear() + blogo() + slPOOLConn() + elif slush in ["D", "d"]: + clear() + blogo() + slHISTConn() + elif slush in ["E", "e"]: + clear() + blogo() + getPoolSlushCheck() + +def bitcoincoremenuLOCALcontrolA(bcore): + if bcore in ["A", "a"]: + while True: + try: + clear() + blogo() + sysinfo() + close() + console() + t.sleep(5) + except: + break + elif bcore in ["B", "b"]: + clear() + blogo() + getgenesis() + input("Continue...") + menuSelection() + elif bcore in ["C", "c"]: + getblock() + elif bcore in ["D", "d"]: + runTheNumbersMenu() + elif bcore in ["E", "e"]: + decodeHex() + elif bcore in ["F", "f"]: + try: + clear() + blogo() + sysinfo() + close() + decodeQR() + input("Continue...") + except: + pass + elif bcore in ["G", "g"]: + getrawtx() + elif bcore in ["H", "h"]: + miscellaneousLOCAL() + elif bcore in ["I", "i"]: + callColdCore() + elif bcore in ["J", "j"]: + pdfconvert() + elif bcore in ["O", "o"]: + bitcoincoremenuLOCALOPRETURN() + elif bcore in ["Z", "z"]: + statsConn() + elif bcore in ["M", "m"]: + miningConn() + elif bcore in ["U", "u"]: + untxsConn() + +def bitcoincoremenuLOCALcontrolAOnchainONLY(bcore): + if bcore in ["A", "a"]: + while True: + try: + clear() + blogo() + sysinfo() + close() + console() + t.sleep(5) + except: + break + elif bcore in ["B", "b"]: + clear() + blogo() + getgenesis() + input("Continue...") + menuSelection() + elif bcore in ["C", "c"]: + getblock() + elif bcore in ["D", "d"]: + runTheNumbersMenuOnchainONLY() + elif bcore in ["E", "e"]: + decodeHexOnchainONLY() + elif bcore in ["F", "f"]: + try: + clear() + blogo() + sysinfo() + close() + decodeQR() + input("Continue...") + except: + pass + elif bcore in ["G", "g"]: + getrawtx() + elif bcore in ["H", "h"]: + miscellaneousLOCALOnchainONLY() + elif bcore in ["I", "i"]: + callColdCore() + elif bcore in ["J", "j"]: + pdfconvert() + elif bcore in ["O", "o"]: + bitcoincoremenuLOCALOPRETURNOnchainONLY() + elif bcore in ["W", "w"]: + walletmenuLOCALOnchainONLY() + elif bcore in ["Z", "z"]: + statsConn() + elif bcore in ["M", "m"]: + miningConn() + elif bcore in ["U", "u"]: + untxsConn() + elif bcore in ["S", "s"]: + searchTXS() + +def walletmenuLOCALcontrolAOnchainONLY(walletmnu): + if walletmnu in ["A", "a"]: + getnewaddressOnchain() + elif walletmnu in ["B", "b"]: + gettransactionsOnchain() + +def bitcoincoremenuLOCALcontrolO(oreturn): + if oreturn in ["A", "a"]: + clear() + blogo() + opreturn() + elif oreturn in ["B", "b"]: + clear() + blogo() + opreturn_view() + elif oreturn in ["C", "c"]: + clear() + blogo() + opretminer() + +def bitcoincoremenuLOCALcontrolOOnchainONLY(oreturn): + if oreturn in ["A", "a"]: + clear() + blogo() + opreturnOnchainONLY() + elif oreturn in ["B", "b"]: + clear() + blogo() + opreturn_view() + elif oreturn in ["C", "c"]: + clear() + blogo() + opretminer() + +def miscellaneousLOCALmenu(misce): + if misce in ["A", "a"]: + while True: + try: + clear() + blogo() + close() + logoA() + tmp() + clear() + blogo() + close() + logoB() + tmp() + clear() + blogo() + close() + logoC() + tmp() + except: + break + elif misce in ["B", "b"]: + clear() + blogo() + close() + sysinfoDetail() + elif misce in ["C", "c"]: + clear() + blogo() + datesConn() + elif misce in ["D", "d"]: + clear() + blogo() + quotesConn() + elif misce in ["P", "p"]: + clear() + blogo() + pgpConn() + elif misce in ["S", "s"]: + clear() + blogo() + satoshiConn() + elif misce in ["R", "r"]: + menuSelection() + +def miscellaneousLOCALmenuOnchainONLY(misce): + if misce in ["A", "a"]: + while True: + try: + clear() + blogo() + close() + logoA() + tmp() + clear() + blogo() + close() + logoB() + tmp() + clear() + blogo() + close() + logoC() + tmp() + except: + break + elif misce in ["B", "b"]: + clear() + blogo() + close() + sysinfoDetail() + elif misce in ["D", "d"]: + clear() + blogo() + quotesConn() + elif misce in ["C", "c"]: + clear() + blogo() + datesConn() + elif misce in ["P", "p"]: + clear() + blogo() + pgpConn() + elif misce in ["S", "s"]: + clear() + blogo() + satoshiConn() + elif misce in ["R", "r"]: + menuSelection() + +def decodeHexLOCAL(hexloc): + if hexloc in ["A", "a"]: + clear() + blogo() + close() + try: + readHexBlock() + while True: + r = input("Do you want to continue decoding? Y/n: ") + if r in ["Y", "y"]: + clear() + blogo() + readHexBlock() + else: + break + except: + pass + elif hexloc in ["B", "b"]: + clear() + blogo() + close() + try: + readHexTx() + while True: + r = input("Do you want to continue decoding? Y/n: ") + if r not in ["Y", "y"]: + break + clear() + blogo() + sysinfo() + readHexTx() + except: + pass + +def decodeHexLOCALOnchainONLY(hexloc): + if hexloc in ["A", "a"]: + clear() + blogo() + close() + try: + readHexBlock() + while True: + r = input("Do you want to continue decoding? Y/n: ") + if r in ["Y", "y"]: + clear() + blogo() + readHexBlock() + else: + break + except: + pass + elif hexloc in ["B", "b"]: + clear() + blogo() + close() + try: + readHexTx() + while True: + r = input("Do you want to continue decoding? Y/n: ") + if r not in ["Y", "y"]: + break + clear() + blogo() + sysinfo() + readHexTx() + except: + pass + +def lightningnetworkLOCALcontrol(lncore): + if lncore in ["A", "a"]: + while True: + try: + clear() + blogo() + sysinfo() + close() + consoleLN() + t.sleep(5) + except: + break + elif lncore in ["B", "b"]: + clear() + blogo() + localaddinvoice() + elif lncore in ["C", "c"]: + clear() + blogo() + localpayinvoice() + elif lncore in ["D", "d"]: + clear() + blogo() + localkeysend() + elif lncore in ["E", "e"]: + clear() + blogo() + localnewaddress() + elif lncore in ["F", "f"]: + clear() + blogo() + locallistinvoices() + elif lncore in ["G", "g"]: + clear() + blogo() + localchannelbalance() + elif lncore in ["H", "h"]: + clear() + blogo() + locallistchannels() + elif lncore in ["I", "i"]: + clear() + blogo() + localrebalancelnd() + elif lncore in ["J", "j"]: + clear() + blogo() + locallistpeersQQ() + elif lncore in ["K", "k"]: + clear() + blogo() + localconnectpeer() + elif lncore in ["L", "l"]: + clear() + blogo() + localbalanceOC() + elif lncore in ["M", "m"]: + clear() + blogo() + locallistchaintxns() + elif lncore in ["N", "n"]: + clear() + blogo() + localgetinfo() + elif lncore in ["O", "o"]: + clear() + blogo() + localgetnetworkinfo() + elif lncore in ["P", "p"]: + clear() + blogo() + chatConn() + elif lncore in ["Z", "z"]: + clear() + blogo() + stalnConn() + elif lncore in ["T", "t"]: + clear() + blogo() + ranConn() + elif lncore in ["Q", "q"]: + if os.path.isfile("lnbitSN.conf"): + lnbitsLNURLwList() + elif lncore in ["S", "s"]: + if os.path.isfile("lnbitSN.conf"): + lnbitsLNURLw() + elif lncore in ["R", "r"]: + menuSelection() + +def chatConnA(menuch): + if menuch in ["A", "a"]: + pyCHATA() + elif menuch in ["B", "b"]: + pyCHATB() + elif menuch in ["C", "c"]: + pyCHATC() + +def chatConnB(pyCHATA): + if pyCHATA in ["A", "a"]: + clear() + blogo() + localchatsendA() + elif pyCHATA in ["B", "b"]: + clear() + blogo() + localchatnewA() + elif pyCHATA in ["C", "c"]: + clear() + blogo() + localchatlistA() + +def chatConnC(pyCHATB): + if pyCHATB in ["A", "a"]: + clear() + blogo() + localchatsendB() + elif pyCHATB in ["B", "b"]: + clear() + blogo() + localchatnewB() + elif pyCHATB in ["C", "c"]: + clear() + blogo() + localchatlistB() + +def chatConnD(pyCHATC): + if pyCHATC in ["A", "a"]: + clear() + blogo() + localchatsendC() + elif pyCHATC in ["B", "b"]: + clear() + blogo() + localchatnewC() + elif pyCHATC in ["C", "c"]: + clear() + blogo() + localchatlistC() + +def platfformsLOCALcontrol(platf): + if platf in ["A", "a"]: + aaccPPiTippinMe() + elif platf in ["B", "b"]: + aaccPPiTallyCo() + elif platf in ["C", "c"]: + mempoolmenu() + elif platf in ["D", "d"]: + clear() + blogo() + CoingeckoPP() + elif platf in ["E", "e"]: + rateSX() + elif platf in ["F", "f"]: + bwtConn() + elif platf in ["G", "g"]: + aaccPPiLNBits() + elif platf in ["H", "h"]: + aaccPPiLNPay() + elif platf in ["I", "i"]: + aaccPPiOpenNode() + elif platf in ["J", "j"]: + satnodeMenu() + elif platf in ["K", "k"]: + weatherMenu() + elif platf in ["L", "l"]: + gameroom() + elif platf in ["M", "m"]: + whalalConn() + elif platf in ["S", "s"]: + slushpoolLOCALOnchainONLY() + elif platf in ["R", "r"]: + menuSelection() + +def platfformsLOCALcontrolOnchainONLY(platf): + if platf in ["A", "a"]: + aaccPPiTippin() + elif platf in ["B", "b"]: + aaccPPiTallyCo() + elif platf in ["C", "c"]: + mempoolmenuOnchainONLY() + elif platf in ["D", "d"]: + clear() + blogo() + CoingeckoPP() + elif platf in ["E", "e"]: + rateSXOncainONLY() + elif platf in ["F", "f"]: + bwtConn() + elif platf in ["G", "g"]: + aaccPPiLNBits() + elif platf in ["H", "h"]: + aaccPPiLNPay() + elif platf in ["I", "i"]: + aaccPPiOpenNode() + elif platf in ["J", "j"]: + satnodeMenuOnchainONLY() + elif platf in ["K", "k"]: + weatherMenuOnchainONLY() + elif platf in ["L", "l"]: + gameroom() + elif platf in ["M", "m"]: + whalalConn() + elif platf in ["S", "s"]: + slushpoolLOCALOnchainONLY() + elif platf in ["R", "r"]: + menuSelection() + +#----------------------------REMOTE MENUS + +def mainmenuREMOTEcontrol(menuS): #Execution of the Main Menu options + if menuS in ["A", "a"]: + while True: + try: + clear() + close() + remotegetblock() + tmp() + except: + break + elif menuS in ["B", "b"]: + bitcoincoremenuREMOTE() + elif menuS in ["L", "l"]: + lightningnetworkREMOTE() + elif menuS in ["P", "p"]: + APIMenuLOCAL() + elif menuS in ["X", "x"]: + dnt() + elif menuS in ["S", "s"]: + settings4Remote() + elif menuS in ["Q", "q"]: + os._exit(0) + apisnd.close() + donation.close() + clone.close() + logos.close() + feed.close() + sysinf.close() + nodeconnection.close() + exit() + elif menuS in ["T", "t"]: #Test feature fast access + clear() + delay_print("\033[1;32;40mWake up, Neo...") + t.sleep(2) + clear() + delay_print("The Matrix has you...") + t.sleep(2) + clear() + delay_print("Follow the white rabbit.") + t.sleep(3) + clear() + print("Knock, knock, Neo.\033[0;37;40m\n") + t.sleep(2) + clear() + t.sleep(3) + screensv() + elif menuS in ["nym", "Nym", "NYM", "nYm", "nyM", "NYm", "NyM", "nYM"]: + clear() + blogo() + robotNym() + elif menuS in ["wt", "WT", "Wt", "wT"]: + clear() + blogo() + callGitWardenTerminal() + +def bitcoincoremenuREMOTEcontrol(bcore): + if bcore in ["A", "a"]: + while True: + try: + clear() + blogo() + sysinfo() + close() + remoteconsole() + t.sleep(5) + except: + break + elif bcore in ["B", "b"]: + remotegetblockcount() + elif bcore in ["C", "c"]: + runTheNumbersMenuConn() + elif bcore in ["D", "d"]: + try: + clear() + blogo() + sysinfo() + close() + decodeQR() + input("Continue...") + except: + pass + elif bcore in ["E", "e"]: + miscellaneousLOCAL() + elif bcore in ["O", "o"]: + bitcoincoremenuREMOTEOPRETURN() + elif bcore in ["Z", "z"]: + statsConn() + elif bcore in ["M", "m"]: + miningConn() + elif bcore in ["U", "u"]: + untxsConn() + +def bitcoincoremenuREMOTEcontrolO(oreturn): + if oreturn in ["A", "a"]: + clear() + blogo() + opreturn() + elif oreturn in ["B", "b"]: + clear() + blogo() + opreturn_view() + elif oreturn in ["C", "c"]: + clear() + blogo() + opretminer() + +def lightningnetworkREMOTEcontrol(lncore): + if lncore in ["A", "a"]: + clear() + blogo() + getnewinvoice() + elif lncore in ["B", "b"]: + clear() + blogo() + payinvoice() + elif lncore in ["C", "c"]: + clear() + blogo() + getnewaddress() + elif lncore in ["D", "d"]: + clear() + blogo() + listinvoice() + elif lncore in ["E", "e"]: + clear() + blogo() + channelbalance() + elif lncore in ["F", "f"]: + clear() + blogo() + channels() + elif lncore in ["G", "g"]: + clear() + blogo() + balanceOC() + elif lncore in ["H", "h"]: + clear() + blogo() + listonchaintxs() + elif lncore in ["I", "i"]: + clear() + blogo() + getinfo() + elif lncore in ["Z", "z"]: + clear() + blogo() + stalnConn() + elif lncore in ["T", "t"]: + clear() + blogo() + ranConn() + elif lncore in ["Q", "q"]: + if os.path.isfile("lnbitSN.conf"): + lnbitsLNURLwList() + elif lncore in ["S", "s"]: + if os.path.isfile("lnbitSN.conf"): + lnbitsLNURLw() + elif lncore in ["R", "r"]: + menuSelection() + +def menuC(menuO): # Donation access Menu + if menuO in ["A", "a"]: + dntDev() + elif menuO in ["B", "b"]: + dntTst() + elif menuO in ["R", "r"]: + menuSelection() + +def menuCOnchainONLY(menuO): # Donation access Menu + if menuO in ["A", "a"]: + dntDevOnchainONLY() + elif menuO in ["B", "b"]: + dntTstOnchainONLY() + elif menuO in ["R", "r"]: + menuSelection() + +def menuD(menuN): # Satnode access Menu + if menuN in ["A", "a"]: + satnode() + elif menuN in ["B", "b"]: + readFile() + elif menuN in ["S", "s"]: + try: + clear() + blogo() + close() + 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 in ["F", "f"]: + try: + clear() + blogo() + close() + apisenderFile() + t.sleep(30) + menuSelection() + except: + menuSelection() + elif message in ["T", "t"]: + try: + clear() + blogo() + close() + apisender() + t.sleep(30) + menuSelection() + except: + menuSelection() + except: + menuSelection() + elif menuN in ["C", "c"]: + try: + print("\n\t This only will work on Linux or Unix systems.\n") + a = input("Do we continue? Y/n: ") + if a in ["Y", "y"]: + gitclone() + else: + menuSelection() + except: + pass + elif menuN in ["R", "r"]: + menuSelection() + +def menuE(menuQ): # Dev Donation access Menu + if menuQ in ["A", "a"]: + try: + clear() + blogo() + close() + donationPayNym() + t.sleep(50) + menuSelection() + except: + menuSelection() + elif menuQ in ["B", "b"]: + try: + clear() + blogo() + close() + donationAddr() + t.sleep(50) + menuSelection() + except: + menuSelection() + elif menuQ in ["C", "c"]: + try: + clear() + blogo() + close() + donationLN() + t.sleep(50) + menuSelection() + except: + menuSelection() + elif menuQ in ["R", "r"]: + menuSelection() + +def menuEOnchainONLY(menuQ): # Dev Donation access Menu + if menuQ in ["A", "a"]: + try: + clear() + blogo() + close() + donationPayNym() + t.sleep(50) + menuSelection() + except: + menuSelection() + elif menuQ in ["B", "b"]: + try: + clear() + blogo() + close() + donationAddr() + t.sleep(50) + menuSelection() + except: + menuSelection() + elif menuQ in ["C", "c"]: + try: + clear() + blogo() + close() + donationLN() + t.sleep(50) + menuSelection() + except: + menuSelection() + elif menuQ in ["R", "r"]: + menuSelection() + +def menuF(menuV): # Tester Donation access Menu + if menuV in ["A", "a"]: + try: + clear() + blogo() + close() + donationAddrTst() + t.sleep(50) + menuSelection() + except: + menuSelection() + elif menuV in ["B", "b"]: + try: + clear() + blogo() + close() + donationLNTst() + t.sleep(50) + menuSelection() + except: + menuSelection() + elif menuV in ["R", "r"]: + menuSelection() + +def menuFOnchainONLY(menuV): # Tester Donation access Menu + if menuV in ["A", "a"]: + try: + clear() + blogo() + close() + donationAddrTst() + t.sleep(50) + menuSelection() + except: + menuSelection() + elif menuV in ["B", "b"]: + try: + clear() + blogo() + close() + donationLNTst() + t.sleep(50) + menuSelection() + except: + menuSelection() + elif menuV in ["R", "r"]: + menuSelection() +#--------------------------------------------------------------------------------- +def testClockRemote(): + b = rpc('getblockcount') + c = str(b) + a = c + output = render(str(c), colors=[settingsClock['colorA'], settingsClock['colorB']], align='left') + print(output) + print(""" + + ------------------------- + Front Color: {} + Back Color: {} + ------------------------- + + """.format(settingsClock['colorA'], settingsClock['colorB'])) + try: + print("<<< Cancel Control + C") + input("Enter To Apply...") + settingsClock["gradient"] = "color" + pickle.dump(settingsClock, open("pyblocksettingsClock.conf", "wb")) + except: + pass + + +#--------------------------------- End Main Menu execution -------------------------------- + + +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 not os.path.isdir("$HOME"): + dir = 'mkdir config' + os.system(dir) + + 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")) + + if os.path.isfile('config/blndconnect.conf'): # Check if the file 'bclock.conf' is in the same folder + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + else: + clear() + blogo() + if os.path.isfile('config/init.conf'): + pqr = pickle.load(open("config/init.conf", "rb")) + yesno = pqr + else: + yesno = input("Do you want to connect your Lightning Node? yes/no: ") + pickle.dump(yesno, open("config/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("config/blndconnect.conf", "wb")) # Save the file 'bclock.conf' + menuSelection() + + + except: + print("\n") + sys.exit(101) diff --git a/pybitblock/SPV/apisnd.py b/pybitblock/SPV/apisnd.py new file mode 100644 index 0000000..065fb23 --- /dev/null +++ b/pybitblock/SPV/apisnd.py @@ -0,0 +1,264 @@ +#Developer: Curly60e +#PyBLOCK its a clock of the Bitcoin blockchain. + +import os +import qrcode +import requests +import time as t +import sys +from nodeconnection import * +from pblogo import * +from logos import * + +def clear(): # clear the screen + os.system('cls' if os.name=='nt' else 'clear') + +def apisender(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + message = input("\nInsert your Message: ") + a = sys.getsizeof(message) + mini = 6000 + n = (a * 50) + if n <= mini: + q = str(mini) + elif n >= mini: + k = n + mini + q = str(k) + + url = 'https://api.blockstream.space/order' + sentby = " - PyBLOCK." + print("\n\tATENTION: YOU NEED TO PAY \033[1;31;40m" + q + "\033[0;37;40m MilliSats") + amountmsat = input("\nInsert the amount in MSats: ") + curl = 'curl -F ' "bid={} ".format(amountmsat) + '-F ' + ' "message=' + message + sentby + '" ' + url + sh = os.popen(curl) + clear() + blogo() + sh0 = sh.read() + while True: + if 'Bid too low' in sh0: + print("\n\t\033[1;31;40mATENTION: Per byte bid cannot be below 50 millisatoshis per byte.\033[0;37;40m\n") + print("Try again...\n") + message = input("\nInsert your Message: ") + a = sys.getsizeof(message) + mini = 6000 + n = (a * 50) + if n <= mini: + q = str(mini) + elif n >= mini: + k = n + mini + q = str(k) + + url = 'https://api.blockstream.space/order' + sentby = " - PyBLOCK." + print("\n\tATENTION: YOU NEED TO PAY \033[1;31;40m" + q + "\033[0;37;40m MilliSats") + amountmsat = input("\nInsert the amount in MSats: ") + curl = 'curl -F ' "bid={} ".format(amountmsat) + '-F ' + ' "message=' + message + sentby + '" ' + url + sh = os.popen(curl) + clear() + blogo() + sh0 = sh.read() + elif 'lightning_invoice' in sh0: + break + + sh1 = str(sh0) + shh = sh1.split(',') + invoice = str(shh[6]) + + #---------------Token----------- + authtoken = str(shh[0]) + authtoken1 = authtoken.split(':') + token = authtoken1[1] + #---------------End Token------- + + #---------------Order----------- + uuid = str(shh[1]) + uuid1 = uuid.split(':') + order = uuid1[1] + #---------------End Order------- + + #---------------Amount---------- + msat = str(shh[3]) + msat1 = msat.split(':') + amount = msat1[1] + #---------------End Amount------ + + orderid = str(shh[1]) + ln1 = invoice.split(':') + ln2 = str(ln1[1]) + cln = ln2.strip('"') + print("\n\033[0;37;40mYour Token Authorization: \033[1;31;40m" + token + "\033[0;37;40m") + print("\033[0;37;40mYour Order Number: \033[1;31;40m" + order + "\033[0;37;40m") + print("\033[0;37;40mAmount in MSats: \033[1;33;40m" + amount + "\033[0;37;40m\n") + clear() + blogo() + node_not = input("Do you want to pay this message with your node? Y/n: ") + if node_not in ["Y", "y"]: + lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} + lndconnectData = pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + if lndconnectload['ip_port']: + print("\nInvoice: " + cln + "\n") + payinvoice() + elif lndconnectload['ln']: + print("\nInvoice: " + cln + "\n") + localpayinvoice() + elif node_not in ["N", "n"]: + print("\033[1;30;47m") + qr.add_data(cln) + qr.print_ascii() + print("\033[0;37;40m") + print("\nLND Invoice: " + cln + "\n") + sh.close() + continue1 = input("Continue? Y: ") + if continue1 == "Y" or continue1 == "y": + donate() + else: + t.sleep(2) + +def apisenderFile(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + url = 'https://api.blockstream.space/order' + message = input("\nInsert the path to the File: ") + print("ATENTION: Minimum amount for sending a File is 50000 MSats") + amountmsat = input("\nInsert the amount in MSats: ") + curl = 'curl -F ' "bid={} ".format(amountmsat) + '-F ' + ' "file=@' + message + '" ' + url + sh = os.popen(curl) + sh0 = sh.read() + while True: + try: + if 'Bid too low' in sh0: + print("\n\t\033[1;31;40mATENTION: Per byte bid cannot be below 50 millisatoshis per byte.\033[0;37;40m\n") + print("Try again...\n") + url = 'https://api.blockstream.space/order' + message = input("\nInsert the path to the File: ") + print("ATENTION: Minimum amount for sending a File is 50000 MSats") + amountmsat = input("\nInsert the amount in MSats: ") + curl = 'curl -F ' "bid={} ".format(amountmsat) + '-F ' + ' "file=@' + message + '" ' + url + sh = os.popen(curl) + sh0 = sh.read() + elif 'lightning_invoice' in sh0: + break + except: + break + + sh1 = str(sh0) + shh = sh1.split(',') + invoice = str(shh[6]) + + #---------------Token----------- + authtoken = str(shh[0]) + authtoken1 = authtoken.split(':') + token = authtoken1[1] + #---------------End Token------- + + #---------------Order----------- + uuid = str(shh[1]) + uuid1 = uuid.split(':') + order = uuid1[1] + #---------------End Order------- + + #---------------Amount---------- + msat = str(shh[3]) + msat1 = msat.split(':') + amount = msat1[1] + #---------------End Amount------ + + orderid = str(shh[1]) + ln1 = invoice.split(':') + ln2 = str(ln1[1]) + cln = ln2.strip('"') + print("\n\033[0;37;40mYour Token Authorization: \033[1;31;40m" + token + "\033[0;37;40m") + print("\033[0;37;40mYour Order Number: \033[1;31;40m" + order + "\033[0;37;40m") + print("\033[0;37;40mAmount in MSats: \033[1;33;40m" + amount + "\033[0;37;40m") + clear() + blogo() + try: + node_not = input("Do you want to pay this message with your node? Y/n: ") + if node_not in ["Y", "y"]: + lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} + lndconnectData = pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + if lndconnectload['ip_port']: + print("\nInvoice: " + cln + "\n") + payinvoice() + elif lndconnectload['ln']: + print("\nInvoice: " + cln + "\n") + localpayinvoice() + elif node_not in ["N", "n"]: + print("\033[1;30;47m") + qr.add_data(cln) + qr.print_ascii() + print("\033[0;37;40m") + print("\nLND Invoice: " + cln) + sh.close() + continue1 = input("Continue? Y: ") + if continue1 == "Y" or continue1 == "y": + donate() + else: + t.sleep(2) + except: + pass + +def devAddr(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + print("\n\t\t\033[1;33;44mGive us some love and \033[1;31;44mDONATE\033[1;33;44m us! We will appreciate it. This will be a boost to continue this beautiful project! \033[0;37;40m") + url = 'https://api.tippin.me/v1/public/addinvoice/royalfield370' + response = requests.get(url) + responseB = str(response.text) + responseC = responseB + lnreq = responseC.split(',') + lnbc1 = lnreq[1] + lnbc1S = str(lnbc1) + lnbc1R = lnbc1S.split(':') + lnbc1W = lnbc1R[1] + ln = str(lnbc1W) + ln1 = ln.strip('"') + clear() + blogo() + try: + node_not = input("Do you want to pay this tip with your node? Y/n: ") + if node_not in ["Y", "y"]: + lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} + lndconnectData = pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + if lndconnectload['ip_port']: + print("\nInvoice: " + ln1 + "\n") + payinvoice() + elif lndconnectload['ln']: + print("\nInvoice: " + ln1 + "\n") + localpayinvoice() + elif node_not in ["N", "n"]: + print("\033[1;30;47m") + qr.add_data(ln1) + qr.print_ascii() + print("\033[0;37;40m") + print("LND Invoice: " + ln1) + response.close() + except: + pass + +def donate(): + print("""\t\t + \033[1;31;40mPyBLOCK\033[0;37;40m Menu + + \033[1;32;40mA.\033[0;37;40m Donate + <<< Back Control + C + \n\n""") + menuB = (input("\033[1;32;40mSelect option: \033[0;37;40m")) + if menuB in ["A", "a"]: + devAddr() diff --git a/pybitblock/SPV/bitcoin.pdf b/pybitblock/SPV/bitcoin.pdf new file mode 100644 index 0000000..1e19b73 Binary files /dev/null and b/pybitblock/SPV/bitcoin.pdf differ diff --git a/pybitblock/SPV/clockscript.py b/pybitblock/SPV/clockscript.py new file mode 100644 index 0000000..5f90a25 --- /dev/null +++ b/pybitblock/SPV/clockscript.py @@ -0,0 +1,153 @@ +import pickle +import os +import sys +import base64, codecs, json, requests +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'\u001b[38;5;27m{"■"*(x-1)}' + ) + for i in range(y) + ) + ] + +def blogo(): + + if os.path.isfile('config/pyblocksettings.conf') or os.path.isfile('config/pyblocksettings.conf'): # Check if the file 'bclock.conf' is in the same folder + settingsv = pickle.load(open("config/pyblocksettings.conf", "rb")) # Load the file 'bclock.conf' + settings = settingsv # Copy the variable pathv to 'path' + else: + settings = {"gradient":"", "design":"block", "colorA":"green", "colorB":"yellow"} + pickle.dump(settings, open("config/pyblocksettings.conf", "wb")) + + if settings["gradient"] == "grd": + output = render('PyBLOCK', gradient=[settings['colorA'], settings['colorB']], align='center', font=settings['design']) + else: + output = render('PyBLOCK', colors=[settings['colorA'], settings['colorB']], align='center', font=settings['design']) + + print(output) + +def artist(): # here we convert the result of the command 'getblockcount' on a random art design + while True: + try: + clear() + design() + except: + break + +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 + settingsv = pickle.load(open("config/pyblocksettingsClock.conf", "rb")) # Load the file 'bclock.conf' + settingsClock = settingsv # Copy the variable pathv to 'path' + else: + settingsClock = {"gradient":"", "design":"block", "colorA":"green", "colorB":"yellow"} + pickle.dump(settingsClock, open("config/pyblocksettingsClock.conf", "wb")) + bitcoinclient = path['bitcoincli'] + " getblockcount" + block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string + b = block + a = b + blogo() + output = render(str(b), colors=[settingsClock['colorA'], settingsClock['colorB']], align='center') + print("\x1b[?25l" + output) + bitcoinclient = path['bitcoincli'] + " getbestblockhash" + bb = os.popen(str(bitcoinclient)).read() + ll = bb + bitcoinclientgetblock = path['bitcoincli'] + " getblock " + ll + qq = os.popen(bitcoinclientgetblock).read() + yy = json.loads(qq) + mm = yy + outputsize = render(str(mm['size']) + " bytes", colors=[settingsClock['colorA'], settingsClock['colorB']], align='center', font='tiny') + print("\x1b[?25l" + outputsize) + outputtxs = render(str(mm['nTx']) + " txs", colors=[settingsClock['colorA'], settingsClock['colorB']], align='center', font='tiny') + print("\x1b[?25l" + outputtxs) + sh = int(mm['nTx']) / 4 + shq = int(sh) + ss = str(rectangle(shq)) + print(ss.replace("None","")) + while True: + x = a + bitcoinclient = path['bitcoincli'] + " getblockcount" + block = os.popen(str(bitcoinclient)).read() # 'getblockcount' convert to string + b = block + if b > a: + clear() + blogo() + output = render(str(b), colors=[settingsClock['colorA'], settingsClock['colorB']], align='center') + print("\a\x1b[?25l" + output) + bitcoinclient = path['bitcoincli'] + " getbestblockhash" + bb = os.popen(str(bitcoinclient)).read() + ll = bb + bitcoinclientgetblock = path['bitcoincli'] + " getblock " + ll + qq = os.popen(bitcoinclientgetblock).read() + yy = json.loads(qq) + mm = yy + outputsize = render(str(mm['size']) + " bytes", colors=[settingsClock['colorA'], settingsClock['colorB']], align='center', font='tiny') + print("\x1b[?25l" + outputsize) + outputtxs = render(str(mm['nTx']) + " txs", colors=[settingsClock['colorA'], settingsClock['colorB']], align='center', font='tiny') + print("\x1b[?25l" + outputtxs) + sh = int(mm['nTx']) / 4 + shq = int(sh) + ss = str(rectangle(shq)) + print(ss.replace("None","")) + t.sleep(10) + txs = str(mm['nTx']) + if txs == "1": + try: + p = subprocess.Popen(['curl', 'https://poptart.spinda.net']) + p.wait(5) + except subprocess.TimeoutExpired: + p.kill() + print("\033[0;37;40m\x1b[?25l") + clear() + close() + a = b + 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 + 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) diff --git a/pybitblock/SPV/clockscriptREMOTE.py b/pybitblock/SPV/clockscriptREMOTE.py new file mode 100644 index 0000000..5e1134b --- /dev/null +++ b/pybitblock/SPV/clockscriptREMOTE.py @@ -0,0 +1,89 @@ +import base64, codecs, json, requests +import pickle +import os +import sys +import simplejson as json +from cfonts import render, say + +ndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} +settingsClock = {"gradient":"", "design":"", "colorA":"", "colorB":""} + +def blogo(): + + if os.path.isfile('pyblocksettings.conf') or os.path.isfile('pyblocksettings.conf'): # Check if the file 'bclock.conf' is in the same folder + settingsv = pickle.load(open("pyblocksettings.conf", "rb")) # Load the file 'bclock.conf' + settings = settingsv # Copy the variable pathv to 'path' + else: + settings = {"gradient":"", "design":"block", "colorA":"green", "colorB":"yellow"} + pickle.dump(settings, open("pyblocksettings.conf", "wb")) + + if settings["gradient"] == "grd": + output = render('PyBLOCK', gradient=[settings['colorA'], settings['colorB']], align='center', font=settings['design']) + else: + output = render('PyBLOCK', colors=[settings['colorA'], settings['colorB']], align='center', font=settings['design']) + + print(output) + +def clear(): # clear the screen + os.system('cls' if os.name=='nt' else 'clear') + +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() + 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' + +def rpc(method, params=[]): + payload = json.dumps({ + "jsonrpc": "2.0", + "id": "minebet", + "method": method, + "params": params + }) + path = {"ip_port":"", "rpcuser":"", "rpcpass":"", "bitcoincli":""} + if os.path.isfile('bclock.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' + return requests.post(path['ip_port'], auth=(path['rpcuser'], path['rpcpass']), data=payload).json()['result'] + + +def remotegetblock(): + if os.path.isfile('pyblocksettingsClock.conf') or os.path.isfile('pyblocksettingsClock.conf'): # Check if the file 'bclock.conf' is in the same folder + settingsv = pickle.load(open("pyblocksettingsClock.conf", "rb")) # Load the file 'bclock.conf' + settingsClock = settingsv # Copy the variable pathv to 'path' + else: + settingsClock = {"gradient":"", "design":"block", "colorA":"green", "colorB":"yellow"} + pickle.dump(settingsClock, open("pyblocksettingsClock.conf", "wb")) + b = rpc('getblockcount') + c = str(b) + a = c + output = render(str(c), colors=[settingsClock['colorA'], settingsClock['colorB']], align='center') + print("\x1b[?25l" + output) + while True: + x = a + b = rpc('getblockcount') + c = str(b) + if c > a: + clear() + blogo() + output = render(str(c), colors=[settingsClock['colorA'], settingsClock['colorB']], align='center') + print("\a\x1b[?25l" + output) + a = c + +while True: + try: + clear() + blogo() + remotegetblock() + tmp() + except: + print("\n") + sys.exit(101) diff --git a/pybitblock/SPV/clone.py b/pybitblock/SPV/clone.py new file mode 100644 index 0000000..7f30795 --- /dev/null +++ b/pybitblock/SPV/clone.py @@ -0,0 +1,30 @@ +#Developer: Curly60e +#PyBLOCK its a clock of the Bitcoin blockchain. + + +import os +import os.path +import time as t + + +def gitclone(): + url = "https://github.com/curly60e/satellite" + os.system("git clone " + url) + os.system("mkdir satellite/api/examples/.gnupg") + os.system("gpg --full-generate-key --homedir satellite/api/examples/.gnupg") + +def satnode(): + try: + os.system("python3 satellite/api/examples/demo-rx.py &") + t.sleep(5) + os.system("python3 satellite/api/examples/api_data_reader.py --demo --plaintext ") + except: + os.system("ps -ef | grep api_data_reader.py | grep -v grep | awk '{print $2}' | xargs kill -9") + os.system("ps -ef | grep demo-rx.py | grep -v grep | awk '{print $2}' | xargs kill -9") + +def matrixsc(): + if os.path.isdir('$HOME/pyblock/terminal_matrix'): + print("OK Pass") + else: + url = "https://github.com/curly60e/terminal_matrix.git" + os.system("git clone " + url) diff --git a/pybitblock/SPV/config/bclock.conf b/pybitblock/SPV/config/bclock.conf new file mode 100644 index 0000000..ffcfa41 Binary files /dev/null and b/pybitblock/SPV/config/bclock.conf differ diff --git a/pybitblock/SPV/config/init.conf b/pybitblock/SPV/config/init.conf new file mode 100644 index 0000000..f217242 Binary files /dev/null and b/pybitblock/SPV/config/init.conf differ diff --git a/pybitblock/SPV/config/pyblocksettings.conf b/pybitblock/SPV/config/pyblocksettings.conf new file mode 100644 index 0000000..12f75a4 Binary files /dev/null and b/pybitblock/SPV/config/pyblocksettings.conf differ diff --git a/pybitblock/SPV/config/pyblocksettingsClock.conf b/pybitblock/SPV/config/pyblocksettingsClock.conf new file mode 100644 index 0000000..12f75a4 Binary files /dev/null and b/pybitblock/SPV/config/pyblocksettingsClock.conf differ diff --git a/pybitblock/SPV/config/selection.conf b/pybitblock/SPV/config/selection.conf new file mode 100644 index 0000000..55a5a9c Binary files /dev/null and b/pybitblock/SPV/config/selection.conf differ diff --git a/pybitblock/SPV/config/slushAPI.conf b/pybitblock/SPV/config/slushAPI.conf new file mode 100644 index 0000000..87d51da Binary files /dev/null and b/pybitblock/SPV/config/slushAPI.conf differ diff --git a/pybitblock/SPV/console.py b/pybitblock/SPV/console.py new file mode 100644 index 0000000..b7990f4 --- /dev/null +++ b/pybitblock/SPV/console.py @@ -0,0 +1,11 @@ +import os +import typer + + +def main(): + scriptpath = os.path.join(os.path.dirname(__file__), 'PyBlock.py') + os.system(f"python3 {scriptpath}") + + +if __name__ == "__main__": + typer.run(main) diff --git a/pybitblock/SPV/donation.py b/pybitblock/SPV/donation.py new file mode 100644 index 0000000..d5765c4 --- /dev/null +++ b/pybitblock/SPV/donation.py @@ -0,0 +1,149 @@ +#Developer: Curly60e +#PyBLOCK its a clock of the Bitcoin blockchain. + + +import requests +import qrcode +import pickle +from nodeconnection import * + +def donationAddr(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + url = 'bc1qjzaz34nv2ev55vfdu9m5qh0zq0fwcn6c7pkcrv' + print("\033[1;30;47m") + qr.add_data(url) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("Bitcoin Address Bech32: " + url) + +def donationPayNym(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + url = 'PM8TJhNTTq3YVocXuPtLjKx7pKkdUxqwTerWJ2j2a7dNitgyMmBPN6gK61yE17N2vgvQvKYokXktt6D6GZFTmocvDJhaUJfHt7ehEMmthjsT3NQHseFM' + print("\033[1;30;47m") + qr.add_data(url) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("PayNym: " + url) + +#Dev LN +def donationLN(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + amt = input("Amount: ") + curl = 'curl -X POST https://lnbits.com/api/v1/payments -d ' + "'{" + """"out": false, "amount": {}, "memo": "Donation" """.format(amt) + "}'" + """ -H "X-Api-Key: 1d646820055e4e2da218e801eaacfc94 " -H "Content-type: application/json" """ + sh = os.popen(curl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + q = d['payment_request'] + c = q.lower() + while True: + print("\033[1;30;47m") + qr.add_data(c) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("Lightning Invoice: " + c) + dn = str(d['checking_id']) + t.sleep(10) + checkcurl = 'curl -X GET https://lnbits.com/api/v1/payments/' + dn + """ -H "X-Api-Key: 1d646820055e4e2da218e801eaacfc94" -H "Content-type: application/json" """ + rsh = os.popen(checkcurl).read() + clear() + blogo() + nn = str(rsh) + dd = json.loads(nn) + db = dd['paid'] + if db is not True: + continue + + clear() + blogo() + tick() + bitLN['pd'] = "PAID" + +#Tester Address +def donationAddrTst(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + url = 'bc1qwtzwu2evtchkvnf3ey6520yprsyv7vrjvhula5' + print("\033[1;30;47m") + qr.add_data(url) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("Bitcoin Address Bech32: " + url) + +#Tester LN +def donationLNTst(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + url = 'https://api.tippin.me/v1/public/addinvoice/__B__T__C__' + response = requests.get(url) + responseB = str(response.text) + responseC = responseB + lnreq = responseC.split(',') + lnbc1 = lnreq[1] + lnbc1S = str(lnbc1) + lnbc1R = lnbc1S.split(':') + lnbc1W = lnbc1R[1] + ln = str(lnbc1W) + ln1 = ln.strip('"') + node_not = input("Do you want to pay this tip with your node? Y/n: ") + if node_not in ["Y", "y"]: + lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} + lndconnectData = pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + if lndconnectload['ip_port']: + print("\nInvoice: " + ln1 + "\n") + payinvoice() + elif lndconnectload['ln']: + print("\nInvoice: " + ln1 + "\n") + localpayinvoice() + elif node_not in ["N", "n"]: + print("\033[1;30;47m") + qr.add_data(ln1) + qr.print_ascii() + print("\033[0;37;40m") + print("LND Invoice: " + ln1) + qr.clear() + response.close() + +def decodeQR(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + url = input("Insert your Bitcoin Address to show the QRCode: ") + print("\033[1;30;47m") + qr.add_data(url) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("Bitcoin Address: " + url) diff --git a/pybitblock/SPV/feed.py b/pybitblock/SPV/feed.py new file mode 100644 index 0000000..3edf826 --- /dev/null +++ b/pybitblock/SPV/feed.py @@ -0,0 +1,24 @@ +#Developer: Curly60e +#PyBLOCK its a clock of the Bitcoin blockchain. + + +import os +import os.path +import time as t + + +def readFile(): + try: + print ("\n\033[1;34;40mWaiting for new data...\n") + downloadsFolder = 'downloads/' + while True: + if not os.listdir(downloadsFolder): + continue + else: + print("\t\t\n\033[1;33;40mNew message from Space just arrived...\033[0;37;40m\n") + os.system("cat downloads/*") + os.system("rm downloads/*") + + except: + os.system("ps -ef | grep api_data_reader.py | grep -v grep | awk '{print $2}' | xargs kill -9") + os.system("ps -ef | grep demo-rx.py | grep -v grep | awk '{print $2}' | xargs kill -9") diff --git a/pybitblock/SPV/lnd.py b/pybitblock/SPV/lnd.py new file mode 100644 index 0000000..6a7eed5 --- /dev/null +++ b/pybitblock/SPV/lnd.py @@ -0,0 +1,108 @@ +import base64 +import os +from os.path import expanduser +import codecs +import grpc +import sys + +from grpc_generated import router_pb2_grpc as lnrouterrpc, router_pb2 as lnrouter, rpc_pb2_grpc as lnrpc, rpc_pb2 as ln + +MESSAGE_SIZE_MB = 50 * 1024 * 1024 + + +def debug(message): + sys.stderr.write(message + "\n") + + +class Lnd: + def __init__(self, lnd_dir, server): + os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA' + lnd_dir = expanduser(lnd_dir) + combined_credentials = self.get_credentials(lnd_dir) + channel_options = [ + ('grpc.max_message_length', MESSAGE_SIZE_MB), + ('grpc.max_receive_message_length', MESSAGE_SIZE_MB) + ] + grpc_channel = grpc.secure_channel(server, combined_credentials, channel_options) + self.stub = lnrpc.LightningStub(grpc_channel) + self.router_stub = lnrouterrpc.RouterStub(grpc_channel) + self.graph = None + self.info = None + self.channels = None + + @staticmethod + def get_credentials(lnd_dir): + tls_certificate = open(lnd_dir + '/tls.cert', 'rb').read() + ssl_credentials = grpc.ssl_channel_credentials(tls_certificate) + macaroon = codecs.encode(open(lnd_dir + '/data/chain/bitcoin/mainnet/admin.macaroon', 'rb').read(), 'hex') + auth_credentials = grpc.metadata_call_credentials(lambda _, callback: callback([('macaroon', macaroon)], None)) + combined_credentials = grpc.composite_channel_credentials(ssl_credentials, auth_credentials) + return combined_credentials + + def get_info(self): + if self.info is None: + self.info = self.stub.GetInfo(ln.GetInfoRequest()) + return self.info + + def get_graph(self): + if self.graph is None: + self.graph = self.stub.DescribeGraph(ln.ChannelGraphRequest(include_unannounced=True)) + return self.graph + + def get_own_pubkey(self): + return self.get_info().identity_pubkey + + def get_edges(self): + return self.get_graph().edges + + def generate_invoice(self, memo, amount): + invoice_request = ln.Invoice( + memo=memo, + value=amount, + ) + add_invoice_response = self.stub.AddInvoice(invoice_request) + return self.decode_payment_request(add_invoice_response.payment_request) + + def decode_payment_request(self, payment_request): + request = ln.PayReqString( + pay_req=payment_request, + ) + return self.stub.DecodePayReq(request) + + def get_channels(self): + if self.channels is None: + request = ln.ListChannelsRequest( + active_only=True, + ) + self.channels = self.stub.ListChannels(request).channels + return self.channels + + def get_route(self, pub_key, amount, ignored_edges, ignored_nodes, first_hop_channel_id): + if pub_key: + last_hop_pubkey = base64.b16decode(pub_key, True) + else: + last_hop_pubkey = None + request = ln.QueryRoutesRequest( + pub_key=self.get_own_pubkey(), + last_hop_pubkey=last_hop_pubkey, + amt=amount, + ignored_edges=ignored_edges, + ignored_nodes=ignored_nodes, + use_mission_control=True, + outgoing_chan_id=first_hop_channel_id, + ) + try: + response = self.stub.QueryRoutes(request) + return response.routes + except: + return None + + def send_payment(self, payment_request, route): + request = lnrouter.SendToRouteRequest(route=route) + request.payment_hash = self.hex_string_to_bytes(payment_request.payment_hash) + return self.router_stub.SendToRoute(request) + + @staticmethod + def hex_string_to_bytes(hex_string): + decode_hex = codecs.getdecoder("hex_codec") + return decode_hex(hex_string)[0] diff --git a/pybitblock/SPV/logic.py b/pybitblock/SPV/logic.py new file mode 100644 index 0000000..bff0ef9 --- /dev/null +++ b/pybitblock/SPV/logic.py @@ -0,0 +1,153 @@ +import sys + +from routes import Routes + +DEFAULT_BASE_FEE_SAT_MSAT = 1000 +DEFAULT_FEE_RATE_MSAT = 0.001 + + +def debug(message): + sys.stderr.write(message + "\n") + + +def debugnobreak(message): + sys.stderr.write(message) + + +class Logic: + def __init__(self, lnd, first_hop_channel, last_hop_channel, amount, channel_ratio, excluded, max_fee_factor): + self.lnd = lnd + self.first_hop_channel = first_hop_channel + self.last_hop_channel = last_hop_channel + self.amount = amount + self.channel_ratio = channel_ratio + self.excluded = [] + if excluded: + self.excluded = excluded + self.max_fee_factor = max_fee_factor + + def rebalance(self): + if self.last_hop_channel: + debug(("Sending {:,} satoshis to rebalance to channel with ID %d" + % self.last_hop_channel.chan_id).format(self.amount)) + else: + debug("Sending {:,} satoshis.".format(self.amount)) + if self.channel_ratio != 0.5: + debug("Channel ratio used is %d%%" % int(self.channel_ratio * 100)) + if self.first_hop_channel: + debug("Forced first channel has ID %d" % self.first_hop_channel.chan_id) + + payment_request = self.generate_invoice() + routes = Routes(self.lnd, payment_request, self.first_hop_channel, self.last_hop_channel) + + self.initialize_ignored_channels(routes) + + tried_routes = [] + while routes.has_next(): + route = routes.get_next() + + success = self.try_route(payment_request, route, routes, tried_routes) + if success: + return True + debug("Could not find any suitable route") + return False + + def try_route(self, payment_request, route, routes, tried_routes): + if self.route_is_invalid(route, routes): + return False + + tried_routes.append(route) + debug("") + debug("Trying route #%d" % len(tried_routes)) + debug(Routes.print_route(route)) + + response = self.lnd.send_payment(payment_request, route) + is_successful = response.failure.code == 0 + if is_successful: + debug("") + debug("") + debug("") + debug("Success! Paid fees: %s sat (%s msat)" % (route.total_fees, route.total_fees_msat)) + debug("Successful route:") + debug(Routes.print_route(route)) + debug("") + debug("") + debug("") + return True + else: + self.handle_error(response, route, routes) + return False + + @staticmethod + def handle_error(response, route, routes): + code = response.failure.code + failure_source_pubkey = Logic.get_failure_source_pubkey(response, route) + if code == 15: + debugnobreak("Temporary channel failure, ") + routes.ignore_edge_on_route(failure_source_pubkey, route) + elif code == 18: + debugnobreak("Unknown next peer, ") + routes.ignore_edge_on_route(failure_source_pubkey, route) + elif code == 12: + debugnobreak("Fee insufficient, ") + routes.ignore_edge_on_route(failure_source_pubkey, route) + else: + debug(repr(response)) + debug("Unknown error code %s" % repr(code)) + + @staticmethod + def get_failure_source_pubkey(response, route): + if response.failure.failure_source_index == 0: + failure_source_pubkey = route.hops[-1].pub_key + else: + failure_source_pubkey = route.hops[response.failure.failure_source_index - 1].pub_key + return failure_source_pubkey + + def route_is_invalid(self, route, routes): + first_hop = route.hops[0] + if self.low_local_ratio_after_sending(first_hop, route.total_amt): + debugnobreak("Low local ratio after sending, ") + routes.ignore_first_hop(self.get_channel_for_channel_id(first_hop.chan_id)) + return True + if self.fees_too_high(route): + routes.ignore_node_with_highest_fee(route) + return True + return False + + def low_local_ratio_after_sending(self, first_hop, total_amount): + if self.first_hop_channel: + # Just use the computed/specified amount to drain the first hop, ignoring fees + return False + channel_id = first_hop.chan_id + channel = self.get_channel_for_channel_id(channel_id) + + remote = channel.remote_balance + total_amount + local = channel.local_balance - total_amount + ratio = float(local) / (remote + local) + return ratio < self.channel_ratio + + def fees_too_high(self, route): + hops_with_fees = len(route.hops) - 1 + lnd_fees = hops_with_fees * (DEFAULT_BASE_FEE_SAT_MSAT + (self.amount * DEFAULT_FEE_RATE_MSAT)) + limit = self.max_fee_factor * lnd_fees + return route.total_fees_msat > limit + + def generate_invoice(self): + if self.last_hop_channel: + memo = "Rebalance of channel with ID %d" % self.last_hop_channel.chan_id + else: + memo = "Rebalance of channel with ID %d" % self.first_hop_channel.chan_id + return self.lnd.generate_invoice(memo, self.amount) + + def get_channel_for_channel_id(self, channel_id): + for channel in self.lnd.get_channels(): + if channel.chan_id == channel_id: + return channel + + def initialize_ignored_channels(self, routes): + for channel in self.lnd.get_channels(): + if self.low_local_ratio_after_sending(channel, self.amount): + routes.ignore_first_hop(channel, show_message=False) + if channel.chan_id in self.excluded: + debugnobreak("Channel is excluded, ") + routes.ignore_first_hop(channel) diff --git a/pybitblock/SPV/logos.py b/pybitblock/SPV/logos.py new file mode 100644 index 0000000..f1b6ff2 --- /dev/null +++ b/pybitblock/SPV/logos.py @@ -0,0 +1,112 @@ +#Developer: Curly60e +#PyBLOCK its a clock of the Bitcoin blockchain. + + +def logoA(): + print("""\n\n\033[1;33;40m + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*****@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@@@****************************#@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@***************************************@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@***********************************************@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@*****************************************************@@@@@@@@@@@@@ + @@@@@@@@@@@***********************************************************@@@@@@@@@@ + @@@@@@@@@****************************** *****************************@@@@@@@@ + @@@@@@@******************************* *** ***********************@@@@@@ + @@@@@@********************** .**** **** *************************@@@@@ + @@@@*********************** ,* **************************@@@@ + @@@**************************** ***************************@@ + @@****************************** *. **********************#@ + @@***************************** ******** *********************@ + @****************************** *********** ********************** + @***************************** *********** ********************** + @***************************** *********************** + ***************************** ************************** + @*************************** ******** ************************* + @*************************** ***********. *********************** + @********************* *** ************* *********************** + @@******************* ************ **********************@ + @@******************** **********************@@ + @@@************************** ,***********************@@ + @@@@#*********************** *** *. **************************@@@@ + @@@@@@********************* **** ***********************************@@@@@ + @@@@@@@**************************** **********************************@@@@@@ + @@@@@@@@@***************************************************************@@@@@@@@ + @@@@@@@@@@@**********************************************************,@@@@@@@@@@ + @@@@@@@@@@@@@@*****************************************************@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@***********************************************@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@***************************************@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@@@#***************************@@@@@@@@@@@@@@@@@@@@@@@@@@\033[0;37;40m + """) + +def logoB(): + print("""\n\n\033[1;33;40m + ///// + ////////////////////////////% + /////////////////////////////////////// + /////////////////////////////////////////////// + ///////////////////////////////////////////////////// + /////////////////////////////////////////////////////////// + ////////////////////////////// ///////////////////////////// + /////////////////////////////// /// /////////////////////// + ////////////////////// .//// //// ///////////////////////// + /////////////////////// */ ////////////////////////// + //////////////////////////// *////////////////////////// + ////////////////////////////// /. ////////////////////// + ///////////////////////////// //////// ///////////////////// + ////////////////////////////// //////////* ////////////////////// + ///////////////////////////// /////////// ////////////////////// + ///////////////////////////// /////////////////////// + ///////////////////////////// *///////////////////////// + /////////////////////////// //////// ///////////////////////// + /////////////////////////// ///////////, /////////////////////// + ///////////////////// /// ///////////// /////////////////////// + /////////////////// //////////// ////////////////////// + //////////////////// ////////////////////// + ////////////////////////// */////////////////////// + %/////////////////////// /// /. ////////////////////////// + ///////////////////// //// /////////////////////////////////// + //////////////////////////// ////////////////////////////////// + /////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////* + ///////////////////////////////////////////////////// + /////////////////////////////////////////////// + /////////////////////////////////////// + %/////////////////////////// + /////\033[0;37;40m + """) + +def logoC(): + print("""\n\n\033[1;33;40m + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@ + @@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@ + @@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@ + @@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&& &&&&&&&&&&&&&&&&&&&&&&&@@@@@@ + @@@@@@&&&&&&&&&&&&&&&&&&&&&& *&&&& &&&& &&&&&&&&&&&&&&&&&&&&&&&&&@@@@@ + @@@@&&&&&&&&&&&&&&&&&&&&&&& #& &&&&&&&&&&&&&&&&&&&&&&&&&&@@@@ + @@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&. %&&&&&&&&&&&&&&&&&&&&&&&&&&@@ + @@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &, &&&&&&&&&&&&&&&&&&&&&&@@ + @@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&. &&&&&&&& &&&&&&&&&&&&&&&&&&&&&@ + @&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&% &&&&&&&&&&&&&&&&&&&&&& + @&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&& + @&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&&& + &&&&&&&&&&&&&&&&&&&&&&&&&&&&& %&&&&&&&&&&&&&&&&&&&&&&&&& + @&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&& &&&&&&&&&&&&&&&&&&&&&&&&& + @&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&/ &&&&&&&&&&&&&&&&&&&&&&& + @&&&&&&&&&&&&&&&&&&&&& &&& &&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&&& + @@&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&&@ + @@&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&&@@ + @@@&&&&&&&&&&&&&&&&&&&&&&&&&& %&&&&&&&&&&&&&&&&&&&&&&&@@ + @@@@@&&&&&&&&&&&&&&&&&&&&&&& &&& &, &&&&&&&&&&&&&&&&&&&&&&&&&&@@@@ + @@@@@@&&&&&&&&&&&&&&&&&&&&& &&&& &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@ + @@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@ + @@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@ + @@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@ + @@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@@@@@@ + @@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@@\033[0;37;40m + """) diff --git a/pybitblock/SPV/nodeconnection.py b/pybitblock/SPV/nodeconnection.py new file mode 100644 index 0000000..3fd2079 --- /dev/null +++ b/pybitblock/SPV/nodeconnection.py @@ -0,0 +1,1425 @@ +#Developer: Curly60e +#Tester: __B__T__C__ +#ℙ𝕪𝔹𝕃𝕆ℂ𝕂 𝕚𝕥𝕤 𝕒 𝔹𝕚𝕥𝕔𝕠𝕚𝕟 𝔻𝕒𝕤𝕙𝕓𝕠𝕒𝕣𝕕 𝕨𝕚𝕥𝕙 ℂ𝕪𝕡𝕙𝕖𝕣𝕡𝕦𝕟𝕜 𝕒𝕖𝕤𝕥𝕙𝕖𝕥𝕚𝕔. + + +import base64, codecs, json, requests +import pickle +import os +import os.path +import qrcode +import sys +import simplejson as json +import time as t +import numpy as np +from cfonts import render, say +from art import * +from pblogo import * +from PIL import Image +from robohash import Robohash + + +lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} +settingsClock = {"gradient":"", "design":"", "colorA":"", "colorB":""} + + +def clear(): # clear the screen + os.system('cls' if os.name=='nt' else 'clear') +def closed(): + print("<<< Back Control + C.\n\n") + +#-------------------------RPC BITCOIN NODE CONNECTION + +def rpc(method, params=[]): + payload = json.dumps({ + "jsonrpc": "2.0", + "id": "minebet", + "method": method, + "params": params + }) + path = {"ip_port":"", "rpcuser":"", "rpcpass":"", "bitcoincli":""} + if os.path.isfile('bclock.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' + return requests.post(path['ip_port'], auth=(path['rpcuser'], path['rpcpass']), data=payload).json()['result'] + +def remoteHalving(): + + b = rpc('getblockcount') + c = str(b) + oneh = 0 - int(c) + 210000 + twoh = 210000 - int(c) + 210000 + thrh = 420000 - int(c) + 210000 + forh = 630000 - int(c) + 210000 + fifh = 840000 - int(c) + 210000 + sixh = 1050000 - int(c) + 210000 + sevh = 1260000 - int(c) + 210000 + eith = 1470000 - int(c) + 210000 + ninh = 1680000 - int(c) + 210000 + tenh = 1890000 - int(c) + 210000 + + q = """ + \033[0;37;40m------------------- HALVING HISTORY ------------------- + + 1st Halving: in {} Blocks {} + 2nd Halving: in {} Blocks {} + 3rd Halving: in {} Blocks {} + 4th Halving: in {} Blocks {} + 5th Halving: in {} Blocks {} + 6th Halving: in {} Blocks {} + 7th Halving: in {} Blocks {} + 8th Halving: in {} Blocks {} + 9th Halving: in {} Blocks {} + 10th Halving: in {} Blocks {} + + ------------------------------------------------------- + """.format("0" if int(c) == 210000 else oneh,"\033[1;32;40mCOMPLETE\033[0;37;40m","0" if int(c) == 420000 else twoh,"\033[1;32;40mCOMPLETE\033[0;37;40m", "0" if int(c) == 630000 else thrh,"\033[1;32;40mCOMPLETE\033[0;37;40m","0" if int(c) == 840000 else forh,"\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 840000 else "\033[1;35;40mPENDING\033[0;37;40m", "0" if int(c) >= 1050000 else fifh , "\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 1050000 else "\033[1;35;40mPENDING\033[0;37;40m", sixh, "\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 1260000 else "\033[1;35;40mPENDING\033[0;37;40m", sevh,"\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 1470000 else "\033[1;35;40mPENDING\033[0;37;40m", eith,"\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 1680000 else "\033[1;35;40mPENDING\033[0;37;40m", ninh, "\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 1890000 else "\033[1;35;40mPENDING\033[0;37;40m", tenh, "\033[1;32;40mCOMPLETE\033[0;37;40m" if int(c) >= 1890000 else "\033[1;35;40mPENDING\033[0;37;40m") + print(q) + input("\nContinue...") + + +def remotegetblock(): + if os.path.isfile('pyblocksettingsClock.conf') or os.path.isfile('pyblocksettingsClock.conf'): # Check if the file 'bclock.conf' is in the same folder + settingsv = pickle.load(open("pyblocksettingsClock.conf", "rb")) # Load the file 'bclock.conf' + settingsClock = settingsv # Copy the variable pathv to 'path' + else: + settingsClock = {"gradient":"", "design":"block", "colorA":"green", "colorB":"yellow"} + pickle.dump(settingsClock, open("pyblocksettingsClock.conf", "wb")) + b = rpc('getblockcount') + c = str(b) + a = c + output = render(str(c), colors=[settingsClock['colorA'], settingsClock['colorB']], align='center') + print("\x1b[?25l" + output) + while True: + x = a + b = rpc('getblockcount') + c = str(b) + if c > a: + clear() + closed() + output = render(str(c), colors=[settingsClock['colorA'], settingsClock['colorB']], align='center') + print("\a\x1b[?25l" + output) + a = c + +def remotegetblockcount(): # get access to bitcoin-cli with the command getblockcount + while True: + try: + a = rpc('getblockchaininfo') + d = a + clear() + blogo() + closed() + print(""" + ---------------------------------------------------------------------------- + \tGET BLOCKCHAIN INFORMATION + Chain: {} + Blocks: {} + Best BlockHash: {} + Difficulty: {} + Verification Progress: {} + Size on Disk: {} + Pruned: {} + ---------------------------------------------------------------------------- + """.format(d['chain'], d['blocks'], d['bestblockhash'], d['difficulty'], d['verificationprogress'], d['size_on_disk'], d['pruned'])) + t.sleep(2) + except: + break + +def remoteconsole(): # get into the console from bitcoin-cli + 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") + while True: + cle = input("\033[1;32;40mconsole $>: \033[0;37;40m") + a = rpc(cle) + print(a) + +def runthenumbersConn(): + try: + b = rpc('gettxoutsetinfo') + c = str(b) + print(c) + input("\nContinue...") + except: + pass + +#-------------------------END RPC BITCOIN NODE CONNECTION + +def consoleLN(): # get into the console from bitcoin-cli + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + print("\t\033[0;37;40mThis is \033[1;33;40mLncli's \033[0;37;40mconsole. Type your respective commands you want to display.\n\n") + while True: + cle = input("\033[1;32;40mconsole $>: \033[0;37;40m") + lsd = os.popen(lndconnectload['ln'] + " " + cle) + lsd0 = lsd.read() + lsd1 = str(lsd0) + print(lsd1) + lsd.close() + +def locallistpeersQQ(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + lncli = " listpeers" + while True: + clear() + print("\033[1;32;40m") + blogo() + print("\033[0;37;40m") + print("<<< Back to the Main Menu Press Control + C.\n\n") + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + n = d['peers'] + try: + print("\n\tLIST PEERS\n") + for item_ in n: + s = item_ + hash = s['pub_key'] + rh = Robohash(hash) + rh.assemble(roboset='set1') + if not os.path.isfile(str(f'{hash}.png')): + with open(f'{hash}.png', "wb") as f: + rh.img.save(f, format="png") + + img_path = open(f'{hash}.png', "rb") + img = Image.open(img_path) + + h = 1 + w = int((img.width / img.height) * 5) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + img_path = open(f'{hash}.png', "rb") + img = Image.open(img_path) + + h = 1 + w = int((img.width / img.height) * 5) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + for x in range(h): + for y in range(w): + pix = img_arr[x][y] + print(get_color(pix[0], pix[1], pix[2]), sep='', end='') + print() + print("PubKey: " + s['pub_key'] + " @" + s['address']) + + nd = input("\nSelect PubKey: ") + for item in n: + s = item + nn = s['pub_key'] + if nd == nn: + hash = s['pub_key'] + rh = Robohash(hash) + rh.assemble(roboset='set1') + + img_path = open(f'{hash}.png', "rb") + img = Image.open(img_path) + + h = 20 + w = int((img.width / img.height) * 50) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + for x in range(h): + for y in range(w): + pix = img_arr[x][y] + print(get_color(pix[0], pix[1], pix[2]), sep='', end='') + print() + print("\n----------------------------------------------------------------------------------------------------") + print(""" + PEER DECODED\n + Bytes Sent: {} + Bytes Recv: {} + Sat Sent: {} sats + Sat Recv: {} sats + """.format(s['bytes_sent'], s['bytes_recv'], s['sat_sent'], s['sat_recv'])) + print("-----------------------------------------------------------------------------------------------------\n") + print("\n\tPeer: " + nd) + print("\033[1;30;47m") + qr.add_data(s['pub_key']) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + + pp = input("\nDo you want to disconnect? Y/n: ") + if pp in ["Y", "y"]: + lsd = os.popen(lndconnectload['ln'] + " disconnect" + " " + nd).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + print("\n\tDisconnected from peer " + nd) + input("\nContinue... ") + elif pp in ["N", "n"]: + input("\nContinue... ") + except: + break + +def localconnectpeer(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + try: + clear() + print("\033[1;32;40m") + blogo() + print("\033[0;37;40m") + print("<<< Back to the Main Menu Press Control + C.\n\n") + print("\n\tCONNECT TO NEW PEER\n") + a = input("Insert PeerID@IP:PORT: ") + lncli = " connect " + lsd = os.popen(lndconnectload['ln'] + lncli + a).read() + lsd0 = str(lsd) + print(lsd0) + input("\nContinue... ") + except: + pass + +def locallistchaintxns(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + lncli = " listchaintxns" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + n = d['transactions'] + while True: + clear() + print("\033[1;32;40m") + blogo() + print("\033[0;37;40m") + print("<<< Back to the Main Menu Press Control + C.\n\n") + print("\t\nTransactions\n") + try: + print("\n\tLIST ONCHAIN TRANSACTIONS\n") + for item_ in n: + s = item_ + + print("Transaction Hash: " + s['tx_hash'] + " " + s['amount'] + " sats") + nd = input("\nSelect RHash: ") + + for item in n: + s = item + nn = s['tx_hash'] + trx = s['dest_addresses'] + if nd == nn: + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \nONCHAIN TRANSACTION DECODED + Amount: {} sats + Tx Hash: {} + Block Hash: {} + Block Height: {} + Confirmations: {} + Destination: {} + """.format(s['amount'], s['tx_hash'], s['block_hash'], s['block_height'], s['num_confirmations'], trx)) + print("-----------------------------------------------------------------------------------------------------\n") + print("\nTransaction Hash") + print("\033[1;30;47m") + qr.add_data(s['tx_hash']) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + input("\nContinue... ") + except: + break + +def locallistinvoices(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + lncli = " listinvoices" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + n = d['invoices'] + while True: + clear() + print("\033[1;32;40m") + blogo() + print("\033[0;37;40m") + print("<<< Back to the Main Menu Press Control + C.\n\n") + print("\tInvoices\n") + try: + print("\n\tLIST INVOICES\n") + for item_ in n: + s = item_ + + print("Invoice: " + s['r_hash'] + " " + s['state']) + + nd = input("\nSelect RHash: ") + + for item in n: + s = item + nn = s['r_hash'] + if nd == nn: + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \nINVOICE DECODED + Memo: {} + Invoice: {} + Amount: {} sats + State: {} + """.format(s['memo'], s['payment_request'], s['amt_paid_sat'], s['state'])) + print("----------------------------------------------------------------------------------------------------\n") + print("\033[1;30;47m") + qr.add_data(s['payment_request']) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + input("\nContinue... ") + except: + break + +def locallistchannels(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + lncli = " listchannels" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + n = d['channels'] + while True: + clear() + print("\033[1;32;40m") + blogo() + print("\033[0;37;40m") + print("<<< Back to the Main Menu Press Control + C.\n\n") + print("\t\nChannels\n") + try: + print("\n\tLIST CHANNELS\n") + for item_ in n: + s = item_ + hash = s['remote_pubkey'] + rh = Robohash(hash) + rh.assemble(roboset='set1') + if not os.path.isfile(str(f'{hash}.png')): + with open(f'{hash}.png', "wb") as f: + rh.img.save(f, format="png") + + img_path = open(f'{hash}.png', "rb") + img = Image.open(img_path) + + h = 1 + w = int((img.width / img.height) * 5) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + img_path = open(f'{hash}.png', "rb") + img = Image.open(img_path) + + h = 1 + w = int((img.width / img.height) * 5) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + for x in range(h): + for y in range(w): + pix = img_arr[x][y] + print(get_color(pix[0], pix[1], pix[2]), sep='', end='') + print() + print("Node ID: " + s['remote_pubkey']) + + nd = input("\nSelect a Node ID: ") + for item in n: + s = item + nn = s['remote_pubkey'] + if nd == nn: + hash = s['remote_pubkey'] + rh = Robohash(hash) + rh.assemble(roboset='set1') + + img_path = open(f'{hash}.png', "rb") + img = Image.open(img_path) + + h = 20 + w = int((img.width / img.height) * 50) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + for x in range(h): + for y in range(w): + pix = img_arr[x][y] + print(get_color(pix[0], pix[1], pix[2]), sep='', end='') + print() + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tCHANNEL DECODED + Active: {} + Node ID: {} + Channel Point: {} + Channel Capacity: {} sats + Local Balance: {} sats + Remote Balance: {} sats + Total Sent: {} sats + Total Received: {} sats + """.format(s['active'], s['remote_pubkey'], s['channel_point'], s['capacity'], s['local_balance'], s['remote_balance'], s['total_satoshis_sent'], s['total_satoshis_received'])) + print("----------------------------------------------------------------------------------------------------\n") + + input("\nContinue... ") + except: + break + +def localgetinfo(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + lncli = " getinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + hash = d['identity_pubkey'] + rh = Robohash(hash) + rh.assemble(roboset='set1') + if not os.path.isfile(str(f'{hash}.png')): + with open(f'{hash}.png', "wb") as f: + rh.img.save(f, format="png") + + img_path = open(f'{hash}.png', "rb") + img = Image.open(img_path) + + h = 20 + w = int((img.width / img.height) * 50) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + img_path = open(f'{hash}.png', "rb") + img = Image.open(img_path) + + h = 20 + w = int((img.width / img.height) * 50) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + for x in range(h): + for y in range(w): + pix = img_arr[x][y] + print(get_color(pix[0], pix[1], pix[2]), sep='', end='') + print() + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tNODE INFORMATION + + Version: {} + Node ID: {} + Alias: {} + Color: {} + Pending Channels: {} + Active Channels: {} + Inactive Channels: {} + Peers: {} + URLS: {} + """.format(d['version'], d['identity_pubkey'], d['alias'], d['color'], d['num_pending_channels'], d['num_active_channels'], d['num_inactive_channels'], d['num_peers'], d['uris'])) + print("\033[1;30;47m") + qr.add_data(d['identity_pubkey']) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("----------------------------------------------------------------------------------------------------\n") + input("\nContinue... ") + +def localaddinvoice(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + lncli = " addinvoice" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + try: + amount = input("Amount in sats: ") + mem = input("Memo: ") + memo = mem.replace(" ","_") + lsd = os.popen(lndconnectload['ln'] + lncli + " --memo {}-PyBLOCK --amt {}".format(memo, amount)).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + print("\033[1;30;47m") + qr.add_data(d['payment_request']) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("Lightning Invoice: " + d['payment_request']) + b = str(d['payment_request']) + while True: + lsd = os.popen(lndconnectload['ln'] + " decodepayreq " + b).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + r = d['payment_hash'] + lsdn = os.popen(lndconnectload['ln'] + " lookupinvoice " + r).read() + lsdn0 = str(lsdn) + n = json.loads(lsdn0) + if n['state'] == 'SETTLED': + print("\033[1;32;40m") + clear() + blogo() + tick() + print("\033[0;37;40m") + t.sleep(2) + break + elif n['state'] == 'CANCELED': + print("\033[1;31;40m") + clear() + blogo() + canceled() + print("\033[0;37;40m") + t.sleep(2) + break + except: + pass + +def localpayinvoice(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + try: + invoiceN = input("Insert the invoice to pay: ") + invoice = invoiceN.lower() + lncli = " payinvoice " + lsd = os.popen(lndconnectload['ln'] + " decodepayreq " + invoice).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + if d['num_satoshis'] == "0": + amt = " --amt " + amount = input("Amount in satoshis: ") + os.system(lndconnectload['ln'] + lncli + invoice + amt + amount) + else: + os.system(lndconnectload['ln'] + lncli + invoice ) + t.sleep(2) + except: + pass + +def localgetnetworkinfo(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + lncli = " getnetworkinfo" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tLIGHTNING NETWORK INFORMATION + Numbers of Nodes: {} + Numbers of Channels: {} + Total Network Capacity: {} sats + Average Channel Size: {} + Minimum Channel Size: {} + Maximum Channel Size: {} + Median Channel Size: {} sats + Zombie channels: {} + """.format(d['num_nodes'], d['num_channels'], d['total_network_capacity'], d['avg_channel_size'], d['min_channel_size'], d['max_channel_size'], d['median_channel_size_sat'], d['num_zombie_chans'])) + print("----------------------------------------------------------------------------------------------------\n") + input("\nContinue... ") + +def localFullProtocol(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + + proto1 = """lncli listinvoices | grep "34349334" | tr -d '"' | tr -d ',' | sed 's/34349334/0a0a2d5079424c4f434b204d6573736167652052656365697665643a200a/g' | html2text | xxd -r -p | xargs --null""" + proto2 = """lncli listinvoices | grep "7629171" | tr -d '"' | tr -d ',' | sed 's/7629171/0a0a2d5079424c4f434b204d6573736167652052656365697665643a200a/g' | html2text | xxd -r -p | xargs --null""" + proto3 = """lncli listinvoices | grep "34343434" | tr -d '"' | tr -d ',' | sed 's/34343434/0a0a2d5079424c4f434b204d6573736167652052656365697665643a200a/g' | html2text | xxd -r -p | xargs --null""" + p1 = os.popen(proto1).read() + p2 = os.popen(proto2).read() + p3 = os.popen(proto3).read() + + proto1 = """lncli listpayments | grep "34349334" | tr -d '"' | tr -d ',' | sed 's/34349334/0a0a202d5079424c4f434b204d6573736167653a200a/g' | html2text | xxd -r -p | xargs --null""" + proto2 = """lncli listpayments | grep "7629171" | tr -d '"' | tr -d ',' | sed 's/7629171/0a0a202d5079424c4f434b204d6573736167653a200a/g' | html2text | xxd -r -p | xargs --null""" + proto3 = """lncli listpayments | grep "34343434" | tr -d '"' | tr -d ',' | sed 's/34343434/0a0a202d5079424c4f434b204d6573736167653a200a/g' | html2text | xxd -r -p | xargs --null""" + p1 = os.popen(proto1).list() + p2 = os.popen(proto2).list() + p3 = os.popen(proto3).list() + + + +def localkeysend(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + try: + closed() + print("\n\tYou are going to send a payment using KeySend - Note: You don't need any invoice, just your peer ID.\n") + lncli = " sendpayment " + node = input("Send to NodeID: ") + amount = input("Amount in sats: ") + while True: + if amount in ["", "0"]: + amount = input("\nAmount in sats: ") + else: + break + os.system( + f"""lncli sendpayment --keysend --d={node} --amt={amount}""" + + """ --final_cltv_delta=40""" + ) + + input("\nContinue...") + except: + pass + +def localchatsendA(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + try: + closed() + print("\n\tWrite.\n") + lncli = " sendpayment " + node = input("Send to NodeID: ") + amount = input("Amount in sats: ") + message = input("Message: ") + encoded_message = message.encode('utf-8') + hex_encoded_message = encoded_message.hex() + input("\nContinue...") + + while True: + if amount in ["", "0"]: + amount = input("\nAmount in sats: ") + else: + break + os.system( + f"""lncli sendpayment --keysend --d={node} --amt={amount}""" + + """ --data 34349334=""" + + hex_encoded_message + ) + + input("\nContinue...") + except: + pass + +def localchatnewA(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + try: + closed() + print("\n\tRead.\n") + os.system("""lncli listinvoices | grep "34349334" | tr -d '"' | tr -d ',' | sed 's/34349334/0a0a2d5079424c4f434b204d6573736167652052656365697665643a200a/g' | html2text | xxd -r -p | xargs --null""") + input("\nContinue...") + except: + pass + +def localchatlistA(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + try: + closed() + print("\n\tList.\n") + os.system("""lncli listpayments | grep "34349334" | tr -d '"' | tr -d ',' | sed 's/34349334/0a0a202d5079424c4f434b204d6573736167653a200a/g' | html2text | xxd -r -p | xargs --null""") + input("\nContinue...") + except: + pass + +def localchatsendB(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + try: + closed() + print("\n\tWrite.\n") + lncli = " sendpayment " + node = input("Send to NodeID: ") + amount = input("Amount in sats: ") + message = input("Message: ") + encoded_message = message.encode('utf-8') + hex_encoded_message = encoded_message.hex() + print(encoded_message.hex()) + input("\nContinue...") + + while True: + if amount in ["", "0"]: + amount = input("\nAmount in sats: ") + else: + break + os.system( + f"""lncli sendpayment --keysend --d={node} --amt={amount}""" + + """ --data 7629171=""" + + hex_encoded_message + ) + + input("\nContinue...") + except: + pass + +def localchatnewB(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + try: + closed() + print("\n\tRead.\n") + os.system("""lncli listinvoices | grep "7629171" | tr -d '"' | tr -d ',' | sed 's/7629171/0a0a2d5079424c4f434b204d6573736167652052656365697665643a200a/g' | html2text | xxd -r -p | xargs --null""") + input("\nContinue...") + except: + pass + +def localchatlistB(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + try: + closed() + print("\n\tList.\n") + os.system("""lncli listpayments | grep "7629171" | tr -d '"' | tr -d ',' | sed 's/7629171/0a0a202d5079424c4f434b204d6573736167653a200a/g' | html2text | xxd -r -p | xargs --null""") + input("\nContinue...") + except: + pass + +def localchatsendC(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + try: + closed() + print("\n\tWrite.\n") + lncli = " sendpayment " + node = input("Send to NodeID: ") + amount = input("Amount in sats: ") + message = input("Message: ") + encoded_message = message.encode('utf-8') + hex_encoded_message = encoded_message.hex() + print(encoded_message.hex()) + input("\nContinue...") + + while True: + if amount in ["", "0"]: + amount = input("\nAmount in sats: ") + else: + break + os.system( + f"""lncli sendpayment --keysend --d={node} --amt={amount}""" + + """ --data 34343434=""" + + hex_encoded_message + ) + + input("\nContinue...") + except: + pass + +def localchatnewC(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + try: + closed() + print("\n\tRead.\n") + os.system("""lncli listinvoices | grep "34343434" | tr -d '"' | tr -d ',' | sed 's/34343434/0a0a2d5079424c4f434b204d6573736167652052656365697665643a200a/g' | html2text | xxd -r -p | xargs --null""") + input("\nContinue...") + except: + pass + +def localchatlistC(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + try: + closed() + print("\n\tList.\n") + lncli = " listpayments " + os.system("""lncli listpayments | grep "34343434" | tr -d '"' | tr -d ',' | sed 's/34343434/0a0a202d5079424c4f434b204d6573736167653a200a/g' | html2text | xxd -r -p | xargs --null""") + input("\nContinue...") + except: + pass + +def localchannelbalance(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + lncli = " channelbalance" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + print(""" + --------------------------------------------------------- + + \tLOCAL CHANNEL BALANCE + + Balance: {} sats + Pending Channels: {} sats + + --------------------------------------------------------- + """.format(d['balance'], d['pending_open_balance'])) + input("\nContinue... ") + +def localnewaddress(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + lncli = " newaddress p2wkh" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + print("\033[1;30;47m") + qr.add_data(d['address']) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("Bitcoin Address: " + d['address']) + input("\nContinue... ") + +def localbalanceOC(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + lncli = " walletbalance" + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + print("\n----------------------------------------------------------------------------------------------------") + print("\n\tLOCAL ONCHAIN BALANCE\n") + print("Total Balance: " + d['total_balance'] + " sats") + print("Confirmed Balance: " + d['confirmed_balance'] + " sats") + print("Unconfirmed Balance: " + d['unconfirmed_balance'] + " sats") + print("----------------------------------------------------------------------------------------------------\n") + input("\nContinue... ") + + +def localrebalancelnd(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + lncli = " listchannels" + while True: + lsd = os.popen(lndconnectload['ln'] + lncli).read() + lsd0 = str(lsd) + d = json.loads(lsd0) + n = d['channels'] + clear() + print("\033[1;32;40m") + blogo() + print("\033[0;37;40m") + print("<<< Back to the Main Menu Press Control + C.\n\n") + print("\t\nChannels\n") + try: + print("""\n\tLIST CHANNELS TO REBALANCE\n + \t\033[1;32;40mLOCAL\033[0;37;40m BALANCE \t\033[1;31;40mREMOTE\033[0;37;40m BALANCE + """) + + for item in n: + s = item + if int(s['local_balance']) >= int(s['remote_balance']): + total = int(s['local_balance']) - int(s['remote_balance']) + elif int(s['local_balance']) <= int(s['remote_balance']): + total = int(s['remote_balance']) - int(s['local_balance']) + print("Node ID: " + str(s['chan_id']) + "\t\033[1;32;40m " + str(s['local_balance']) + "\033[0;37;40m sats \033[1;31;40m\t" + str(s['remote_balance']) + "\033[0;37;40m sats \033[3;33;40m" + "\tDIFFERENCE: {}\033[0;37;40m sats".format(str(total)) ) + fromnode = input("\nSelect FROM a Node ID : ") + tonode = input("\nSelect TO a Node ID : ") + amt = input("\nAmount in sats: ") + fee = input("\nMax Fee factor in sats: ") + fromtonode = "python3 rebalance.py -f {} -t {} -a {} --max-fee-factor {}".format(fromnode,tonode,amt,fee) + os.system(str(fromtonode)) + input("Continue...") + except: + break + +# Remote connection with rest ------------------------------------- + +def getnewinvoice(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + try: + amount = input("Amount in sats: ") + memo = input("Memo: ") + url = 'https://{}/v1/invoices'.format(lndconnectload["ip_port"]) + data = { + + } + if amount == "": + r = requests.post( + url, + headers=headers, + verify=cert_path, + json={"memo": f'{memo} -PyBLOCK'}, + ) + + else: + r = requests.post( + url, + headers=headers, + verify=cert_path, + json={"value": amount, "memo": f'{memo} -PyBLOCK'}, + ) + + + a = r.json() + print("\033[1;30;47m") + qr.add_data(a['payment_request']) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("Lightning Invoice: " + a['payment_request']) + b = str(a['payment_request']) + while True: + url = 'https://{}/v1/payreq/{}'.format(lndconnectload["ip_port"], b) + r = requests.get(url, headers=headers, verify=cert_path) + a = r.json() + url = 'https://{}/v1/invoice/{}'.format(lndconnectload["ip_port"],a['payment_hash']) + rr = requests.get(url, headers=headers, verify=cert_path) + m = rr.json() + if m['state'] == 'SETTLED': + print("\033[1;32;40m") + clear() + blogo() + tick() + print("\033[0;37;40m") + t.sleep(2) + break + elif m['state'] == 'CANCELED': + print("\033[1;31;40m") + clear() + blogo() + canceled() + print("\033[0;37;40m") + t.sleep(2) + break + except: + pass + +def payinvoice(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + try: + while True: + bolt11N = input("Insert the invoice to pay: ") + url = 'https://{}/v1/payreq/{}'.format(lndconnectload["ip_port"],bolt11N) + r = requests.get(url, headers=headers, verify=cert_path) + s = r.json() + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tINVOICE DECODED + Destination: {} + Payment Hash: {} + Amount: {} sats + Description: {} + """.format(s['destination'], s['payment_hash'], s['num_satoshis'], s['description'])) + print("----------------------------------------------------------------------------------------------------\n") + print("<<< Cancel Control + C") + input("\nEnter to Continue... ") + bolt11 = bolt11N.lower() + r = requests.post( + url='https://{}/v1/channels/transactions'.format(lndconnectload["ip_port"]), headers=headers, verify=cert_path, json={"payment_request": bolt11} + ) + try: + r.json()['error'] + print("\nThe Invoice don't have an amount. Please insert an Invoice with amount. \n") + continue + except: + break + ok, checking_id, fee_msat, error_message = r.ok, None, 0, None + r = requests.get(url='https://{}/v1/payreq/{}'.format(lndconnectload["ip_port"],bolt11), headers=headers, verify=cert_path,) + t.sleep(5) + if r.ok: + checking_id = r.json()["payment_hash"] + print("\033[1;32;40m") + clear() + blogo() + tick() + else: + error_message = r.json()["error"] + print("\033[1;31;40m") + clear() + blogo() + canceled() + print("\033[0;37;40m") + t.sleep(2) + except: + pass + +def getnewaddress(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + try: + url = 'https://{}/v1/newaddress'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + addr = r.json() + print("\033[1;30;47m") + qr.add_data(addr['address']) + qr.print_ascii() + print("\033[0;37;40m") + print("Bitcoin Address: " + addr['address']) + qr.clear() + input("\nContinue... ") + except: + pass + +def listinvoice(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/invoices'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + a = r.json() + n = a['invoices'] + while True: + clear() + print("\033[1;32;40m") + blogo() + print("\033[0;37;40m") + print("<<< Back to the Main Menu Press Control + C.\n\n") + print("\tInvoices\n") + try: + print("\n\tLIST INVOICES\n") + for r in range(len(n)): + s = n[r] + print("Invoice: " + s['r_hash'] + " " + s['state']) + + nd = input("\nSelect RHash: ") + for item in n: + s = item + nn = s['r_hash'] + if nd == nn: + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tINVOICE DECODED + Memo: {} + Invoice: {} + Amount: {} sats + State: {} + """.format(s['memo'], s['payment_request'], s['amt_paid_sat'], s['state'])) + print("----------------------------------------------------------------------------------------------------\n") + print("\033[1;30;47m") + qr.add_data(s['payment_request']) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + input("\nContinue... ") + except: + break + input("\nContinue... ") + +def getinfo(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/getinfo'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + a = r.json() + hash = a['identity_pubkey'] + rh = Robohash(hash) + rh.assemble(roboset='set1') + if not os.path.isfile(str(f'{hash}.png')): + with open(f'{hash}.png', "wb") as f: + rh.img.save(f, format="png") + + img_path = open(f'{hash}.png', "rb") + img = Image.open(img_path) + + h = 20 + w = int((img.width / img.height) * 50) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + img_path = open(f'{hash}.png', "rb") + img = Image.open(img_path) + + h = 20 + w = int((img.width / img.height) * 50) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + for x in range(h): + for y in range(w): + pix = img_arr[x][y] + print(get_color(pix[0], pix[1], pix[2]), sep='', end='') + print() + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \t NODE INFORMATION + Version: {} + Node ID: {} + Alias: {} + Color: {} + Pending Channels: {} + Active Channels: {} + Inactive Channels: {} + Peers: {} + URLS: {} + """.format(a['version'], a['identity_pubkey'], a['alias'], a['color'], a['num_pending_channels'], a['num_active_channels'], a['num_inactive_channels'], a['num_peers'], a['uris'])) + print("\033[1;30;47m") + qr.add_data(a['identity_pubkey']) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("----------------------------------------------------------------------------------------------------\n") + input("\nContinue... ") + +#--------------------------------- NYMs ----------------------------------- + +def get_ansi_color_code(r, g, b): + if r == g == b: + if r < 8: + return 16 + if r > 248: + return 231 + return round(((r - 8) / 247) * 24) + 232 + return 16 + (36 * round(r / 255 * 5)) + (6 * round(g / 255 * 5)) + round(b / 255 * 5) + + +def get_color(r, g, b): + return "\x1b[48;5;{}m \x1b[0m".format(int(get_ansi_color_code(r,g,b))) + +def channels(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/channels'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + a = r.json() + n = a['channels'] + while True: + clear() + print("\033[1;32;40m") + blogo() + print("\033[0;37;40m") + print("<<< Back to the Main Menu Press Control + C.\n\n") + print("\t\nChannels\n") + try: + print("\n\tLIST CHANNELS\n") + for r in range(len(n)): + s = n[r] + hash = s['remote_pubkey'] + rh = Robohash(hash) + rh.assemble(roboset='set1') + if not os.path.isfile(str(f'{hash}.png')): + with open(f'{hash}.png', "wb") as f: + rh.img.save(f, format="png") + + img_path = open(f'{hash}.png', "rb") + img = Image.open(img_path) + + h = 1 + w = int((img.width / img.height) * 5) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + img_path = open(f'{hash}.png', "rb") + img = Image.open(img_path) + + h = 1 + w = int((img.width / img.height) * 5) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + for x in range(h): + for y in range(w): + pix = img_arr[x][y] + print(get_color(pix[0], pix[1], pix[2]), sep='', end='') + print() + print("Node ID: " + s['remote_pubkey']) + + nd = input("\nSelect a Node ID: ") + for item in n: + s = item + nn = s['remote_pubkey'] + if nd == nn: + hash = s['remote_pubkey'] + rh = Robohash(hash) + rh.assemble(roboset='set1') + + img_path = open(f'{hash}.png', "rb") + img = Image.open(img_path) + + h = 20 + w = int((img.width / img.height) * 50) + + img = img.resize((w,h), Image.ANTIALIAS) + img_arr = np.asarray(img) + h,w,c = img_arr.shape + + for x in range(h): + for y in range(w): + pix = img_arr[x][y] + print(get_color(pix[0], pix[1], pix[2]), sep='', end='') + print() + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tCHANNEL DECODED + Active: {} + Node ID: {} + Channel Point: {} + Channel Capacity: {} sats + Local Balance: {} sats + Remote Balance: {} sats + Total Sent: {} sats + Total Received: {} sats + """.format(s['active'], s['remote_pubkey'], s['channel_point'], s['capacity'], s['local_balance'], s['remote_balance'], s['total_satoshis_sent'], s['total_satoshis_received'])) + print("----------------------------------------------------------------------------------------------------\n") + + input("\nContinue... ") + except: + break + +def channelbalance(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/balance/channels'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + a = r.json() + print(""" + --------------------------------------------------------- + + \tLOCAL CHANNEL BALANCE + + Balance: {} sats + Pending Channels: {} sats + + --------------------------------------------------------- + """.format(a['balance'], a['pending_open_balance'])) + input("\nContinue... ") + +def listonchaintxs(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/transactions'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + a = r.json() + n = a['transactions'] + while True: + clear() + print("\033[1;32;40m") + blogo() + print("\033[0;37;40m") + print("<<< Back to the Main Menu Press Control + C.\n\n") + print("\t\nTransactions\n") + try: + print("\n\tLIST ONCHAIN TRANSACTIONS\n") + for r in range(len(n)): + s = n[r] + print("Transaction Hash: " + " " + s['tx_hash'] + " sats") + nd = input("\nSelect RHash: ") + + for item in n: + s = item + nn = s['tx_hash'] + trx = s['dest_addresses'] + if nd == nn: + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tONCHAIN TRANSACTION DECODED + Amount: {} sats + Tx Hash: {} + Block Hash: {} + Block Height: {} + Confirmations: {} + Destination: {} + """.format(s['amount'], s['tx_hash'], s['block_hash'], s['block_height'], s['num_confirmations'], trx)) + print("----------------------------------------------------------------------------------------------------\n") + print("\nTransaction Hash") + print("\033[1;30;47m") + qr.add_data(s['tx_hash']) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + input("\nContinue... ") + except: + break + +def balanceOC(): + lndconnectData= pickle.load(open("config/blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = 'https://{}/v1/balance/blockchain'.format(lndconnectload["ip_port"]) + r = requests.get(url, headers=headers, verify=cert_path) + a = r.json() + print("\n----------------------------------------------------------------------------------------------------") + print("\n\tLOCAL ONCHAIN BALANCE\n") + print("Total Balance: " + a['total_balance'] + " sats") + print("Confirmed Balance: " + a['confirmed_balance'] + " sats") + print("Unconfirmed Balance: " + a['unconfirmed_balance'] + " sats") + print("----------------------------------------------------------------------------------------------------\n") + input("\nContinue... ") + +# END Remote connection with rest ------------------------------------- +#---------------------------------OPENDIME----------------------------- + +def ADDRbalance(): + import os, sys; sys.path.insert(0, os.path.normpath(__file__ + '/support/pycode.zip')) + import support.pycode.od_wallet; support.pycode.od_wallet.main() diff --git a/pybitblock/SPV/pblogo.py b/pybitblock/SPV/pblogo.py new file mode 100644 index 0000000..866ef40 --- /dev/null +++ b/pybitblock/SPV/pblogo.py @@ -0,0 +1,69 @@ +#Developer: Curly60e +#PyBLOCK its a clock of the Bitcoin blockchain. + +import os +import pickle +from cfonts import render, say + +def blogo(): + + if os.path.isfile('config/pyblocksettinconfig/gs.conf') or os.path.isfile('config/pyblocksettings.conf'): # Check if the file 'bclock.conf' is in the same folder + settingsv = pickle.load(open("config/pyblocksettings.conf", "rb")) # Load the file 'bclock.conf' + settings = settingsv # Copy the variable pathv to 'path' + else: + settings = {"gradient":"", "design":"block", "colorA":"green", "colorB":"yellow"} + pickle.dump(settings, open("config/pyblocksettings.conf", "wb")) + + if settings["gradient"] == "grd": + output = render('PyBLOCK', gradient=[settings['colorA'], settings['colorB']], align='left', font=settings['design']) + else: + output = render('PyBLOCK', colors=[settings['colorA'], settings['colorB']], align='left', font=settings['design']) + + print(output) + +def tick(): + print("""\033[1;32;40m + + + + + @ + @ + @ + @@ + @@ + @@@ + @@@ @@. + @@@@@@@ + @@@@@@@@ + @@@@ + @@@@ + @ @@@@ + @@@@@@@@ + @@@@@@@@ + @@@ + @@@ + @@ + @@ + @ + @ + + + + + + +\033[0;37;40m""") + +def canceled(): + print(""" + ) ( ( + ( ( ( /( ( )\ ) )\ ) + )\ )\ )\()) )\ ( (()/( ( (()/( + (((_)((((_)( ((_)\ (((_) )\ /(_)) )\ /(_)) + )\___ )\ _ )\ _((_) )\___ ((_) (_)) ((_)(_))_ +((/ __|(_)_\(_)| \| |((/ __|| __|| | | __|| \ + | (__ / _ \ | .` | | (__ | _| | |__ | _| | |) | + \___|/_/ \_\ |_|\_| \___||___||____||___||___/ + +""") diff --git a/pybitblock/SPV/ppi.py b/pybitblock/SPV/ppi.py new file mode 100644 index 0000000..892a954 --- /dev/null +++ b/pybitblock/SPV/ppi.py @@ -0,0 +1,2180 @@ +#Developer: Curly60e +#Tester: __B__T__C__ +#ℙ𝕪𝔹𝕃𝕆ℂ𝕂 𝕚𝕥𝕤 𝕒 𝔹𝕚𝕥𝕔𝕠𝕚𝕟 𝔻𝕒𝕤𝕙𝕓𝕠𝕒𝕣𝕕 𝕨𝕚𝕥𝕙 ℂ𝕪𝕡𝕙𝕖𝕣𝕡𝕦𝕟𝕜 𝕒𝕖𝕤𝕥𝕙𝕖𝕥𝕚𝕔. + + +import base64, codecs, json, requests +import pickle +import os +import os.path +import qrcode +import lnpay_py +import requests +import xmltodict +import time as t +import simplejson as json +from art import * +from cfonts import render, say +from nodeconnection import * +from pblogo import * +from logos import * +from lnpay_py.wallet import LNPayWallet +from pycoingecko import CoinGeckoAPI + +def clear(): # clear the screen + os.system('cls' if os.name=='nt' else 'clear') + +def closed(): + print("<<< Back Control + C.\n\n") + +def opreturnOnchainONLY(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + try: + clear() + blogo() + output = render( + "OP_RETURN Message", colors=['yellow'], align='left', font='tiny' + ) + + print(output) + message = input("Message: ") + curl = ( + "curl --header " + + """"Content-Type: application/json" """ + + "--request POST --data " + + """'{"message":""" + + f'"{message}...PyBLOCK"' + + "}'" + + " https://opreturnbot.com/api/create" + ) + + while True: + if len(message) <= 70: + break + clear() + blogo() + print("Error! Only 80 characters allowed!") + message = input("\nMessage: ") + a = os.popen(curl).read() + b = str(a) + clear() + blogo() + print("\033[1;30;47m") + qr.add_data(b) + qr.print_ascii() + print("\033[0;37;40m") + print(f'LND Invoice: {b}') + qr.clear() + input("\nContinue...") + if lndconnectload['ln']: + invoiceN = b + invoice = invoiceN.lower() + lncli = " payinvoice " + lsd = os.popen(f'{lndconnectload["ln"]} decodepayreq {invoice}').read() + lsd0 = str(lsd) + d = json.loads(lsd0) + url = f"http://opreturnbot.com/api/status/{d['payment_hash']}" + else: + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/payreq/{b}' + r = requests.get(url, headers=headers, verify=cert_path) + s = r.json() + url = f"http://opreturnbot.com/api/status/{s['payment_hash']}" + response = requests.get(url) + responseB = str(response.text) + responseC = responseB + clear() + blogo() + print("\nTransaction ID: " + responseC) + input("\nContinue...") + except: + pass + +def opreturn(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + try: + lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} + 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() + 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' + + 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' + ] = f'http://{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")) + clear() + blogo() + output = render( + "OP_RETURN Message", colors=['yellow'], align='left', font='tiny' + ) + + print(output) + message = input("Message: ") + curl = ( + "curl --header " + + """"Content-Type: application/json" """ + + "--request POST --data " + + """'{"message":""" + + f'"{message}...PyBLOCK"' + + "}'" + + " https://opreturnbot.com/api/create" + ) + + while True: + if len(message) <= 70: + break + clear() + blogo() + print("Error! Only 80 characters allowed!") + message = input("\nMessage: ") + a = os.popen(curl).read() + b = str(a) + node_not = input("\nDo you want to pay this invoice with your node? Y/n: ") + if node_not in ["Y", "y"]: + lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} + lndconnectData = pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + if lndconnectload['ip_port']: + print("\nInvoice: " + b + "\n") + payinvoice() + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/payreq/{b}' + r = requests.get(url, headers=headers, verify=cert_path) + s = r.json() + url = f"http://opreturnbot.com/api/status/{s['payment_hash']}" + response = requests.get(url) + responseB = str(response.text) + responseC = responseB + clear() + blogo() + print("\nTransaction ID: " + responseC) + input("\nContinue...") + elif lndconnectload['ln']: + print("\nInvoice: " + b + "\n") + localpayinvoice() + invoiceN = b + invoice = invoiceN.lower() + lncli = " payinvoice " + lsd = os.popen(f'{lndconnectload["ln"]} decodepayreq {invoice}').read() + lsd0 = str(lsd) + d = json.loads(lsd0) + url = f"http://opreturnbot.com/api/status/{d['payment_hash']}" + response = requests.get(url) + responseB = str(response.text) + responseC = responseB + clear() + blogo() + print("\nTransaction ID: " + responseC) + input("\nContinue...") + else: + clear() + blogo() + print("\033[1;30;47m") + qr.add_data(b) + qr.print_ascii() + print("\033[0;37;40m") + print(f'LND Invoice: {b}') + qr.clear() + input("\nContinue...") + if lndconnectload['ln']: + invoiceN = b + invoice = invoiceN.lower() + lncli = " payinvoice " + lsd = os.popen(f'{lndconnectload["ln"]} decodepayreq {invoice}').read() + lsd0 = str(lsd) + d = json.loads(lsd0) + url = f"http://opreturnbot.com/api/status/{d['payment_hash']}" + else: + cert_path = lndconnectload["tls"] + macaroon = codecs.encode(open(lndconnectload["macaroon"], 'rb').read(), 'hex') + headers = {'Grpc-Metadata-macaroon': macaroon} + url = f'https://{lndconnectload["ip_port"]}/v1/payreq/{b}' + r = requests.get(url, headers=headers, verify=cert_path) + s = r.json() + url = f"http://opreturnbot.com/api/status/{s['payment_hash']}" + response = requests.get(url) + responseB = str(response.text) + responseC = responseB + clear() + blogo() + print("\nTransaction ID: " + responseC) + input("\nContinue...") + except: + pass + +def opreturn_view(): + try: + clear() + blogo() + output = render( + "OP_RETURN Message", colors=['yellow'], align='left', font='tiny' + ) + + print(output) + responseC = input("TX ID: ") + url2 = f'http://opreturnbot.com/api/view/{responseC}' + r = requests.get(url2) + r2 = str(r.text) + r3 = r2 + clear() + blogo() + print("\nTransaction ID: " + responseC) + print(f'OP_RETURN Message: {r3}') + input("\nContinue...") + except: + pass + +def opretminer(): + try: + conn = """curl -s 'https://bitcointicker.co/latestblocks/' | xargs --null | html2text | grep "Coinbase" -A 70 | tr -d '|' | grep -v "Coinbase" | grep '6.25'""" + a = os.popen(conn).read() + clear() + blogo() + closed() + output = render( + "decoded coinbase", colors=['yellow'], align='left', font='tiny' + ) + + print(output) + print(a) + input("") + except: + pass + +#-----------------------------GAMES-------------------------------- +#------------------------------------------------------------------ + +def gameroom(): + try: + clear() + blogo() + print(""" + -------------------------------------- + + INITIATE ARCADE? + + -------------------------------------- + """.format(closed())) + input("\a\nContinue...") + conn = "ssh gameroom@bitreich.org" + os.system(conn).read() + except: + pass +#---------------------------------------------------------------------- + +#-----------------------------Stats-------------------------------- + +def statsConn(): + try: + 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() + closed() + output = render("stats", colors=['yellow'], align='left', font='tiny') + print(output) + print(a) + input("\a\nContinue...") + except: + pass + +#-----------------------------END Stats-------------------------------- + +#-----------------------------PGP-------------------------------- + +def pgpConn(): + try: + conn = """curl -s https://web.archive.org/web/20110228054007/http://www.bitcoin.org/Satoshi_Nakamoto.asc""" + a = os.popen(conn).read() + clear() + blogo() + closed() + output = render( + "pgp", colors=['yellow'], align='left', font='tiny' + ) + + print(output) + print(a) + input("\a\nContinue...") + except: + pass + +#-----------------------------END PGP-------------------------------- + +#-----------------------------Satoshi-------------------------------- + +def satoshiConn(): + try: + conn = """curl -s https://www.metzdowd.com/pipermail/cryptography/2009-January/014994.html | html2text | tail -n 82 | grep -v "Unsubscribe" | grep -v "Next message" | grep -v "Previous message"| grep -v "Messages sorted" | grep -v "More information" | grep -v "list]" """ + a = os.popen(conn).read() + clear() + blogo() + closed() + output = render( + "𝐒𝐚𝐭𝐨𝐬𝐡𝐢 𝐍𝐚𝐤𝐚𝐦𝐨𝐭𝐨. 𝟎𝐱𝟏𝟖𝐂𝟎𝟗𝐄𝟖𝟔𝟓𝐄𝐂𝟗𝟒𝟖𝐀𝟏. 𝐃𝐄𝟒𝐄 𝐅𝐂𝐀𝟑 𝐄𝟏𝐀𝐁 𝟗𝐄𝟒𝟏 𝐂𝐄𝟗𝟔 𝐂𝐄𝐂𝐁 𝟏𝟖𝐂𝟎 𝟗𝐄𝟖𝟔 𝟓𝐄𝐂𝟗 𝟒𝟖𝐀𝟏.", colors=['green'], align='left', font='console' + ) + + print(output) + print(a) + input("\a\nContinue...") + except: + pass + +#-----------------------------END Satoshi-------------------------------- + +#-----------------------------Whale Alert-------------------------------- + +def whalalConn(): + try: + conn = """curl -s 'https://api.whale-alert.io/v1/transactions?api_key=3LYGErNwoCSj6QUsWOWdpEuGTuYxakMZ&limit=7¤cy=btc' | jq -C '.transactions[]' | tr -d '{|}|,|"|:|' | grep -E "blockchain|amount" -A 8 | grep -v -E "\--|from|symbol|to|id" | xargs -L 1 | sed 's/blockchain/PyBLØCK/g' | sed 's/amount/₿/g' | sed 's/_usd/=$/g' | sed 's/bitcoin/WHALE ALERT/g' | grep -E ' '""" + a = os.popen(conn).read() + clear() + blogo() + closed() + output = render("whale alert", colors=['yellow'], align='left', font='tiny') + print(output) + print(a) + input("\a\nContinue...") + except: + pass + +#-----------------------------END Whale Alert-------------------------------- +#-----------------------------bwt.dev-------------------------------- + +def bwtConn(): + try: + conn = "curl -s https://bwt.dev/banner.txt" + a = os.popen(conn).read() + clear() + blogo() + closed() + print(a) + input("\a\nContinue...") + except: + pass + +#-----------------------------END bwt.dev-------------------------------- +#-----------------------------Dates-------------------------------- + +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 ','""" + a = os.popen(conn).read() + clear() + blogo() + closed() + output = render("dates", colors=['yellow'], align='left', font='tiny') + print(output) + print(a) + input("\a\nContinue...") + except: + pass + +#-----------------------------END Dates-------------------------------- +#-----------------------------Quotes-------------------------------- + +def quotesConn(): + try: + conn = """curl -s "https://bitcoinexplorer.org/api/quotes/all" | jq -C '.[]' | tr -d '{|}|]|,' | sed 's/text/Quote/g' | sed 's/speaker/By/g' | sed 's/url/Link/g' | sed 's/date/Date/g' | grep -v -E 'conQuote'""" + a = os.popen(conn).read() + clear() + blogo() + closed() + output = render("quotes", colors=['yellow'], align='left', font='tiny') + print(output) + print(a) + input("\a\nContinue...") + except: + pass + +#-----------------------------END Quotes-------------------------------- +#-----------------------------Hashrate-------------------------------- + +def miningConn(): + try: + conn = """curl -s "https://bitcoinexplorer.org/api/mining/hashrate" | jq -C '.[]' | tr -d '{|}|]|,'""" + a = os.popen(conn).read() + clear() + blogo() + closed() + output = render("hashrate", colors=['yellow'], align='left', font='tiny') + print(output) + print(a) + input("\a\nContinue...") + except: + pass + +#-----------------------------END Hashrate-------------------------------- +#-----------------------------StatsLN-------------------------------- + +def stalnConn(): + try: + conn = """curl -s 'https://1ml.com' | html2text | xargs -L 1 | grep -E "Number" -A 8""" + a = os.popen(conn).read() + clear() + blogo() + closed() + output = render( + "lightning stats", colors=['yellow'], align='left', font='tiny' + ) + + print(output) + print(a) + input("\a\nContinue...") + except: + pass + +#-----------------------------END StatsLN-------------------------------- +#-----------------------------StatRanking-------------------------------- +def ranConn(): + try: + conn = """curl -s 'https://1ml.com/node?order=capacity&json=true' | jq -C '.[]' | xargs -L 1 | tr -d '{|}|]|,' | grep -v -E "last_update|color|noderank" | sed 's/alias/Node/g' | grep -v -E "addresses" | grep -E " " | sed 's/capacity/RANK/g' +""" + a = os.popen(conn).read() + clear() + blogo() + closed() + output = render("ranking", colors=['yellow'], align='left', font='tiny') + print(output) + print(a) + input("\a\nContinue...") + except: + pass +#-----------------------------END Ranking-------------------------------- + +def trustednode(): + try: + clear() + blogo() + closed() + addv = """ + --------------------------------------------------------------- + + REMEMBER TO INITIALIZE \033[1;35;40mTOR\033[0;37;40m ON THE SHELL + + $ source torsocks on + + --------------------------------------------------------------- + + """ + print(addv) + input("\a\nContinue...") + conn = "telnet cut45oarvxfvfydrjery6slyeca4zpal7tljygdt5bji7l3jsrrgwkad.onion 6023" + os.system(conn) + except: + pass +#-----------------------------END GAMES-------------------------------- + +#-----------------------------wttr.in-------------------------------- +def wttrDataV1(): + try: + clear() + blogo() + weatherList = """ + ------------------------------------------------------------------------------------ + + + + \033[1;31;40m*\033[0;37;40m uruguay # city name + \033[1;31;40m*\033[0;37;40m ~Giza+pyramid # any location (+ for spaces) + \033[1;31;40m*\033[0;37;40m Москва # Unicode name of any location in any language + \033[1;31;40m*\033[0;37;40m muc # airport code (3 letters) + \033[1;31;40m*\033[0;37;40m @lightninghood.com # domain name + \033[1;31;40m*\033[0;37;40m 94107 # area codes + \033[1;31;40m*\033[0;37;40m -78.46,106.79 # GPS coordinates + \033[1;31;40m*\033[0;37;40m moon # Moon phase (add ,+US or ,+France for these cities) + \033[1;31;40m*\033[0;37;40m moon@2009-01-03 # Moon phase for the date (@2016-10-25) + + PRESS \033[1;32;40mM\033[0;37;40m TO INSERT MORE DATA + + ------------------------------------------------------------------------------------ + + """ + print(weatherList) + selectData = input("Insert your data \033[1;31;40m*\033[0;37;40m : ") + if selectData in ['M', 'm']: + moreData = """ + + ------------------------------------------------------------------------------------ + Supported languages + + ar af be ca da de el es et fr fa hi hu ia id it nb nl + oc pl pt-br ro ru tr th uk vi zh-cn zh-tw (supported) + + ------------------------------------------------------------------------------------ + ------------------------------------------------------------------------------------ + Units + + m # metric (SI) (used by default everywhere except US) + u # USCS (used by default in US) + M # show wind speed in m/s + + ------------------------------------------------------------------------------------ + """ + print(moreData) + selectData2 = input("Insert your data \033[1;31;40m*\033[0;37;40m : ") + lang = input("Insert your language: ") + unit = input("Insert your metric units: ") + list = "curl '" + lang + ".wttr.in/" + selectData2 + "?F&" + unit + "'" + else: + list = f'curl wttr.in/{selectData}?F' + a = os.popen(list).read() + clear() + blogo() + print(a) + input("Continue...") + except: + pass + +def wttrDataV2(): + try: + clear() + blogo() + weatherList = """ + ------------------------------------------------------------------------------------ + + + + \033[1;31;40m*\033[0;37;40m uruguay # city name + \033[1;31;40m*\033[0;37;40m ~Giza+pyramid # any location (+ for spaces) + \033[1;31;40m*\033[0;37;40m Москва # Unicode name of any location in any language + \033[1;31;40m*\033[0;37;40m muc # airport code (3 letters) + \033[1;31;40m*\033[0;37;40m @lightninghood.com # domain name + \033[1;31;40m*\033[0;37;40m 94107 # area codes + \033[1;31;40m*\033[0;37;40m -78.46,106.79 # GPS coordinates + + PRESS \033[1;32;40mM\033[0;37;40m TO INSERT MORE DATA + + ------------------------------------------------------------------------------------ + + """ + print(weatherList) + selectData = input("Insert your data \033[1;31;40m*\033[0;37;40m : ") + if selectData in ['M', 'm']: + moreData = """ + + ------------------------------------------------------------------------------------ + Supported languages + + ar af be ca da de el es et fr fa hi hu ia id it nb nl + oc pl pt-br ro ru tr th uk vi zh-cn zh-tw (supported) + + ------------------------------------------------------------------------------------ + ------------------------------------------------------------------------------------ + Units + + m # metric (SI) (used by default everywhere except US) + u # USCS (used by default in US) + M # show wind speed in m/s + + ------------------------------------------------------------------------------------ + """ + print(moreData) + selectData2 = input("Insert your data \033[1;31;40m*\033[0;37;40m : ") + lang = input("Insert your language: ") + unit = input("Insert your metric units: ") + list = "curl 'v2.wttr.in/" + selectData2 + "?" + unit + "&F&lang=" + lang + "'" + + else: + list = f'curl v2.wttr.in/{selectData}?F' + a = os.popen(list).read() + clear() + blogo() + print(a) + input("Continue...") + except: + pass + + +#-----------------------------END wttr.in-------------------------------- + +#-----------------------------RATE.SX-------------------------------- + +def rateSXList(): + try: + clear() + blogo() + fiat = """ + ------------------------------------------- + AUD Australian dollar + BRL Brazilian real + CAD Canadian dollar + CHF Swiss franc + CLP Chilean peso + CNY Chinese yuan + CZK Czech koruna + DKK Danish krone + EUR Euro + GBP Pound sterling + HKD Hong Kong dollar + HUF Hungarian forint + IDR Indonesian rupiah + ILS Israeli shekel + INR Indian rupee + JPY Japanese yen + KRW South Korean won + MXN Mexican peso + MYR Malaysian ringgit + NOK Norwegian krone + NZD New Zealand dollar + PHP Philippine peso + PKR Pakistani rupee + PLN Polish zloty + RUB Russian ruble + SEK Swedish krona + SGD Singapore dollar + THB Thai baht + TRY Turkish lira + TWD New Taiwan dollar + USD Dollars + ------------------------------------------- + """ + print(fiat) + selectFiat = input("Insert a Fiat currency: ") + except: + pass + while True: + try: + list = "curl -s '" + selectFiat + ".rate.sx/?F&n=1'" + a = os.popen(list).read() + clear() + blogo() + closed() + print(a) + t.sleep(20) + except: + break + +def rateSXGraph(): + try: + clear() + blogo() + fiat = """ + ------------------------------------------- + AUD Australian dollar + BRL Brazilian real + CAD Canadian dollar + CHF Swiss franc + CLP Chilean peso + CNY Chinese yuan + CZK Czech koruna + DKK Danish krone + EUR Euro + GBP Pound sterling + HKD Hong Kong dollar + HUF Hungarian forint + IDR Indonesian rupiah + ILS Israeli shekel + INR Indian rupee + JPY Japanese yen + KRW South Korean won + MXN Mexican peso + MYR Malaysian ringgit + NOK Norwegian krone + NZD New Zealand dollar + PHP Philippine peso + PKR Pakistani rupee + PLN Polish zloty + RUB Russian ruble + SEK Swedish krona + SGD Singapore dollar + THB Thai baht + TRY Turkish lira + TWD New Taiwan dollar + USD Dollars + ------------------------------------------- + """ + print(fiat) + selectFiat = input("Insert a Fiat currency: ") + except: + pass + while True: + try: + list = "curl -s '" + selectFiat + """.rate.sx/btc' | grep -v -E 'Use'""" + a = os.popen(list).read() + clear() + blogo() + closed() + print(a) + t.sleep(20) + except: + break + +#-----------------------------END RATE.SX-------------------------------- + + + +#-----------------------------COINGECKO-------------------------------- + +def CoingeckoPP(): + try: + btcInfo = CoinGeckoAPI() + n = btcInfo.get_price(ids='bitcoin', vs_currencies='usd,eur,gbp,jpy,aud') + q = n['bitcoin'] + usd = q['usd'] + eur = q['eur'] + gbp = q['gbp'] + jpy = q['jpy'] + aud = q['aud'] + + + print(""" + --------------------COINGECKO BITCOIN PRICE----------------------- + + 1 BTC = {} USD + 1 BTC = {} EUR + 1 BTC = {} GBP + 1 BTC = {} JPY + 1 BTC = {} AUD + + ------------------------------------------------------------------ + + ...BUT... + + 1 BTC = 1 BTC + + ------------------------------------------------------------------ + """.format(usd,eur,gbp,jpy,aud)) + input("Continue...") + except: + pass + +#-----------------------------END COINGECKO-------------------------------- + + +#-----------------------------LNBITS-------------------------------- + +def loadFileConnLNBits(lnbitLoad): + lnbitLoad = {"wallet_name":"", "wallet_id":"", "admin_key":"", "invoice_read_key":""} + + if os.path.isfile('lnbit.conf'): # Check if the file 'bclock.conf' is in the same folder + lnbitData= pickle.load(open("lnbit.conf", "rb")) # Load the file 'bclock.conf' + lnbitLoad = lnbitData # Copy the variable pathv to 'path' + else: + 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. + WE WILL NEED SOME INFORMATION FROM YOUR ACCOUNT THAT THE ONLY ONE THAT WILL HAVE ACCESS IS YOU. + 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"] = input("Wallet ID: ") + lnbitLoad["admin_key"] = input("Admin key: ") + lnbitLoad["invoice_read_key"] = input("Invoice/read key: ") + pickle.dump(lnbitLoad, open("lnbit.conf", "wb")) + return lnbitLoad + +def createFileConnLNBits(): + 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. + WE WILL NEED SOME INFORMATION FROM YOUR ACCOUNT THAT THE ONLY ONE THAT WILL HAVE ACCESS IS YOU. + 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_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: ") + + pickle.dump(lnbitLoad, open("lnbit.conf", "wb")) + +def lnbitCreateNewInvoice(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + try: + print("\n\tLNBITS CREATE INVOICE\n") + amt = input("Amount: ") + memo = input("Memo: ") + a = loadFileConnLNBits(['invoice_read_key']) + b = str(a['invoice_read_key']) + curl = ( + 'curl -X POST https://lnbits.com/api/v1/payments -d ' + + "'{" + + f""""out": false, "amount": {amt}, "memo": "{memo} -PyBLOCK" """ + + "}'" + + f""" -H "X-Api-Key: {b} " -H "Content-type: application/json" """ + ) + + sh = os.popen(curl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + q = d['payment_request'] + c = q.lower() + node_not = input("Do you want to pay this invoice with your node? Y/n: ") + + while True: + if node_not in ["Y", "y"]: + lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} + lndconnectData = pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + if lndconnectload['ip_port']: + print("\nInvoice: " + c + "\n") + payinvoice() + elif lndconnectload['ln']: + print("\nInvoice: " + c + "\n") + localpayinvoice() + elif node_not in ["N", "n"]: + print("\033[1;30;47m") + qr.add_data(c) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print(f'Lightning Invoice: {c}') + t.sleep(10) + dn = str(d['checking_id']) + checkcurl = ( + f'curl -X GET https://lnbits.com/api/v1/payments/{dn}' + + f""" -H "X-Api-Key: {b}" -H "Content-type: application/json" """ + ) + + + rsh = os.popen(checkcurl).read() + clear() + blogo() + nn = str(rsh) + dd = json.loads(nn) + db = dd['paid'] + if db != True: + continue + clear() + blogo() + tick() + t.sleep(2) + break + except: + pass + +def lnbitPayInvoice(): + bolt = input("Invoice: ") + a = loadFileConnLNBits(['admin_key']) + b = str(a['admin_key']) + curl = ( + 'curl -X POST https://lnbits.com/api/v1/payments -d ' + + "'{" + + f""""out": true, "bolt11": "{bolt}" """ + + "}'" + + f""" -H "X-Api-Key: {b}" -H "Content-type: application/json" """ + ) + + try: + sh = os.popen(curl).read() + n = str(sh) + d = json.loads(n) + dn = str(d['checking_id']) + a = loadFileConnLNBits(['invoice_read_key']) + b = str(a['invoice_read_key']) + while True: + checkcurl = ( + f'curl -X GET https://lnbits.com/api/v1/payments/{dn}' + + f""" -H "X-Api-Key: {b}" -H "Content-type: application/json" """ + ) + + + rsh = os.popen(checkcurl).read() + clear() + blogo() + nn = str(rsh) + dd = json.loads(nn) + db = dd['paid'] + if db != True: + continue + tick() + t.sleep(2) + break + except: + pass + +def lnbitCreatePayWall(): + while True: + try: + url = input("Url: ") + memo = input("Memo: ") + desc = input("Description: ") + amt = input("Amount in sats: ") + remb = input("Remembers Y/n: ") + a = loadFileConnLNBits(['admin_key']) + b = str(a['admin_key']) + if remb in ["Y", "y"]: + remember = "true" + elif remb in ["N", "n"]: + remember = "false" + curl = ( + 'curl -X POST https://lnbits.com/paywall/api/v1/paywalls -d ' + + "'{" + + f""""url": "{url}", "memo": "{memo}", "description": "{desc}", "amount": {amt}, "remembers": {remember} """ + + "}'" + + f""" -H "Content-type: application/json" -H "X-Api-Key: {b}" """ + ) + + sh = os.popen(curl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + print("\n\tPAYWALL CREATED SUCCESSFULLY\n") + t.sleep(2) + clear() + aa = loadFileConnLNBits(['invoice_read_key']) + bb = str(a['invoice_read_key']) + checkcurl = ( + 'curl -X GET https://lnbits.com/paywall/api/v1/paywalls -H' + + f""" "X-Api-Key: {bb}" """ + ) + + sh = os.popen(checkcurl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + while True: + print("\n\tLNBITS PAYWALL LIST\n") + for item_ in d: + s = item_ + print(f'ID: {s["id"]}') + nd = input("\nSelect ID: ") + for item in d: + s = item + nn = s['id'] + if nd == nn: + print("\n----------------------------------------------------------------------------------------------------------------") + print(""" + \tLNBITS PAYWALL DECODED + + ID: {} + Amount: {} sats + Description: {} + Memo: {} + Extras: {} + Remembers: {} + URL: {} + Wallet: {} + """.format(s['id'], s['amount'], s['description'], s['memo'], s['extras'], s['remembers'], s['url'], s['wallet'])) + print("----------------------------------------------------------------------------------------------------------------\n") + input("Continue...") + clear() + blogo() + except: + break + +def lnbitListPawWall(): + a = loadFileConnLNBits(['invoice_read_key']) + b = str(a['invoice_read_key']) + checkcurl = ( + 'curl -X GET https://lnbits.com/paywall/api/v1/paywalls -H' + + f""" "X-Api-Key: {b}" """ + ) + + sh = os.popen(checkcurl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + while True: + print("\n\tLNBITS PAYWALL LIST\n") + try: + for item_ in d: + s = item_ + print(f'ID: {s["id"]}') + nd = input("\nSelect ID: ") + for item in d: + s = item + nn = s['id'] + if nd == nn: + print("\n----------------------------------------------------------------------------------------------------------------") + print(""" + \tLNBITS PAYWALL DECODED + + ID: {} + Amount: {} sats + Description: {} + Memo: {} + Extras: {} + Remembers: {} + URL: {} + Wallet: {} + """.format(s['id'], s['amount'], s['description'], s['memo'], s['extras'], s['remembers'], s['url'], s['wallet'])) + print("----------------------------------------------------------------------------------------------------------------\n") + except: + break + input("Continue...") + clear() + blogo() + +def lnbitDeletePayWall(): + while True: + try: + a = loadFileConnLNBits(['invoice_read_key']) + b = str(a['invoice_read_key']) + checkcurl = ( + 'curl -X GET https://lnbits.com/paywall/api/v1/paywalls -H' + + f""" "X-Api-Key: {b}" """ + ) + + sh = os.popen(checkcurl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + while True: + print("\n\tLNBITS PAYWALL LIST\n") + try: + for item_ in d: + s = item_ + print(f'ID: {s["id"]}') + nd = input("\nSelect ID: ") + for item in d: + s = item + nn = s['id'] + if nd == nn: + print("\n----------------------------------------------------------------------------------------------------------------") + print(""" + \tLNBITS PAYWALL DECODED + + ID: {} + Amount: {} sats + Description: {} + Memo: {} + Extras: {} + Remembers: {} + URL: {} + Wallet: {} + """.format(s['id'], s['amount'], s['description'], s['memo'], s['extras'], s['remembers'], s['url'], s['wallet'])) + print("----------------------------------------------------------------------------------------------------------------\n") + except: + break + input("Continue...") + break + print("\n\tDELETE PAYWALL\n") + a = loadFileConnLNBits(['admin_key']) + b = str(a['admin_key']) + id = input("Insert PayWall ID: ") + curl = ( + f"curl -X DELETE https://lnbits.com/paywall/api/v1/paywalls/{id}" + + f""" -H "X-Api-Key: {b}" """ + ) + + sh = os.popen(curl).read() + clear() + blogo() + print("\n\tPAYWALL DELETED SUCCESSFULLY\n") + t.sleep(2) + clear() + except: + break + +def lnbitsLNURLw(): + while True: + try: + clear() + blogo() + print(""" + ---------------------- + CREATE LNURL + ----------------------\n""") + title = input("Title: ") + minwith = input("Minimum Withdraw: ") + maxwith = input("Maximum Withdraw: ") + usesw = input("Uses: ") + waittime = input("Wait Time: ") + isunique = input("Is unique? true/false: ") + a = loadFileConnLNBits(['admin_key']) + b = str(a['admin_key']) + curl = ( + 'curl -X POST https://lnbits.com/withdraw/api/v1/links -d ' + + """'{"title":""" + + f'"{title}", "min_withdrawable": {minwith}, "max_withdrawable": {maxwith}, "uses": {usesw}, "wait_time": {waittime}, "is_unique": {isunique}' + + "}'" + + f' -H "Content-type: application/json" -H "X-Api-Key: {b}"' + ) + + sh = os.popen(curl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + print("\n\tLNURLW CREATED SUCCESSFULLY\n") + t.sleep(2) + clear() + while True: + checkcurl = f'curl -X GET https://lnbits.com/withdraw/api/v1/links -H "X-Api-Key: {b}"' + + sh = os.popen(checkcurl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + print("\n\tLNBITS LNURLW LIST\n") + for item_ in d: + s = item_ + print(f'ID: {s["id"]} Uses: ' + str(s['uses']) + " Used: " + str(s['used'])) + nd = input("\nSelect ID: ") + for item in d: + s = item + nn = s['id'] + if nd == nn: + print("\n----------------------------------------------------------------------------------------------------------------") + print(""" + \tLNBITS LNURLW DECODED + + ID: {} + LNURL: {} + Wait Time: {} + Uses: {} + Used: {} + Minimum Withdraw: {} + Maximum Withdraw: {} + """.format(s['id'], s['lnurl'], s['wait_time'], s['uses'], s['used'], s['min_withdrawable'], s['max_withdrawable'])) + print("----------------------------------------------------------------------------------------------------------------\n") + input("Continue...") + clear() + blogo() + except: + break + +def lnbitsLNURLwList(): + try: + while True: + a = loadFileConnLNBits(['admin_key']) + b = str(a['admin_key']) + checkcurl = f'curl -X GET https://lnbits.com/withdraw/api/v1/links -H "X-Api-Key: {b}"' + + sh = os.popen(checkcurl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + print("\n\tLNBITS LNURLW LIST\n") + for item_ in d: + s = item_ + print(f'ID: {s["id"]} Uses: ' + str(s['uses']) + " Used: " + str(s['used'])) + nd = input("\nSelect ID: ") + for item in d: + s = item + nn = s['id'] + if nd == nn: + print("\n----------------------------------------------------------------------------------------------------------------") + print(""" + \tLNBITS LNURLW DECODED + + ID: {} + LNURL: {} + Wait Time: {} + Uses: {} + Used: {} + Minimum Withdraw: {} + Maximum Withdraw: {} + """.format(s['id'], s['lnurl'], s['wait_time'], s['uses'], s['used'], s['min_withdrawable'], s['max_withdrawable'])) + print("----------------------------------------------------------------------------------------------------------------\n") + input("Continue...") + except: + print("\n") + +#-------------------------1d646820055e4e2da218e801eaacfc94----END LNBITS-------------------------------- +#-----------------------------LNPAY-------------------------------- + +def loadFileConnLNPay(lnpayLoad): + lnpayLoad = {"key":""} + + if os.path.isfile('lnpay.conf'): # Check if the file 'bclock.conf' is in the same folder + lnpayData= pickle.load(open("lnpay.conf", "rb")) # Load the file 'bclock.conf' + lnpayLoad = lnpayData # Copy the variable pathv to 'path' + else: + 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 LNPAY.CO. + WE WILL NEED SOME INFORMATION FROM YOUR ACCOUNT THAT THE ONLY ONE THAT WILL HAVE ACCESS IS YOU. + IF YOU DELETE THIS FILE YOU WILL NEED TO PAY AGAIN TO GET ACCESS FROM PyBLOCK. + SAVE THE FILE '\033[1;33;40mlnpaySN.conf\033[0;37;40m' IN A SAFE PLACE.\n + """) + lnpayLoad["key"] = input("API Key: ") + print("\n\tWALLET ACCESS KEYS\n") + lnpayLoad["wallet_key_id"] = input("Wallet Admin: ") + pickle.dump(lnpayLoad, open("lnpay.conf", "wb")) + clear() + blogo() + return lnpayLoad + +def createFileConnLNPay(): + 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 LNPAY.CO. + WE WILL NEED SOME INFORMATION FROM YOUR ACCOUNT THAT THE ONLY ONE THAT WILL HAVE ACCESS IS YOU. + IF YOU DELETE THIS FILE YOU WILL NEED TO PAY AGAIN TO GET ACCESS FROM PyBLOCK. + SAVE THE FILE '\033[1;33;40mlnpaySN.conf\033[0;37;40m' IN A SAFE PLACE.\n + """) + lnpayLoad["key"] = input("API Key: ") + print("\n\tWALLET ACCESS KEYS\n") + lnpayLoad["wallet_key_id"] = input("Wallet Admin: ") + pickle.dump(lnpayLoad, open("lnpay.conf", "wb")) + +def lnpayGetBalance(): + a = loadFileConnLNPay(['key']) + b = str(a['key']) + n = loadFileConnLNPay(['wallet_key_id']) + q = str(n['wallet_key_id']) + lnpay_py.initialize(b) + clear() + blogo() + my_wallet = LNPayWallet(q) + info = my_wallet.get_info() + print("\n---------------------------------------------------------------------------------------------------") + print(""" + \tLNPAY WALLET BALANCE + + Wallet ID: {} + Wallet Name: {} + Balance: {} sats + """.format(info['id'], info['user_label'], info['balance'])) + print("---------------------------------------------------------------------------------------------------\n") + input("\nContinue... ") + +def lnpayCreateInvoice(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + a = loadFileConnLNPay(['key']) + b = str(a['key']) + n = loadFileConnLNPay(['wallet_key_id']) + q = str(n['wallet_key_id']) + lnpay_py.initialize(b) + clear() + blogo() + my_wallet = LNPayWallet(q) + amt = input("\nAmount in Sats: ") + memo = input("Memo: ") + invoice_params = {'num_satoshis': amt, 'memo': f'{memo} -PyBLOCK'} + try: + invoice = my_wallet.create_invoice(invoice_params) + clear() + blogo() + node_not = input("Do you want to pay this invoice with your node? Y/n: ") + while True: + if node_not in ["Y", "y"]: + lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} + lndconnectData = pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + if lndconnectload['ip_port']: + print("\nInvoice: " + invoice['payment_request'] + "\n") + payinvoice() + elif lndconnectload['ln']: + print("\nInvoice: " + invoice['payment_request'] + "\n") + localpayinvoice() + elif node_not in ["N", "n"]: + print("\033[1;30;47m") + qr.add_data(invoice['payment_request']) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print(f'Lightning Invoice: {invoice["payment_request"]}') + t.sleep(10) + curl = f'curl -u {b}: https://api.lnpay.co/v1/lntx/{invoice["id"]}?fields=settled,num_satoshis' + + rsh = os.popen(curl).read() + clear() + blogo() + nn = str(rsh) + dd = json.loads(nn) + db = dd['settled'] + if db != 1: + continue + clear() + blogo() + tick() + t.sleep(2) + break + except: + pass + +def lnpayGetTransactions(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + a = loadFileConnLNPay(['key']) + b = str(a['key']) + n = loadFileConnLNPay(['wallet_key_id']) + q = str(n['wallet_key_id']) + lnpay_py.initialize(b) + clear() + blogo() + my_wallet = LNPayWallet(q) + + transactions = my_wallet.get_transactions() + while True: + try: + print("\n\tLNPAY LIST PAYMENTS\n") + for transaction_ in transactions: + s = transaction_ + q = s['lnTx'] + + print(f'ID: {s["id"]}') + nd = input("\nSelect ID: ") + for transaction in transactions: + s = transaction + nn = s['id'] + nnn = s['lnTx'] + if nd == nn: + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tLNPAY LIST PAYMENT DECODED + + ID: {} + Amount: {} sats + Memo: {} + Invoice: {} + RHash: {} + """.format(nnn['id'], nnn['num_satoshis'], nnn['memo'], nnn['payment_request'], nnn['r_hash_decoded'])) + print("----------------------------------------------------------------------------------------------------\n") + print("\033[1;30;47m") + qr.add_data(nnn['payment_request']) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + input("Continue...") + clear() + blogo() + except: + break + clear() + blogo() + +def lnpayPayInvoice(): + a = loadFileConnLNPay(['key']) + b = str(a['key']) + n = loadFileConnLNPay(['wallet_key_id']) + q = str(n['wallet_key_id']) + lnpay_py.initialize(b) + clear() + blogo() + my_wallet = LNPayWallet(q) + try: + print("\n\tLNPAY PAY INVOICE\n") + inv = input("\nInvoice: ") + 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) + dd = json.loads(nn) + clear() + blogo() + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tLNPAY INVOICE DECODED + + Destination: {} + Amount: {} sats + Memo: {} + Invoice: {} + """.format(dd['destination'], dd['num_satoshis'], dd['description'], inv)) + print("----------------------------------------------------------------------------------------------------\n") + print("<<< Cancel Control + C") + input("\nEnter to Continue... ") + invoice_params = { + 'payment_request': inv + } + pay_result = my_wallet.pay_invoice(invoice_params) + except: + pass + +def lnpayTransBWallets(): + a = loadFileConnLNPay(['key']) + b = str(a['key']) + n = loadFileConnLNPay(['wallet_key_id']) + q = str(n['wallet_key_id']) + lnpay_py.initialize(b) + clear() + blogo() + print("""\n\tLNPAY TRANSFER BETWEEN WALLETS + \nCaution: If you Transfer to another of your LNPay wallets + you will only access to your funds via Web.\n""") + try: + wall = input("Wallet destination ID: ") + amt = input("Amount in Sats: ") + memo = input("Memo: ") + my_wallet = LNPayWallet(q) + transfer_params = { + 'dest_wallet_id': wall, + 'num_satoshis': amt, + 'memo': memo + } + transfer_result = my_wallet.internal_transfer(transfer_params) + p = transfer_result['wtx_transfer_in'] + e = transfer_result['wtx_transfer_out'] + f = e['wal'] + v = p['wal'] + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tLNPAY TRANSFER BETEWWN WALLETS INFORMATION + + ID: {} + Amount: {} sats + Memo: {} + To Wallet: {} + From Wallet: {} + """.format(p['id'], p['num_satoshis'], p['user_label'], v['user_label'], f['user_label'])) + print("----------------------------------------------------------------------------------------------------\n") + input("Continue...") + except: + pass + +#-----------------------------END LNPAY-------------------------------- +#-----------------------------OPENNODE-------------------------------- + +def loadFileConnOpenNode(opennodeLoad): + opennodeLoad = {"key":"","wdr":"","inv":""} + + if os.path.isfile('opennode.conf'): # Check if the file 'bclock.conf' is in the same folder + opennodeData= pickle.load(open("opennode.conf", "rb")) # Load the file 'bclock.conf' + opennodeLoad = opennodeData # Copy the variable pathv to 'path' + else: + 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. + WE WILL NEED SOME INFORMATION FROM YOUR ACCOUNT THAT THE ONLY ONE THAT WILL HAVE ACCESS IS YOU. + 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"] = input("API Withdrawall Key: ") + opennodeLoad["inv"] = input("API Invoices Key: ") + pickle.dump(opennodeLoad, open("opennode.conf", "wb")) + clear() + blogo() + return opennodeLoad + +def createFileConnOpenNode(): + 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. + WE WILL NEED SOME INFORMATION FROM YOUR ACCOUNT THAT THE ONLY ONE THAT WILL HAVE ACCESS IS YOU. + 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 = {'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")) + +def OpenNodelistfunds(): + a = loadFileConnOpenNode(['wdr']) + b = str(a['wdr']) + curl = ( + "curl https://api.opennode.co/v1/account/balance -H " + + f'"Content-Type: application/json" -H "Authorization: {b}"' + ) + + sh = os.popen(curl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + r = d['data'] + p = r['balance'] + print("\n----------------------------------------------------------------------------------------------------") + print(""" + OPENNODE BALANCE + + Amount: {} sats + """.format(p['BTC'])) + print("----------------------------------------------------------------------------------------------------\n") + input("Continue...") + +def OpenNodeCheckStatus(): + curl = "curl -X GET https://status.opennode.com/history.rss" + sh = os.popen(curl).read() + clear() + blogo() + my_dict=xmltodict.parse(sh) + n=json.dumps(my_dict) + nn = str(n) + qq = json.loads(n) + a = qq['rss'] + b = a['channel'] + c = b['title'] + d = b['item'] + dd = d[0] + e = dd['title'] + print(""" + \n---------------------------------------------------------------------------------------------------- + \n\t{} + + {}\n + {} + + \n---------------------------------------------------------------------------------------------------- + """.format(c.upper(),e,b['pubDate'])) + input("Enter to Continue...") + +def OpenNodecreatecharge(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + a = loadFileConnOpenNode(['key']) + b = str(a['key']) + fiat = input("Are you going to pay in FIAT? Y/n:") + if fiat in ["Y", "y"]: + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tFIAT supported on OpenNode: + + AED,AFN,ALL,AMD,ANG,AOA,ARS,AUD,AWG,AZN,BAM,BBD,BDT,BGN,BHD,BIF,BMD,BND,BOB,BRL,BSD,BTN,BWP, + BYN,BZD,CAD,CDF,CHF,CLF,CLP,CNH,CNY,COP,CRC,CUC,CUP,CVE,CZK,DJF,DKK,DOP,DZD,EGP,ERN,ETB,EUR, + FJD,FKP,GBP,GEL,GGP,GHS,GIP,GMD,GNF,GTQ,GYD,HKD,HNL,HRK,HTG,HUF,IDR,ILS,IMP,INR,IQD,IRR,ISK, + JEP,JMD,JOD,JPY,KES,KGS,KHR,KMF,KPW,KRW,KWD,KYD,KZT,LAK,LBP,LKR,LRD,LSL,LYD,MAD,MDL,MGA,MKD, + MMK,MNT,MOP,MRO,MUR,MVR,MWK,MXN,MYR,MZN,NAD,NGN,NIO,NOK,NPR,NZD,OMR,PAB,PEN,PGK,PHP,PKR,PLN, + PYG,QAR,RON,RSD,RUB,RWF,SAR,SBD,SCR,SDG,SEK,SGD,SHP,SLL,SOS,SRD,SSP,STD,SVC,SYP,SZL,THB,TJS, + TMT,TND,TOP,TRY,TTD,TWD,TZS,UAH,UGX,USD,UYU,UZS,VES,VND,VUV,WST,XAF,XAG,XAU,XCD,XDR,XOF,XPD, + XPF,XPT,YER,ZAR,ZMW,ZWL,USDC. + """) + print("\n----------------------------------------------------------------------------------------------------") + selection = input("Select a FIAT currency: ") + amt = input(f"Amount in {selection}: ") + curl = ( + 'curl https://api.opennode.co/v1/charges -X POST -H ' + + f'"Authorization: {b}"' + + ' -H "Content-Type: application/json" -d ' + + "'{" + + f'"amount": "{amt}", "currency": "{selection.upper()}"' + + "}'" + ) + + sh = os.popen(curl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + dd = d['data'] + qq = dd['lightning_invoice'] + pp = dd['address'] + nn = qq['payreq'] + mm = nn.lower() + while True: + try: + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tOPENNODE PAYMENT REQUEST + + Amount: {} {} + ID: {} + Status: {} + Invoice: {} + Onchain Address: {} + Amount: {} sats + """.format(amt, selection.upper(), dd['id'], dd['status'], mm, pp, dd['amount'])) + print("----------------------------------------------------------------------------------------------------\n") + pay = input("Invoice or Onchain Address? I/O: ") + if pay in ["I", "i"]: + node_not = input("Do you want to pay this invoice with your node? Y/n: ") + if node_not in ["Y", "y"]: + lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} + lndconnectData = pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + if lndconnectload['ip_port']: + print("\nInvoice: " + mm + "\n") + payinvoice() + elif lndconnectload['ln']: + print("\nInvoice: " + mm + "\n") + localpayinvoice() + elif node_not in ["N", "n"]: + print("\033[1;30;47m") + qr.add_data(mm) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("\nLightning Invoice: " + mm) + elif pay in ["O", "o"]: + print("\033[1;30;47m") + qr.add_data(pp) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("\nAmount in sats: {} sats".format(dd['amount'])) + print("\nOnchain Address: " + pp) + input("\nContinue...") + clear() + blogo() + except: + break + elif fiat in ["N", "n"]: + amt = input("Amount in sats: ") + curl = ( + 'curl https://api.opennode.co/v1/charges -X POST -H' + + f'"Authorization: {b}"' + + ' -H "Content-Type: application/json" -d ' + + "'{" + + f'"amount": "{amt}", "currency": "BTC"' + + "}'" + ) + + sh = os.popen(curl).read() + clear() + blogo() + n = str(sh) + d = json.loads(n) + dd = d['data'] + qq = dd['lightning_invoice'] + nn = qq['payreq'] + pp = dd['address'] + mm = nn.lower() + while True: + try: + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tOPENNODE PAYMENT REQUEST + + Amount: {} sats + ID: {} + Status: {} + Invoice: {} + Onchain Address: {} + Amount: {} sats + """.format(amt, dd['id'], dd['status'], mm, pp, dd['amount'])) + print("----------------------------------------------------------------------------------------------------\n") + pay = input("Invoice or Onchain Address? I/O: ") + if pay in ["I", "i"]: + node_not = input("Do you want to pay this invoice with your node? Y/n: ") + if node_not in ["Y", "y"]: + lndconnectData = pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + if lndconnectload['ip_port']: + print("\nInvoice: " + mm + "\n") + payinvoice() + elif lndconnectload['ln']: + print("\nInvoice: " + mm + "\n") + localpayinvoice() + elif node_not in ["N", "n"]: + print("\033[1;30;47m") + qr.add_data(mm) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("\nLightning Invoice: " + mm) + elif pay in ["O", "o"]: + print("\033[1;30;47m") + qr.add_data(pp) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + print("\nAmount in sats: {} sats".format(dd['amount'])) + print("\nOnchain Address: " + pp) + input("\nContinue...") + clear() + blogo() + except: + break + +def OpenNodeiniciatewithdrawal(): + a = loadFileConnOpenNode(['wdr']) + b = str(a['wdr']) + c = loadFileConnOpenNode(['key']) + d = str(a['key']) + lnchain = input("Are you going to pay with Lightning or Onchain? L/O: ") + clear() + blogo() + if lnchain in ["L", "l"]: + try: + while True: + invoice = input("\nInvoice: ") + checkcurl = ( + f'curl https://api.opennode.co/v1/charge/decode -X POST -H "Authorization: {b}" -H "Content-Type: application/json" -d ' + + "'{" + + f'"pay_req": "{invoice}"' + + "}'" + ) + + ssh = os.popen(checkcurl).read() + nn = str(ssh) + dd = json.loads(nn) + print(dd) + if invoice != "": + break + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tOPENNODE TRANSFER REQUEST + + Message: {} + """.format(dd['message'])) + print("----------------------------------------------------------------------------------------------------\n") + rr = dd['data'] + ss = rr['pay_req'] + + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tOPENNODE TRANSFER REQUEST + + Network: {} + Amount: {} sats + Destination: {} + Hash: {} + """.format(ss['network'],ss['amount'],ss['pub_key'],ss['hash'])) + print("----------------------------------------------------------------------------------------------------\n") + print("<<< Cancel Control + C") + input("\nEnter to Continue... ") + + curl = ( + f'curl https://api.opennode.co/v2/withdrawals -X POST -H "Content-Type: application/json" -H "Authorization: {b}"' + + " -d '{" + + f'"type": "ln", "address": "{invoice}", "callback_url": ""' + + "}'" + ) + + sh = os.popen(curl).read() + n = str(sh) + d = json.loads(n) + clear() + blogo() + tick() + t.sleep(2) + except: + pass + + elif lnchain in ["O", "o"]: + try: + while True: + print("\n\tOPENNODE TRANSFER REQUEST\n") + print("\n\tMinimum amount 200000 sats\n") + address = input("\nBitcoin Address: ") + amt = int(input("Amount in sats: ")) + curl = ( + f'curl https://api.opennode.co/v2/withdrawals -X POST -H "Content-Type: application/json" -H "Authorization: {b}"' + + " -d '{" + + f'"type": "chain", "amount": {amt}, "address": "{address}", "callback_url": ""' + + "}'" + ) + + if amt < 199999: + sh = os.popen(curl).read() + n = str(sh) + d = json.loads(n) + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tOPENNODE TRANSFER REQUEST + + Message: {} + """.format(d['message'])) + print("----------------------------------------------------------------------------------------------------\n") + elif amt > 200000: + sh = os.popen(curl).read() + n = str(sh) + d = json.loads(n) + dd = d['data'] + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tOPENNODE TRANSFER REQUEST + + Amount: {} sats + Address Destination: {} + Fee: {} + Status: {} + """.format(dd['amount'],dd['address'],dd['fee'], dd['status'])) + print("----------------------------------------------------------------------------------------------------\n") + input("\nContinue... ") + clear() + blogo() + logoB() + t.sleep(2) + break + except: + pass + +def OpenNodeListPayments(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + a = loadFileConnOpenNode(['wdr']) + b = str(a['wdr']) + curl = f'curl https://api.opennode.co/v1/withdrawals -H "Content-Type: application/json" -H "Authorization: {b}"' + + sh = os.popen(curl).read() + clear() + blogo() + print("\n\tOPENNODE TRANSACTIONS LIST\n") + n = str(sh) + d = json.loads(n) + da = d['data'] + while True: + try: + for item_ in da: + s = item_ + n = s['status'] + q = str(n) + print(f'ID: {s["id"]} {q}') + nd = input("\nSelect ID: ") + for item in da: + s = item + nn = s['id'] + if nd == nn: + print("\n----------------------------------------------------------------------------------------------------") + print(""" + \tOPENNODE TRANSACTION DECODED + ID: {} + Amount: {} sats + Type: {} + Invoice or Tx ID: {} + Status: {} + """.format(s['id'], s['amount'], s['type'], s['reference'], s['status'])) + print("----------------------------------------------------------------------------------------------------\n") + print("\033[1;30;47m") + qr.add_data(s['reference']) + qr.print_ascii() + print("\033[0;37;40m") + qr.clear() + input("Continue...") + clear() + blogo() + print("\n\tOPENNODE TRANSACTIONS LIST\n") + except: + break + +#-----------------------------END OPENNODE-------------------------------- +#-----------------------------TIPPINME-------------------------------- + +def loadFileTippinMe(tippinmeLoad): + tippinmeLoad = {"key":""} + + if os.path.isfile('tippinme.conf'): # Check if the file 'bclock.conf' is in the same folder + tippinmeData= pickle.load(open("tippinme.conf", "rb")) # Load the file 'bclock.conf' + tippinmeLoad = tippinmeData # Copy the variable pathv to 'path' + else: + 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: ") + pickle.dump(tippinmeLoad, open("tippinme.conf", "wb")) + clear() + blogo() + return tippinmeLoad + +def createFileTippinMe(): + 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: ")} + pickle.dump(tippinmeLoad, open("tippinme.conf", "wb")) + +def tippinmeGetInvoice(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + a = loadFileTippinMe(['key']) + b = str(a['key']) + try: + print("\n\tTIPPINME GENERATE INVOICE\n") + q = input("Amount in Sats: ") + clear() + blogo() + url = f'https://api.tippin.me/v1/public/addinvoice/{b}/{q}' + response = requests.get(url) + responseB = str(response.text) + responseC = responseB + lnreq = responseC.split(',') + lnbc1 = lnreq[1] + lnbc1S = str(lnbc1) + lnbc1R = lnbc1S.split(':') + lnbc1W = lnbc1R[1] + ln = str(lnbc1W) + ln1 = ln.strip('"') + node_not = input("Do you want to pay this invoice with your node? Y/n: ") + if node_not in ["Y", "y"]: + lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} + lndconnectData = pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + if lndconnectload['ip_port']: + print("\nInvoice: " + ln1 + "\n") + payinvoice() + elif lndconnectload['ln']: + print("\nInvoice: " + ln1 + "\n") + localpayinvoice() + elif node_not in ["N", "n"]: + print("\033[1;30;47m") + qr.add_data(ln1) + qr.print_ascii() + print("\033[0;37;40m") + print(f'LND Invoice: {ln1}') + response.close() + input("Continue...") + except: + pass + +#-----------------------------END TIPPINME-------------------------------- +#-----------------------------TALLYCOIN------------------------------ +def loadFileConnTallyCo(tallycoLoad): + tallycoLoad = {"tallyco.conf":"","id":""} + + if os.path.isfile('tallyco.conf'): # Check if the file 'bclock.conf' is in the same folder + tallyData= pickle.load(open("tallyco.conf", "rb")) # Load the file 'bclock.conf' + tallycoLoad = tallyData # Copy the variable pathv to 'path' + else: + 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. + WE WILL NEED SOME INFORMATION FROM YOUR ACCOUNT THAT THE ONLY ONE THAT WILL HAVE ACCESS IS YOU. + IF YOU DELETE THIS FILE YOU WILL NEED TO PAY AGAIN TO GET ACCESS FROM PyBLOCK. + 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: ") + pickle.dump(tallycoLoad, open("tallyco.conf", "wb")) + clear() + blogo() + return tallycoLoad + +def createFileConnTallyCo(): + 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. + WE WILL NEED SOME INFORMATION FROM YOUR ACCOUNT THAT THE ONLY ONE THAT WILL HAVE ACCESS IS YOU. + IF YOU DELETE THIS FILE YOU WILL NEED TO PAY AGAIN TO GET ACCESS FROM PyBLOCK. + 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 = {'fundraiser_id': '', 'id': input("User ID or Twitter @USER: ")} + pickle.dump(tallycoLoad, open("tallyco.conf", "wb")) + +def tallycoGetPayment(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + c = loadFileConnTallyCo(['id']) + d = str(c['id']) + try: + amount = input("Amount in Sats: ") + print("""\nPayment Method Example: 'ln' or 'btc' + 'ln' = Lightnin Netowrk + 'btc'= Bitcoin Onchain Payment + \n""") + lnd_onchain = input("Payment Method: ") + curl = ( + "curl -d " + + f'"type=profile&id={d}&satoshi_amount={amount}&payment_method={lnd_onchain}"' + + " -X POST https://api.tallyco.in/v1/payment/request/" + ) + + tallycomethod = os.popen(curl).read() + n = str(tallycomethod) + d = json.loads(n) + clear() + blogo() + if lnd_onchain == "ln": + e = d['lightning_pay_request'] + f = e.lower() + print("\033[1;30;47m") + qr.add_data(f) + qr.print_ascii() + print("\033[0;37;40m") + print(f'LND Invoice: {f}') + qr.clear() + input("\nContinue...") + elif lnd_onchain == "btc": + e = d['btc_address'] + print("\033[1;30;47m") + qr.add_data(e) + qr.print_ascii() + print("\033[0;37;40m") + print(f'Amount: {d["cost"]}') + print(f'Bitcoin Address: {e}') + qr.clear() + input("\nContinue...") + except: + pass + + +def tallycoDonateid(): + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + clear() + blogo() + try: + donate = input("Donate to ID: ") + amount = input("Amount in Sats: ") + print("""\nPayment Method Example: 'ln' or 'btc' + 'ln' = Lightnin Netowrk + 'btc'= Bitcoin Onchain Payment + \n""") + lnd_onchain = input("Payment Method: ") + curl = ( + "curl -d " + + f'"type=profile&id={donate}&satoshi_amount={amount}&payment_method={lnd_onchain}"' + + " -X POST https://api.tallyco.in/v1/payment/request/" + ) + + tallycomethod = os.popen(curl).read() + n = str(tallycomethod) + d = json.loads(n) + clear() + blogo() + if lnd_onchain in ["ln", "lN", "Ln", "LN"]: + node_not = input("Do you want to pay this tip with your node? Y/n: ") + if node_not in ["Y", "y"]: + lndconnectload = {"ip_port":"", "tls":"", "macaroon":"", "ln":""} + lndconnectData = pickle.load(open("blndconnect.conf", "rb")) # Load the file 'bclock.conf' + lndconnectload = lndconnectData # Copy the variable pathv to 'path' + if lndconnectload['ip_port']: + e = d['lightning_pay_request'] + f = e.lower() + print("\nInvoice: " + f + "\n") + payinvoice() + elif lndconnectload['ln']: + e = d['lightning_pay_request'] + f = e.lower() + print("\nInvoice: " + f + "\n") + localpayinvoice() + elif node_not in ["N", "n"]: + e = d['lightning_pay_request'] + f = e.lower() + print("\033[1;30;47m") + qr.add_data(f) + qr.print_ascii() + print("\033[0;37;40m") + print(f'LND Invoice: {f}') + qr.clear() + input("\nContinue...") + elif lnd_onchain in ["btc", "bTC", "BtC", "BTC", "BTc", "btC"]: + e = d['btc_address'] + print("\033[1;30;47m") + qr.add_data(e) + qr.print_ascii() + print("\033[0;37;40m") + print(f'Amount: {d["cost"]}') + print(f'Bitcoin Address: {e}') + qr.clear() + input("\nContinue...") + except: + pass + + +#-----------------------------END TALLYCOIN------------------------------ +#-----------------------------MEMPOOL.SPACE------------------------------ + +def fee(): + try: + while True: + r = requests.get('https://mempool.space/api/v1/fees/recommended') + r.headers['Content-Type'] + n = r.text + di = json.loads(n) + clear() + blogo() + print(""" + ------------------------ + Fastest Fee: {} + Half Hour Fee: {} + Hour Fee: {} + ------------------------ + <<< Back Control + C + """.format(di['fastestFee'], di['halfHourFee'], di['hourFee'])) + t.sleep(5) + print("\n\t Getting New Information") + except: + pass + +def blocks(): + try: + while True: + clear() + blogo() + print("\n\t Getting New Information") + r = requests.get('https://mempool.space/api/v1/fees/mempool-blocks') + r.headers['Content-Type'] + n = r.text + di = json.loads(n) + for n in range(len(di)): + q = di[n] + clear() + blogo() + print(""" + ----------------------------------------- + BLOCK + ----------------------------------------- + Block Size: {} bytes + Block VSize: {} bytes + Transactions: {} + Total Fees: {} + Median Fee: {} + ----------------------------------------- + <<< Back Control + C + """.format(q['blockSize'], q['blockVSize'], q['nTx'], q['totalFees'], q['medianFee'])) + t.sleep(3) + except: + pass + + +#-----------------------------END MEMPOOL.SPACE------------------------------ diff --git a/pybitblock/SPV/rebalance.py b/pybitblock/SPV/rebalance.py new file mode 100644 index 0000000..52d4b52 --- /dev/null +++ b/pybitblock/SPV/rebalance.py @@ -0,0 +1,256 @@ +#!/usr/bin/env python + +import argparse +import math +import os +import platform +import sys + +from lnd import Lnd +from logic import Logic + +MAX_CHANNEL_CAPACITY = 16777215 +MAX_SATOSHIS_PER_TRANSACTION = 4294967 + + +def main(): + argument_parser = get_argument_parser() + arguments = argument_parser.parse_args() + lnd = Lnd(arguments.lnddir, arguments.grpc) + first_hop_channel_id = vars(arguments)['from'] + to_channel = arguments.to + + if arguments.ratio < 1 or arguments.ratio > 50: + print("--ratio must be between 1 and 50") + sys.exit(1) + channel_ratio = float(arguments.ratio) / 100 + + if arguments.incoming is not None and not arguments.list_candidates: + print("--outgoing and --incoming only work in conjunction with --list-candidates") + sys.exit(1) + + if arguments.list_candidates: + incoming = arguments.incoming is None or arguments.incoming + if incoming: + list_incoming_candidates(lnd, channel_ratio) + else: + list_outgoing_candidates(lnd, channel_ratio) + sys.exit(0) + + if to_channel is None and first_hop_channel_id is None: + argument_parser.print_help() + sys.exit(1) + + percentage = arguments.percentage + if percentage: + if percentage < 1 or percentage > 100: + print("--percentage must be between 1 and 100") + argument_parser.print_help() + sys.exit(1) + + # the 'to' argument might be an index, or a channel ID + if to_channel and to_channel < 10000: + # here we are in the "channel index" case + index = int(to_channel) - 1 + candidates = get_incoming_rebalance_candidates(lnd, channel_ratio) + candidate = candidates[index] + last_hop_channel = candidate + else: + # else the channel argument should be the channel ID + last_hop_channel = get_channel_for_channel_id(lnd, to_channel) + + first_hop_channel = get_channel_for_channel_id(lnd, first_hop_channel_id) + + amount = get_amount(arguments, first_hop_channel, last_hop_channel) + + if amount == 0: + print("Amount is 0, nothing to do") + sys.exit(0) + + max_fee_factor = arguments.max_fee_factor + excluded = arguments.exclude + return Logic(lnd, first_hop_channel, last_hop_channel, amount, channel_ratio, excluded, + max_fee_factor).rebalance() + + +def get_amount(arguments, first_hop_channel, last_hop_channel): + if last_hop_channel: + amount = get_rebalance_amount(last_hop_channel) + else: + amount = get_rebalance_amount(first_hop_channel) + + if arguments.percentage: + amount = int(round(amount * arguments.percentage / 100)) + + if last_hop_channel and first_hop_channel: + rebalance_amount_from_channel = get_rebalance_amount(first_hop_channel) + amount = min(amount, rebalance_amount_from_channel) + + if arguments.amount: + amount = min(amount, int(arguments.amount)) + + amount = min(amount, MAX_SATOSHIS_PER_TRANSACTION) + + return amount + + +def get_channel_for_channel_id(lnd, channel_id): + for channel in lnd.get_channels(): + if channel.chan_id == channel_id: + return channel + return None + + +def get_argument_parser(): + parser = argparse.ArgumentParser() + parser.add_argument("--lnddir", + default="~/.lnd", + dest="lnddir", + help="(default ~/.lnd) lnd directory") + parser.add_argument("--grpc", + default="localhost:10009", + dest="grpc", + help="(default localhost:10009) lnd gRPC endpoint") + parser.add_argument("-r", "--ratio", + type=int, + default=50, + help="(default: 50) ratio for channel imbalance between 1 and 50, " + "eg. 45 to only show channels (-l) with less than 45%% of the " + "funds on the local (-i) or remote (-o) side") + list_group = parser.add_argument_group("list candidates", "Show the unbalanced channels.") + list_group.add_argument("-l", "--list-candidates", action="store_true", + help="list candidate channels for rebalance") + + direction_group = list_group.add_mutually_exclusive_group() + direction_group.add_argument("-o", "--outgoing", + action="store_const", + const=False, + dest="incoming", + help="lists channels with less than x%% of the funds on the remote side (see --ratio)") + direction_group.add_argument("-i", "--incoming", + action="store_const", + const=True, + dest="incoming", + help="(default) lists channels with less than x%% of the funds on the local side " + "(see --ratio)") + + rebalance_group = parser.add_argument_group("rebalance", + "Rebalance a channel. You need to specify at least" + " the 'from' channel (-f) or the 'to' channel (-t).") + rebalance_group.add_argument("-f", "--from", + metavar="CHANNEL", + type=int, + help="channel ID of the outgoing channel " + "(funds will be taken from this channel)") + rebalance_group.add_argument("-t", "--to", + metavar="CHANNEL", + type=int, + help="channel ID of the incoming channel " + "(funds will be sent to this channel). " + "You may also use the index as shown in the incoming candidate list (-l -i).") + amount_group = rebalance_group.add_mutually_exclusive_group() + amount_group.add_argument("-a", "--amount", + type=int, + help="Amount of the rebalance, in satoshis. If not specified, " + "the amount computed for a perfect rebalance will be used" + " (up to the maximum of 4,294,967 satoshis)") + amount_group.add_argument("-p", "--percentage", + type=int, + help="Set the amount to send to a percentage of the amount required to rebalance. " + "As an example, if this is set to 50, the amount will half of the default. " + "See --amount.") + rebalance_group.add_argument("-e", "--exclude", + type=int, + action="append", + help="Exclude the given channel ID as the outgoing channel (no funds will be taken " + "out of excluded channels)") + rebalance_group.add_argument("--max-fee-factor", + type=float, + default=10, + help="(default: 10) Reject routes that cost more than x times the lnd default " + "(base: 1 sat, rate: 1 millionth sat) per hop on average") + return parser + + +def list_incoming_candidates(lnd, channel_ratio): + candidates = get_incoming_rebalance_candidates(lnd, channel_ratio) + list_candidates(candidates) + + +def list_outgoing_candidates(lnd, channel_ratio): + candidates = get_outgoing_rebalance_candidates(lnd, channel_ratio) + list_candidates(candidates) + + +def list_candidates(candidates): + index = 0 + for candidate in candidates: + index += 1 + rebalance_amount_int = get_rebalance_amount(candidate) + rebalance_amount = "{:,}".format(rebalance_amount_int) + if rebalance_amount_int > MAX_SATOSHIS_PER_TRANSACTION: + rebalance_amount += " (max per transaction: {:,})".format(MAX_SATOSHIS_PER_TRANSACTION) + + print("(%2d) Channel ID: " % index + str(candidate.chan_id)) + print("Pubkey: " + candidate.remote_pubkey) + print("Local ratio: {:.3f}".format(get_local_ratio(candidate))) + print("Capacity: {:,}".format(candidate.capacity)) + print("Remote balance: {:,}".format(candidate.remote_balance)) + print("Local balance: {:,}".format(candidate.local_balance)) + print("Amount for 50-50: " + rebalance_amount) + print(get_capacity_and_ratio_bar(candidate)) + print("") + + +def get_rebalance_amount(channel): + return abs(int(math.ceil(float(get_remote_surplus(channel)) / 2))) + + +def get_incoming_rebalance_candidates(lnd, channel_ratio): + low_local = list(filter(lambda c: get_local_ratio(c) < channel_ratio, lnd.get_channels())) + low_local = list(filter(lambda c: get_rebalance_amount(c) > 0, low_local)) + return sorted(low_local, key=get_remote_surplus, reverse=False) + + +def get_outgoing_rebalance_candidates(lnd, channel_ratio): + high_local = list(filter(lambda c: get_local_ratio(c) > 1 - channel_ratio, lnd.get_channels())) + high_local = list(filter(lambda c: get_rebalance_amount(c) > 0, high_local)) + return sorted(high_local, key=get_remote_surplus, reverse=True) + + +def get_local_ratio(channel): + remote = channel.remote_balance + local = channel.local_balance + return float(local) / (remote + local) + + +def get_remote_surplus(channel): + return channel.remote_balance - channel.local_balance + + +def get_capacity_and_ratio_bar(candidate): + columns = get_columns() + columns_scaled_to_capacity = int(round(columns * float(candidate.capacity) / MAX_CHANNEL_CAPACITY)) + + bar_width = columns_scaled_to_capacity - 2 + result = "|" + ratio = get_local_ratio(candidate) + length = int(round(ratio * bar_width)) + for x in range(0, length): + result += "=" + for x in range(length, bar_width): + result += " " + return result + "|" + + +def get_columns(): + if platform.system() == 'Linux' and sys.__stdin__.isatty(): + return int(os.popen('stty size', 'r').read().split()[1]) + else: + return 80 + + +success = main() +if success: + sys.exit(0) +sys.exit(1) diff --git a/pybitblock/SPV/routes.py b/pybitblock/SPV/routes.py new file mode 100644 index 0000000..4ac36c0 --- /dev/null +++ b/pybitblock/SPV/routes.py @@ -0,0 +1,115 @@ +import base64 +import sys + +MAX_ROUTES_TO_REQUEST = 100 + + +def debug(message): + sys.stderr.write(message + "\n") + + +def debugnobreak(message): + sys.stderr.write(message) + + +class Routes: + def __init__(self, lnd, payment_request, first_hop_channel, last_hop_channel): + self.lnd = lnd + self.payment_request = payment_request + self.first_hop_channel = first_hop_channel + self.last_hop_channel = last_hop_channel + self.all_routes = [] + self.returned_routes = [] + self.ignored_edges = [] + self.ignored_nodes = [] + self.num_requested_routes = 0 + + def has_next(self): + self.update_routes() + return self.returned_routes < self.all_routes + + def get_next(self): + self.update_routes() + for route in self.all_routes: + if route not in self.returned_routes: + self.returned_routes.append(route) + return route + return None + + def update_routes(self): + while True: + if self.returned_routes < self.all_routes: + return + if self.num_requested_routes >= MAX_ROUTES_TO_REQUEST: + return + self.request_route() + + def request_route(self): + amount = self.get_amount() + if self.last_hop_channel: + last_hop_pubkey = self.last_hop_channel.remote_pubkey + else: + last_hop_pubkey = None + if self.first_hop_channel: + first_hop_channel_id = self.first_hop_channel.chan_id + else: + first_hop_channel_id = None + routes = self.lnd.get_route(last_hop_pubkey, amount, self.ignored_edges, + self.ignored_nodes, first_hop_channel_id) + if routes is None: + self.num_requested_routes = MAX_ROUTES_TO_REQUEST + else: + self.num_requested_routes += 1 + for route in routes: + self.add_route(route) + + def add_route(self, route): + if route is None: + return + if route not in self.all_routes: + self.all_routes.append(route) + + @staticmethod + def print_route(route): + route_str = " -> ".join(str(h.chan_id) for h in route.hops) + return route_str + + def get_amount(self): + return self.payment_request.num_satoshis + + def ignore_first_hop(self, channel, show_message=True): + own_key = self.lnd.get_own_pubkey() + other_key = channel.remote_pubkey + self.ignore_edge_from_to(channel.chan_id, own_key, other_key, show_message) + + def ignore_edge_on_route(self, failure_source_pubkey, route): + ignore_next = False + for hop in route.hops: + if ignore_next: + self.ignore_edge_from_to(hop.chan_id, failure_source_pubkey, hop.pub_key) + return + if hop.pub_key == failure_source_pubkey: + ignore_next = True + + def ignore_node_with_highest_fee(self, route): + max_fee_msat = 0 + max_fee_hop = None + for hop in route.hops: + if hop.fee_msat > max_fee_msat: + max_fee_msat = hop.fee_msat + max_fee_hop = hop + + pub_key = max_fee_hop.pub_key + debugnobreak("High fees (%s msat), " % max_fee_msat) + self.ignore_node(pub_key) + + def ignore_edge_from_to(self, chan_id, from_pubkey, to_pubkey, show_message=True): + if show_message: + debug("ignoring channel %s (from %s to %s)" % (chan_id, from_pubkey, to_pubkey)) + direction_reverse = from_pubkey > to_pubkey + edge = {"channel_id": chan_id, "direction_reverse": direction_reverse} + self.ignored_edges.append(edge) + + def ignore_node(self, pub_key): + debug("ignoring node %s" % pub_key) + self.ignored_nodes.append(base64.b16decode(pub_key, True)) diff --git a/pybitblock/SPV/sysinf.py b/pybitblock/SPV/sysinf.py new file mode 100644 index 0000000..bf0ec4f --- /dev/null +++ b/pybitblock/SPV/sysinf.py @@ -0,0 +1,27 @@ +#Developer: Curly60e +#PyBLOCK its a clock of the Bitcoin blockchain. + +import os +import psutil +import time as t +from pblogo import * + + +def clear(): # clear the screen + os.system('cls' if os.name=='nt' else 'clear') + +def sysinfoDetail(): #Cpu and memory usage +# gives a single float value + while True: + try: + clear() + blogo() + 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[3;33;40mMemory Available: \033[1;32;40m" "{} \033[0;37;40mMB".format(int(psutil.virtual_memory().available / 1024 / 1024))) + print(" \033[3;33;40mDisk Usage: \033[1;32;40m" "{}%\033[0;37;40m%".format(psutil.disk_usage('/').percent)) + print(" \033[0;37;40m----------------------------") + t.sleep(1) + except: + break