react-native-nitro-ark 0.0.15 → 0.0.17

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
@@ -80,296 +80,99 @@ namespace bark
80
80
  const char *bark_error_message(const bark_BarkError *error);
81
81
 
82
82
  /// 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
83
  void bark_free_string(char *s);
96
84
 
97
85
  /// Create a new mnemonic
98
- ///
99
- /// @return The mnemonic string as a C string, or NULL on error
100
86
  char *bark_create_mnemonic();
101
87
 
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);
88
+ /// Load an existing wallet or create a new one at the specified directory
89
+ bark_BarkError *bark_load_wallet(const char *datadir, bark_BarkCreateOpts opts);
90
+
91
+ /// Close the currently loaded wallet
92
+ bark_BarkError *bark_close_wallet();
108
93
 
109
94
  /// 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);
95
+ bark_BarkError *bark_get_balance(bool no_sync, bark_BarkBalance *balance_out);
119
96
 
120
97
  /// 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);
98
+ bark_BarkError *bark_get_onchain_address(char **address_out);
131
99
 
132
100
  /// 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,
101
+ bark_BarkError *bark_send_onchain(const char *destination,
146
102
  uint64_t amount_sat,
147
103
  bool no_sync,
148
104
  char **txid_out);
149
105
 
150
106
  /// 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);
107
+ bark_BarkError *bark_drain_onchain(const char *destination, bool no_sync, char **txid_out);
165
108
 
166
109
  /// 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,
110
+ bark_BarkError *bark_send_many_onchain(const char *const *destinations,
181
111
  const uint64_t *amounts_sat,
182
112
  uintptr_t num_outputs,
183
113
  bool no_sync,
184
114
  char **txid_out);
185
115
 
186
116
  /// 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);
117
+ bark_BarkError *bark_get_onchain_utxos(bool no_sync, char **utxos_json_out);
199
118
 
200
119
  /// 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);
120
+ bark_BarkError *bark_get_vtxo_pubkey(const uint32_t *index, char **pubkey_hex_out);
211
121
 
212
122
  /// 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);
123
+ bark_BarkError *bark_get_vtxos(bool no_sync, char **vtxos_json_out);
225
124
 
226
125
  /// 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,
126
+ bark_BarkError *bark_refresh_vtxos(bark_BarkRefreshOpts refresh_opts,
239
127
  bool no_sync,
240
128
  char **status_json_out);
241
129
 
242
130
  /// 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);
131
+ bark_BarkError *bark_board_amount(uint64_t amount_sat, bool no_sync, char **status_json_out);
257
132
 
258
133
  /// 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,
134
+ bark_BarkError *bark_board_all(bool no_sync, char **status_json_out);
135
+
136
+ bark_BarkError *bark_send(const char *destination,
275
137
  uint64_t amount_sat,
276
138
  const char *comment,
277
139
  bool no_sync,
278
140
  char **status_json_out);
279
141
 
280
142
  /// 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,
143
+ bark_BarkError *bark_send_round_onchain(const char *destination,
294
144
  uint64_t amount_sat,
295
145
  bool no_sync,
296
146
  char **status_json_out);
297
147
 
298
148
  /// 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,
149
+ bark_BarkError *bark_offboard_specific(const char *const *specific_vtxo_ids,
313
150
  uintptr_t num_specific_vtxo_ids,
314
151
  const char *optional_address,
315
152
  bool no_sync,
316
153
  char **status_json_out);
317
154
 
318
155
  /// 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,
156
+ bark_BarkError *bark_offboard_all(const char *optional_address,
331
157
  bool no_sync,
332
158
  char **status_json_out);
333
159
 
334
160
  /// 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,
161
+ bark_BarkError *bark_exit_start_specific(const char *const *specific_vtxo_ids,
347
162
  uintptr_t num_specific_vtxo_ids,
348
163
  char **status_json_out);
349
164
 
350
165
  /// 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);
166
+ bark_BarkError *bark_exit_start_all(char **status_json_out);
361
167
 
362
168
  /// 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);
169
+ bark_BarkError *bark_exit_progress_once(char **status_json_out);
170
+
171
+ /// FFI: Creates a BOLT11 invoice for receiving payments.
172
+ bark_BarkError *bark_bolt11_invoice(uint64_t amount_msat, char **invoice_out);
173
+
174
+ /// FFI: Claims a BOLT11 payment using an invoice.
175
+ bark_BarkError *bark_claim_bolt11_payment(const char *bolt11);
373
176
 
374
177
  } // extern "C"
375
178