react-native-zcash 0.6.13 → 0.6.14

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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.6.14 (2024-04-12)
6
+
7
+ - fixed: Include missing Rust header file.
8
+
5
9
  ## 0.6.13 (2024-04-12)
6
10
 
7
11
  - fixed: Update the packaging scripts to clean leftover files.
@@ -0,0 +1,1157 @@
1
+ #include <stdarg.h>
2
+ #include <stdbool.h>
3
+ #include <stdint.h>
4
+ #include <stdlib.h>
5
+
6
+ /**
7
+ * A struct that contains an account identifier along with a pointer to the binary encoding
8
+ * of an associated key.
9
+ *
10
+ * # Safety
11
+ *
12
+ * - `encoding` must be non-null and must point to an array of `encoding_len` bytes.
13
+ */
14
+ typedef struct FFIBinaryKey {
15
+ uint32_t account_id;
16
+ uint8_t *encoding;
17
+ uintptr_t encoding_len;
18
+ } FFIBinaryKey;
19
+
20
+ /**
21
+ * A struct that contains an account identifier along with a pointer to the string encoding
22
+ * of an associated key.
23
+ *
24
+ * # Safety
25
+ *
26
+ * - `encoding` must be non-null and must point to a null-terminated UTF-8 string.
27
+ */
28
+ typedef struct FFIEncodedKey {
29
+ uint32_t account_id;
30
+ char *encoding;
31
+ } FFIEncodedKey;
32
+
33
+ /**
34
+ * A struct that contains a pointer to, and length information for, a heap-allocated
35
+ * slice of [`FFIEncodedKey`] values.
36
+ *
37
+ * # Safety
38
+ *
39
+ * - `ptr` must be non-null and must be valid for reads for `len * mem::size_of::<FFIEncodedKey>()`
40
+ * many bytes, and it must be properly aligned. This means in particular:
41
+ * - The entire memory range pointed to by `ptr` must be contained within a single allocated
42
+ * object. Slices can never span across multiple allocated objects.
43
+ * - `ptr` must be non-null and aligned even for zero-length slices.
44
+ * - `ptr` must point to `len` consecutive properly initialized values of type
45
+ * [`FFIEncodedKey`].
46
+ * - The total size `len * mem::size_of::<FFIEncodedKey>()` of the slice pointed to
47
+ * by `ptr` must be no larger than isize::MAX. See the safety documentation of pointer::offset.
48
+ * - See the safety documentation of [`FFIEncodedKey`]
49
+ */
50
+ typedef struct FFIEncodedKeys {
51
+ struct FFIEncodedKey *ptr;
52
+ uintptr_t len;
53
+ } FFIEncodedKeys;
54
+
55
+ /**
56
+ * A struct that contains a subtree root.
57
+ *
58
+ * # Safety
59
+ *
60
+ * - `root_hash_ptr` must be non-null and must be valid for reads for `root_hash_ptr_len`
61
+ * bytes, and it must have an alignment of `1`.
62
+ * - The total size `root_hash_ptr_len` of the slice pointed to by `root_hash_ptr` must
63
+ * be no larger than `isize::MAX`. See the safety documentation of `pointer::offset`.
64
+ */
65
+ typedef struct FfiSubtreeRoot {
66
+ uint8_t *root_hash_ptr;
67
+ uintptr_t root_hash_ptr_len;
68
+ uint32_t completing_block_height;
69
+ } FfiSubtreeRoot;
70
+
71
+ /**
72
+ * A struct that contains a pointer to, and length information for, a heap-allocated
73
+ * slice of [`FfiSubtreeRoot`] values.
74
+ *
75
+ * # Safety
76
+ *
77
+ * - `ptr` must be non-null and must be valid for reads for `len * mem::size_of::<FfiSubtreeRoot>()`
78
+ * many bytes, and it must be properly aligned. This means in particular:
79
+ * - The entire memory range pointed to by `ptr` must be contained within a single
80
+ * allocated object. Slices can never span across multiple allocated objects.
81
+ * - `ptr` must be non-null and aligned even for zero-length slices.
82
+ * - `ptr` must point to `len` consecutive properly initialized values of type
83
+ * [`FfiSubtreeRoot`].
84
+ * - The total size `len * mem::size_of::<FfiSubtreeRoot>()` of the slice pointed to
85
+ * by `ptr` must be no larger than isize::MAX. See the safety documentation of
86
+ * `pointer::offset`.
87
+ * - See the safety documentation of [`FfiSubtreeRoot`]
88
+ */
89
+ typedef struct FfiSubtreeRoots {
90
+ struct FfiSubtreeRoot *ptr;
91
+ uintptr_t len;
92
+ } FfiSubtreeRoots;
93
+
94
+ /**
95
+ * A struct that contains details about scan progress.
96
+ *
97
+ * When `denominator` is zero, the numerator encodes a non-progress indicator:
98
+ * - 0: progress is unknown.
99
+ * - 1: an error occurred.
100
+ */
101
+ typedef struct FfiScanProgress {
102
+ uint64_t numerator;
103
+ uint64_t denominator;
104
+ } FfiScanProgress;
105
+
106
+ /**
107
+ * A struct that contains the start (inclusive) and end (exclusive) of a range of blocks
108
+ * to scan.
109
+ */
110
+ typedef struct FfiScanRange {
111
+ int32_t start;
112
+ int32_t end;
113
+ uint8_t priority;
114
+ } FfiScanRange;
115
+
116
+ /**
117
+ * A struct that contains a pointer to, and length information for, a heap-allocated
118
+ * slice of [`FfiScanRange`] values.
119
+ *
120
+ * # Safety
121
+ *
122
+ * - `ptr` must be non-null and must be valid for reads for `len * mem::size_of::<FfiScanRange>()`
123
+ * many bytes, and it must be properly aligned. This means in particular:
124
+ * - The entire memory range pointed to by `ptr` must be contained within a single
125
+ * allocated object. Slices can never span across multiple allocated objects.
126
+ * - `ptr` must be non-null and aligned even for zero-length slices.
127
+ * - `ptr` must point to `len` consecutive properly initialized values of type
128
+ * [`FfiScanRange`].
129
+ * - The total size `len * mem::size_of::<FfiScanRange>()` of the slice pointed to
130
+ * by `ptr` must be no larger than isize::MAX. See the safety documentation of
131
+ * `pointer::offset`.
132
+ */
133
+ typedef struct FfiScanRanges {
134
+ struct FfiScanRange *ptr;
135
+ uintptr_t len;
136
+ } FfiScanRanges;
137
+
138
+ typedef struct FFIBlockMeta {
139
+ uint32_t height;
140
+ uint8_t *block_hash_ptr;
141
+ uintptr_t block_hash_ptr_len;
142
+ uint32_t block_time;
143
+ uint32_t sapling_outputs_count;
144
+ uint32_t orchard_actions_count;
145
+ } FFIBlockMeta;
146
+
147
+ typedef struct FFIBlocksMeta {
148
+ struct FFIBlockMeta *ptr;
149
+ uintptr_t len;
150
+ } FFIBlocksMeta;
151
+
152
+ /**
153
+ * Initializes global Rust state, such as the logging infrastructure and threadpools.
154
+ *
155
+ * When `show_trace_logs` is `true`, Rust events at the `TRACE` level will be logged.
156
+ *
157
+ * # Panics
158
+ *
159
+ * This method panics if called more than once.
160
+ */
161
+ void zcashlc_init_on_load(bool show_trace_logs);
162
+
163
+ /**
164
+ * Returns the length of the last error message to be logged.
165
+ */
166
+ int32_t zcashlc_last_error_length(void);
167
+
168
+ /**
169
+ * Copies the last error message into the provided allocated buffer.
170
+ *
171
+ * # Safety
172
+ *
173
+ * - `buf` must be non-null and valid for reads for `length` bytes, and it must have an alignment
174
+ * of `1`.
175
+ * - The memory referenced by `buf` must not be mutated for the duration of the function call.
176
+ * - The total size `length` must be no larger than `isize::MAX`. See the safety documentation of
177
+ * pointer::offset.
178
+ */
179
+ int32_t zcashlc_error_message_utf8(char *buf, int32_t length);
180
+
181
+ /**
182
+ * Clears the record of the last error message.
183
+ */
184
+ void zcashlc_clear_last_error(void);
185
+
186
+ /**
187
+ * Sets up the internal structure of the data database. The value for `seed` may be provided as a
188
+ * null pointer if the caller wishes to attempt migrations without providing the wallet's seed
189
+ * value.
190
+ *
191
+ * Returns 0 if successful, 1 if the seed must be provided in order to execute the requested
192
+ * migrations, or -1 otherwise.
193
+ *
194
+ * # Safety
195
+ *
196
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
197
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
198
+ * operating system's preferred representation.
199
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
200
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
201
+ * documentation of pointer::offset.
202
+ * - `seed` must be non-null and valid for reads for `seed_len` bytes, and it must have an
203
+ * alignment of `1`.
204
+ * - The memory referenced by `seed` must not be mutated for the duration of the function call.
205
+ * - The total size `seed_len` must be no larger than `isize::MAX`. See the safety documentation
206
+ * of pointer::offset.
207
+ */
208
+ int32_t zcashlc_init_data_database(const uint8_t *db_data,
209
+ uintptr_t db_data_len,
210
+ const uint8_t *seed,
211
+ uintptr_t seed_len,
212
+ uint32_t network_id);
213
+
214
+ /**
215
+ * Frees a FFIBinaryKey value
216
+ *
217
+ * # Safety
218
+ *
219
+ * - `ptr` must be non-null and must point to a struct having the layout of [`FFIBinaryKey`].
220
+ * See the safety documentation of [`FFIBinaryKey`].
221
+ */
222
+ void zcashlc_free_binary_key(struct FFIBinaryKey *ptr);
223
+
224
+ /**
225
+ * Adds the next available account-level spend authority, given the current set of [ZIP 316]
226
+ * account identifiers known, to the wallet database.
227
+ *
228
+ * Returns the newly created [ZIP 316] account identifier, along with the binary encoding of the
229
+ * [`UnifiedSpendingKey`] for the newly created account. The caller should manage the memory of
230
+ * (and store) the returned spending keys in a secure fashion.
231
+ *
232
+ * If `seed` was imported from a backup and this method is being used to restore a
233
+ * previous wallet state, you should use this method to add all of the desired
234
+ * accounts before scanning the chain from the seed's birthday height.
235
+ *
236
+ * By convention, wallets should only allow a new account to be generated after funds
237
+ * have been received by the currently available account (in order to enable
238
+ * automated account recovery).
239
+ *
240
+ * # Safety
241
+ *
242
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
243
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
244
+ * operating system's preferred representation.
245
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
246
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
247
+ * documentation of pointer::offset.
248
+ * - `seed` must be non-null and valid for reads for `seed_len` bytes, and it must have an
249
+ * alignment of `1`.
250
+ * - The memory referenced by `seed` must not be mutated for the duration of the function call.
251
+ * - The total size `seed_len` must be no larger than `isize::MAX`. See the safety documentation
252
+ * of pointer::offset.
253
+ * - Call [`zcashlc_free_binary_key`] to free the memory associated with the returned pointer when
254
+ * you are finished using it.
255
+ *
256
+ * [ZIP 316]: https://zips.z.cash/zip-0316
257
+ */
258
+ struct FFIBinaryKey *zcashlc_create_account(const uint8_t *db_data,
259
+ uintptr_t db_data_len,
260
+ const uint8_t *seed,
261
+ uintptr_t seed_len,
262
+ const uint8_t *treestate,
263
+ uintptr_t treestate_len,
264
+ int64_t recover_until,
265
+ uint32_t network_id);
266
+
267
+ /**
268
+ * Frees an array of FFIEncodedKeys values as allocated by `zcashlc_derive_unified_viewing_keys_from_seed`
269
+ *
270
+ * # Safety
271
+ *
272
+ * - `ptr` must be non-null and must point to a struct having the layout of [`FFIEncodedKeys`].
273
+ * See the safety documentation of [`FFIEncodedKeys`].
274
+ */
275
+ void zcashlc_free_keys(struct FFIEncodedKeys *ptr);
276
+
277
+ /**
278
+ * Derives and returns a unified spending key from the given seed for the given account ID.
279
+ *
280
+ * Returns the binary encoding of the spending key. The caller should manage the memory of (and
281
+ * store, if necessary) the returned spending key in a secure fashion.
282
+ *
283
+ * # Safety
284
+ *
285
+ * - `seed` must be non-null and valid for reads for `seed_len` bytes, and it must have an
286
+ * alignment of `1`.
287
+ * - The memory referenced by `seed` must not be mutated for the duration of the function call.
288
+ * - The total size `seed_len` must be no larger than `isize::MAX`. See the safety documentation
289
+ * of pointer::offset.
290
+ * - Call `zcashlc_free_binary_key` to free the memory associated with the returned pointer when
291
+ * you are finished using it.
292
+ */
293
+ struct FFIBinaryKey *zcashlc_derive_spending_key(const uint8_t *seed,
294
+ uintptr_t seed_len,
295
+ int32_t account,
296
+ uint32_t network_id);
297
+
298
+ /**
299
+ * Obtains the unified full viewing key for the given binary-encoded unified spending key
300
+ * and returns the resulting encoded UFVK string. `usk_ptr` should point to an array of `usk_len`
301
+ * bytes containing a unified spending key encoded as returned from the `zcashlc_create_account`
302
+ * or `zcashlc_derive_spending_key` functions.
303
+ *
304
+ * # Safety
305
+ *
306
+ * - `usk_ptr` must be non-null and must point to an array of `usk_len` bytes.
307
+ * - The memory referenced by `usk_ptr` must not be mutated for the duration of the function call.
308
+ * - The total size `usk_len` must be no larger than `isize::MAX`. See the safety documentation
309
+ * of pointer::offset.
310
+ * - Call [`zcashlc_string_free`] to free the memory associated with the returned pointer
311
+ * when you are done using it.
312
+ */
313
+ char *zcashlc_spending_key_to_full_viewing_key(const uint8_t *usk_ptr,
314
+ uintptr_t usk_len,
315
+ uint32_t network_id);
316
+
317
+ /**
318
+ * Returns the most-recently-generated unified payment address for the specified account.
319
+ *
320
+ * # Safety
321
+ *
322
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
323
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
324
+ * operating system's preferred representation.
325
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
326
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
327
+ * documentation of pointer::offset.
328
+ * - Call [`zcashlc_string_free`] to free the memory associated with the returned pointer
329
+ * when done using it.
330
+ */
331
+ char *zcashlc_get_current_address(const uint8_t *db_data,
332
+ uintptr_t db_data_len,
333
+ int32_t account,
334
+ uint32_t network_id);
335
+
336
+ /**
337
+ * Returns a newly-generated unified payment address for the specified account, with the next
338
+ * available diversifier.
339
+ *
340
+ * # Safety
341
+ *
342
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
343
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
344
+ * operating system's preferred representation.
345
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
346
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
347
+ * documentation of pointer::offset.
348
+ * - Call [`zcashlc_string_free`] to free the memory associated with the returned pointer
349
+ * when done using it.
350
+ */
351
+ char *zcashlc_get_next_available_address(const uint8_t *db_data,
352
+ uintptr_t db_data_len,
353
+ int32_t account,
354
+ uint32_t network_id);
355
+
356
+ /**
357
+ * Returns a list of the transparent receivers for the diversified unified addresses that have
358
+ * been allocated for the provided account.
359
+ *
360
+ * # Safety
361
+ *
362
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
363
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
364
+ * operating system's preferred representation.
365
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
366
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
367
+ * documentation of pointer::offset.
368
+ * - Call [`zcashlc_free_keys`] to free the memory associated with the returned pointer
369
+ * when done using it.
370
+ */
371
+ struct FFIEncodedKeys *zcashlc_list_transparent_receivers(const uint8_t *db_data,
372
+ uintptr_t db_data_len,
373
+ int32_t account_id,
374
+ uint32_t network_id);
375
+
376
+ /**
377
+ * Extracts the typecodes of the receivers within the given Unified Address.
378
+ *
379
+ * Returns a pointer to a slice of typecodes. `len_ret` is set to the length of the
380
+ * slice.
381
+ *
382
+ * See the following sections of ZIP 316 for details on how to interpret typecodes:
383
+ * - [List of known typecodes](https://zips.z.cash/zip-0316#encoding-of-unified-addresses)
384
+ * - [Adding new types](https://zips.z.cash/zip-0316#adding-new-types)
385
+ * - [Metadata Items](https://zips.z.cash/zip-0316#metadata-items)
386
+ *
387
+ * # Safety
388
+ *
389
+ * - `ua` must be non-null and must point to a null-terminated UTF-8 string containing an
390
+ * encoded Unified Address.
391
+ * - Call [`zcashlc_free_typecodes`] to free the memory associated with the returned
392
+ * pointer when done using it.
393
+ */
394
+ uint32_t *zcashlc_get_typecodes_for_unified_address_receivers(const char *ua, uintptr_t *len_ret);
395
+
396
+ /**
397
+ * Frees a list of typecodes previously obtained from the FFI.
398
+ *
399
+ * # Safety
400
+ *
401
+ * - `data` and `len` must have been obtained from
402
+ * [`zcashlc_get_typecodes_for_unified_address_receivers`].
403
+ */
404
+ void zcashlc_free_typecodes(uint32_t *data, uintptr_t len);
405
+
406
+ /**
407
+ * Returns the transparent receiver within the given Unified Address, if any.
408
+ *
409
+ * # Safety
410
+ *
411
+ * - `ua` must be non-null and must point to a null-terminated UTF-8 string.
412
+ * - Call [`zcashlc_string_free`] to free the memory associated with the returned pointer
413
+ * when done using it.
414
+ */
415
+ char *zcashlc_get_transparent_receiver_for_unified_address(const char *ua);
416
+
417
+ /**
418
+ * Returns the Sapling receiver within the given Unified Address, if any.
419
+ *
420
+ * # Safety
421
+ *
422
+ * - `ua` must be non-null and must point to a null-terminated UTF-8 string.
423
+ * - Call [`zcashlc_string_free`] to free the memory associated with the returned pointer
424
+ * when done using it.
425
+ */
426
+ char *zcashlc_get_sapling_receiver_for_unified_address(const char *ua);
427
+
428
+ /**
429
+ * Returns true when the provided address decodes to a valid Sapling payment address for the
430
+ * specified network, false in any other case.
431
+ *
432
+ * # Safety
433
+ *
434
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
435
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
436
+ */
437
+ bool zcashlc_is_valid_shielded_address(const char *address, uint32_t network_id);
438
+
439
+ /**
440
+ * Returns the network type and address kind for the given address string,
441
+ * if the address is a valid Zcash address.
442
+ *
443
+ * Address kind codes are as follows:
444
+ * * p2pkh: 0
445
+ * * p2sh: 1
446
+ * * sapling: 2
447
+ * * unified: 3
448
+ *
449
+ * # Safety
450
+ *
451
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
452
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
453
+ */
454
+ bool zcashlc_get_address_metadata(const char *address,
455
+ uint32_t *network_id_ret,
456
+ uint32_t *addr_kind_ret);
457
+
458
+ /**
459
+ * Returns true when the address is a valid transparent payment address for the specified network,
460
+ * false in any other case.
461
+ *
462
+ * # Safety
463
+ *
464
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
465
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
466
+ */
467
+ bool zcashlc_is_valid_transparent_address(const char *address, uint32_t network_id);
468
+
469
+ /**
470
+ * Returns true when the provided key decodes to a valid Sapling extended spending key for the
471
+ * specified network, false in any other case.
472
+ *
473
+ * # Safety
474
+ *
475
+ * - `extsk` must be non-null and must point to a null-terminated UTF-8 string.
476
+ * - The memory referenced by `extsk` must not be mutated for the duration of the function call.
477
+ */
478
+ bool zcashlc_is_valid_sapling_extended_spending_key(const char *extsk, uint32_t network_id);
479
+
480
+ /**
481
+ * Returns true when the provided key decodes to a valid Sapling extended full viewing key for the
482
+ * specified network, false in any other case.
483
+ *
484
+ * # Safety
485
+ *
486
+ * - `key` must be non-null and must point to a null-terminated UTF-8 string.
487
+ * - The memory referenced by `key` must not be mutated for the duration of the function call.
488
+ */
489
+ bool zcashlc_is_valid_viewing_key(const char *key, uint32_t network_id);
490
+
491
+ /**
492
+ * Returns true when the provided key decodes to a valid unified full viewing key for the
493
+ * specified network, false in any other case.
494
+ *
495
+ * # Safety
496
+ *
497
+ * - `ufvk` must be non-null and must point to a null-terminated UTF-8 string.
498
+ * - The memory referenced by `ufvk` must not be mutated for the duration of the
499
+ * function call.
500
+ */
501
+ bool zcashlc_is_valid_unified_full_viewing_key(const char *ufvk, uint32_t network_id);
502
+
503
+ /**
504
+ * Returns true when the provided key decodes to a valid unified address for the
505
+ * specified network, false in any other case.
506
+ *
507
+ * # Safety
508
+ *
509
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
510
+ * - The memory referenced by `address` must not be mutated for the duration of the
511
+ * function call.
512
+ */
513
+ bool zcashlc_is_valid_unified_address(const char *address, uint32_t network_id);
514
+
515
+ /**
516
+ * Returns the balance for the specified account, including all unspent notes that we know about.
517
+ *
518
+ * # Safety
519
+ *
520
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
521
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
522
+ * operating system's preferred representation.
523
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
524
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
525
+ * documentation of pointer::offset.
526
+ */
527
+ int64_t zcashlc_get_balance(const uint8_t *db_data,
528
+ uintptr_t db_data_len,
529
+ int32_t account,
530
+ uint32_t network_id);
531
+
532
+ /**
533
+ * Returns the verified balance for the account, which ignores notes that have been
534
+ * received too recently and are not yet deemed spendable according to `min_confirmations`.
535
+ *
536
+ * # Safety
537
+ *
538
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
539
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
540
+ * operating system's preferred representation.
541
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
542
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
543
+ * documentation of pointer::offset.
544
+ */
545
+ int64_t zcashlc_get_verified_balance(const uint8_t *db_data,
546
+ uintptr_t db_data_len,
547
+ int32_t account,
548
+ uint32_t network_id,
549
+ uint32_t min_confirmations);
550
+
551
+ /**
552
+ * Returns the verified transparent balance for `address`, which ignores utxos that have been
553
+ * received too recently and are not yet deemed spendable according to `min_confirmations`.
554
+ *
555
+ * # Safety
556
+ *
557
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
558
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
559
+ * operating system's preferred representation.
560
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
561
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
562
+ * documentation of pointer::offset.
563
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
564
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
565
+ */
566
+ int64_t zcashlc_get_verified_transparent_balance(const uint8_t *db_data,
567
+ uintptr_t db_data_len,
568
+ const char *address,
569
+ uint32_t network_id,
570
+ uint32_t min_confirmations);
571
+
572
+ /**
573
+ * Returns the verified transparent balance for `account`, which ignores utxos that have been
574
+ * received too recently and are not yet deemed spendable according to `min_confirmations`.
575
+ *
576
+ * # Safety
577
+ *
578
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
579
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
580
+ * operating system's preferred representation.
581
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
582
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
583
+ * documentation of pointer::offset.
584
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
585
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
586
+ */
587
+ int64_t zcashlc_get_verified_transparent_balance_for_account(const uint8_t *db_data,
588
+ uintptr_t db_data_len,
589
+ uint32_t network_id,
590
+ int32_t account,
591
+ uint32_t min_confirmations);
592
+
593
+ /**
594
+ * Returns the balance for `address`, including all UTXOs that we know about.
595
+ *
596
+ * # Safety
597
+ *
598
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
599
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
600
+ * operating system's preferred representation.
601
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
602
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
603
+ * documentation of pointer::offset.
604
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
605
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
606
+ */
607
+ int64_t zcashlc_get_total_transparent_balance(const uint8_t *db_data,
608
+ uintptr_t db_data_len,
609
+ const char *address,
610
+ uint32_t network_id);
611
+
612
+ /**
613
+ * Returns the balance for `account`, including all UTXOs that we know about.
614
+ *
615
+ * # Safety
616
+ *
617
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
618
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
619
+ * operating system's preferred representation.
620
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
621
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
622
+ * documentation of pointer::offset.
623
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
624
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
625
+ */
626
+ int64_t zcashlc_get_total_transparent_balance_for_account(const uint8_t *db_data,
627
+ uintptr_t db_data_len,
628
+ uint32_t network_id,
629
+ int32_t account);
630
+
631
+ /**
632
+ * Returns the memo for a note by copying the corresponding bytes to the received
633
+ * pointer in `memo_bytes_ret`.
634
+ *
635
+ * # Safety
636
+ *
637
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
638
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
639
+ * operating system's preferred representation.
640
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
641
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
642
+ * documentation of pointer::offset.
643
+ * - `txid_bytes` must be non-null and valid for reads for 32 bytes, and it must have an alignment
644
+ * of `1`.
645
+ * - `memo_bytes_ret` must be non-null and must point to an allocated 512-byte region of memory.
646
+ */
647
+ bool zcashlc_get_memo(const uint8_t *db_data,
648
+ uintptr_t db_data_len,
649
+ const uint8_t *txid_bytes,
650
+ uint16_t output_index,
651
+ uint8_t *memo_bytes_ret,
652
+ uint32_t network_id);
653
+
654
+ /**
655
+ * Returns the memo for a note, if it is known and a valid UTF-8 string.
656
+ *
657
+ * # Safety
658
+ *
659
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
660
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
661
+ * operating system's preferred representation.
662
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
663
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
664
+ * documentation of pointer::offset.
665
+ * - `txid_bytes` must be non-null and valid for reads for 32 bytes, and it must have an alignment
666
+ * of `1`.
667
+ * - Call [`zcashlc_string_free`] to free the memory associated with the returned pointer
668
+ * when done using it.
669
+ */
670
+ char *zcashlc_get_memo_as_utf8(const uint8_t *db_data,
671
+ uintptr_t db_data_len,
672
+ const uint8_t *txid_bytes,
673
+ uint16_t output_index,
674
+ uint32_t network_id);
675
+
676
+ /**
677
+ * Returns a ZIP-32 signature of the given seed bytes.
678
+ *
679
+ * # Safety
680
+ * - `seed` must be non-null and valid for reads for `seed_len` bytes, and it must have an
681
+ * alignment of `1`.
682
+ * - The memory referenced by `seed` must not be mutated for the duration of the function call.
683
+ * - The total size `seed_len` must be at least 32 no larger than `252`. See the safety documentation
684
+ * of pointer::offset.
685
+ */
686
+ bool zcashlc_seed_fingerprint(const uint8_t *seed,
687
+ uintptr_t seed_len,
688
+ uint8_t *signature_bytes_ret);
689
+
690
+ /**
691
+ * Returns the most recent block height to which it is possible to reset the state
692
+ * of the data database.
693
+ *
694
+ * # Safety
695
+ *
696
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
697
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
698
+ * operating system's preferred representation.
699
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
700
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
701
+ * documentation of pointer::offset.
702
+ */
703
+ int32_t zcashlc_get_nearest_rewind_height(const uint8_t *db_data,
704
+ uintptr_t db_data_len,
705
+ int32_t height,
706
+ uint32_t network_id);
707
+
708
+ /**
709
+ * Rewinds the data database to the given height.
710
+ *
711
+ * If the requested height is greater than or equal to the height of the last scanned
712
+ * block, this function does nothing.
713
+ *
714
+ * # Safety
715
+ *
716
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
717
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
718
+ * operating system's preferred representation.
719
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
720
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
721
+ * documentation of pointer::offset.
722
+ */
723
+ bool zcashlc_rewind_to_height(const uint8_t *db_data,
724
+ uintptr_t db_data_len,
725
+ int32_t height,
726
+ uint32_t network_id);
727
+
728
+ /**
729
+ * Adds a sequence of Sapling subtree roots to the data store.
730
+ *
731
+ * Returns true if the subtrees could be stored, false otherwise. When false is returned,
732
+ * caller should check for errors.
733
+ *
734
+ * # Safety
735
+ *
736
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
737
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
738
+ * operating system's preferred representation.
739
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
740
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
741
+ * documentation of `pointer::offset`.
742
+ * - `roots` must be non-null and initialized.
743
+ * - The memory referenced by `roots` must not be mutated for the duration of the function call.
744
+ */
745
+ bool zcashlc_put_sapling_subtree_roots(const uint8_t *db_data,
746
+ uintptr_t db_data_len,
747
+ uint64_t start_index,
748
+ const struct FfiSubtreeRoots *roots,
749
+ uint32_t network_id);
750
+
751
+ /**
752
+ * Updates the wallet's view of the blockchain.
753
+ *
754
+ * This method is used to provide the wallet with information about the state of the blockchain,
755
+ * and detect any previously scanned data that needs to be re-validated before proceeding with
756
+ * scanning. It should be called at wallet startup prior to calling `zcashlc_suggest_scan_ranges`
757
+ * in order to provide the wallet with the information it needs to correctly prioritize scanning
758
+ * operations.
759
+ *
760
+ * # Safety
761
+ *
762
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
763
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
764
+ * operating system's preferred representation.
765
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
766
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
767
+ * documentation of `pointer::offset`.
768
+ */
769
+ bool zcashlc_update_chain_tip(const uint8_t *db_data,
770
+ uintptr_t db_data_len,
771
+ int32_t height,
772
+ uint32_t network_id);
773
+
774
+ /**
775
+ * Returns the height to which the wallet has been fully scanned.
776
+ *
777
+ * This is the height for which the wallet has fully trial-decrypted this and all
778
+ * preceding blocks above the wallet's birthday height.
779
+ *
780
+ * Returns a non-negative block height, -1 if empty, or -2 if an error occurred.
781
+ *
782
+ * # Safety
783
+ *
784
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
785
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
786
+ * operating system's preferred representation.
787
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
788
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
789
+ * documentation of `pointer::offset`.
790
+ */
791
+ int64_t zcashlc_fully_scanned_height(const uint8_t *db_data,
792
+ uintptr_t db_data_len,
793
+ uint32_t network_id);
794
+
795
+ /**
796
+ * Returns the maximum height that the wallet has scanned.
797
+ *
798
+ * If the wallet is fully synced, this will be equivalent to `zcashlc_block_fully_scanned`;
799
+ * otherwise the maximal scanned height is likely to be greater than the fully scanned
800
+ * height due to the fact that out-of-order scanning can leave gaps.
801
+ *
802
+ * Returns a non-negative block height, -1 if empty, or -2 if an error occurred.
803
+ *
804
+ * # Safety
805
+ *
806
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
807
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
808
+ * operating system's preferred representation.
809
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
810
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
811
+ * documentation of `pointer::offset`.
812
+ */
813
+ int64_t zcashlc_max_scanned_height(const uint8_t *db_data,
814
+ uintptr_t db_data_len,
815
+ uint32_t network_id);
816
+
817
+ /**
818
+ * Returns the scan progress derived from the current wallet state.
819
+ *
820
+ * # Safety
821
+ *
822
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must
823
+ * have an alignment of `1`. Its contents must be a string representing a valid system
824
+ * path in the operating system's preferred representation.
825
+ * - The memory referenced by `db_data` must not be mutated for the duration of the
826
+ * function call.
827
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
828
+ * documentation of pointer::offset.
829
+ */
830
+ struct FfiScanProgress zcashlc_get_scan_progress(const uint8_t *db_data,
831
+ uintptr_t db_data_len,
832
+ uint32_t network_id);
833
+
834
+ /**
835
+ * Frees an array of FfiScanRanges values as allocated by `zcashlc_derive_unified_viewing_keys_from_seed`
836
+ *
837
+ * # Safety
838
+ *
839
+ * - `ptr` must be non-null and must point to a struct having the layout of [`FfiScanRanges`].
840
+ * See the safety documentation of [`FfiScanRanges`].
841
+ */
842
+ void zcashlc_free_scan_ranges(struct FfiScanRanges *ptr);
843
+
844
+ /**
845
+ * Returns a list of suggested scan ranges based upon the current wallet state.
846
+ *
847
+ * This method should only be used in cases where the `CompactBlock` data that will be
848
+ * made available to `zcashlc_scan_blocks` for the requested block ranges includes note
849
+ * commitment tree size information for each block; or else the scan is likely to fail if
850
+ * notes belonging to the wallet are detected.
851
+ *
852
+ * # Safety
853
+ *
854
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must
855
+ * have an alignment of `1`. Its contents must be a string representing a valid system
856
+ * path in the operating system's preferred representation.
857
+ * - The memory referenced by `db_data` must not be mutated for the duration of the
858
+ * function call.
859
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
860
+ * documentation of pointer::offset.
861
+ * - Call [`zcashlc_free_scan_ranges`] to free the memory associated with the returned
862
+ * pointer when done using it.
863
+ */
864
+ struct FfiScanRanges *zcashlc_suggest_scan_ranges(const uint8_t *db_data,
865
+ uintptr_t db_data_len,
866
+ uint32_t network_id);
867
+
868
+ /**
869
+ * Scans new blocks added to the cache for any transactions received by the tracked
870
+ * accounts, while checking that they form a valid chan.
871
+ *
872
+ * This function is built on the core assumption that the information provided in the
873
+ * block cache is more likely to be accurate than the previously-scanned information.
874
+ * This follows from the design (and trust) assumption that the `lightwalletd` server
875
+ * provides accurate block information as of the time it was requested.
876
+ *
877
+ * This function **assumes** that the caller is handling rollbacks.
878
+ *
879
+ * For brand-new light client databases, this function starts scanning from the Sapling
880
+ * activation height. This height can be fast-forwarded to a more recent block by calling
881
+ * [`zcashlc_init_blocks_table`] before this function.
882
+ *
883
+ * Scanned blocks are required to be height-sequential. If a block is missing from the
884
+ * cache, an error will be signalled.
885
+ *
886
+ * # Safety
887
+ *
888
+ * - `fs_block_db_root` must be non-null and valid for reads for `fs_block_db_root_len` bytes, and it must have an
889
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
890
+ * operating system's preferred representation.
891
+ * - The memory referenced by `fs_block_db_root` must not be mutated for the duration of the function call.
892
+ * - The total size `fs_block_db_root_len` must be no larger than `isize::MAX`. See the safety
893
+ * documentation of pointer::offset.
894
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
895
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
896
+ * operating system's preferred representation.
897
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
898
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
899
+ * documentation of pointer::offset.
900
+ */
901
+ int32_t zcashlc_scan_blocks(const uint8_t *fs_block_cache_root,
902
+ uintptr_t fs_block_cache_root_len,
903
+ const uint8_t *db_data,
904
+ uintptr_t db_data_len,
905
+ int32_t from_height,
906
+ uint32_t scan_limit,
907
+ uint32_t network_id);
908
+
909
+ /**
910
+ * Inserts a UTXO into the wallet database.
911
+ *
912
+ * # Safety
913
+ *
914
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
915
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
916
+ * operating system's preferred representation.
917
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
918
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
919
+ * documentation of pointer::offset.
920
+ * - `txid_bytes` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
921
+ * alignment of `1`.
922
+ * - The memory referenced by `txid_bytes_len` must not be mutated for the duration of the function call.
923
+ * - The total size `txid_bytes_len` must be no larger than `isize::MAX`. See the safety
924
+ * documentation of pointer::offset.
925
+ * - `script_bytes` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
926
+ * alignment of `1`.
927
+ * - The memory referenced by `script_bytes_len` must not be mutated for the duration of the function call.
928
+ * - The total size `script_bytes_len` must be no larger than `isize::MAX`. See the safety
929
+ * documentation of pointer::offset.
930
+ */
931
+ bool zcashlc_put_utxo(const uint8_t *db_data,
932
+ uintptr_t db_data_len,
933
+ const uint8_t *txid_bytes,
934
+ uintptr_t txid_bytes_len,
935
+ int32_t index,
936
+ const uint8_t *script_bytes,
937
+ uintptr_t script_bytes_len,
938
+ int64_t value,
939
+ int32_t height,
940
+ uint32_t network_id);
941
+
942
+ /**
943
+ * # Safety
944
+ * Initializes the `FsBlockDb` sqlite database. Does nothing if already created
945
+ *
946
+ * Returns true when successful, false otherwise. When false is returned caller
947
+ * should check for errors.
948
+ * - `fs_block_db_root` must be non-null and valid for reads for `fs_block_db_root_len` bytes, and it must have an
949
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
950
+ * operating system's preferred representation.
951
+ * - The memory referenced by `fs_block_db_root` must not be mutated for the duration of the function call.
952
+ * - The total size `fs_block_db_root_len` must be no larger than `isize::MAX`. See the safety
953
+ * documentation of pointer::offset.
954
+ */
955
+ bool zcashlc_init_block_metadata_db(const uint8_t *fs_block_db_root,
956
+ uintptr_t fs_block_db_root_len);
957
+
958
+ /**
959
+ * Writes the blocks provided in `blocks_meta` into the `BlockMeta` database
960
+ *
961
+ * Returns true if the `blocks_meta` could be stored into the `FsBlockDb`. False
962
+ * otherwise.
963
+ *
964
+ * When false is returned caller should check for errors.
965
+ *
966
+ * # Safety
967
+ *
968
+ * - `fs_block_db_root` must be non-null and valid for reads for `fs_block_db_root_len` bytes, and it must have an
969
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
970
+ * operating system's preferred representation.
971
+ * - The memory referenced by `fs_block_db_root` must not be mutated for the duration of the function call.
972
+ * - The total size `fs_block_db_root_len` must be no larger than `isize::MAX`. See the safety
973
+ * documentation of pointer::offset.
974
+ * - Block metadata represented in `blocks_meta` must be non-null. Caller must guarantee that the
975
+ * memory reference by this pointer is not freed up, dereferenced or invalidated while this function
976
+ * is invoked.
977
+ */
978
+ bool zcashlc_write_block_metadata(const uint8_t *fs_block_db_root,
979
+ uintptr_t fs_block_db_root_len,
980
+ struct FFIBlocksMeta *blocks_meta);
981
+
982
+ /**
983
+ * Rewinds the data database to the given height.
984
+ *
985
+ * If the requested height is greater than or equal to the height of the last scanned
986
+ * block, this function does nothing.
987
+ *
988
+ * # Safety
989
+ *
990
+ * - `fs_block_db_root` must be non-null and valid for reads for `fs_block_db_root_len` bytes, and it must have an
991
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
992
+ * operating system's preferred representation.
993
+ * - The memory referenced by `fs_block_db_root` must not be mutated for the duration of the function call.
994
+ * - The total size `fs_block_db_root_len` must be no larger than `isize::MAX`. See the safety
995
+ * documentation of pointer::offset.
996
+ */
997
+ bool zcashlc_rewind_fs_block_cache_to_height(const uint8_t *fs_block_db_root,
998
+ uintptr_t fs_block_db_root_len,
999
+ int32_t height);
1000
+
1001
+ /**
1002
+ * Get the latest cached block height in the filesystem block cache
1003
+ *
1004
+ * Returns a non-negative block height, -1 if empty, or -2 if an error occurred.
1005
+ *
1006
+ * # Safety
1007
+ *
1008
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1009
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1010
+ * operating system's preferred representation.
1011
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
1012
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1013
+ * documentation of pointer::offset.
1014
+ * - `tx` must be non-null and valid for reads for `tx_len` bytes, and it must have an
1015
+ * alignment of `1`.
1016
+ * - The memory referenced by `tx` must not be mutated for the duration of the function call.
1017
+ * - The total size `tx_len` must be no larger than `isize::MAX`. See the safety
1018
+ * documentation of pointer::offset.
1019
+ */
1020
+ int32_t zcashlc_latest_cached_block_height(const uint8_t *fs_block_db_root,
1021
+ uintptr_t fs_block_db_root_len);
1022
+
1023
+ /**
1024
+ * Decrypts whatever parts of the specified transaction it can and stores them in db_data.
1025
+ *
1026
+ * # Safety
1027
+ *
1028
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1029
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1030
+ * operating system's preferred representation.
1031
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
1032
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1033
+ * documentation of pointer::offset.
1034
+ * - `tx` must be non-null and valid for reads for `tx_len` bytes, and it must have an
1035
+ * alignment of `1`.
1036
+ * - The memory referenced by `tx` must not be mutated for the duration of the function call.
1037
+ * - The total size `tx_len` must be no larger than `isize::MAX`. See the safety
1038
+ * documentation of pointer::offset.
1039
+ */
1040
+ int32_t zcashlc_decrypt_and_store_transaction(const uint8_t *db_data,
1041
+ uintptr_t db_data_len,
1042
+ const uint8_t *tx,
1043
+ uintptr_t tx_len,
1044
+ uint32_t _mined_height,
1045
+ uint32_t network_id);
1046
+
1047
+ /**
1048
+ * Creates a transaction paying the specified address from the given account.
1049
+ *
1050
+ * Returns the row index of the newly-created transaction in the `transactions` table
1051
+ * within the data database. The caller can read the raw transaction bytes from the `raw`
1052
+ * column in order to broadcast the transaction to the network.
1053
+ *
1054
+ * Do not call this multiple times in parallel, or you will generate transactions that
1055
+ * double-spend the same notes.
1056
+ *
1057
+ * # Safety
1058
+ *
1059
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1060
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1061
+ * operating system's preferred representation.
1062
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
1063
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1064
+ * documentation of pointer::offset.
1065
+ * - `usk_ptr` must be non-null and must point to an array of `usk_len` bytes containing a unified
1066
+ * spending key encoded as returned from the `zcashlc_create_account` or
1067
+ * `zcashlc_derive_spending_key` functions.
1068
+ * - The memory referenced by `usk_ptr` must not be mutated for the duration of the function call.
1069
+ * - The total size `usk_len` must be no larger than `isize::MAX`. See the safety documentation
1070
+ * of pointer::offset.
1071
+ * - `to` must be non-null and must point to a null-terminated UTF-8 string.
1072
+ * - `memo` must either be null (indicating an empty memo or a transparent recipient) or point to a
1073
+ * 512-byte array.
1074
+ * - `spend_params` must be non-null and valid for reads for `spend_params_len` bytes, and it must have an
1075
+ * alignment of `1`. Its contents must be the Sapling spend proving parameters.
1076
+ * - The memory referenced by `spend_params` must not be mutated for the duration of the function call.
1077
+ * - The total size `spend_params_len` must be no larger than `isize::MAX`. See the safety
1078
+ * documentation of pointer::offset.
1079
+ * - `output_params` must be non-null and valid for reads for `output_params_len` bytes, and it must have an
1080
+ * alignment of `1`. Its contents must be the Sapling output proving parameters.
1081
+ * - The memory referenced by `output_params` must not be mutated for the duration of the function call.
1082
+ * - The total size `output_params_len` must be no larger than `isize::MAX`. See the safety
1083
+ * documentation of pointer::offset.
1084
+ * - `txid_bytes_ret` must be non-null and must point to an allocated 32-byte region of memory.
1085
+ */
1086
+ bool zcashlc_create_to_address(const uint8_t *db_data,
1087
+ uintptr_t db_data_len,
1088
+ const uint8_t *usk_ptr,
1089
+ uintptr_t usk_len,
1090
+ const char *to,
1091
+ int64_t value,
1092
+ const uint8_t *memo,
1093
+ const uint8_t *spend_params,
1094
+ uintptr_t spend_params_len,
1095
+ const uint8_t *output_params,
1096
+ uintptr_t output_params_len,
1097
+ uint32_t network_id,
1098
+ uint32_t min_confirmations,
1099
+ bool use_zip317_fees,
1100
+ uint8_t *txid_bytes_ret);
1101
+
1102
+ int32_t zcashlc_branch_id_for_height(int32_t height, uint32_t network_id);
1103
+
1104
+ /**
1105
+ * Frees strings returned by other zcashlc functions.
1106
+ *
1107
+ * # Safety
1108
+ *
1109
+ * - `s` should be a non-null pointer returned as a string by another zcashlc function.
1110
+ */
1111
+ void zcashlc_string_free(char *s);
1112
+
1113
+ /**
1114
+ * Shield transparent UTXOs by sending them to an address associated with the specified Sapling
1115
+ * spending key.
1116
+ *
1117
+ * # Safety
1118
+ *
1119
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1120
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1121
+ * operating system's preferred representation.
1122
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
1123
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1124
+ * documentation of pointer::offset.
1125
+ * - `usk_ptr` must be non-null and must point to an array of `usk_len` bytes containing a unified
1126
+ * spending key encoded as returned from the `zcashlc_create_account` or
1127
+ * `zcashlc_derive_spending_key` functions.
1128
+ * - The memory referenced by `usk_ptr` must not be mutated for the duration of the function call.
1129
+ * - The total size `usk_len` must be no larger than `isize::MAX`. See the safety documentation
1130
+ * - `memo` must either be null (indicating an empty memo) or point to a 512-byte array.
1131
+ * - `shielding_threshold` a non-negative shielding threshold amount in zatoshi
1132
+ * - `spend_params` must be non-null and valid for reads for `spend_params_len` bytes, and it must have an
1133
+ * alignment of `1`. Its contents must be the Sapling spend proving parameters.
1134
+ * - The memory referenced by `spend_params` must not be mutated for the duration of the function call.
1135
+ * - The total size `spend_params_len` must be no larger than `isize::MAX`. See the safety
1136
+ * documentation of pointer::offset.
1137
+ * - `output_params` must be non-null and valid for reads for `output_params_len` bytes, and it must have an
1138
+ * alignment of `1`. Its contents must be the Sapling output proving parameters.
1139
+ * - The memory referenced by `output_params` must not be mutated for the duration of the function call.
1140
+ * - The total size `output_params_len` must be no larger than `isize::MAX`. See the safety
1141
+ * documentation of pointer::offset.
1142
+ * - `txid_bytes_ret` must be non-null and must point to an allocated 32-byte region of memory.
1143
+ */
1144
+ bool zcashlc_shield_funds(const uint8_t *db_data,
1145
+ uintptr_t db_data_len,
1146
+ const uint8_t *usk_ptr,
1147
+ uintptr_t usk_len,
1148
+ const uint8_t *memo,
1149
+ uint64_t shielding_threshold,
1150
+ const uint8_t *spend_params,
1151
+ uintptr_t spend_params_len,
1152
+ const uint8_t *output_params,
1153
+ uintptr_t output_params_len,
1154
+ uint32_t network_id,
1155
+ uint32_t min_confirmations,
1156
+ bool use_zip317_fees,
1157
+ uint8_t *txid_bytes_ret);
@@ -8,32 +8,32 @@
8
8
  <key>BinaryPath</key>
