/******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC * * * COMMERCIAL LICENSE USAGE * * Licensees holding a valid commercial license may use this file in accordance * with the commercial license agreement provided with the Software or, alternatively, * in accordance with the terms contained in a written agreement between you and * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. * * Alternatively, this file may be used under the AGPL license as follows: * * AGPL LICENSE USAGE * * This program is free software: you can redistribute it and/or modify it under the * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. * * This program 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 Affero General Public License for more details. * [Permissions of this strong copyleft license are conditioned on making available * complete source code of licensed works and modifications, which include larger * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * BTC API. * * This header-file defines easy to use function, which are preparing the JSON-RPC-Request, which is then executed and verified by the incubed-client. * */ #ifndef IN3_BTC_API_H #define IN3_BTC_API_H #ifdef __cplusplus extern "C" { #endif #include "client.h" #include "bytes.h" #include "api_utils.h" /**< The current error or null if all is ok */ #define btc_last_error() api_last_error() /** the tx in */ typedef struct btc_transaction_in { uint32_t vout; /**< the tx index of the output */ bytes32_t txid; /**< the tx id of the output */ uint32_t sequence; /**< the sequence */ bytes_t script; /**< the script */ bytes_t txinwitness; /**< witnessdata (if used) */ } btc_transaction_in_t; /** the tx out */ typedef struct btc_transaction_out { uint64_t value; /**< the value of the tx */ uint32_t n; /**< the index */ bytes_t script_pubkey; /**< the script pubkey (or signature)*/ } btc_transaction_out_t; /** a transaction */ typedef struct btc_transaction { bool in_active_chain; /**< true if it is part of the active chain */ bytes_t data; /**< the serialized transaction-data */ bytes32_t txid; /**< the transaction id */ bytes32_t hash; /**< the transaction hash */ uint32_t size; /**< raw size of the transaction */ uint32_t vsize; /**< virtual size of the transaction */ uint32_t weight; /**< weight of the tx */ uint32_t version; /**< used version */ uint32_t locktime; /**< locktime */ btc_transaction_in_t* vin; /**< array of transaction inputs */ btc_transaction_out_t* vout; /**< array of transaction outputs */ uint32_t vin_len; /**< number of tx inputs */ uint32_t vout_len; /**< number of tx outputs */ bytes32_t blockhash; /**< hash of block containing the tx */ uint32_t confirmations; /**< number of confirmations or blocks mined on top of the containing block*/ uint32_t time; /**< unix timestamp in seconds since 1970 */ uint32_t blocktime; /**< unix timestamp in seconds since 1970 */ } btc_transaction_t; /** the blockheader */ typedef struct btc_blockheader { bytes32_t hash; /**< the hash of the blockheader */ uint32_t confirmations; /**< number of confirmations or blocks mined on top of the containing block*/ uint32_t height; /**< block number */ uint32_t version; /**< used version */ bytes32_t merkleroot; /**< merkle root of the trie of all transactions in the block */ uint32_t time; /**< unix timestamp in seconds since 1970 */ uint32_t nonce; /**< nonce-field of the block */ uint8_t bits[4]; /**