react-native-nitro-ark 0.0.16 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cpp/bark-cpp.h CHANGED
@@ -43,7 +43,6 @@ namespace bark
43
43
 
44
44
  struct bark_BarkCreateOpts
45
45
  {
46
- bool force;
47
46
  bool regtest;
48
47
  bool signet;
49
48
  bool bitcoin;
@@ -80,324 +79,99 @@ namespace bark
80
79
  const char *bark_error_message(const bark_BarkError *error);
81
80
 
82
81
  /// Frees a C string allocated by a bark-cpp function.
83
- ///
84
- /// This function should be called by the C/C++ side on any `char*`
85
- /// that was returned by functions like `bark_create_mnemonic`,
86
- /// `bark_get_onchain_address`, `bark_send_onchain`, etc.
87
- ///
88
- /// # Safety
89
- ///
90
- /// The pointer `s` must have been previously allocated by Rust using
91
- /// `CString::into_raw` or a similar mechanism within this library.
92
- /// Calling this with a null pointer is safe (it does nothing).
93
- /// Calling this with a pointer not allocated by this library, or calling
94
- /// it more than once on the same pointer, results in undefined behavior.
95
82
  void bark_free_string(char *s);
96
83
 
97
84
  /// Create a new mnemonic
98
- ///
99
- /// @return The mnemonic string as a C string, or NULL on error
100
85
  char *bark_create_mnemonic();
101
86
 
102
- /// Create a new wallet at the specified directory
103
- ///
104
- /// @param datadir Path to the data directory
105
- /// @param opts Creation options
106
- /// @return Error pointer or NULL on success
107
- bark_BarkError *bark_create_wallet(const char *datadir, bark_BarkCreateOpts opts);
87
+ /// Load an existing wallet or create a new one at the specified directory
88
+ bark_BarkError *bark_load_wallet(const char *datadir, bark_BarkCreateOpts opts);
89
+
90
+ /// Close the currently loaded wallet
91
+ bark_BarkError *bark_close_wallet();
108
92
 
109
93
  /// Get offchain and onchain balances
110
- ///
111
- /// @param datadir Path to the data directory
112
- /// @param no_sync Whether to skip syncing the wallet
113
- /// @param balance_out Pointer to a BarkBalance struct where the result will be stored
114
- /// @return Error pointer or NULL on success
115
- bark_BarkError *bark_get_balance(const char *datadir,
116
- bool no_sync,
117
- const char *mnemonic,
118
- bark_BarkBalance *balance_out);
94
+ bark_BarkError *bark_get_balance(bool no_sync, bark_BarkBalance *balance_out);
119
95
 
120
96
  /// Get an onchain address.
121
- ///
122
- /// The returned address string must be freed by the caller using `bark_free_string`.
123
- ///
124
- /// @param datadir Path to the data directory
125
- /// @param mnemonic The wallet mnemonic phrase
126
- /// @param address_out Pointer to a `*mut c_char` where the address string pointer will be written.
127
- /// @return Error pointer or NULL on success.
128
- bark_BarkError *bark_get_onchain_address(const char *datadir,
129
- const char *mnemonic,
130
- char **address_out);
97
+ bark_BarkError *bark_get_onchain_address(char **address_out);
131
98
 
132
99
  /// Send funds using the onchain wallet.
133
- ///
134
- /// The returned transaction ID string must be freed by the caller using `bark_free_string`.
135
- ///
136
- /// @param datadir Path to the data directory
137
- /// @param mnemonic The wallet mnemonic phrase
138
- /// @param destination The destination Bitcoin address as a string
139
- /// @param amount_sat The amount to send in satoshis
140
- /// @param no_sync Whether to skip syncing the wallet before sending
141
- /// @param txid_out Pointer to a `*mut c_char` where the transaction ID string pointer will be written.
142
- /// @return Error pointer or NULL on success.
143
- bark_BarkError *bark_send_onchain(const char *datadir,
144
- const char *mnemonic,
145
- const char *destination,
100
+ bark_BarkError *bark_send_onchain(const char *destination,
146
101
  uint64_t amount_sat,
147
102
  bool no_sync,
148
103
  char **txid_out);
149
104
 
150
105
  /// Send all funds from the onchain wallet to a destination address.
151
- ///
152
- /// The returned transaction ID string must be freed by the caller using `bark_free_string`.
153
- ///
154
- /// @param datadir Path to the data directory
155
- /// @param mnemonic The wallet mnemonic phrase
156
- /// @param destination The destination Bitcoin address as a string
157
- /// @param no_sync Whether to skip syncing the wallet before sending
158
- /// @param txid_out Pointer to a `*mut c_char` where the transaction ID string pointer will be written.
159
- /// @return Error pointer or NULL on success.
160
- bark_BarkError *bark_drain_onchain(const char *datadir,
161
- const char *mnemonic,
162
- const char *destination,
163
- bool no_sync,
164
- char **txid_out);
106
+ bark_BarkError *bark_drain_onchain(const char *destination, bool no_sync, char **txid_out);
165
107
 
166
108
  /// Send funds to multiple recipients using the onchain wallet.
167
- ///
168
- /// The returned transaction ID string must be freed by the caller using `bark_free_string`.
169
- ///
170
- /// @param datadir Path to the data directory
171
- /// @param mnemonic The wallet mnemonic phrase
172
- /// @param destinations Array of C strings representing destination Bitcoin addresses
173
- /// @param amounts_sat Array of u64 representing amounts in satoshis (must match destinations array length)
174
- /// @param num_outputs The number of outputs (length of the destinations and amounts_sat arrays)
175
- /// @param no_sync Whether to skip syncing the wallet before sending
176
- /// @param txid_out Pointer to a `*mut c_char` where the transaction ID string pointer will be written.
177
- /// @return Error pointer or NULL on success.
178
- bark_BarkError *bark_send_many_onchain(const char *datadir,
179
- const char *mnemonic,
180
- const char *const *destinations,
109
+ bark_BarkError *bark_send_many_onchain(const char *const *destinations,
181
110
  const uint64_t *amounts_sat,
182
111
  uintptr_t num_outputs,
183
112
  bool no_sync,
184
113
  char **txid_out);
185
114
 
186
115
  /// Get the list of onchain UTXOs as a JSON string.
187
- ///
188
- /// The returned JSON string must be freed by the caller using `bark_free_string`.
189
- ///
190
- /// @param datadir Path to the data directory
191
- /// @param mnemonic The wallet mnemonic phrase
192
- /// @param no_sync Whether to skip syncing the wallet before fetching
193
- /// @param utxos_json_out Pointer to a `*mut c_char` where the JSON string pointer will be written.
194
- /// @return Error pointer or NULL on success.
195
- bark_BarkError *bark_get_onchain_utxos(const char *datadir,
196
- const char *mnemonic,
197
- bool no_sync,
198
- char **utxos_json_out);
116
+ bark_BarkError *bark_get_onchain_utxos(bool no_sync, char **utxos_json_out);
199
117
 
200
118
  /// Get the wallet's VTXO public key (hex string).
201
- ///
202
- /// The returned public key string must be freed by the caller using `bark_free_string`.
203
- ///
204
- /// @param datadir Path to the data directory
205
- /// @param mnemonic The wallet mnemonic phrase
206
- /// @param pubkey_hex_out Pointer to a `*mut c_char` where the hex string pointer will be written.
207
- /// @return Error pointer or NULL on success.
208
- bark_BarkError *bark_get_vtxo_pubkey(const char *datadir,
209
- const char *mnemonic,
210
- char **pubkey_hex_out);
119
+ bark_BarkError *bark_get_vtxo_pubkey(const uint32_t *index, char **pubkey_hex_out);
211
120
 
212
121
  /// Get the list of VTXOs as a JSON string.
213
- ///
214
- /// The returned JSON string must be freed by the caller using `bark_free_string`.
215
- ///
216
- /// @param datadir Path to the data directory
217
- /// @param mnemonic The wallet mnemonic phrase
218
- /// @param no_sync Whether to skip syncing the wallet before fetching
219
- /// @param vtxos_json_out Pointer to a `*mut c_char` where the JSON string pointer will be written.
220
- /// @return Error pointer or NULL on success.
221
- bark_BarkError *bark_get_vtxos(const char *datadir,
222
- const char *mnemonic,
223
- bool no_sync,
224
- char **vtxos_json_out);
122
+ bark_BarkError *bark_get_vtxos(bool no_sync, char **vtxos_json_out);
225
123
 
226
124
  /// Refresh VTXOs based on specified criteria.
227
- ///
228
- /// The returned JSON status string must be freed by the caller using `bark_free_string`.
229
- ///
230
- /// @param datadir Path to the data directory
231
- /// @param mnemonic The wallet mnemonic phrase
232
- /// @param refresh_opts Options specifying which VTXOs to refresh
233
- /// @param no_sync Whether to skip syncing the wallet before refreshing
234
- /// @param status_json_out Pointer to a `*mut c_char` where the JSON status string will be written.
235
- /// @return Error pointer or NULL on success.
236
- bark_BarkError *bark_refresh_vtxos(const char *datadir,
237
- const char *mnemonic,
238
- bark_BarkRefreshOpts refresh_opts,
125
+ bark_BarkError *bark_refresh_vtxos(bark_BarkRefreshOpts refresh_opts,
239
126
  bool no_sync,
240
127
  char **status_json_out);
241
128
 
242
129
  /// Board a specific amount from the onchain wallet into Ark.
243
- ///
244
- /// The returned JSON status string must be freed by the caller using `bark_free_string`.
245
- ///
246
- /// @param datadir Path to the data directory
247
- /// @param mnemonic The wallet mnemonic phrase
248
- /// @param amount_sat The amount in satoshis to board
249
- /// @param no_sync Whether to skip syncing the onchain wallet before boarding
250
- /// @param status_json_out Pointer to a `*mut c_char` where the JSON status string will be written.
251
- /// @return Error pointer or NULL on success.
252
- bark_BarkError *bark_board_amount(const char *datadir,
253
- const char *mnemonic,
254
- uint64_t amount_sat,
255
- bool no_sync,
256
- char **status_json_out);
130
+ bark_BarkError *bark_board_amount(uint64_t amount_sat, bool no_sync, char **status_json_out);
257
131
 
258
132
  /// Board all available funds from the onchain wallet into Ark.
259
- ///
260
- /// The returned JSON status string must be freed by the caller using `bark_free_string`.
261
- ///
262
- /// @param datadir Path to the data directory
263
- /// @param mnemonic The wallet mnemonic phrase
264
- /// @param no_sync Whether to skip syncing the onchain wallet before boarding
265
- /// @param status_json_out Pointer to a `*mut c_char` where the JSON status string will be written.
266
- /// @return Error pointer or NULL on success.
267
- bark_BarkError *bark_board_all(const char *datadir,
268
- const char *mnemonic,
269
- bool no_sync,
270
- char **status_json_out);
271
-
272
- bark_BarkError *bark_send(const char *datadir,
273
- const char *mnemonic,
274
- const char *destination,
133
+ bark_BarkError *bark_board_all(bool no_sync, char **status_json_out);
134
+
135
+ bark_BarkError *bark_send(const char *destination,
275
136
  uint64_t amount_sat,
276
137
  const char *comment,
277
138
  bool no_sync,
278
139
  char **status_json_out);
279
140
 
280
141
  /// Send an onchain payment via an Ark round.
281
- ///
282
- /// The returned JSON status string must be freed by the caller using `bark_free_string`.
283
- ///
284
- /// @param datadir Path to the data directory
285
- /// @param mnemonic The wallet mnemonic phrase
286
- /// @param destination The destination Bitcoin address as a string
287
- /// @param amount_sat The amount in satoshis to send
288
- /// @param no_sync Whether to skip syncing the wallet before sending
289
- /// @param status_json_out Pointer to a `*mut c_char` where the JSON status string will be written.
290
- /// @return Error pointer or NULL on success.
291
- bark_BarkError *bark_send_round_onchain(const char *datadir,
292
- const char *mnemonic,
293
- const char *destination,
142
+ bark_BarkError *bark_send_round_onchain(const char *destination,
294
143
  uint64_t amount_sat,
295
144
  bool no_sync,
296
145
  char **status_json_out);
297
146
 
298
147
  /// Offboard specific VTXOs to an optional onchain address.
299
- ///
300
- /// The returned JSON result string must be freed by the caller using `bark_free_string`.
301
- ///
302
- /// @param datadir Path to the data directory
303
- /// @param mnemonic The wallet mnemonic phrase
304
- /// @param specific_vtxo_ids Array of VtxoId strings (cannot be empty)
305
- /// @param num_specific_vtxo_ids Number of VtxoIds in the array
306
- /// @param optional_address Optional destination Bitcoin address (pass NULL if not provided)
307
- /// @param no_sync Whether to skip syncing the wallet
308
- /// @param status_json_out Pointer to a `*mut c_char` where the JSON result string will be written.
309
- /// @return Error pointer or NULL on success.
310
- bark_BarkError *bark_offboard_specific(const char *datadir,
311
- const char *mnemonic,
312
- const char *const *specific_vtxo_ids,
148
+ bark_BarkError *bark_offboard_specific(const char *const *specific_vtxo_ids,
313
149
  uintptr_t num_specific_vtxo_ids,
314
150
  const char *optional_address,
315
151
  bool no_sync,
316
152
  char **status_json_out);
317
153
 
318
154
  /// Offboard all VTXOs to an optional onchain address.
319
- ///
320
- /// The returned JSON result string must be freed by the caller using `bark_free_string`.
321
- ///
322
- /// @param datadir Path to the data directory
323
- /// @param mnemonic The wallet mnemonic phrase
324
- /// @param optional_address Optional destination Bitcoin address (pass NULL if not provided)
325
- /// @param no_sync Whether to skip syncing the wallet
326
- /// @param status_json_out Pointer to a `*mut c_char` where the JSON result string will be written.
327
- /// @return Error pointer or NULL on success.
328
- bark_BarkError *bark_offboard_all(const char *datadir,
329
- const char *mnemonic,
330
- const char *optional_address,
155
+ bark_BarkError *bark_offboard_all(const char *optional_address,
331
156
  bool no_sync,
332
157
  char **status_json_out);
333
158
 
334
159
  /// Start the exit process for specific VTXOs.
335
- ///
336
- /// The returned JSON success string must be freed by the caller using `bark_free_string`.
337
- ///
338
- /// @param datadir Path to the data directory
339
- /// @param mnemonic The wallet mnemonic phrase
340
- /// @param specific_vtxo_ids Array of VtxoId strings (cannot be empty)
341
- /// @param num_specific_vtxo_ids Number of VtxoIds in the array
342
- /// @param status_json_out Pointer to a `*mut c_char` where the JSON success string will be written.
343
- /// @return Error pointer or NULL on success.
344
- bark_BarkError *bark_exit_start_specific(const char *datadir,
345
- const char *mnemonic,
346
- const char *const *specific_vtxo_ids,
160
+ bark_BarkError *bark_exit_start_specific(const char *const *specific_vtxo_ids,
347
161
  uintptr_t num_specific_vtxo_ids,
348
162
  char **status_json_out);
349
163
 
350
164
  /// Start the exit process for all VTXOs in the wallet.
351
- ///
352
- /// The returned JSON success string must be freed by the caller using `bark_free_string`.
353
- ///
354
- /// @param datadir Path to the data directory
355
- /// @param mnemonic The wallet mnemonic phrase
356
- /// @param status_json_out Pointer to a `*mut c_char` where the JSON success string will be written.
357
- /// @return Error pointer or NULL on success.
358
- bark_BarkError *bark_exit_start_all(const char *datadir,
359
- const char *mnemonic,
360
- char **status_json_out);
165
+ bark_BarkError *bark_exit_start_all(char **status_json_out);
361
166
 
362
167
  /// Progress the exit process once and return the current status.
363
- ///
364
- /// The returned JSON status string must be freed by the caller using `bark_free_string`.
365
- ///
366
- /// @param datadir Path to the data directory
367
- /// @param mnemonic The wallet mnemonic phrase
368
- /// @param status_json_out Pointer to a `*mut c_char` where the JSON status string will be written.
369
- /// @return Error pointer or NULL on success.
370
- bark_BarkError *bark_exit_progress_once(const char *datadir,
371
- const char *mnemonic,
372
- char **status_json_out);
168
+ bark_BarkError *bark_exit_progress_once(char **status_json_out);
373
169
 
374
170
  /// FFI: Creates a BOLT11 invoice for receiving payments.
375
- ///
376
- /// # Arguments
377
- /// * `datadir` - The directory where the wallet data is stored.
378
- /// * `mnemonic` - The wallet's mnemonic phrase.
379
- /// * `amount_msat` - The amount for the invoice in millisatoshis.
380
- /// * `invoice_out` - A pointer to a C string that will be populated with the BOLT11 invoice.
381
- ///
382
- /// # Returns
383
- /// A null pointer on success, or a pointer to a `BarkError` on failure.
384
- bark_BarkError *bark_bolt11_invoice(const char *datadir,
385
- const char *mnemonic,
386
- uint64_t amount_msat,
387
- char **invoice_out);
171
+ bark_BarkError *bark_bolt11_invoice(uint64_t amount_msat, char **invoice_out);
388
172
 
389
173
  /// FFI: Claims a BOLT11 payment using an invoice.
390
- ///
391
- /// # Arguments
392
- /// * `datadir` - The directory where the wallet data is stored.
393
- /// * `mnemonic` - The wallet's mnemonic phrase.
394
- /// * `bolt11` - The BOLT11 invoice to be paid/claimed.
395
- ///
396
- /// # Returns
397
- /// A null pointer on success, or a pointer to a `BarkError` on failure.
398
- bark_BarkError *bark_claim_bolt11_payment(const char *datadir,
399
- const char *mnemonic,
400
- const char *bolt11);
174
+ bark_BarkError *bark_claim_bolt11_payment(const char *bolt11);
401
175
 
402
176
  } // extern "C"
403
177