From 7936f53ac85e666f91aa779935424a7fe9dc2a50 Mon Sep 17 00:00:00 2001 From: curly60e <55191248+curly60e@users.noreply.github.com> Date: Wed, 24 Nov 2021 19:56:39 -0300 Subject: [PATCH 1/2] Wallet improvement --- PyBlock.py | 182 +++++++++++++++++++++++++++++------------------------ 1 file changed, 99 insertions(+), 83 deletions(-) diff --git a/PyBlock.py b/PyBlock.py index 6da250b..de79fa6 100644 --- a/PyBlock.py +++ b/PyBlock.py @@ -88,93 +88,115 @@ def getblock(): # get access to bitcoin-cli with the command getblockchaininfo break def getnewaddressOnchain(): - #try: - clear() - blogo() - close() - qr = qrcode.QRCode( - version=1, - error_correction=qrcode.constants.ERROR_CORRECT_L, - box_size=10, - border=4, - ) - getadd = " getnewaddress" - getbal = " getbalance" - getfeemempool = " getmempoolinfo" - gna = os.popen(path['bitcoincli'] + getadd) - gnaa = gna.read() - gna1 = str(gnaa) - gnb = os.popen(path['bitcoincli'] + getbal) - gnbb= gnb.read() - gnb1 = str(gnbb) - output = render(str("BTC: " + gnb1), colors=['yellow'], align='left', font='tiny') - print("""--------------------------------------------------------------- - {} ----------------------------------------------------------------""".format(output)) - print("\033[1;30;47m") - qr.add_data(gna1) - qr.print_ascii() - print("\033[0;37;40m") - qr.clear() - print("\x1b[?25l" + "Bitcoin Address: " + gna1) - gna.close() - a = gnb1 - getbal = " getbalance" - while True: - x = a + 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) - gnaq = os.popen(path['bitcoincli'] + getfeemempool) - gnaaq = gnaq.read() - gna1q = str(gnaaq) - d = json.loads(gna1q) - nn = d['total_fee'] / d['bytes'] * 100000000 - print("\n\033[ALive Fee: ~{} sats/byte \033[A".format(str(nn))) - if gnb1 > a: - clear() - blogo() - close() - getadd = " getnewaddress" - gna = os.popen(path['bitcoincli'] + getadd) - gnaa = gna.read() - gna1 = str(gnaa) - output = render(str("BTC: " + gnb1), colors=['yellow'], align='left', font='tiny') - print("""--------------------------------------------------------------- - {} + gnu = os.popen(path['bitcoincli'] + getunconfirm) + gnua= gnu.read() + gnub = str(gnua) + output = render(str(gnb1 + " BTC"), colors=['yellow'], align='left', font='tiny') + print("""--------------------------------------------------------------- + {} ---------------------------------------------------------------""".format(output)) - getfeemempool = " getmempoolinfo" + 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) - print("Total Fee: " + str(d['total_fee'])) - print("\033[1;30;47m") - qr.add_data(gna1) - qr.print_ascii() - print("\033[0;37;40m") - qr.clear() - print("\x1b[?25l" + "Bitcoin Address: " + gna1) - gna.close() - a = gnb1 - #except: - # walletmenuLOCALOnchainONLY() + nn = float(d['total_fee']) / float(d['bytes']) * float(100000000) + print("\n\033[ALive Fee: ~{} sat/vB \033[A".format(nn)) + 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(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 + except: + walletmenuLOCALOnchainONLY() def gettransactionsOnchain(): - clear() - blogo() - close() - listtxs = " listunspent" - gna = os.popen(path['bitcoincli'] + listtxs) - gnaa = gna.read() - gna1 = str(gnaa) - d = json.loads(gna1) - sort_order = sorted(d, key=lambda x:x['confirmations']) - print("\t\t--------- TRANSACIONS LIST ---------\n\n") - for q in sort_order: - print(str("TxID: ") + str(q['txid']) + str(" | ") + str("Amount: ") + str(q['amount']) + str(" BTC") + str(" | ") + str("Conf:") + str(q['confirmations'])) - input("\nContinue...") - walletmenuLOCALOnchainONLY() + try: + while True: + clear() + blogo() + close() + listtxs = " listunspent" + gna = os.popen(path['bitcoincli'] + listtxs) + gnaa = gna.read() + gna1 = str(gnaa) + d = json.loads(gna1) + getbal = " getbalance" + gnb = os.popen(path['bitcoincli'] + getbal) + gnbb= gnb.read() + gnb1 = str(gnbb) + sort_order = sorted(d, key=lambda x:x['confirmations']) + print("\t\t --------- TRANSACIONS LIST ---------\n\n") + for q in sort_order: + print(str("TxID: ") + "\u001b[38;5;40m{}\033[0;37;40m".format(str(q['txid'])) + str(" | ") + str("Amount: ") + "\u001b[38;5;202m{} BTC\033[0;37;40m".format(str(q['amount'])) + str(" | ") + str("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" @@ -691,7 +713,6 @@ def bitcoincoremenuLOCAL(): \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[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")) @@ -723,7 +744,6 @@ def bitcoincoremenuLOCALOnchainONLY(): \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[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")) @@ -4480,8 +4500,6 @@ def bitcoincoremenuLOCALcontrolA(bcore): pdfconvert() elif bcore in ["O", "o"]: bitcoincoremenuLOCALOPRETURN() - elif bcore in ["Z", "z"]: - statsconn() def bitcoincoremenuLOCALcontrolAOnchainONLY(bcore): if bcore in ["A", "a"]: @@ -4529,8 +4547,6 @@ def bitcoincoremenuLOCALcontrolAOnchainONLY(bcore): bitcoincoremenuLOCALOPRETURN() elif bcore in ["W", "w"]: walletmenuLOCALOnchainONLY() - elif bcore in ["Z", "z"]: - statsconn() def walletmenuLOCALcontrolAOnchainONLY(walletmnu): if walletmnu in ["A", "a"]: From 8972712ac6021abab9ee34b25361c649469f851b Mon Sep 17 00:00:00 2001 From: curly60e <55191248+curly60e@users.noreply.github.com> Date: Wed, 24 Nov 2021 20:01:52 -0300 Subject: [PATCH 2/2] Fixes --- PyBlock.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PyBlock.py b/PyBlock.py index de79fa6..5eb29c6 100644 --- a/PyBlock.py +++ b/PyBlock.py @@ -713,6 +713,7 @@ def bitcoincoremenuLOCAL(): \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[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")) @@ -744,6 +745,7 @@ def bitcoincoremenuLOCALOnchainONLY(): \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[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")) @@ -4500,6 +4502,8 @@ def bitcoincoremenuLOCALcontrolA(bcore): pdfconvert() elif bcore in ["O", "o"]: bitcoincoremenuLOCALOPRETURN() + elif bcore in ["Z", "z"]: + statsconn() def bitcoincoremenuLOCALcontrolAOnchainONLY(bcore): if bcore in ["A", "a"]: @@ -4547,7 +4551,9 @@ def bitcoincoremenuLOCALcontrolAOnchainONLY(bcore): bitcoincoremenuLOCALOPRETURN() elif bcore in ["W", "w"]: walletmenuLOCALOnchainONLY() - + elif bcore in ["Z", "z"]: + statsconn() + def walletmenuLOCALcontrolAOnchainONLY(walletmnu): if walletmnu in ["A", "a"]: getnewaddressOnchain()