9
9
  <string>libzcashlc.a</string>
10
10
  <key>LibraryIdentifier</key>
11
- <string>ios-arm64_x86_64-simulator</string>
11
+ <string>ios-arm64</string>
12
12
  <key>LibraryPath</key>
13
13
  <string>libzcashlc.a</string>
14
14
  <key>SupportedArchitectures</key>
15
15
  <array>
16
16
  <string>arm64</string>
17
- <string>x86_64</string>
18
17
  </array>
19
18
  <key>SupportedPlatform</key>
20
19
  <string>ios</string>
21
- <key>SupportedPlatformVariant</key>
22
- <string>simulator</string>
23
20
  </dict>
24
21
  <dict>
25
22
  <key>BinaryPath</key>
26
23
  <string>libzcashlc.a</string>
27
24
  <key>LibraryIdentifier</key>
28
- <string>ios-arm64</string>
25
+ <string>ios-arm64_x86_64-simulator</string>
29
26
  <key>LibraryPath</key>
30
27
  <string>libzcashlc.a</string>
31
28
  <key>SupportedArchitectures</key>
32
29
  <array>
33
30
  <string>arm64</string>
31
+ <string>x86_64</string>
34
32
  </array>
35
33
  <key>SupportedPlatform</key>
36
34
  <string>ios</string>
35
+ <key>SupportedPlatformVariant</key>
36
+ <string>simulator</string>
37
37
  </dict>
38
38
  </array>
39
39
  <key>CFBundlePackageType</key>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-zcash",
3
- "version": "0.6.13",
3
+ "version": "0.6.14",
4
4
  "description": "Zcash library for React Native",
5
5
  "homepage": "https://github.com/EdgeApp/react-native-zcash",
6
6
  "repository": {