Ejemplo n.º 1
0
def _decode_move(hex_message):
    move_hash = get_game_precommit(hex_message)
    salt = "".join(['4' for i in range(0, 64)])
    hex_salt = str_to_hex(salt)

    for move in range(ROCK, NUM_MOVES):
        test_hash = Web3.soliditySha3(['uint256', 'bytes32'], [move, hex_salt])  #pylint: disable=E1120
        str_test_hash = hex_to_str(test_hash.hex())
        if str_test_hash == move_hash:
            return move

    reverse_hash_fail(hex_message)
    return -1
Ejemplo n.º 2
0
def channel_message():
    request_json = request.get_json()
    current_app.logger.info(f'Request_json: {request_json}')

    message = hex_to_str(request_json['data'])
    fb_message_key = request_json.get('message_key')
    fb_message.message_consumed(fb_message_key, g.bot_addr)

    d_response = set_response_message()

    if len(message) >= 64:
        d_response = game_engine_message(message, g.bot_addr)
    # A message of length 64 or shorter is an adjudicator address
    else:
        d_response = wallet.fund_adjudicator(message, g.bot_addr)
        current_app.logger.info(d_response.get('message'))

    return jsonify(d_response)
Ejemplo n.º 3
0
 def _set_bot_addr():
     request_json = request.get_json()
     g.bot_addr = hex_to_str(request_json.get('address_key')).lower()
Ejemplo n.º 4
0
def get_last_message_for_channel(hex_message, bot_addr):
    message_ref = get_wallet_channel_ref(
        bot_addr, hex_message).child(K_RECEIVED).child(K_MESSAGE)
    last_message = message_ref.get()
    return hex_to_str(last_message)