Exemplo n.º 1
0
 def generate_next_block(self):
     coinbase_tx = new_coinbase_transaction(
         get_public_from_wallet(),
         self.get_latest_block()['index'] + 1)
     transactions = [coinbase_tx
                     ] + self.transaction_pool.get_transaction_pool()
     return self.generate_raw_next_block(transactions)
Exemplo n.º 2
0
def do_has_amount_for_transaction(amount):
    try:
        create_transaction(get_public_from_wallet(), amount,
                           get_private_from_wallet(),
                           blockchain.get_unspent_tx_outs(),
                           blockchain.transaction_pool.get_transaction_pool())
        return jsonify(True), 200
    except Exception as e:
        traceback.print_exc()
        tx = str(e)
        return jsonify(False), 200
Exemplo n.º 3
0
 def find_block(self, index, previous_hash, transactions, difficulty):
     previous_time_stamp = 0
     while (True):
         timestamp = time()
         if previous_time_stamp != timestamp:
             temp_block = self.raw_block(index, timestamp, 
                                         previous_hash, transactions, 
                                         difficulty, self.get_my_account_balance(), 
                                         get_public_from_wallet())
             if self.is_block_staking_valid(temp_block):
                 return temp_block
             previous_time_stamp = timestamp
Exemplo n.º 4
0
def do_address():
    address = get_public_from_wallet()
    return jsonify({'address': address}), 200
Exemplo n.º 5
0
 def get_my_account_balance(self):
     return self.get_account_balance(get_public_from_wallet())
Exemplo n.º 6
0
 def get_my_unspent_transaction_outputs(self):
     return find_unspent_tx_outs(get_public_from_wallet(),
                                 self.get_unspent_tx_outs())