コード例 #1
0
ファイル: api.py プロジェクト: vcgato29/counterparty-lib
        def unpack(data_hex):
            data = binascii.unhexlify(data_hex)
            message_type_id, message = message_type.unpack(data)

            # TODO: Enabled only for `send`.
            if message_type_id == send.ID:
                unpack_method = send.unpack
            else:
                raise APIError('unsupported message type')
            unpacked = unpack_method(db, message, util.CURRENT_BLOCK_INDEX)
            return message_type_id, unpacked
コード例 #2
0
def parse(db, tx, message):
    if not config.TESTNET:  # TODO
        return

    try:
        gasprice, startgas, endowment = struct.unpack(FORMAT, message[:LENGTH])
    except struct.error:
        gasprice, startgas, endowment = 0, 0, 0  # TODO: Is this ideal

    code = util.hexlify(message[LENGTH:])
    source, destination, data = execute.compose(db, tx['source'], '', gasprice,
                                                startgas, endowment, code)
    message_type_id, message = message_type.unpack(data, tx['block_index'])

    # Execute transaction upon publication, for actual creation of contract.
    execute.parse(db, tx, message)