def cli_print_block_chain(): blk_chain = BlockChain() if not blk_chain.Verify_Block_Chain(): print("Your database may be damaged. Cannot open this database.") return print(blk_chain) for i in range(blk_chain.get_length()): print(blk_chain.get_block(i))
def cli_check_balance(Addr): blk_chain = BlockChain() if not blk_chain.Verify_Block_Chain(): print("Your database may be damaged. Cannot open this file.") return ws = WS.wallets() wallet = ws.get_wallet_by_addr(Addr) amount = blk_chain.FindBalance(wallet._hashPublicKey) print("Address: {addr}\nAmount: {a}".format(addr=Addr, a=amount))
def cli_sending(From, To, amount): blk_chain = BlockChain() if not blk_chain.Verify_Block_Chain(): print("Your database may be damaged. Cannot open this database.") return tx = transaction.NewUTXOTransaction(From, To, amount, blk_chain) if tx == None: print("Error: not enough funds") return blk_chain.add_block(tx) print("From: {f}\nTo: {t}\nAmount: {a}".format(f=From, t=To, a=amount))
def cli_printblock(height): blk_chain = BlockChain() if not blk_chain.Verify_Block_Chain(): print("Your database may be damaged. Cannot open this file.") return print(blk_chain.get_block(height - 1))