zcash-sync/binding.h

429 lines
11 KiB
C
Raw Permalink Normal View History

2023-03-13 16:58:16 -07:00
#if !defined(__APPLE__) || !defined(TARGET_OS_IPHONE)
2022-06-09 04:28:37 -07:00
typedef char int8_t;
typedef unsigned char uint8_t;
typedef short int uint16_t;
typedef long long int int64_t;
typedef long long int uint64_t;
typedef long long int uintptr_t;
typedef long int int32_t;
typedef long int uint32_t;
2022-10-18 20:57:13 -07:00
#ifndef __cplusplus
2022-06-09 04:28:37 -07:00
typedef char bool;
#endif
2022-12-30 14:01:52 -08:00
#endif
2022-06-09 04:28:37 -07:00
typedef void *DartPostCObjectFnType;
2022-12-29 15:03:35 -08:00
2023-02-21 00:36:29 -08:00
#define EXPIRY_HEIGHT_OFFSET 50
2022-07-13 20:22:12 -07:00
#define QR_DATA_SIZE 256
2022-06-08 05:48:16 -07:00
2022-11-15 19:51:52 -08:00
#define MAX_ATTEMPTS 10
2022-08-18 21:07:55 -07:00
#define N 200000
2022-11-18 07:28:56 -08:00
typedef struct CResult_u8 {
uint8_t value;
char *error;
2022-12-29 15:03:35 -08:00
uint32_t len;
2022-11-18 07:28:56 -08:00
} CResult_u8;
2022-09-22 01:55:32 -07:00
typedef struct CResult_u32 {
uint32_t value;
char *error;
2022-12-29 15:03:35 -08:00
uint32_t len;
2022-09-22 01:55:32 -07:00
} CResult_u32;
2023-02-28 00:55:46 -08:00
typedef struct CResult______u8 {
const uint8_t *value;
char *error;
uint32_t len;
} CResult______u8;
2022-09-22 01:55:32 -07:00
typedef struct CResult_____c_char {
char *value;
char *error;
2022-12-29 15:03:35 -08:00
uint32_t len;
2022-09-22 01:55:32 -07:00
} CResult_____c_char;
typedef struct CResult_u64 {
uint64_t value;
char *error;
2022-12-29 15:03:35 -08:00
uint32_t len;
2022-09-22 01:55:32 -07:00
} CResult_u64;
2023-03-05 17:15:11 -08:00
typedef struct CResult_bool {
bool value;
char *error;
uint32_t len;
} CResult_bool;
2022-12-29 15:03:35 -08:00
#define Account_VT_ID 4
#define Account_VT_NAME 6
#define Account_VT_BALANCE 8
#define AccountVec_VT_ACCOUNTS 4
#define Balance_VT_SHIELDED 4
#define Balance_VT_UNCONFIRMED_SPENT 6
#define Balance_VT_UNDER_CONFIRMED 10
#define Balance_VT_EXCLUDED 12
#define Balance_VT_SAPLING 14
#define Balance_VT_ORCHARD 16
#define Height_VT_HEIGHT 4
#define Height_VT_TIMESTAMP 6
#define ShieldedNote_VT_VALUE 8
#define ShieldedNote_VT_SPENT 16
#define ShieldedNoteVec_VT_NOTES 4
2022-12-30 05:31:54 -08:00
#define ShieldedTx_VT_TX_ID 6
2022-12-29 15:03:35 -08:00
2022-12-30 05:31:54 -08:00
#define ShieldedTx_VT_SHORT_TX_ID 10
2022-12-29 15:03:35 -08:00
2022-12-30 05:31:54 -08:00
#define ShieldedTx_VT_ADDRESS 18
2022-12-29 15:03:35 -08:00
2022-12-30 05:31:54 -08:00
#define ShieldedTx_VT_MEMO 20
2022-12-29 15:03:35 -08:00
2022-12-30 05:31:54 -08:00
#define ShieldedTxVec_VT_TXS 4
2022-12-29 15:03:35 -08:00
2022-12-30 05:31:54 -08:00
#define Message_VT_ID_MSG 4
2022-12-29 15:03:35 -08:00
2022-12-30 05:31:54 -08:00
#define Message_VT_ID_TX 6
2022-12-29 15:03:35 -08:00
2022-12-30 05:31:54 -08:00
#define Message_VT_FROM 12
2022-12-29 15:03:35 -08:00
2022-12-30 05:31:54 -08:00
#define Message_VT_TO 14
2022-12-29 15:03:35 -08:00
2022-12-30 05:31:54 -08:00
#define Message_VT_SUBJECT 16
2022-12-29 15:03:35 -08:00
2022-12-30 05:31:54 -08:00
#define Message_VT_BODY 18
2022-12-29 15:03:35 -08:00
2022-12-30 05:31:54 -08:00
#define Message_VT_READ 20
2022-12-29 15:03:35 -08:00
2022-12-30 05:31:54 -08:00
#define Message_VT_INCOMING 22
2022-12-29 15:03:35 -08:00
2022-12-30 05:31:54 -08:00
#define MessageVec_VT_MESSAGES 4
#define PrevNext_VT_PREV 4
#define PrevNext_VT_NEXT 6
#define SendTemplate_VT_TITLE 6
#define SendTemplate_VT_AMOUNT 10
#define SendTemplate_VT_FIAT_AMOUNT 12
#define SendTemplate_VT_FEE_INCLUDED 14
#define SendTemplate_VT_FIAT 16
#define SendTemplate_VT_INCLUDE_REPLY_TO 18
#define SendTemplateVec_VT_TEMPLATES 4
#define ContactVec_VT_CONTACTS 4
#define TxTimeValueVec_VT_VALUES 4
#define Quote_VT_PRICE 6
#define Spending_VT_RECIPIENT 4
2022-12-29 15:03:35 -08:00
2022-12-30 07:29:59 -08:00
#define AddressBalance_VT_INDEX 4
2023-02-28 00:55:46 -08:00
#define Backup_VT_SEED 6
#define Backup_VT_SK 10
#define Backup_VT_FVK 12
#define Backup_VT_UVK 14
2023-03-09 17:10:28 -08:00
#define RaptorQDrops_VT_DROPS 4
#define AGEKeys_VT_PK 6
#define Servers_VT_URLS 4
#define Progress_VT_TRIAL_DECRYPTIONS 6
#define Progress_VT_DOWNLOADED 8
2023-03-10 22:43:10 -08:00
#define KeyPack_VT_T_ADDR 4
#define KeyPack_VT_T_KEY 6
#define KeyPack_VT_Z_ADDR 8
#define KeyPack_VT_Z_KEY 10
#define Recipient_VT_REPLY_TO 10
#define Recipient_VT_MAX_AMOUNT_PER_NOTE 16
#define UnsignedTxSummary_VT_RECIPIENTS 4
#define TxOutput_VT_POOL 10
#define TxReport_VT_OUTPUTS 4
#define TxReport_VT_TRANSPARENT 6
#define TxReport_VT_NET_SAPLING 12
#define TxReport_VT_NET_ORCHARD 14
#define TxReport_VT_FEE 16
#define TxReport_VT_PRIVACY_LEVEL 18
2022-07-13 20:22:12 -07:00
void dummy_export(void);
2022-06-22 06:03:49 -07:00
2022-06-08 05:48:16 -07:00
void dart_post_cobject(DartPostCObjectFnType ptr);
2022-07-13 20:22:12 -07:00
void deallocate_str(char *s);
2022-12-29 15:03:35 -08:00
void deallocate_bytes(uint8_t *ptr, uint32_t len);
2022-11-18 07:28:56 -08:00
struct CResult_u8 init_wallet(uint8_t coin, char *db_path);
2022-06-08 05:48:16 -07:00
2022-11-18 07:28:56 -08:00
struct CResult_u8 migrate_db(uint8_t coin, char *db_path);
2022-11-18 03:02:53 -08:00
2022-11-18 07:28:56 -08:00
struct CResult_u8 migrate_data_db(uint8_t coin);
2022-11-15 02:21:47 -08:00
2022-06-08 05:48:16 -07:00
void set_active(uint8_t active);
void set_coin_lwd_url(uint8_t coin, char *lwd_url);
2022-07-14 18:12:25 -07:00
char *get_lwd_url(uint8_t coin);
2023-03-05 17:15:11 -08:00
void set_coin_passwd(uint8_t coin, char *passwd);
2022-06-08 05:48:16 -07:00
void reset_app(void);
2022-11-17 17:02:03 -08:00
void mempool_run(int64_t port);
void mempool_set_active(uint8_t coin, uint32_t id_account);
2022-09-22 01:55:32 -07:00
struct CResult_u32 new_account(uint8_t coin, char *name, char *data, int32_t index);
2022-06-08 05:48:16 -07:00
2022-07-16 20:23:56 -07:00
void new_sub_account(char *name, int32_t index, uint32_t count);
2022-11-18 07:28:56 -08:00
struct CResult_u8 convert_to_watchonly(uint8_t coin, uint32_t id_account);
2022-11-17 01:13:51 -08:00
2023-02-28 00:55:46 -08:00
struct CResult______u8 get_backup(uint8_t coin, uint32_t id_account);
2022-11-17 01:13:51 -08:00
2023-03-14 05:07:37 -07:00
struct CResult_u8 get_available_addrs(uint8_t coin, uint32_t account);
2022-11-12 17:39:12 -08:00
struct CResult_____c_char get_address(uint8_t coin, uint32_t id_account, uint8_t ua_type);
2022-07-16 20:23:56 -07:00
void import_transparent_key(uint8_t coin, uint32_t id_account, char *path);
2022-06-08 05:48:16 -07:00
2022-07-23 06:25:08 -07:00
void import_transparent_secret_key(uint8_t coin, uint32_t id_account, char *secret_key);
2022-07-21 18:08:29 -07:00
void cancel_warp(void);
2022-09-22 01:55:32 -07:00
struct CResult_u8 warp(uint8_t coin,
bool get_tx,
uint32_t anchor_offset,
uint32_t max_cost,
int64_t port);
2022-06-08 05:48:16 -07:00
int8_t is_valid_key(uint8_t coin, char *key);
bool valid_address(uint8_t coin, char *address);
2023-02-25 15:53:50 -08:00
struct CResult_____c_char get_diversified_address(uint8_t ua_type, uint32_t time);
2022-06-08 05:48:16 -07:00
2022-09-22 01:55:32 -07:00
struct CResult_u32 get_latest_height(void);
2022-06-08 05:48:16 -07:00
2023-04-14 06:00:42 -07:00
struct CResult_u8 ledger_build_keys(void);
struct CResult_____c_char ledger_get_fvk(uint8_t coin);
struct CResult_____c_char ledger_get_address(void);
2022-06-08 05:48:16 -07:00
void skip_to_last_height(uint8_t coin);
2022-09-22 01:55:32 -07:00
struct CResult_u32 rewind_to(uint32_t height);
2022-09-06 19:38:16 -07:00
void rescan_from(uint32_t height);
2022-06-08 05:48:16 -07:00
2022-09-22 01:55:32 -07:00
struct CResult_u64 get_taddr_balance(uint8_t coin, uint32_t id_account);
2022-06-08 05:48:16 -07:00
2022-11-29 07:24:01 -08:00
struct CResult_____c_char transfer_pools(uint8_t coin,
uint32_t account,
uint8_t from_pool,
uint8_t to_pool,
uint64_t amount,
2022-12-10 14:01:10 -08:00
bool fee_included,
2022-12-05 09:43:50 -08:00
char *memo,
2022-12-08 01:17:18 -08:00
uint64_t split_amount,
2022-11-29 07:24:01 -08:00
uint32_t confirmations);
2022-12-10 14:01:10 -08:00
struct CResult_____c_char shield_taddr(uint8_t coin,
uint32_t account,
uint64_t amount,
uint32_t confirmations);
2022-06-08 05:48:16 -07:00
2023-03-13 00:49:15 -07:00
struct CResult______u8 scan_transparent_accounts(uint8_t coin,
uint32_t account,
uint32_t gap_limit);
2022-06-08 05:48:16 -07:00
2022-11-12 17:39:12 -08:00
struct CResult_____c_char prepare_multi_payment(uint8_t coin,
uint32_t account,
2023-03-10 22:43:10 -08:00
uint8_t *recipients_bytes,
uint64_t recipients_len,
2022-09-22 01:55:32 -07:00
uint32_t anchor_offset);
2022-06-08 05:48:16 -07:00
2023-03-10 22:43:10 -08:00
struct CResult______u8 transaction_report(uint8_t coin, char *plan);
2022-11-12 17:39:12 -08:00
2022-11-29 07:24:01 -08:00
struct CResult_____c_char sign(uint8_t coin, uint32_t account, char *tx_plan, int64_t _port);
2022-11-12 17:39:12 -08:00
struct CResult_____c_char sign_and_broadcast(uint8_t coin, uint32_t account, char *tx_plan);
2022-06-08 05:48:16 -07:00
2022-09-22 01:55:32 -07:00
struct CResult_____c_char broadcast_tx(char *tx_str);
2022-06-08 05:48:16 -07:00
2023-02-21 00:36:29 -08:00
bool is_valid_tkey(char *sk);
struct CResult_____c_char sweep_tkey(uint32_t last_height,
char *sk,
uint8_t pool,
uint32_t confirmations);
2022-09-22 01:55:32 -07:00
struct CResult_u32 get_activation_date(void);
2022-06-08 05:48:16 -07:00
2022-09-22 01:55:32 -07:00
struct CResult_u32 get_block_by_time(uint32_t time);
2022-06-08 05:48:16 -07:00
2022-09-22 01:55:32 -07:00
struct CResult_u32 sync_historical_prices(int64_t now, uint32_t days, char *currency);
2022-06-08 05:48:16 -07:00
void store_contact(uint32_t id, char *name, char *address, bool dirty);
2022-09-22 01:55:32 -07:00
struct CResult_____c_char commit_unsaved_contacts(uint32_t anchor_offset);
2022-06-08 05:48:16 -07:00
void mark_message_read(uint32_t message, bool read);
void mark_all_messages_read(bool read);
void truncate_data(void);
2022-09-02 01:44:31 -07:00
void truncate_sync_data(void);
2023-03-07 19:46:54 -08:00
bool check_account(uint8_t coin, uint32_t account);
2022-06-08 05:48:16 -07:00
void delete_account(uint8_t coin, uint32_t account);
2023-01-29 07:40:02 -08:00
struct CResult_____c_char make_payment_uri(uint8_t coin,
char *address,
uint64_t amount,
char *memo);
2022-06-08 05:48:16 -07:00
2022-09-22 01:55:32 -07:00
struct CResult_____c_char parse_payment_uri(char *uri);
2022-06-08 05:48:16 -07:00
2023-03-09 17:10:28 -08:00
struct CResult______u8 generate_key(void);
2022-11-22 01:53:16 -08:00
struct CResult_u8 zip_backup(char *key, char *dst_dir);
2022-12-24 13:04:42 -08:00
struct CResult_u8 unzip_backup(char *key, char *data_path, char *dst_dir);
2022-11-22 01:53:16 -08:00
2023-03-09 17:10:28 -08:00
struct CResult______u8 split_data(uint32_t id, char *data);
2022-06-20 02:05:11 -07:00
2022-09-22 01:55:32 -07:00
struct CResult_____c_char merge_data(char *drop);
2022-06-21 17:18:47 -07:00
2022-09-22 01:55:32 -07:00
struct CResult_____c_char get_tx_summary(char *tx);
2022-07-13 20:22:12 -07:00
2023-03-09 17:10:28 -08:00
struct CResult_____c_char get_best_server(uint8_t *servers, uint64_t len);
2022-07-17 19:55:57 -07:00
2022-07-21 18:08:29 -07:00
void import_from_zwl(uint8_t coin, char *name, char *data);
2022-07-26 19:11:36 -07:00
2023-03-10 22:43:10 -08:00
struct CResult______u8 derive_zip32(uint8_t coin,
uint32_t id_account,
uint32_t account,
uint32_t external,
bool has_address,
uint32_t address);
2022-08-13 19:56:42 -07:00
2023-02-26 23:27:22 -08:00
struct CResult_u8 clear_tx_details(uint8_t coin, uint32_t account);
2022-12-29 15:03:35 -08:00
struct CResult______u8 get_account_list(uint8_t coin);
2023-01-04 02:39:13 -08:00
struct CResult_u32 get_active_account(uint8_t coin);
struct CResult_u8 set_active_account(uint8_t coin, uint32_t id);
2022-12-29 15:03:35 -08:00
struct CResult_____c_char get_t_addr(uint8_t coin, uint32_t id);
struct CResult_____c_char get_sk(uint8_t coin, uint32_t id);
struct CResult_u8 update_account_name(uint8_t coin, uint32_t id, char *name);
struct CResult______u8 get_balances(uint8_t coin, uint32_t id, uint32_t confirmed_height);
struct CResult______u8 get_db_height(uint8_t coin);
struct CResult______u8 get_notes(uint8_t coin, uint32_t id);
2022-12-30 05:31:54 -08:00
struct CResult______u8 get_txs(uint8_t coin, uint32_t id);
struct CResult______u8 get_messages(uint8_t coin, uint32_t id);
struct CResult______u8 get_prev_next_message(uint8_t coin,
uint32_t id,
char *subject,
uint32_t height);
struct CResult______u8 get_templates(uint8_t coin);
struct CResult_u32 save_send_template(uint8_t coin, uint8_t *template_, uint64_t len);
struct CResult_u8 delete_send_template(uint8_t coin, uint32_t id);
struct CResult______u8 get_contacts(uint8_t coin);
struct CResult______u8 get_pnl_txs(uint8_t coin, uint32_t id, uint32_t timestamp);
2022-12-30 07:29:59 -08:00
struct CResult______u8 get_historical_prices(uint8_t coin, uint32_t timestamp, char *currency);
2022-12-30 05:31:54 -08:00
struct CResult______u8 get_spendings(uint8_t coin, uint32_t id, uint32_t timestamp);
2022-12-30 07:29:59 -08:00
struct CResult_u8 update_excluded(uint8_t coin, uint32_t id, bool excluded);
struct CResult_u8 invert_excluded(uint8_t coin, uint32_t id);
2023-01-07 08:53:58 -08:00
struct CResult______u8 get_checkpoints(uint8_t coin);
2023-03-05 17:15:11 -08:00
struct CResult_bool decrypt_db(char *db_path, char *passwd);
struct CResult_u8 clone_db_with_passwd(uint8_t coin, char *temp_path, char *passwd);
2023-03-13 16:58:16 -07:00
struct CResult_____c_char get_property(uint8_t coin, char *name);
struct CResult_u8 set_property(uint8_t coin, char *name, char *value);
2023-04-15 01:53:16 -07:00
struct CResult_____c_char ledger_send(uint8_t coin, char *tx_plan);
2023-04-18 16:55:10 -07:00
struct CResult_u32 ledger_import_account(uint8_t coin, char *name);
struct CResult_bool ledger_has_account(uint8_t coin, uint32_t account);
2022-08-13 19:56:42 -07:00
bool has_cuda(void);
2022-08-18 21:07:55 -07:00
bool has_metal(void);
2022-08-21 10:48:34 -07:00
bool has_gpu(void);
void use_gpu(bool v);