Example #1
0
 def __init__(self,
              my_port=50082,
              core_node_host=None,
              core_node_port=None,
              pass_phrase=None):
     self.server_state = STATE_INIT
     print('Initializing server...')
     self.my_ip = self.__get_myip()
     print('Server IP address is set to ... ', self.my_ip)
     self.my_port = my_port
     self.cm = ConnectionManager(self.my_ip, self.my_port,
                                 self.__handle_message)
     self.mpmh = MyProtocolMessageHandler()
     self.core_node_host = core_node_host
     self.core_node_port = core_node_port
     self.bb = BlockBuilder()
     my_genesis_block = self.bb.generate_genesis_block()
     self.bm = BlockchainManager(my_genesis_block.to_dict())
     self.prev_block_hash = self.bm.get_hash(my_genesis_block.to_dict())
     self.tp = TransactionPool()
     self.is_bb_running = False
     self.flag_stop_block_build = False
     self.mpm_store = MessageStore()
     self.km = KeyManager(None, pass_phrase)
     self.rsa_util = RSAUtil()
     self.um = UTXOManager(self.km.my_address())
Example #2
0
def main():

    k_m = KeyManager()
    um = UTXOManager(k_m.my_address())

    i_k_m = KeyManager()
    u_k_m = KeyManager()

    t1 = CoinbaseTransaction(k_m.my_address())
    t2 = CoinbaseTransaction(k_m.my_address())
    t3 = CoinbaseTransaction(k_m.my_address())

    t4 = Transaction([TransactionInput(t1.to_dict(), 0)], [
        TransactionOutput(u_k_m.my_address(), 10.0),
        TransactionOutput(i_k_m.my_address(), 20.0)
    ])

    transactions = []
    transactions.append(t1.to_dict())
    transactions.append(t2.to_dict())
    transactions.append(t3.to_dict())
    transactions.append(t4.to_dict())

    um.extract_utxos(transactions)

    balance = um.my_balance

    print(balance)