def key(name, password=None, display=True): print("Reading BCH private key from ORBIT wallet...") print(" Name: {}".format(name)) wpath = path(name) print(" File: {}".format(wpath)) wallet = access(wpath, password_handler(password)) key_hex = wallet.to_hex() key_bytes = wallet.to_bytes() key_der = wallet.to_der() key_pem = wallet.to_pem() key_int = wallet.to_int() key_wif = wallet.to_wif() if display: print() print(" Private BCH key (bytes): {}".format(key_bytes)) print(" Private BCH key (base58): {}".format(b58encode(key_bytes))) print(" Private BCH key (hex): {}".format(key_hex)) #print(" Private BCH key (hex base58): {}".format(b58encode(key_hex))) print(" Private BCH key (der): {}".format(key_der)) print(" Private BCH key (der base58): {}".format( b58encode(key_der))) print(" Private BCH key (der base64): {}".format( b64encode(key_der))) print(" Private BCH key (pem): {}".format(key_pem)) print(" Private BCH key (int): {}".format(key_int)) print(" Private BCH key (wif): {}".format(key_wif)) return (key_hex, key_bytes, key_der, key_pem, key_int)
def address(name, password=None, display=True): print("Reading BCH address from ORBIT wallet file...") print(" Name: {}".format(name)) wpath = path(name) print(" File: {}".format(wpath)) wallet = access(wpath, password_handler(password)) if display: print() print(" Public BCH address: {}".format(wallet.address)) return wallet.address
def balance(name, password=None, display=True): print("Reading BCH address from ORBIT wallet file...") print(" Name: {}".format(name)) wpath = path(name) print(" File: {}".format(wpath)) wallet = access(wpath, password_handler(password)) balance = wallet.get_balance() if display: print() print(" Current balance : {} satoshi".format(balance)) return balance
def tokens(name, password=None): print("Opening wallet...") print(" Name: {}".format(name)) wpath = path(name) print(" File: {}".format(wpath)) wallet = access(wpath, password_handler(password)) print() print("Connecting to ORBIT node to retrieve token information...") host = get_orbit_host() port = get_orbit_port() print(" Host: {}".format(host)) print(" Port: {}".format(port)) client = Client(host=host, port=port) tokens = client.get_user_tokens(wallet.address)[Endpoints.USER_TOKENS] if tokens: for token in tokens: print() print(" Token @ {}".format(token['address'])) print(" Name: {}".format(token['name'])) print(" Symbol: {}".format(token['symbol'])) decimals = token['decimals'] print(" Decimals: {}".format(decimals)) print(" Balance") total = token['units'] print(" Total: {} ({} unit{})".format( Decimal(total).scaleb(-1 * decimals), total, "" if total == 1 else "s")) available = token['available'] print(" Available: {} ({} unit{})".format( Decimal(available).scaleb(-1 * decimals), available, "" if available == 1 else "s")) else: print() print(" No tokens")
def on_wallets_currentIndexChanged(self, index): if self.wallet: self.wallet = None if index > 0: self.error.setText("") def password(): password = Password(self) if password.exec_(): return password.password.text() else: raise ValueError("User abort") try: wpath = path(self.wallets.currentText()) self.wallet = access(wpath, get_password=password) self.on_refreshCashButton_clicked() except ValueError as e: self.error.setText("{}".format(e)) self.wallets.setCurrentIndex(0) self.refresh()