10 #include <libex/str.h>
11 #include <libex/list.h>
12 #include <libex/json.h>
17 typedef enum { TX_SEND
, TX_RECV
} tx_category_t
;
19 static inline str_t
*coin_str_to_int_str (const char *amount
) {
20 return str_to_int_str(amount
, COIN_DSCALE
);
23 char *coin_double_to_int_str (double amount
);
25 double coin_getbalance (chain_conf_t
*conf
, const char *account
);
26 char *coin_getbalance_as_str (chain_conf_t
*conf
, const char *account
);
27 char *coin_getnewaddress (chain_conf_t
*conf
, const char *account
);
28 int coin_listtransactions (chain_conf_t
*conf
, const char *account
, int from
, int count
, json_item_h fn
, void *userdata
, int flags
);
29 int coin_listaccounts (chain_conf_t
*conf
, json_item_h fn
, void *userdata
, int flags
);
30 int coin_getaddressesbyaccount (chain_conf_t
*conf
, const char *account
, json_item_h fn
, void *userdata
, int flags
);
31 int coin_gettransaction (chain_conf_t
*conf
, const char *txid
, json_item_h fn
, void *userdata
);
32 char *coin_sendfrom_z (chain_conf_t
*conf
, const char *from_account
, const char *to_address
, mpz_srcptr amount
);
33 char *coin_sendtoaddress_z (chain_conf_t
*conf
, const char *to_address
, mpz_srcptr amount
);
34 char *coin_encryptwallet (chain_conf_t
*conf
, const char *pass
);
35 void coin_walletlock (chain_conf_t
*conf
);
36 void coin_walletpassphrase (chain_conf_t
*conf
, const char *pass
, int timeout
);
37 void coin_stop (chain_conf_t
*conf
);
40 static inline double btc_getbalance (const char *account
) {
41 return coin_getbalance(btc_conf_ptr
, account
);
44 static inline char *btc_getbalance_as_str (const char *account
) {
45 return coin_getbalance_as_str(btc_conf_ptr
, account
);
48 static inline char *btc_getnewaddress (const char *account
) {
49 return coin_getnewaddress(btc_conf_ptr
, account
);
52 static inline int btc_listtransactions (const char *account
, int from
, int count
, json_item_h fn
, void *userdata
, int flags
) {
53 return coin_listtransactions(btc_conf_ptr
, account
, from
, count
, fn
, userdata
, flags
);
56 static inline int btc_listaccounts (json_item_h fn
, void *userdata
, int flags
) {
57 return coin_listaccounts(btc_conf_ptr
, fn
, userdata
, flags
);
60 static inline int btc_getaddressesbyaccount (const char *account
, json_item_h fn
, void *userdata
, int flags
) {
61 return coin_getaddressesbyaccount(btc_conf_ptr
, account
, fn
, userdata
, flags
);
64 static inline int btc_gettransaction (const char *txid
, json_item_h fn
, void *userdata
) {
65 return coin_gettransaction(btc_conf_ptr
, txid
, fn
, userdata
);
68 static inline char *btc_sendfrom_z (const char *from_account
, const char *to_address
, mpz_srcptr amount
) {
69 return coin_sendfrom_z(btc_conf_ptr
, from_account
, to_address
, amount
);
72 static inline char *btc_sendtoaddress_z (const char *to_address
, mpz_srcptr amount
) {
73 return coin_sendtoaddress_z(btc_conf_ptr
, to_address
, amount
);
76 static inline char *btc_encryptwallet (const char *pass
) {
77 return coin_encryptwallet(btc_conf_ptr
, pass
);
80 static inline void btc_walletlock () {
81 coin_walletlock(btc_conf_ptr
);
84 static inline void btc_walletpassphrase (const char *pass
, int timeout
) {
85 coin_walletpassphrase(btc_conf_ptr
, pass
, timeout
);
88 static inline void btc_stop () {
89 coin_stop(btc_conf_ptr
);
93 static inline double ltc_getbalance (const char *account
) {
94 return coin_getbalance(ltc_conf_ptr
, account
);
97 static inline char *ltc_getbalance_as_str (const char *account
) {
98 return coin_getbalance_as_str(ltc_conf_ptr
, account
);
101 static inline char *ltc_getnewaddress (const char *account
) {
102 return coin_getnewaddress(ltc_conf_ptr
, account
);
105 static inline int ltc_listtransactions (const char *account
, int from
, int count
, json_item_h fn
, void *userdata
, int flags
) {
106 return coin_listtransactions(ltc_conf_ptr
, account
, from
, count
, fn
, userdata
, flags
);
109 static inline int ltc_listaccounts (json_item_h fn
, void *userdata
, int flags
) {
110 return coin_listaccounts(ltc_conf_ptr
, fn
, userdata
, flags
);
113 static inline int ltc_getaddressesbyaccount (const char *account
, json_item_h fn
, void *userdata
, int flags
) {
114 return coin_getaddressesbyaccount(ltc_conf_ptr
, account
, fn
, userdata
, flags
);
117 static inline int ltc_gettransaction (const char *txid
, json_item_h fn
, void *userdata
) {
118 return coin_gettransaction(ltc_conf_ptr
, txid
, fn
, userdata
);
121 static inline char *ltc_sendfrom_z (const char *from_account
, const char *to_address
, mpz_srcptr amount
) {
122 return coin_sendfrom_z(ltc_conf_ptr
, from_account
, to_address
, amount
);
125 static inline char *ltc_sendtoaddress_z (const char *to_address
, mpz_srcptr amount
) {
126 return coin_sendtoaddress_z(ltc_conf_ptr
, to_address
, amount
);
129 static inline char *ltc_encryptwallet (const char *pass
) {
130 return coin_encryptwallet(ltc_conf_ptr
, pass
);
133 static inline void ltc_walletlock () {
134 coin_walletlock(ltc_conf_ptr
);
137 static inline void ltc_walletpassphrase (const char *pass
, int timeout
) {
138 coin_walletpassphrase(ltc_conf_ptr
, pass
, timeout
);
141 static inline void ltc_stop () {
142 coin_stop(ltc_conf_ptr
);
146 #define MCH_STREAM_PUBKEYS 0x01
147 #define MCH_STREAM_ITEMS 0x02
148 #define MCH_STREAM_ACCESS 0x04
149 typedef int mch_stream_t
;
151 #define MCA_ISCOMPRESSED 0x00000001
152 #define MCA_ISMINE 0x00000002
153 #define MCA_ISSCRIPT 0x00000004
154 #define MCA_ISVALID 0x00000008
155 #define MCA_ISWATCHONLY 0x00000010
156 #define MCA_ISSYCHRONIZED 0x00000020
163 void mch_address_free (mch_address_t
*addr
);
165 typedef void (*balance_h
) (strptr_t
*, strptr_t
*, long double, void*);
166 int mch_getmultibalances (chain_conf_t
*conf
,
167 const char *addresses
, size_t addresses_len
,
168 const char *assets
, size_t assets_len
,
169 int miniconf
, balance_h fn
, void *userdata
);
170 char *mch_getnewaddress (chain_conf_t
*conf
);
171 int mch_getaddressbalances (chain_conf_t
*conf
,
172 const char *address
, size_t address_len
,
173 int miniconf
, json_item_h fn
, void *userdata
, int flags
);
174 char *mch_issue (chain_conf_t
*conf
,
175 const char *asset
, size_t asset_len
,
176 const char *address
, size_t address_len
,
177 double amount
, int digits
, int can_issuemore
);
178 char *mch_sendfrom_d (chain_conf_t
*conf
,
179 const char *from_address
, size_t from_address_len
,
180 const char *to_address
, size_t to_address_len
,
181 const char *asset
, size_t asset_len
, double amount
,
182 const char *data
, size_t data_len
);
183 mch_address_t
*mch_validateaddress (chain_conf_t
*conf
, const char *address
, size_t address_len
);
184 int mch_listaddresstransactions (chain_conf_t
*conf
,
185 const char *address
, size_t address_len
,
186 int from
, int count
, json_item_h fn
, void *userdata
, int flags
);
187 int mch_getwallettransaction (chain_conf_t
*conf
,
188 const char *txid
, size_t txid_len
,
189 json_item_h fn
, void *userdata
);
190 int mch_listpermissions (chain_conf_t
*conf
,
191 const char *address
, size_t address_len
,
192 json_item_h fn
, void *userdata
);
193 int mch_grant (chain_conf_t
*conf
,
194 const char *address
, size_t address_len
,
195 const char *permissions
, size_t permissions_len
);
196 int mch_revoke (chain_conf_t
*conf
,
197 const char *address
, size_t address_len
,
198 const char *permissions
, size_t permissions_len
);
199 char *mch_dumpprivkey (chain_conf_t
*conf
,
200 const char *address
, size_t address_len
);
201 int mch_importprivkey (chain_conf_t
*conf
,
202 const char *privkey
, size_t privkey_len
,
204 int mch_getblockchainparams (chain_conf_t
*conf
, json_item_h fn
, void *userdata
, int flags
);
205 int mch_getaddresses (chain_conf_t
*conf
, json_item_h fn
, void *userdata
, int flags
);
206 int mch_dumpwallet (chain_conf_t
*conf
, const char *filename
);
207 int mch_importwallet (chain_conf_t
*conf
, const char *filename
);
208 char *mch_createstream (chain_conf_t
*conf
, mch_stream_t mch_stream
, int is_open
);
209 char *mch_publishfrom (chain_conf_t
*conf
, const char *address
, size_t address_len
,
210 mch_stream_t mch_stream
, char *key
,
211 char *data_hex
, size_t data_hext_len
);
212 int mch_subscribestream (chain_conf_t
*conf
, mch_stream_t mch_stream
);
213 int mch_liststreampublisheritems (chain_conf_t
*conf
, mch_stream_t mch_stream
,
214 const char *address
, size_t address_len
, int from
, int count
,
215 json_item_h fn
, void *userdata
, int flags
);
216 char *mch_gettxoutdata (chain_conf_t
*conf
, const char *txid
, size_t txid_len
, int vout
);
217 int mch_liststreamitems (chain_conf_t
*conf
, mch_stream_t mch_stream
,
219 json_item_h fn
, void *userdata
, int flags
);
220 int mch_liststreamkeyitems (chain_conf_t
*conf
, const char *key
, size_t key_len
, mch_stream_t mch_stream
,
221 int from
, int count
,
222 json_item_h fn
, void *userdata
, int flags
);
223 char *mch_stop (chain_conf_t
*conf
);