def main(): blockchain = Blockchain() wallet1 = Wallet() wallet2 = Wallet() tri1 = Transaction('COINBASE', wallet2.public_key, 50) tri2 = Transaction('COINBASE', wallet1.public_key, 50) blockchain.add_new_transaction(tri1) blockchain.add_new_transaction(tri2) blockchain.mine() tr = Transaction(wallet1.public_key, wallet2.public_key, 3) tr5 = Transaction(wallet1.public_key, wallet2.public_key, 6) tr2 = Transaction('Pedro', 'Lucas', 2) tr3 = Transaction('Lucas', 'Antonio', 1) tr4 = Transaction('Juan', 'Lucas', 3) blockchain.add_new_transaction(tr2) blockchain.add_new_transaction(tr5) blockchain.add_new_transaction(tr) blockchain.mine() blockchain.add_new_transaction(tr3) blockchain.mine() print(blockchain.chain[0]) print('-----------------------') print(blockchain.chain[1]) print('-----------------------') print(blockchain.last_block) print('-----------------------') blockchain.add_new_transaction(tr4) blockchain.mine() print(blockchain.last_block) print('-----------------------') print('Saldo wallet1: ', wallet1.amount(blockchain)) print('Saldo wallet2: ', wallet2.amount(blockchain))
from transaction import Transaction from wallet import Wallet from blockchain import BlockChain w1 = Wallet("x") p_key = w1.public_key.exportKey() print(p_key) w = Wallet.findWallet(p_key) print(vars(w)) w2 = Wallet("asdf") w3 = Wallet("a") w4 = Wallet("b") w1.amount = 100 t1 = Transaction(w1, w2, 5) t2 = Transaction(w1, w3, 5) t3 = Transaction(w1, w4, 5) block_chain = BlockChain() block_chain.create_block([t1, t2, t3]) t4 = Transaction(w1, w2, 5) t5 = Transaction(w1, w3, 5) t6 = Transaction(w1, w4, 5) block_chain.create_block([t4, t5, t6])