/* * Authors: * Dmitriy A. Gearasimov <kahovski@gmail.com> * DeM Labs Inc. https://demlabs.net * DeM Labs Open source community https://github.com/demlabsinc * Copyright (c) 2017-2018 * All rights reserved. This file is part of DAP (Deus Applications Prototypes) the open source project DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. DAP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <stdint.h> #include <string.h> //#include <glib.h> #include "dap_common.h" #include "dap_list.h" #include "dap_chain_common.h" #include "dap_sign.h" #include "dap_chain_datum_tx.h" #include "dap_chain_datum_tx_in.h" #include "dap_chain_datum_tx_out.h" #include "dap_chain_datum_tx_in_cond.h" #include "dap_chain_datum_tx_out_cond.h" #include "dap_chain_datum_tx_sig.h" #include "dap_chain_datum_tx_pkey.h" #include "dap_chain_datum_tx_token.h" #include "dap_chain_datum_tx_receipt.h" /** * Get item type * * return type, or TX_ITEM_TYPE_ANY if error */ dap_chain_tx_item_type_t dap_chain_datum_tx_item_get_type(const uint8_t *a_item); /** * Get item size * * return size, 0 Error */ size_t dap_chain_datum_item_tx_get_size(const uint8_t *a_item); /** * Create item dap_chain_tx_token_t * * return item, NULL Error */ dap_chain_tx_token_t* dap_chain_datum_tx_item_token_create(dap_chain_hash_fast_t * a_datum_token_hash,const char * a_ticker); /** * Create item dap_chain_tx_out_t * * return item, NULL Error */ dap_chain_tx_in_t* dap_chain_datum_tx_item_in_create(dap_chain_hash_fast_t *a_tx_prev_hash, uint32_t a_tx_out_prev_idx); dap_chain_tx_in_cond_t* dap_chain_datum_tx_item_in_cond_create(dap_chain_hash_fast_t *a_tx_prev_hash, uint32_t a_tx_out_prev_idx, uint32_t a_receipt_idx); /** * Create item dap_chain_tx_out_t * * return item, NULL Error */ dap_chain_tx_out_t* dap_chain_datum_tx_item_out_create(const dap_chain_addr_t *a_addr, uint64_t a_value); /** * Create item dap_chain_tx_out_cond_t * * return item, NULL Error */ dap_chain_tx_out_cond_t* dap_chain_datum_tx_item_out_cond_create_srv_pay(dap_enc_key_t *a_key, dap_chain_net_srv_uid_t a_srv_uid, uint64_t a_value, uint64_t a_value_max_per_unit, dap_chain_net_srv_price_unit_uid_t a_unit, const void *a_cond, size_t a_cond_size); /** * Create item dap_chain_tx_sig_t * * return item, NULL Error */ dap_chain_tx_sig_t* dap_chain_datum_tx_item_sign_create(dap_enc_key_t *a_key, const void *a_data, size_t a_data_size); /** * Get sign from sign item * * return sign, NULL Error */ dap_sign_t* dap_chain_datum_tx_item_sign_get_sig(dap_chain_tx_sig_t *a_tx_sig); /** * Get item from transaction * * a_tx [in] transaction * a_item_idx_start[in/out] start index / found index of item in transaction, if 0 then from beginning * a_type[in] type of item being find, if TX_ITEM_TYPE_ANY - any item * a_item_out_size size[out] size of returned item * return item data, NULL Error index or bad format transaction */ uint8_t* dap_chain_datum_tx_item_get( dap_chain_datum_tx_t *a_tx, int *a_item_idx_start, dap_chain_tx_item_type_t a_type, int *a_item_out_size); // Get all item from transaction by type dap_list_t* dap_chain_datum_tx_items_get(dap_chain_datum_tx_t *a_tx, dap_chain_tx_item_type_t a_type, int *a_item_count);