Created
September 6, 2019 21:22
-
-
Save vincenzopalazzo/1f1245ab200ed59a0604dee134f42863 to your computer and use it in GitHub Desktop.
Simple Console gui bitcoin core for calculate the amount on the an address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException | |
rpc_user = 'vincent' | |
rpc_password = 'vincent' | |
rpc_connection = AuthServiceProxy("http://%s:%[email protected]:18332"%(rpc_user, rpc_password)) | |
def createNewAddress(): | |
address = rpc_connection.getnewaddress(); | |
print("The new address is: ", address) | |
def getListTransaction(address): | |
if address is None: | |
raise Exception("Address null") | |
listTransactions = rpc_connection.listunspent(); | |
transactionAddress = []; | |
for transaction in listTransactions: | |
if address == transaction['address']: | |
transactionAddress.append(transaction) | |
print("The transacrions address: ", transactionAddress) | |
print("The num transaction address is", len(transactionAddress)) | |
for tx in transactionAddress: | |
print("----------- Transaction -----------") | |
print("Address: ", tx['address']) | |
print("Label: ", tx['label']) | |
print("Ammount: ", tx['amount']) | |
def getAmmount(address): | |
if address is None: | |
raise Exception("Address null") | |
listTransactions = rpc_connection.listunspent(); | |
ammountAddress = float(format(0, '.8f')); | |
for transaction in listTransactions: | |
if address == transaction['address']: | |
ammountAddress = format(float(ammountAddress) + float(transaction['amount']), '.8f'); | |
print("Address: ", address, "have ", ammountAddress) | |
def consoleGUI(): | |
print(" _____________ BITCOIN CORE CONSOLE ___________") | |
print("| 1. Create new Address |") | |
print("| 2. List Transaction address |") | |
print("| 3. Get ammount |") | |
print("| 0. Exit |") | |
print("|______________________________________________|") | |
print("\nChoise -> "); | |
num = input(); | |
if (int(num) < 0) and (int(num) > 3): | |
print("Error choise") | |
return None | |
else: | |
return num | |
if __name__ == '__main__': | |
while True: | |
value = consoleGUI(); | |
if int(value) == 0: | |
print("Bey") | |
break | |
if int(value) == 1: | |
createNewAddress() | |
if int(value) == 2: | |
print("Insert address -> ") | |
addr = input() | |
getListTransaction(addr) | |
if int(value) == 3: | |
print("Insert address -> ") | |
addr = input() | |
getAmmount(addr) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code use python3 and this library