def send_transaction(self, address, amount): tx = create_transaction(address, amount, get_private_from_wallet(), self.get_unspent_tx_outs(), get_transaction_pool()) add_to_transaction_pool(tx, self.get_unspent_tx_outs()) # broadCastTransactionPool() return tx
def construct_next_block_with_transaction(self, receiver_address, amount): if not is_valid_address(receiver_address): print('invalid address') return if not isinstance(amount, int): print('invalid amount') return coinbase_tx = get_coinbase_transaction(get_public_from_wallet(), self.blocks[-1].index + 1) tx = create_transaction(receiver_address, amount, get_private_from_wallet(), self.get_unspent_tx_outs(), get_transaction_pool()) if not tx: return False block_data = [coinbase_tx, tx] return self.generate_next_block(block_data)
def construct_next_block(self): coinbase_tx = get_coinbase_transaction(get_public_from_wallet(), self.blocks[-1].index + 1) block_data = [coinbase_tx] + get_transaction_pool() return self.generate_next_block(block_data)
def response_transaction_pool_msg(self): return {'data': JSON.dumps(get_transaction_pool())}