2021-06-30 17:44:46 -07:00
|
|
|
/*! \file */
|
|
|
|
/*******************************************
|
|
|
|
* *
|
|
|
|
* File auto-generated by `::safer_ffi`. *
|
|
|
|
* *
|
|
|
|
* Do not manually edit this file. *
|
|
|
|
* *
|
|
|
|
*******************************************/
|
|
|
|
|
|
|
|
#ifndef __RUST_BDK_FFI__
|
|
|
|
#define __RUST_BDK_FFI__
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-07-04 15:54:23 -07:00
|
|
|
typedef struct BlockchainConfig BlockchainConfig_t;
|
|
|
|
|
|
|
|
typedef struct DatabaseConfig DatabaseConfig_t;
|
|
|
|
|
|
|
|
typedef struct OpaqueWallet OpaqueWallet_t;
|
|
|
|
|
2021-07-03 20:40:08 -07:00
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
/** \remark Has the same ABI as `uint16_t` **/
|
|
|
|
#ifdef DOXYGEN
|
|
|
|
typedef enum FfiError
|
|
|
|
#else
|
|
|
|
typedef uint16_t FfiError_t; enum
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_NONE,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_INVALID_U32_BYTES,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_GENERIC,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_SCRIPT_DOESNT_HAVE_ADDRESS_FORM,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_NO_RECIPIENTS,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_NO_UTXOS_SELECTED,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_OUTPUT_BELOW_DUST_LIMIT,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_INSUFFICIENT_FUNDS,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_BN_B_TOTAL_TRIES_EXCEEDED,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_BN_B_NO_EXACT_MATCH,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_UNKNOWN_UTXO,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_TRANSACTION_NOT_FOUND,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_TRANSACTION_CONFIRMED,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_IRREPLACEABLE_TRANSACTION,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_FEE_RATE_TOO_LOW,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_FEE_TOO_LOW,
|
|
|
|
/** . */
|
2021-09-25 21:17:40 -07:00
|
|
|
FFI_ERROR_FEE_RATE_UNAVAILABLE,
|
|
|
|
/** . */
|
2021-07-03 20:40:08 -07:00
|
|
|
FFI_ERROR_MISSING_KEY_ORIGIN,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_KEY,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_CHECKSUM_MISMATCH,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_SPENDING_POLICY_REQUIRED,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_INVALID_POLICY_PATH_ERROR,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_SIGNER,
|
|
|
|
/** . */
|
2021-09-25 21:17:40 -07:00
|
|
|
FFI_ERROR_INVALID_NETWORK,
|
|
|
|
/** . */
|
2021-07-03 20:40:08 -07:00
|
|
|
FFI_ERROR_INVALID_PROGRESS_VALUE,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_PROGRESS_UPDATE_ERROR,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_INVALID_OUTPOINT,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_DESCRIPTOR,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_ADDRESS_VALIDATOR,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_ENCODE,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_MINISCRIPT,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_BIP32,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_SECP256K1,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_JSON,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_HEX,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_PSBT,
|
|
|
|
/** . */
|
2021-09-25 21:17:40 -07:00
|
|
|
FFI_ERROR_PSBT_PARSE,
|
|
|
|
/** . */
|
2021-07-03 20:40:08 -07:00
|
|
|
FFI_ERROR_ELECTRUM,
|
|
|
|
/** . */
|
|
|
|
FFI_ERROR_SLED,
|
|
|
|
}
|
|
|
|
#ifdef DOXYGEN
|
|
|
|
FfiError_t
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
2021-06-30 17:44:46 -07:00
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
OpaqueWallet_t * ok;
|
|
|
|
|
2021-07-03 20:40:08 -07:00
|
|
|
FfiError_t err;
|
2021-06-30 17:44:46 -07:00
|
|
|
|
2021-07-03 19:07:49 -07:00
|
|
|
} FfiResult_OpaqueWallet_ptr_t;
|
2021-06-30 17:44:46 -07:00
|
|
|
|
2021-07-03 19:07:49 -07:00
|
|
|
FfiResult_OpaqueWallet_ptr_t new_wallet_result (
|
2021-06-30 17:44:46 -07:00
|
|
|
char const * descriptor,
|
|
|
|
char const * change_descriptor,
|
2021-09-25 21:17:40 -07:00
|
|
|
char const * network,
|
2021-06-30 17:44:46 -07:00
|
|
|
BlockchainConfig_t const * blockchain_config,
|
|
|
|
DatabaseConfig_t const * database_config);
|
|
|
|
|
|
|
|
void free_wallet_result (
|
2021-07-03 19:07:49 -07:00
|
|
|
FfiResult_OpaqueWallet_ptr_t wallet_result);
|
|
|
|
|
2021-07-04 15:54:23 -07:00
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
FfiError_t err;
|
|
|
|
|
|
|
|
} FfiResultVoid_t;
|
|
|
|
|
2021-07-03 19:24:29 -07:00
|
|
|
FfiResultVoid_t sync_wallet (
|
2021-07-03 10:16:02 -07:00
|
|
|
OpaqueWallet_t const * opaque_wallet);
|
|
|
|
|
2021-07-04 15:54:23 -07:00
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
char * ok;
|
|
|
|
|
|
|
|
FfiError_t err;
|
|
|
|
|
|
|
|
} FfiResult_char_ptr_t;
|
|
|
|
|
2021-07-03 10:16:02 -07:00
|
|
|
FfiResult_char_ptr_t new_address (
|
|
|
|
OpaqueWallet_t const * opaque_wallet);
|
|
|
|
|
2021-06-30 17:44:46 -07:00
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
char * txid;
|
|
|
|
|
|
|
|
uint32_t vout;
|
|
|
|
|
|
|
|
} OutPoint_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
uint64_t value;
|
|
|
|
|
|
|
|
char * script_pubkey;
|
|
|
|
|
|
|
|
} TxOut_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
OutPoint_t outpoint;
|
|
|
|
|
|
|
|
TxOut_t txout;
|
|
|
|
|
|
|
|
uint16_t keychain;
|
|
|
|
|
|
|
|
} LocalUtxo_t;
|
|
|
|
|
|
|
|
/** \brief
|
|
|
|
* Same as [`Vec<T>`][`rust::Vec`], but with guaranteed `#[repr(C)]` layout
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
LocalUtxo_t * ptr;
|
|
|
|
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
size_t cap;
|
|
|
|
|
|
|
|
} Vec_LocalUtxo_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
Vec_LocalUtxo_t ok;
|
|
|
|
|
2021-07-03 20:40:08 -07:00
|
|
|
FfiError_t err;
|
2021-06-30 17:44:46 -07:00
|
|
|
|
2021-07-03 19:07:49 -07:00
|
|
|
} FfiResult_Vec_LocalUtxo_t;
|
2021-06-30 17:44:46 -07:00
|
|
|
|
2021-07-03 19:07:49 -07:00
|
|
|
FfiResult_Vec_LocalUtxo_t list_unspent (
|
2021-06-30 17:44:46 -07:00
|
|
|
OpaqueWallet_t const * opaque_wallet);
|
|
|
|
|
2021-07-04 15:54:23 -07:00
|
|
|
void free_veclocalutxo_result (
|
2021-07-03 19:07:49 -07:00
|
|
|
FfiResult_Vec_LocalUtxo_t unspent_result);
|
|
|
|
|
2021-07-04 15:54:23 -07:00
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
uint64_t ok;
|
|
|
|
|
|
|
|
FfiError_t err;
|
|
|
|
|
|
|
|
} FfiResult_uint64_t;
|
|
|
|
|
|
|
|
FfiResult_uint64_t balance (
|
|
|
|
OpaqueWallet_t const * opaque_wallet);
|
|
|
|
|
2021-09-25 21:17:40 -07:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2021-07-04 22:10:16 -07:00
|
|
|
typedef struct {
|
|
|
|
|
2021-09-25 21:17:40 -07:00
|
|
|
uint32_t height;
|
2021-07-04 22:10:16 -07:00
|
|
|
|
|
|
|
uint64_t timestamp;
|
|
|
|
|
2021-09-25 21:17:40 -07:00
|
|
|
} ConfirmationTime_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
char * txid;
|
|
|
|
|
2021-07-04 22:10:16 -07:00
|
|
|
uint64_t received;
|
|
|
|
|
|
|
|
uint64_t sent;
|
|
|
|
|
2021-09-25 21:17:40 -07:00
|
|
|
int64_t fee;
|
|
|
|
|
|
|
|
bool is_confirmed;
|
|
|
|
|
|
|
|
ConfirmationTime_t confirmation_time;
|
2021-07-04 22:10:16 -07:00
|
|
|
|
2021-09-25 21:17:40 -07:00
|
|
|
bool verified;
|
2021-07-04 22:10:16 -07:00
|
|
|
|
|
|
|
} TransactionDetails_t;
|
|
|
|
|
|
|
|
/** \brief
|
|
|
|
* Same as [`Vec<T>`][`rust::Vec`], but with guaranteed `#[repr(C)]` layout
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
TransactionDetails_t * ptr;
|
|
|
|
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
size_t cap;
|
|
|
|
|
|
|
|
} Vec_TransactionDetails_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
Vec_TransactionDetails_t ok;
|
|
|
|
|
|
|
|
FfiError_t err;
|
|
|
|
|
|
|
|
} FfiResult_Vec_TransactionDetails_t;
|
|
|
|
|
|
|
|
FfiResult_Vec_TransactionDetails_t list_transactions (
|
|
|
|
OpaqueWallet_t const * opaque_wallet);
|
|
|
|
|
|
|
|
void free_vectxdetails_result (
|
|
|
|
FfiResult_Vec_TransactionDetails_t txdetails_result);
|
|
|
|
|
2021-07-04 15:54:23 -07:00
|
|
|
BlockchainConfig_t * new_electrum_config (
|
|
|
|
char const * url,
|
|
|
|
char const * socks5,
|
|
|
|
int16_t retry,
|
2021-09-25 21:17:40 -07:00
|
|
|
int16_t timeout,
|
|
|
|
size_t stop_gap);
|
2021-07-04 15:54:23 -07:00
|
|
|
|
|
|
|
void free_blockchain_config (
|
|
|
|
BlockchainConfig_t * blockchain_config);
|
|
|
|
|
|
|
|
void free_string_result (
|
|
|
|
FfiResult_char_ptr_t string_result);
|
|
|
|
|
|
|
|
void free_void_result (
|
|
|
|
FfiResultVoid_t void_result);
|
|
|
|
|
|
|
|
void free_uint64_result (
|
|
|
|
FfiResult_uint64_t void_result);
|
|
|
|
|
|
|
|
/** \brief
|
|
|
|
* Free a Rust-allocated string
|
|
|
|
*/
|
|
|
|
void free_string (
|
|
|
|
char * string);
|
|
|
|
|
2021-06-30 17:44:46 -07:00
|
|
|
DatabaseConfig_t * new_memory_config (void);
|
|
|
|
|
|
|
|
DatabaseConfig_t * new_sled_config (
|
|
|
|
char const * path,
|
|
|
|
char const * tree_name);
|
|
|
|
|
|
|
|
void free_database_config (
|
|
|
|
DatabaseConfig_t * database_config);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __RUST_BDK_FFI__ */
|