def history(account): wallet = utils.get_selected_wallet() if wallet is None: return accounts = rpc.wallet_balances( config.get("wallets").get(wallet))["balances"].keys() matches = [x for x in accounts if x.startswith(account)] if not matches: print( "Could not locate any account addresses in the currently selected wallet that match the entry." ) return if len(matches) > 1: print( "Multiple matches were found for your given query. Please be more specific." ) for match in matches: print(match) return match = matches[0] history = rpc.history(match)["history"] if not history: print("No history available for this account.") return print("History for account: " + match) for transaction in history: print(transaction['type'] + " " + transaction['amount'] + " ITCO to/from " + transaction['account'])
def status(): wallet = utils.get_selected_wallet() if wallet is None: return wallet_info = rpc.wallet_info(config.get("wallets")[wallet]) print(wallet + ":") print("Balance: " + wallet_info["balance"] + " ITCO") print("Pending: " + wallet_info["pending"] + " ITCO") print("Number of accounts: " + wallet_info["accounts_count"]) print()
def list_account(verbose): wallet = utils.get_selected_wallet() if wallet is None: return wallet_balances = rpc.wallet_balances(config.get("wallets").get(wallet)) for account, balances in wallet_balances["balances"].items(): print(account + (":" if verbose else "")) if verbose: print("Balance: " + balances["balance"] + " ITCO") print("Pending: " + balances["pending"] + " ITCO") print()
def send(): print("Please enter the address of the account you'd like to send from") sender = click.prompt("") wallet = utils.get_selected_wallet() if wallet is None: return accounts = rpc.wallet_balances( utils.get_wallet_from_name(wallet))["balances"].keys() matches = [x for x in accounts if x.startswith(sender)] if not matches: print( "Could not locate any account addresses in the currently selected wallet that match the entry." ) return if len(matches) > 1: print( "Multiple matches were found for your given query. Please be more specific." ) for match in matches: print(match) return match = matches[0] print("Found a match based on your input: " + match) if not click.confirm("Is this correct"): print("Aborting...") return print("Please enter the address of the account you'd like to send to") recv = click.prompt("") balance = int(rpc.account_balance(match)["balance"]) print("You currently have " + str(balance) + " ITCO available to send.") amount = click.prompt("How much would you like to send", type=int) if amount > balance: print("The amount entered was higher than your available balance!") return print("You are about to send " + str(amount) + " ITCO from " + match + " to " + recv) print( "Please triple check your target address and amount. This action is NOT reversible." ) if not click.confirm("Is this correct"): print("Aborting...") return response = rpc.send(utils.get_wallet_from_name(wallet), match, recv, amount) if 'error' in response.keys(): print('An error occurred during sending: ' + response['error']) return print("Transaction sent in block: " + response['block'])
def qr(account): wallet = utils.get_selected_wallet() if wallet is None: return accounts = rpc.wallet_balances( utils.get_wallet_from_name(wallet))["balances"].keys() matches = [x for x in accounts if x.startswith(account)] if not matches: print( "Could not locate any account addresses in the currently selected wallet that match the entry." ) return if len(matches) > 1: print( "Multiple matches were found for your given query. Please be more specific." ) for match in matches: print(match) return match = matches[0] qr = qrcode.QRCode(error_correction=qrcode.ERROR_CORRECT_Q) qr.add_data(match) qr.print_ascii()
def selected_wallet(): wallet = utils.get_selected_wallet() if wallet is None: return print("Currently selected wallet is: " + wallet) print("Wallet ID: " + config.get("wallets")[wallet])
def new_account(): wallet = utils.get_selected_wallet() if wallet is None: return account = rpc.create_account(utils.get_wallet_from_name(wallet))['account'] print("New account created: " + account)