react-native-zcash 0.6.13 → 0.7.0

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.
Files changed (162) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/android/build.gradle +4 -4
  3. package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/2470000.json +8 -0
  4. package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/2480000.json +8 -0
  5. package/android/src/main/java/app/edge/rnzcash/RNZcashModule.kt +51 -9
  6. package/ios/RNZcash.m +8 -0
  7. package/ios/RNZcash.swift +66 -16
  8. package/ios/ZCashLightClientKit/Block/Actions/DownloadAction.swift +1 -1
  9. package/ios/ZCashLightClientKit/Block/Actions/EnhanceAction.swift +3 -1
  10. package/ios/ZCashLightClientKit/Block/Actions/FetchUTXOsAction.swift +1 -1
  11. package/ios/ZCashLightClientKit/Block/Actions/ProcessSuggestedScanRangesAction.swift +11 -2
  12. package/ios/ZCashLightClientKit/Block/Actions/RewindAction.swift +2 -2
  13. package/ios/ZCashLightClientKit/Block/Actions/ScanAction.swift +28 -11
  14. package/ios/ZCashLightClientKit/Block/Actions/UpdateChainTipAction.swift +4 -4
  15. package/ios/ZCashLightClientKit/Block/Actions/UpdateSubtreeRootsAction.swift +36 -7
  16. package/ios/ZCashLightClientKit/Block/Actions/ValidateServerAction.swift +1 -1
  17. package/ios/ZCashLightClientKit/Block/CompactBlockProcessor.swift +93 -51
  18. package/ios/ZCashLightClientKit/Block/Download/BlockDownloader.swift +0 -26
  19. package/ios/ZCashLightClientKit/Block/Enhance/BlockEnhancer.swift +5 -6
  20. package/ios/ZCashLightClientKit/Block/FetchUnspentTxOutputs/UTXOFetcher.swift +1 -11
  21. package/ios/ZCashLightClientKit/Block/SaplingParameters/SaplingParametersHandler.swift +6 -4
  22. package/ios/ZCashLightClientKit/Block/Scan/BlockScanner.swift +10 -12
  23. package/ios/ZCashLightClientKit/Checkpoint/BundleCheckpointSource.swift +38 -0
  24. package/ios/ZCashLightClientKit/Checkpoint/BundleCheckpointURLProvider.swift +40 -0
  25. package/ios/ZCashLightClientKit/{Constants/Checkpoint+Constants.swift → Checkpoint/Checkpoint+helpers.swift} +1 -33
  26. package/ios/ZCashLightClientKit/Checkpoint/CheckpointSource.swift +34 -0
  27. package/ios/ZCashLightClientKit/Checkpoint/CheckpointSourceFactory.swift +14 -0
  28. package/ios/ZCashLightClientKit/ClosureSynchronizer.swift +61 -6
  29. package/ios/ZCashLightClientKit/CombineSynchronizer.swift +63 -4
  30. package/ios/ZCashLightClientKit/Constants/ZcashSDK.swift +4 -0
  31. package/ios/ZCashLightClientKit/DAO/TransactionDao.swift +21 -33
  32. package/ios/ZCashLightClientKit/DAO/UnspentTransactionOutputDao.swift +0 -182
  33. package/ios/ZCashLightClientKit/Entity/AccountEntity.swift +0 -173
  34. package/ios/ZCashLightClientKit/Entity/TransactionEntity.swift +5 -2
  35. package/ios/ZCashLightClientKit/Error/Sourcery/generateErrorCode.sh +1 -1
  36. package/ios/ZCashLightClientKit/Error/ZcashError.swift +53 -1
  37. package/ios/ZCashLightClientKit/Error/ZcashErrorCode.swift +19 -1
  38. package/ios/ZCashLightClientKit/Error/ZcashErrorCodeDefinition.swift +32 -0
  39. package/ios/ZCashLightClientKit/Initializer.swift +8 -17
  40. package/ios/ZCashLightClientKit/Metrics/SDKMetrics.swift +103 -217
  41. package/ios/ZCashLightClientKit/Model/Proposal.swift +45 -0
  42. package/ios/ZCashLightClientKit/Model/ScanSummary.swift +14 -0
  43. package/ios/ZCashLightClientKit/Model/WalletSummary.swift +58 -0
  44. package/ios/ZCashLightClientKit/Model/WalletTypes.swift +0 -16
  45. package/ios/ZCashLightClientKit/Modules/Service/GRPC/LightWalletGRPCService.swift +5 -3
  46. package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/proposal.pb.swift +934 -0
  47. package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/proto/proposal.proto +138 -0
  48. package/ios/ZCashLightClientKit/Modules/Service/LightWalletService.swift +2 -4
  49. package/ios/ZCashLightClientKit/Providers/LatestBlocksDataProvider.swift +9 -1
  50. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2272500.json +8 -0
  51. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2275000.json +8 -0
  52. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2277500.json +8 -0
  53. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2282500.json +8 -0
  54. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2285000.json +8 -0
  55. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2287500.json +8 -0
  56. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2292500.json +8 -0
  57. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2295000.json +8 -0
  58. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2297500.json +8 -0
  59. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2302500.json +8 -0
  60. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2305000.json +8 -0
  61. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2307500.json +8 -0
  62. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2312500.json +8 -0
  63. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2315000.json +8 -0
  64. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2317500.json +8 -0
  65. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2322500.json +8 -0
  66. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2325000.json +8 -0
  67. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2327500.json +8 -0
  68. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2332500.json +8 -0
  69. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2335000.json +8 -0
  70. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2337500.json +8 -0
  71. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2342500.json +8 -0
  72. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2345000.json +8 -0
  73. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2347500.json +8 -0
  74. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2352500.json +8 -0
  75. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2355000.json +8 -0
  76. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2357500.json +8 -0
  77. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2362500.json +8 -0
  78. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2365000.json +8 -0
  79. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2367500.json +8 -0
  80. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2372500.json +8 -0
  81. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2375000.json +8 -0
  82. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2377500.json +8 -0
  83. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2382500.json +8 -0
  84. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2385000.json +8 -0
  85. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2387500.json +8 -0
  86. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2392500.json +8 -0
  87. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2395000.json +8 -0
  88. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2397500.json +8 -0
  89. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2402500.json +8 -0
  90. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2405000.json +8 -0
  91. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2407500.json +8 -0
  92. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2412500.json +8 -0
  93. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2415000.json +8 -0
  94. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2417500.json +8 -0
  95. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2422500.json +8 -0
  96. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2425000.json +8 -0
  97. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2427500.json +8 -0
  98. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2432500.json +8 -0
  99. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2435000.json +8 -0
  100. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2437500.json +8 -0
  101. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2442500.json +8 -0
  102. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2445000.json +8 -0
  103. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2447500.json +8 -0
  104. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2452500.json +8 -0
  105. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2455000.json +8 -0
  106. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2457500.json +8 -0
  107. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2462500.json +8 -0
  108. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2465000.json +8 -0
  109. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2467500.json +8 -0
  110. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2470000.json +8 -0
  111. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2472500.json +8 -0
  112. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2480000.json +8 -0
  113. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2560000.json +8 -0
  114. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2570000.json +8 -0
  115. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2580000.json +8 -0
  116. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2590000.json +8 -0
  117. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2600000.json +8 -0
  118. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2610000.json +8 -0
  119. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2620000.json +8 -0
  120. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2630000.json +8 -0
  121. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2640000.json +8 -0
  122. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2650000.json +8 -0
  123. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2660000.json +8 -0
  124. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2670000.json +8 -0
  125. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2680000.json +8 -0
  126. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2690000.json +8 -0
  127. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2700000.json +8 -0
  128. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2710000.json +8 -0
  129. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2720000.json +8 -0
  130. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2730000.json +8 -0
  131. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2740000.json +8 -0
  132. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2750000.json +8 -0
  133. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2760000.json +8 -0
  134. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2770000.json +8 -0
  135. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2780000.json +8 -0
  136. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2790000.json +8 -0
  137. package/ios/ZCashLightClientKit/Rust/ZcashKeyDerivationBackend.swift +1 -5
  138. package/ios/ZCashLightClientKit/Rust/ZcashRustBackend.swift +327 -153
  139. package/ios/ZCashLightClientKit/Rust/ZcashRustBackendWelding.swift +78 -36
  140. package/ios/ZCashLightClientKit/Rust/zcashlc.h +1441 -0
  141. package/ios/ZCashLightClientKit/Synchronizer/ClosureSDKSynchronizer.swift +43 -14
  142. package/ios/ZCashLightClientKit/Synchronizer/CombineSDKSynchronizer.swift +52 -14
  143. package/ios/ZCashLightClientKit/Synchronizer/Dependencies.swift +10 -6
  144. package/ios/ZCashLightClientKit/Synchronizer/SDKSynchronizer.swift +220 -70
  145. package/ios/ZCashLightClientKit/Synchronizer.swift +105 -29
  146. package/ios/ZCashLightClientKit/Transaction/TransactionEncoder.swift +61 -32
  147. package/ios/ZCashLightClientKit/Transaction/WalletTransactionEncoder.swift +52 -61
  148. package/ios/ZCashLightClientKit/Utils/DBActor.swift +21 -0
  149. package/ios/ZCashLightClientKit/Utils/LoggingProxy.swift +5 -0
  150. package/ios/ZCashLightClientKit/Utils/OSLogger.swift +71 -14
  151. package/ios/libzcashlc.xcframework/ios-arm64/libzcashlc.a +0 -0
  152. package/ios/libzcashlc.xcframework/ios-arm64_x86_64-simulator/libzcashlc.a +0 -0
  153. package/lib/rnzcash.rn.js +21 -6
  154. package/lib/rnzcash.rn.js.map +1 -1
  155. package/lib/src/react-native.d.ts +2 -1
  156. package/lib/src/types.d.ts +9 -1
  157. package/package.json +1 -1
  158. package/src/react-native.ts +23 -4
  159. package/src/types.ts +10 -1
  160. package/ios/ZCashLightClientKit/Model/ScanProgress.swift +0 -29
  161. package/ios/ZCashLightClientKit/Repository/UnspentTransactionOutputRepository.swift +0 -16
  162. /package/ios/ZCashLightClientKit/{Model → Checkpoint}/Checkpoint.swift +0 -0
@@ -0,0 +1,1441 @@
1
+ #include <stdarg.h>
2
+ #include <stdbool.h>
3
+ #include <stdint.h>
4
+ #include <stdlib.h>
5
+
6
+ /**
7
+ * A struct that contains details about an account in the wallet.
8
+ */
9
+ typedef struct FfiAccount {
10
+ uint8_t seed_fingerprint[32];
11
+ uint32_t account_index;
12
+ } FfiAccount;
13
+
14
+ /**
15
+ * A struct that contains a pointer to, and length information for, a heap-allocated
16
+ * slice of [`FfiAccount`] values.
17
+ *
18
+ * # Safety
19
+ *
20
+ * - `ptr` must be non-null and must be valid for reads for `len * mem::size_of::<FfiAccount>()`
21
+ * many bytes, and it must be properly aligned. This means in particular:
22
+ * - The entire memory range pointed to by `ptr` must be contained within a single allocated
23
+ * object. Slices can never span across multiple allocated objects.
24
+ * - `ptr` must be non-null and aligned even for zero-length slices.
25
+ * - `ptr` must point to `len` consecutive properly initialized values of type
26
+ * [`FfiAccount`].
27
+ * - The total size `len * mem::size_of::<FfiAccount>()` of the slice pointed to
28
+ * by `ptr` must be no larger than isize::MAX. See the safety documentation of pointer::offset.
29
+ * - See the safety documentation of [`FfiAccount`]
30
+ */
31
+ typedef struct FfiAccounts {
32
+ struct FfiAccount *ptr;
33
+ uintptr_t len;
34
+ } FfiAccounts;
35
+
36
+ /**
37
+ * A struct that contains an account identifier along with a pointer to the binary encoding
38
+ * of an associated key.
39
+ *
40
+ * # Safety
41
+ *
42
+ * - `encoding` must be non-null and must point to an array of `encoding_len` bytes.
43
+ */
44
+ typedef struct FFIBinaryKey {
45
+ uint32_t account_id;
46
+ uint8_t *encoding;
47
+ uintptr_t encoding_len;
48
+ } FFIBinaryKey;
49
+
50
+ /**
51
+ * A struct that contains an account identifier along with a pointer to the string encoding
52
+ * of an associated key.
53
+ *
54
+ * # Safety
55
+ *
56
+ * - `encoding` must be non-null and must point to a null-terminated UTF-8 string.
57
+ */
58
+ typedef struct FFIEncodedKey {
59
+ uint32_t account_id;
60
+ char *encoding;
61
+ } FFIEncodedKey;
62
+
63
+ /**
64
+ * A struct that contains a pointer to, and length information for, a heap-allocated
65
+ * slice of [`FFIEncodedKey`] values.
66
+ *
67
+ * # Safety
68
+ *
69
+ * - `ptr` must be non-null and must be valid for reads for `len * mem::size_of::<FFIEncodedKey>()`
70
+ * many bytes, and it must be properly aligned. This means in particular:
71
+ * - The entire memory range pointed to by `ptr` must be contained within a single allocated
72
+ * object. Slices can never span across multiple allocated objects.
73
+ * - `ptr` must be non-null and aligned even for zero-length slices.
74
+ * - `ptr` must point to `len` consecutive properly initialized values of type
75
+ * [`FFIEncodedKey`].
76
+ * - The total size `len * mem::size_of::<FFIEncodedKey>()` of the slice pointed to
77
+ * by `ptr` must be no larger than isize::MAX. See the safety documentation of pointer::offset.
78
+ * - See the safety documentation of [`FFIEncodedKey`]
79
+ */
80
+ typedef struct FFIEncodedKeys {
81
+ struct FFIEncodedKey *ptr;
82
+ uintptr_t len;
83
+ } FFIEncodedKeys;
84
+
85
+ /**
86
+ * A struct that contains a subtree root.
87
+ *
88
+ * # Safety
89
+ *
90
+ * - `root_hash_ptr` must be non-null and must be valid for reads for `root_hash_ptr_len`
91
+ * bytes, and it must have an alignment of `1`.
92
+ * - The total size `root_hash_ptr_len` of the slice pointed to by `root_hash_ptr` must
93
+ * be no larger than `isize::MAX`. See the safety documentation of `pointer::offset`.
94
+ */
95
+ typedef struct FfiSubtreeRoot {
96
+ uint8_t *root_hash_ptr;
97
+ uintptr_t root_hash_ptr_len;
98
+ uint32_t completing_block_height;
99
+ } FfiSubtreeRoot;
100
+
101
+ /**
102
+ * A struct that contains a pointer to, and length information for, a heap-allocated
103
+ * slice of [`FfiSubtreeRoot`] values.
104
+ *
105
+ * # Safety
106
+ *
107
+ * - `ptr` must be non-null and must be valid for reads for `len * mem::size_of::<FfiSubtreeRoot>()`
108
+ * many bytes, and it must be properly aligned. This means in particular:
109
+ * - The entire memory range pointed to by `ptr` must be contained within a single
110
+ * allocated object. Slices can never span across multiple allocated objects.
111
+ * - `ptr` must be non-null and aligned even for zero-length slices.
112
+ * - `ptr` must point to `len` consecutive properly initialized values of type
113
+ * [`FfiSubtreeRoot`].
114
+ * - The total size `len * mem::size_of::<FfiSubtreeRoot>()` of the slice pointed to
115
+ * by `ptr` must be no larger than isize::MAX. See the safety documentation of
116
+ * `pointer::offset`.
117
+ * - See the safety documentation of [`FfiSubtreeRoot`]
118
+ */
119
+ typedef struct FfiSubtreeRoots {
120
+ struct FfiSubtreeRoot *ptr;
121
+ uintptr_t len;
122
+ } FfiSubtreeRoots;
123
+
124
+ /**
125
+ * Balance information for a value within a single pool in an account.
126
+ */
127
+ typedef struct FfiBalance {
128
+ /**
129
+ * The value in the account that may currently be spent; it is possible to compute witnesses
130
+ * for all the notes that comprise this value, and all of this value is confirmed to the
131
+ * required confirmation depth.
132
+ */
133
+ int64_t spendable_value;
134
+ /**
135
+ * The value in the account of shielded change notes that do not yet have sufficient
136
+ * confirmations to be spendable.
137
+ */
138
+ int64_t change_pending_confirmation;
139
+ /**
140
+ * The value in the account of all remaining received notes that either do not have sufficient
141
+ * confirmations to be spendable, or for which witnesses cannot yet be constructed without
142
+ * additional scanning.
143
+ */
144
+ int64_t value_pending_spendability;
145
+ } FfiBalance;
146
+
147
+ /**
148
+ * Balance information for a single account.
149
+ *
150
+ * The sum of this struct's fields is the total balance of the account.
151
+ */
152
+ typedef struct FfiAccountBalance {
153
+ uint32_t account_id;
154
+ /**
155
+ * The value of unspent Sapling outputs belonging to the account.
156
+ */
157
+ struct FfiBalance sapling_balance;
158
+ /**
159
+ * The value of unspent Orchard outputs belonging to the account.
160
+ */
161
+ struct FfiBalance orchard_balance;
162
+ /**
163
+ * The value of all unspent transparent outputs belonging to the account,
164
+ * irrespective of confirmation depth.
165
+ *
166
+ * Unshielded balances are not subject to confirmation-depth constraints, because the
167
+ * only possible operation on a transparent balance is to shield it, it is possible
168
+ * to create a zero-conf transaction to perform that shielding, and the resulting
169
+ * shielded notes will be subject to normal confirmation rules.
170
+ */
171
+ int64_t unshielded;
172
+ } FfiAccountBalance;
173
+
174
+ /**
175
+ * A struct that contains details about scan progress.
176
+ *
177
+ * When `denominator` is zero, the numerator encodes a non-progress indicator:
178
+ * - 0: progress is unknown.
179
+ * - 1: an error occurred.
180
+ */
181
+ typedef struct FfiScanProgress {
182
+ uint64_t numerator;
183
+ uint64_t denominator;
184
+ } FfiScanProgress;
185
+
186
+ /**
187
+ * A type representing the potentially-spendable value of unspent outputs in the wallet.
188
+ *
189
+ * The balances reported using this data structure may overestimate the total spendable
190
+ * value of the wallet, in the case that the spend of a previously received shielded note
191
+ * has not yet been detected by the process of scanning the chain. The balances reported
192
+ * using this data structure can only be certain to be unspent in the case that
193
+ * [`Self::is_synced`] is true, and even in this circumstance it is possible that a newly
194
+ * created transaction could conflict with a not-yet-mined transaction in the mempool.
195
+ *
196
+ * # Safety
197
+ *
198
+ * - `account_balances` must be non-null and must be valid for reads for
199
+ * `account_balances_len * mem::size_of::<FfiAccountBalance>()` many bytes, and it must
200
+ * be properly aligned. This means in particular:
201
+ * - The entire memory range pointed to by `account_balances` must be contained within
202
+ * a single allocated object. Slices can never span across multiple allocated objects.
203
+ * - `account_balances` must be non-null and aligned even for zero-length slices.
204
+ * - `account_balances` must point to `len` consecutive properly initialized values of
205
+ * type [`FfiAccountBalance`].
206
+ * - The total size `account_balances_len * mem::size_of::<FfiAccountBalance>()` of the
207
+ * slice pointed to by `account_balances` must be no larger than `isize::MAX`. See the
208
+ * safety documentation of `pointer::offset`.
209
+ * - `scan_progress` must, if non-null, point to a struct having the layout of
210
+ * [`FfiScanProgress`].
211
+ */
212
+ typedef struct FfiWalletSummary {
213
+ struct FfiAccountBalance *account_balances;
214
+ uintptr_t account_balances_len;
215
+ int32_t chain_tip_height;
216
+ int32_t fully_scanned_height;
217
+ struct FfiScanProgress *scan_progress;
218
+ uint64_t next_sapling_subtree_index;
219
+ uint64_t next_orchard_subtree_index;
220
+ } FfiWalletSummary;
221
+
222
+ /**
223
+ * A struct that contains the start (inclusive) and end (exclusive) of a range of blocks
224
+ * to scan.
225
+ */
226
+ typedef struct FfiScanRange {
227
+ int32_t start;
228
+ int32_t end;
229
+ uint8_t priority;
230
+ } FfiScanRange;
231
+
232
+ /**
233
+ * A struct that contains a pointer to, and length information for, a heap-allocated
234
+ * slice of [`FfiScanRange`] values.
235
+ *
236
+ * # Safety
237
+ *
238
+ * - `ptr` must be non-null and must be valid for reads for `len * mem::size_of::<FfiScanRange>()`
239
+ * many bytes, and it must be properly aligned. This means in particular:
240
+ * - The entire memory range pointed to by `ptr` must be contained within a single
241
+ * allocated object. Slices can never span across multiple allocated objects.
242
+ * - `ptr` must be non-null and aligned even for zero-length slices.
243
+ * - `ptr` must point to `len` consecutive properly initialized values of type
244
+ * [`FfiScanRange`].
245
+ * - The total size `len * mem::size_of::<FfiScanRange>()` of the slice pointed to
246
+ * by `ptr` must be no larger than isize::MAX. See the safety documentation of
247
+ * `pointer::offset`.
248
+ */
249
+ typedef struct FfiScanRanges {
250
+ struct FfiScanRange *ptr;
251
+ uintptr_t len;
252
+ } FfiScanRanges;
253
+
254
+ /**
255
+ * Metadata about modifications to the wallet state made in the course of scanning a set
256
+ * of blocks.
257
+ */
258
+ typedef struct FfiScanSummary {
259
+ int32_t scanned_start;
260
+ int32_t scanned_end;
261
+ uint64_t spent_sapling_note_count;
262
+ uint64_t received_sapling_note_count;
263
+ } FfiScanSummary;
264
+
265
+ typedef struct FFIBlockMeta {
266
+ uint32_t height;
267
+ uint8_t *block_hash_ptr;
268
+ uintptr_t block_hash_ptr_len;
269
+ uint32_t block_time;
270
+ uint32_t sapling_outputs_count;
271
+ uint32_t orchard_actions_count;
272
+ } FFIBlockMeta;
273
+
274
+ typedef struct FFIBlocksMeta {
275
+ struct FFIBlockMeta *ptr;
276
+ uintptr_t len;
277
+ } FFIBlocksMeta;
278
+
279
+ /**
280
+ * A struct that contains a pointer to, and length information for, a heap-allocated
281
+ * boxed slice.
282
+ *
283
+ * # Safety
284
+ *
285
+ * - `ptr` must be non-null and valid for reads for `len` bytes, and it must have an
286
+ * alignment of `1`. Its contents must be an encoded Proposal protobuf.
287
+ * - The memory referenced by `ptr` must not be mutated for the lifetime of the struct
288
+ * (up until [`zcashlc_free_boxed_slice`] is called with it).
289
+ * - The total size `len` must be no larger than `isize::MAX`. See the safety
290
+ * documentation of `pointer::offset`.
291
+ */
292
+ typedef struct FfiBoxedSlice {
293
+ uint8_t *ptr;
294
+ uintptr_t len;
295
+ } FfiBoxedSlice;
296
+
297
+ /**
298
+ * A struct that contains a pointer to, and length information for, a heap-allocated
299
+ * slice of `[u8; 32]` arrays.
300
+ *
301
+ * # Safety
302
+ *
303
+ * - `ptr` must be non-null and must be valid for reads for `len * mem::size_of::<[u8; 32]>()`
304
+ * many bytes, and it must be properly aligned. This means in particular:
305
+ * - The entire memory range pointed to by `ptr` must be contained within a single
306
+ * allocated object. Slices can never span across multiple allocated objects.
307
+ * - `ptr` must be non-null and aligned even for zero-length slices.
308
+ * - `ptr` must point to `len` consecutive properly initialized values of type
309
+ * `[u8; 32]`.
310
+ * - The total size `len * mem::size_of::<[u8; 32]>()` of the slice pointed to
311
+ * by `ptr` must be no larger than isize::MAX. See the safety documentation of
312
+ * `pointer::offset`.
313
+ */
314
+ typedef struct FfiTxIds {
315
+ uint8_t (*ptr)[32];
316
+ uintptr_t len;
317
+ } FfiTxIds;
318
+
319
+ /**
320
+ * Initializes global Rust state, such as the logging infrastructure and threadpools.
321
+ *
322
+ * When `show_trace_logs` is `true`, Rust events at the `TRACE` level will be logged.
323
+ *
324
+ * # Panics
325
+ *
326
+ * This method panics if called more than once.
327
+ */
328
+ void zcashlc_init_on_load(bool show_trace_logs);
329
+
330
+ /**
331
+ * Returns the length of the last error message to be logged.
332
+ */
333
+ int32_t zcashlc_last_error_length(void);
334
+
335
+ /**
336
+ * Copies the last error message into the provided allocated buffer.
337
+ *
338
+ * # Safety
339
+ *
340
+ * - `buf` must be non-null and valid for reads for `length` bytes, and it must have an alignment
341
+ * of `1`.
342
+ * - The memory referenced by `buf` must not be mutated for the duration of the function call.
343
+ * - The total size `length` must be no larger than `isize::MAX`. See the safety documentation of
344
+ * pointer::offset.
345
+ */
346
+ int32_t zcashlc_error_message_utf8(char *buf, int32_t length);
347
+
348
+ /**
349
+ * Clears the record of the last error message.
350
+ */
351
+ void zcashlc_clear_last_error(void);
352
+
353
+ /**
354
+ * Sets up the internal structure of the data database. The value for `seed` may be provided as a
355
+ * null pointer if the caller wishes to attempt migrations without providing the wallet's seed
356
+ * value.
357
+ *
358
+ * Returns:
359
+ * - 0 if successful.
360
+ * - 1 if the seed must be provided in order to execute the requested migrations
361
+ * - 2 if the provided seed is not relevant to any of the derived accounts in the wallet.
362
+ * - -1 on error.
363
+ *
364
+ * # Safety
365
+ *
366
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
367
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
368
+ * operating system's preferred representation.
369
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
370
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
371
+ * documentation of pointer::offset.
372
+ * - `seed` must be non-null and valid for reads for `seed_len` bytes, and it must have an
373
+ * alignment of `1`.
374
+ * - The memory referenced by `seed` must not be mutated for the duration of the function call.
375
+ * - The total size `seed_len` must be no larger than `isize::MAX`. See the safety documentation
376
+ * of pointer::offset.
377
+ */
378
+ int32_t zcashlc_init_data_database(const uint8_t *db_data,
379
+ uintptr_t db_data_len,
380
+ const uint8_t *seed,
381
+ uintptr_t seed_len,
382
+ uint32_t network_id);
383
+
384
+ /**
385
+ * Frees an array of FfiAccounts values as allocated by `zcashlc_list_accounts`.
386
+ *
387
+ * # Safety
388
+ *
389
+ * - `ptr` must be non-null and must point to a struct having the layout of [`FfiAccounts`].
390
+ * See the safety documentation of [`FfiAccounts`].
391
+ */
392
+ void zcashlc_free_accounts(struct FfiAccounts *ptr);
393
+
394
+ /**
395
+ * Returns a list of the accounts in the wallet.
396
+ *
397
+ * # Safety
398
+ *
399
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
400
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
401
+ * operating system's preferred representation.
402
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
403
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
404
+ * documentation of pointer::offset.
405
+ * - Call [`zcashlc_free_accounts`] to free the memory associated with the returned pointer
406
+ * when done using it.
407
+ */
408
+ struct FfiAccounts *zcashlc_list_accounts(const uint8_t *db_data,
409
+ uintptr_t db_data_len,
410
+ uint32_t network_id);
411
+
412
+ /**
413
+ * Frees a FFIBinaryKey value
414
+ *
415
+ * # Safety
416
+ *
417
+ * - `ptr` must be non-null and must point to a struct having the layout of [`FFIBinaryKey`].
418
+ * See the safety documentation of [`FFIBinaryKey`].
419
+ */
420
+ void zcashlc_free_binary_key(struct FFIBinaryKey *ptr);
421
+
422
+ /**
423
+ * Adds the next available account-level spend authority, given the current set of [ZIP 316]
424
+ * account identifiers known, to the wallet database.
425
+ *
426
+ * Returns the newly created [ZIP 316] account identifier, along with the binary encoding of the
427
+ * [`UnifiedSpendingKey`] for the newly created account. The caller should manage the memory of
428
+ * (and store) the returned spending keys in a secure fashion.
429
+ *
430
+ * If `seed` was imported from a backup and this method is being used to restore a
431
+ * previous wallet state, you should use this method to add all of the desired
432
+ * accounts before scanning the chain from the seed's birthday height.
433
+ *
434
+ * By convention, wallets should only allow a new account to be generated after funds
435
+ * have been received by the currently available account (in order to enable
436
+ * automated account recovery).
437
+ *
438
+ * # Safety
439
+ *
440
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
441
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
442
+ * operating system's preferred representation.
443
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
444
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
445
+ * documentation of pointer::offset.
446
+ * - `seed` must be non-null and valid for reads for `seed_len` bytes, and it must have an
447
+ * alignment of `1`.
448
+ * - The memory referenced by `seed` must not be mutated for the duration of the function call.
449
+ * - The total size `seed_len` must be no larger than `isize::MAX`. See the safety documentation
450
+ * of pointer::offset.
451
+ * - Call [`zcashlc_free_binary_key`] to free the memory associated with the returned pointer when
452
+ * you are finished using it.
453
+ *
454
+ * [ZIP 316]: https://zips.z.cash/zip-0316
455
+ */
456
+ struct FFIBinaryKey *zcashlc_create_account(const uint8_t *db_data,
457
+ uintptr_t db_data_len,
458
+ const uint8_t *seed,
459
+ uintptr_t seed_len,
460
+ const uint8_t *treestate,
461
+ uintptr_t treestate_len,
462
+ int64_t recover_until,
463
+ uint32_t network_id);
464
+
465
+ /**
466
+ * Checks whether the given seed is relevant to any of the accounts in the wallet.
467
+ *
468
+ * Returns:
469
+ * - `1` for `Ok(true)`.
470
+ * - `0` for `Ok(false)`.
471
+ * - `-1` for `Err(_)`.
472
+ */
473
+ int8_t zcashlc_is_seed_relevant_to_any_derived_account(const uint8_t *db_data,
474
+ uintptr_t db_data_len,
475
+ const uint8_t *seed,
476
+ uintptr_t seed_len,
477
+ uint32_t network_id);
478
+
479
+ /**
480
+ * Frees an array of FFIEncodedKeys values as allocated by `zcashlc_derive_unified_viewing_keys_from_seed`
481
+ *
482
+ * # Safety
483
+ *
484
+ * - `ptr` must be non-null and must point to a struct having the layout of [`FFIEncodedKeys`].
485
+ * See the safety documentation of [`FFIEncodedKeys`].
486
+ */
487
+ void zcashlc_free_keys(struct FFIEncodedKeys *ptr);
488
+
489
+ /**
490
+ * Derives and returns a unified spending key from the given seed for the given account ID.
491
+ *
492
+ * Returns the binary encoding of the spending key. The caller should manage the memory of (and
493
+ * store, if necessary) the returned spending key in a secure fashion.
494
+ *
495
+ * # Safety
496
+ *
497
+ * - `seed` must be non-null and valid for reads for `seed_len` bytes, and it must have an
498
+ * alignment of `1`.
499
+ * - The memory referenced by `seed` must not be mutated for the duration of the function call.
500
+ * - The total size `seed_len` must be no larger than `isize::MAX`. See the safety documentation
501
+ * of pointer::offset.
502
+ * - Call `zcashlc_free_binary_key` to free the memory associated with the returned pointer when
503
+ * you are finished using it.
504
+ */
505
+ struct FFIBinaryKey *zcashlc_derive_spending_key(const uint8_t *seed,
506
+ uintptr_t seed_len,
507
+ int32_t account,
508
+ uint32_t network_id);
509
+
510
+ /**
511
+ * Obtains the unified full viewing key for the given binary-encoded unified spending key
512
+ * and returns the resulting encoded UFVK string. `usk_ptr` should point to an array of `usk_len`
513
+ * bytes containing a unified spending key encoded as returned from the `zcashlc_create_account`
514
+ * or `zcashlc_derive_spending_key` functions.
515
+ *
516
+ * # Safety
517
+ *
518
+ * - `usk_ptr` must be non-null and must point to an array of `usk_len` bytes.
519
+ * - The memory referenced by `usk_ptr` must not be mutated for the duration of the function call.
520
+ * - The total size `usk_len` must be no larger than `isize::MAX`. See the safety documentation
521
+ * of pointer::offset.
522
+ * - Call [`zcashlc_string_free`] to free the memory associated with the returned pointer
523
+ * when you are done using it.
524
+ */
525
+ char *zcashlc_spending_key_to_full_viewing_key(const uint8_t *usk_ptr,
526
+ uintptr_t usk_len,
527
+ uint32_t network_id);
528
+
529
+ /**
530
+ * Returns the most-recently-generated unified payment address for the specified account.
531
+ *
532
+ * # Safety
533
+ *
534
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
535
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
536
+ * operating system's preferred representation.
537
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
538
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
539
+ * documentation of pointer::offset.
540
+ * - Call [`zcashlc_string_free`] to free the memory associated with the returned pointer
541
+ * when done using it.
542
+ */
543
+ char *zcashlc_get_current_address(const uint8_t *db_data,
544
+ uintptr_t db_data_len,
545
+ int32_t account,
546
+ uint32_t network_id);
547
+
548
+ /**
549
+ * Returns a newly-generated unified payment address for the specified account, with the next
550
+ * available diversifier.
551
+ *
552
+ * # Safety
553
+ *
554
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
555
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
556
+ * operating system's preferred representation.
557
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
558
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
559
+ * documentation of pointer::offset.
560
+ * - Call [`zcashlc_string_free`] to free the memory associated with the returned pointer
561
+ * when done using it.
562
+ */
563
+ char *zcashlc_get_next_available_address(const uint8_t *db_data,
564
+ uintptr_t db_data_len,
565
+ int32_t account,
566
+ uint32_t network_id);
567
+
568
+ /**
569
+ * Returns a list of the transparent receivers for the diversified unified addresses that have
570
+ * been allocated for the provided account.
571
+ *
572
+ * # Safety
573
+ *
574
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
575
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
576
+ * operating system's preferred representation.
577
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
578
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
579
+ * documentation of pointer::offset.
580
+ * - Call [`zcashlc_free_keys`] to free the memory associated with the returned pointer
581
+ * when done using it.
582
+ */
583
+ struct FFIEncodedKeys *zcashlc_list_transparent_receivers(const uint8_t *db_data,
584
+ uintptr_t db_data_len,
585
+ int32_t account_id,
586
+ uint32_t network_id);
587
+
588
+ /**
589
+ * Extracts the typecodes of the receivers within the given Unified Address.
590
+ *
591
+ * Returns a pointer to a slice of typecodes. `len_ret` is set to the length of the
592
+ * slice.
593
+ *
594
+ * See the following sections of ZIP 316 for details on how to interpret typecodes:
595
+ * - [List of known typecodes](https://zips.z.cash/zip-0316#encoding-of-unified-addresses)
596
+ * - [Adding new types](https://zips.z.cash/zip-0316#adding-new-types)
597
+ * - [Metadata Items](https://zips.z.cash/zip-0316#metadata-items)
598
+ *
599
+ * # Safety
600
+ *
601
+ * - `ua` must be non-null and must point to a null-terminated UTF-8 string containing an
602
+ * encoded Unified Address.
603
+ * - Call [`zcashlc_free_typecodes`] to free the memory associated with the returned
604
+ * pointer when done using it.
605
+ */
606
+ uint32_t *zcashlc_get_typecodes_for_unified_address_receivers(const char *ua, uintptr_t *len_ret);
607
+
608
+ /**
609
+ * Frees a list of typecodes previously obtained from the FFI.
610
+ *
611
+ * # Safety
612
+ *
613
+ * - `data` and `len` must have been obtained from
614
+ * [`zcashlc_get_typecodes_for_unified_address_receivers`].
615
+ */
616
+ void zcashlc_free_typecodes(uint32_t *data, uintptr_t len);
617
+
618
+ /**
619
+ * Returns the transparent receiver within the given Unified Address, if any.
620
+ *
621
+ * # Safety
622
+ *
623
+ * - `ua` must be non-null and must point to a null-terminated UTF-8 string.
624
+ * - Call [`zcashlc_string_free`] to free the memory associated with the returned pointer
625
+ * when done using it.
626
+ */
627
+ char *zcashlc_get_transparent_receiver_for_unified_address(const char *ua);
628
+
629
+ /**
630
+ * Returns the Sapling receiver within the given Unified Address, if any.
631
+ *
632
+ * # Safety
633
+ *
634
+ * - `ua` must be non-null and must point to a null-terminated UTF-8 string.
635
+ * - Call [`zcashlc_string_free`] to free the memory associated with the returned pointer
636
+ * when done using it.
637
+ */
638
+ char *zcashlc_get_sapling_receiver_for_unified_address(const char *ua);
639
+
640
+ /**
641
+ * Returns true when the provided address decodes to a valid Sapling payment address for the
642
+ * specified network, false in any other case.
643
+ *
644
+ * # Safety
645
+ *
646
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
647
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
648
+ */
649
+ bool zcashlc_is_valid_sapling_address(const char *address, uint32_t network_id);
650
+
651
+ /**
652
+ * Returns the network type and address kind for the given address string,
653
+ * if the address is a valid Zcash address.
654
+ *
655
+ * Address kind codes are as follows:
656
+ * * p2pkh: 0
657
+ * * p2sh: 1
658
+ * * sapling: 2
659
+ * * unified: 3
660
+ *
661
+ * # Safety
662
+ *
663
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
664
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
665
+ */
666
+ bool zcashlc_get_address_metadata(const char *address,
667
+ uint32_t *network_id_ret,
668
+ uint32_t *addr_kind_ret);
669
+
670
+ /**
671
+ * Returns true when the address is a valid transparent payment address for the specified network,
672
+ * false in any other case.
673
+ *
674
+ * # Safety
675
+ *
676
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
677
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
678
+ */
679
+ bool zcashlc_is_valid_transparent_address(const char *address, uint32_t network_id);
680
+
681
+ /**
682
+ * Returns true when the provided key decodes to a valid Sapling extended spending key for the
683
+ * specified network, false in any other case.
684
+ *
685
+ * # Safety
686
+ *
687
+ * - `extsk` must be non-null and must point to a null-terminated UTF-8 string.
688
+ * - The memory referenced by `extsk` must not be mutated for the duration of the function call.
689
+ */
690
+ bool zcashlc_is_valid_sapling_extended_spending_key(const char *extsk, uint32_t network_id);
691
+
692
+ /**
693
+ * Returns true when the provided key decodes to a valid Sapling extended full viewing key for the
694
+ * specified network, false in any other case.
695
+ *
696
+ * # Safety
697
+ *
698
+ * - `key` must be non-null and must point to a null-terminated UTF-8 string.
699
+ * - The memory referenced by `key` must not be mutated for the duration of the function call.
700
+ */
701
+ bool zcashlc_is_valid_viewing_key(const char *key, uint32_t network_id);
702
+
703
+ /**
704
+ * Returns true when the provided key decodes to a valid unified full viewing key for the
705
+ * specified network, false in any other case.
706
+ *
707
+ * # Safety
708
+ *
709
+ * - `ufvk` must be non-null and must point to a null-terminated UTF-8 string.
710
+ * - The memory referenced by `ufvk` must not be mutated for the duration of the
711
+ * function call.
712
+ */
713
+ bool zcashlc_is_valid_unified_full_viewing_key(const char *ufvk, uint32_t network_id);
714
+
715
+ /**
716
+ * Returns true when the provided key decodes to a valid unified address for the
717
+ * specified network, false in any other case.
718
+ *
719
+ * # Safety
720
+ *
721
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
722
+ * - The memory referenced by `address` must not be mutated for the duration of the
723
+ * function call.
724
+ */
725
+ bool zcashlc_is_valid_unified_address(const char *address, uint32_t network_id);
726
+
727
+ /**
728
+ * Returns the verified transparent balance for `address`, which ignores utxos that have been
729
+ * received too recently and are not yet deemed spendable according to `min_confirmations`.
730
+ *
731
+ * # Safety
732
+ *
733
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
734
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
735
+ * operating system's preferred representation.
736
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
737
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
738
+ * documentation of pointer::offset.
739
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
740
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
741
+ */
742
+ int64_t zcashlc_get_verified_transparent_balance(const uint8_t *db_data,
743
+ uintptr_t db_data_len,
744
+ const char *address,
745
+ uint32_t network_id,
746
+ uint32_t min_confirmations);
747
+
748
+ /**
749
+ * Returns the verified transparent balance for `account`, which ignores utxos that have been
750
+ * received too recently and are not yet deemed spendable according to `min_confirmations`.
751
+ *
752
+ * # Safety
753
+ *
754
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
755
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
756
+ * operating system's preferred representation.
757
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
758
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
759
+ * documentation of pointer::offset.
760
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
761
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
762
+ */
763
+ int64_t zcashlc_get_verified_transparent_balance_for_account(const uint8_t *db_data,
764
+ uintptr_t db_data_len,
765
+ uint32_t network_id,
766
+ int32_t account,
767
+ uint32_t min_confirmations);
768
+
769
+ /**
770
+ * Returns the balance for `address`, including all UTXOs that we know about.
771
+ *
772
+ * # Safety
773
+ *
774
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
775
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
776
+ * operating system's preferred representation.
777
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
778
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
779
+ * documentation of pointer::offset.
780
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
781
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
782
+ */
783
+ int64_t zcashlc_get_total_transparent_balance(const uint8_t *db_data,
784
+ uintptr_t db_data_len,
785
+ const char *address,
786
+ uint32_t network_id);
787
+
788
+ /**
789
+ * Returns the balance for `account`, including all UTXOs that we know about.
790
+ *
791
+ * # Safety
792
+ *
793
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
794
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
795
+ * operating system's preferred representation.
796
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
797
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
798
+ * documentation of pointer::offset.
799
+ * - `address` must be non-null and must point to a null-terminated UTF-8 string.
800
+ * - The memory referenced by `address` must not be mutated for the duration of the function call.
801
+ */
802
+ int64_t zcashlc_get_total_transparent_balance_for_account(const uint8_t *db_data,
803
+ uintptr_t db_data_len,
804
+ uint32_t network_id,
805
+ int32_t account);
806
+
807
+ /**
808
+ * Returns the memo for a note by copying the corresponding bytes to the received
809
+ * pointer in `memo_bytes_ret`.
810
+ *
811
+ * # Safety
812
+ *
813
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
814
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
815
+ * operating system's preferred representation.
816
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
817
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
818
+ * documentation of pointer::offset.
819
+ * - `txid_bytes` must be non-null and valid for reads for 32 bytes, and it must have an alignment
820
+ * of `1`.
821
+ * - `memo_bytes_ret` must be non-null and must point to an allocated 512-byte region of memory.
822
+ */
823
+ bool zcashlc_get_memo(const uint8_t *db_data,
824
+ uintptr_t db_data_len,
825
+ const uint8_t *txid_bytes,
826
+ uint32_t output_pool,
827
+ uint16_t output_index,
828
+ uint8_t *memo_bytes_ret,
829
+ uint32_t network_id);
830
+
831
+ /**
832
+ * Returns the memo for a note, if it is known and a valid UTF-8 string.
833
+ *
834
+ * # Safety
835
+ *
836
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
837
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
838
+ * operating system's preferred representation.
839
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
840
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
841
+ * documentation of pointer::offset.
842
+ * - `txid_bytes` must be non-null and valid for reads for 32 bytes, and it must have an alignment
843
+ * of `1`.
844
+ * - Call [`zcashlc_string_free`] to free the memory associated with the returned pointer
845
+ * when done using it.
846
+ */
847
+ char *zcashlc_get_memo_as_utf8(const uint8_t *db_data,
848
+ uintptr_t db_data_len,
849
+ const uint8_t *txid_bytes,
850
+ uint16_t output_index,
851
+ uint32_t network_id);
852
+
853
+ /**
854
+ * Returns a ZIP-32 signature of the given seed bytes.
855
+ *
856
+ * # Safety
857
+ * - `seed` must be non-null and valid for reads for `seed_len` bytes, and it must have an
858
+ * alignment of `1`.
859
+ * - The memory referenced by `seed` must not be mutated for the duration of the function call.
860
+ * - The total size `seed_len` must be at least 32 no larger than `252`. See the safety documentation
861
+ * of pointer::offset.
862
+ */
863
+ bool zcashlc_seed_fingerprint(const uint8_t *seed,
864
+ uintptr_t seed_len,
865
+ uint8_t *signature_bytes_ret);
866
+
867
+ /**
868
+ * Returns the most recent block height to which it is possible to reset the state
869
+ * of the data database.
870
+ *
871
+ * # Safety
872
+ *
873
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
874
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
875
+ * operating system's preferred representation.
876
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
877
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
878
+ * documentation of pointer::offset.
879
+ */
880
+ int32_t zcashlc_get_nearest_rewind_height(const uint8_t *db_data,
881
+ uintptr_t db_data_len,
882
+ int32_t height,
883
+ uint32_t network_id);
884
+
885
+ /**
886
+ * Rewinds the data database to the given height.
887
+ *
888
+ * If the requested height is greater than or equal to the height of the last scanned
889
+ * block, this function does nothing.
890
+ *
891
+ * # Safety
892
+ *
893
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
894
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
895
+ * operating system's preferred representation.
896
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
897
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
898
+ * documentation of pointer::offset.
899
+ */
900
+ bool zcashlc_rewind_to_height(const uint8_t *db_data,
901
+ uintptr_t db_data_len,
902
+ int32_t height,
903
+ uint32_t network_id);
904
+
905
+ /**
906
+ * Adds a sequence of Sapling subtree roots to the data store.
907
+ *
908
+ * Returns true if the subtrees could be stored, false otherwise. When false is returned,
909
+ * caller should check for errors.
910
+ *
911
+ * # Safety
912
+ *
913
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
914
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
915
+ * operating system's preferred representation.
916
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
917
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
918
+ * documentation of `pointer::offset`.
919
+ * - `roots` must be non-null and initialized.
920
+ * - The memory referenced by `roots` must not be mutated for the duration of the function call.
921
+ */
922
+ bool zcashlc_put_sapling_subtree_roots(const uint8_t *db_data,
923
+ uintptr_t db_data_len,
924
+ uint64_t start_index,
925
+ const struct FfiSubtreeRoots *roots,
926
+ uint32_t network_id);
927
+
928
+ /**
929
+ * Adds a sequence of Orchard subtree roots to the data store.
930
+ *
931
+ * Returns true if the subtrees could be stored, false otherwise. When false is returned,
932
+ * caller should check for errors.
933
+ *
934
+ * # Safety
935
+ *
936
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
937
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
938
+ * operating system's preferred representation.
939
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
940
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
941
+ * documentation of `pointer::offset`.
942
+ * - `roots` must be non-null and initialized.
943
+ * - The memory referenced by `roots` must not be mutated for the duration of the function call.
944
+ */
945
+ bool zcashlc_put_orchard_subtree_roots(const uint8_t *db_data,
946
+ uintptr_t db_data_len,
947
+ uint64_t start_index,
948
+ const struct FfiSubtreeRoots *roots,
949
+ uint32_t network_id);
950
+
951
+ /**
952
+ * Updates the wallet's view of the blockchain.
953
+ *
954
+ * This method is used to provide the wallet with information about the state of the blockchain,
955
+ * and detect any previously scanned data that needs to be re-validated before proceeding with
956
+ * scanning. It should be called at wallet startup prior to calling `zcashlc_suggest_scan_ranges`
957
+ * in order to provide the wallet with the information it needs to correctly prioritize scanning
958
+ * operations.
959
+ *
960
+ * # Safety
961
+ *
962
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
963
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
964
+ * operating system's preferred representation.
965
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
966
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
967
+ * documentation of `pointer::offset`.
968
+ */
969
+ bool zcashlc_update_chain_tip(const uint8_t *db_data,
970
+ uintptr_t db_data_len,
971
+ int32_t height,
972
+ uint32_t network_id);
973
+
974
+ /**
975
+ * Returns the height to which the wallet has been fully scanned.
976
+ *
977
+ * This is the height for which the wallet has fully trial-decrypted this and all
978
+ * preceding blocks above the wallet's birthday height.
979
+ *
980
+ * Returns a non-negative block height, -1 if empty, or -2 if an error occurred.
981
+ *
982
+ * # Safety
983
+ *
984
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
985
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
986
+ * operating system's preferred representation.
987
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
988
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
989
+ * documentation of `pointer::offset`.
990
+ */
991
+ int64_t zcashlc_fully_scanned_height(const uint8_t *db_data,
992
+ uintptr_t db_data_len,
993
+ uint32_t network_id);
994
+
995
+ /**
996
+ * Returns the maximum height that the wallet has scanned.
997
+ *
998
+ * If the wallet is fully synced, this will be equivalent to `zcashlc_block_fully_scanned`;
999
+ * otherwise the maximal scanned height is likely to be greater than the fully scanned
1000
+ * height due to the fact that out-of-order scanning can leave gaps.
1001
+ *
1002
+ * Returns a non-negative block height, -1 if empty, or -2 if an error occurred.
1003
+ *
1004
+ * # Safety
1005
+ *
1006
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1007
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1008
+ * operating system's preferred representation.
1009
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
1010
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1011
+ * documentation of `pointer::offset`.
1012
+ */
1013
+ int64_t zcashlc_max_scanned_height(const uint8_t *db_data,
1014
+ uintptr_t db_data_len,
1015
+ uint32_t network_id);
1016
+
1017
+ /**
1018
+ * Returns the account balances and sync status given the specified minimum number of
1019
+ * confirmations.
1020
+ *
1021
+ * Returns `fully_scanned_height = -1` if the wallet has no balance data available.
1022
+ *
1023
+ * # Safety
1024
+ *
1025
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must
1026
+ * have an alignment of `1`. Its contents must be a string representing a valid system
1027
+ * path in the operating system's preferred representation.
1028
+ * - The memory referenced by `db_data` must not be mutated for the duration of the
1029
+ * function call.
1030
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1031
+ * documentation of pointer::offset.
1032
+ */
1033
+ struct FfiWalletSummary *zcashlc_get_wallet_summary(const uint8_t *db_data,
1034
+ uintptr_t db_data_len,
1035
+ uint32_t network_id,
1036
+ uint32_t min_confirmations);
1037
+
1038
+ /**
1039
+ * Frees an [`FfiWalletSummary`] value.
1040
+ *
1041
+ * # Safety
1042
+ *
1043
+ * - `ptr` must be non-null and must point to a struct having the layout of [`FfiWalletSummary`].
1044
+ * See the safety documentation of [`FfiWalletSummary`].
1045
+ */
1046
+ void zcashlc_free_wallet_summary(struct FfiWalletSummary *ptr);
1047
+
1048
+ /**
1049
+ * Frees an array of FfiScanRanges values as allocated by `zcashlc_derive_unified_viewing_keys_from_seed`
1050
+ *
1051
+ * # Safety
1052
+ *
1053
+ * - `ptr` must be non-null and must point to a struct having the layout of [`FfiScanRanges`].
1054
+ * See the safety documentation of [`FfiScanRanges`].
1055
+ */
1056
+ void zcashlc_free_scan_ranges(struct FfiScanRanges *ptr);
1057
+
1058
+ /**
1059
+ * Returns a list of suggested scan ranges based upon the current wallet state.
1060
+ *
1061
+ * This method should only be used in cases where the `CompactBlock` data that will be
1062
+ * made available to `zcashlc_scan_blocks` for the requested block ranges includes note
1063
+ * commitment tree size information for each block; or else the scan is likely to fail if
1064
+ * notes belonging to the wallet are detected.
1065
+ *
1066
+ * # Safety
1067
+ *
1068
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must
1069
+ * have an alignment of `1`. Its contents must be a string representing a valid system
1070
+ * path in the operating system's preferred representation.
1071
+ * - The memory referenced by `db_data` must not be mutated for the duration of the
1072
+ * function call.
1073
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1074
+ * documentation of pointer::offset.
1075
+ * - Call [`zcashlc_free_scan_ranges`] to free the memory associated with the returned
1076
+ * pointer when done using it.
1077
+ */
1078
+ struct FfiScanRanges *zcashlc_suggest_scan_ranges(const uint8_t *db_data,
1079
+ uintptr_t db_data_len,
1080
+ uint32_t network_id);
1081
+
1082
+ /**
1083
+ * Scans new blocks added to the cache for any transactions received by the tracked
1084
+ * accounts, while checking that they form a valid chan.
1085
+ *
1086
+ * This function is built on the core assumption that the information provided in the
1087
+ * block cache is more likely to be accurate than the previously-scanned information.
1088
+ * This follows from the design (and trust) assumption that the `lightwalletd` server
1089
+ * provides accurate block information as of the time it was requested.
1090
+ *
1091
+ * This function **assumes** that the caller is handling rollbacks.
1092
+ *
1093
+ * For brand-new light client databases, this function starts scanning from the Sapling
1094
+ * activation height. This height can be fast-forwarded to a more recent block by calling
1095
+ * [`zcashlc_init_blocks_table`] before this function.
1096
+ *
1097
+ * Scanned blocks are required to be height-sequential. If a block is missing from the
1098
+ * cache, an error will be signalled.
1099
+ *
1100
+ * # Safety
1101
+ *
1102
+ * - `fs_block_db_root` must be non-null and valid for reads for `fs_block_db_root_len` bytes, and it must have an
1103
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1104
+ * operating system's preferred representation.
1105
+ * - The memory referenced by `fs_block_db_root` must not be mutated for the duration of the function call.
1106
+ * - The total size `fs_block_db_root_len` must be no larger than `isize::MAX`. See the safety
1107
+ * documentation of pointer::offset.
1108
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1109
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1110
+ * operating system's preferred representation.
1111
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
1112
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1113
+ * documentation of pointer::offset.
1114
+ */
1115
+ struct FfiScanSummary *zcashlc_scan_blocks(const uint8_t *fs_block_cache_root,
1116
+ uintptr_t fs_block_cache_root_len,
1117
+ const uint8_t *db_data,
1118
+ uintptr_t db_data_len,
1119
+ int32_t from_height,
1120
+ const uint8_t *from_state,
1121
+ uintptr_t from_state_len,
1122
+ uint32_t scan_limit,
1123
+ uint32_t network_id);
1124
+
1125
+ /**
1126
+ * Frees an [`FfiScanSummary`] value.
1127
+ *
1128
+ * # Safety
1129
+ *
1130
+ * - `ptr` must be non-null and must point to a struct having the layout of [`FfiScanSummary`].
1131
+ */
1132
+ void zcashlc_free_scan_summary(struct FfiScanSummary *ptr);
1133
+
1134
+ /**
1135
+ * Inserts a UTXO into the wallet database.
1136
+ *
1137
+ * # Safety
1138
+ *
1139
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1140
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1141
+ * operating system's preferred representation.
1142
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
1143
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1144
+ * documentation of pointer::offset.
1145
+ * - `txid_bytes` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1146
+ * alignment of `1`.
1147
+ * - The memory referenced by `txid_bytes_len` must not be mutated for the duration of the function call.
1148
+ * - The total size `txid_bytes_len` must be no larger than `isize::MAX`. See the safety
1149
+ * documentation of pointer::offset.
1150
+ * - `script_bytes` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1151
+ * alignment of `1`.
1152
+ * - The memory referenced by `script_bytes_len` must not be mutated for the duration of the function call.
1153
+ * - The total size `script_bytes_len` must be no larger than `isize::MAX`. See the safety
1154
+ * documentation of pointer::offset.
1155
+ */
1156
+ bool zcashlc_put_utxo(const uint8_t *db_data,
1157
+ uintptr_t db_data_len,
1158
+ const uint8_t *txid_bytes,
1159
+ uintptr_t txid_bytes_len,
1160
+ int32_t index,
1161
+ const uint8_t *script_bytes,
1162
+ uintptr_t script_bytes_len,
1163
+ int64_t value,
1164
+ int32_t height,
1165
+ uint32_t network_id);
1166
+
1167
+ /**
1168
+ * # Safety
1169
+ * Initializes the `FsBlockDb` sqlite database. Does nothing if already created
1170
+ *
1171
+ * Returns true when successful, false otherwise. When false is returned caller
1172
+ * should check for errors.
1173
+ * - `fs_block_db_root` must be non-null and valid for reads for `fs_block_db_root_len` bytes, and it must have an
1174
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1175
+ * operating system's preferred representation.
1176
+ * - The memory referenced by `fs_block_db_root` must not be mutated for the duration of the function call.
1177
+ * - The total size `fs_block_db_root_len` must be no larger than `isize::MAX`. See the safety
1178
+ * documentation of pointer::offset.
1179
+ */
1180
+ bool zcashlc_init_block_metadata_db(const uint8_t *fs_block_db_root,
1181
+ uintptr_t fs_block_db_root_len);
1182
+
1183
+ /**
1184
+ * Writes the blocks provided in `blocks_meta` into the `BlockMeta` database
1185
+ *
1186
+ * Returns true if the `blocks_meta` could be stored into the `FsBlockDb`. False
1187
+ * otherwise.
1188
+ *
1189
+ * When false is returned caller should check for errors.
1190
+ *
1191
+ * # Safety
1192
+ *
1193
+ * - `fs_block_db_root` must be non-null and valid for reads for `fs_block_db_root_len` bytes, and it must have an
1194
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1195
+ * operating system's preferred representation.
1196
+ * - The memory referenced by `fs_block_db_root` must not be mutated for the duration of the function call.
1197
+ * - The total size `fs_block_db_root_len` must be no larger than `isize::MAX`. See the safety
1198
+ * documentation of pointer::offset.
1199
+ * - Block metadata represented in `blocks_meta` must be non-null. Caller must guarantee that the
1200
+ * memory reference by this pointer is not freed up, dereferenced or invalidated while this function
1201
+ * is invoked.
1202
+ */
1203
+ bool zcashlc_write_block_metadata(const uint8_t *fs_block_db_root,
1204
+ uintptr_t fs_block_db_root_len,
1205
+ struct FFIBlocksMeta *blocks_meta);
1206
+
1207
+ /**
1208
+ * Rewinds the data database to the given height.
1209
+ *
1210
+ * If the requested height is greater than or equal to the height of the last scanned
1211
+ * block, this function does nothing.
1212
+ *
1213
+ * # Safety
1214
+ *
1215
+ * - `fs_block_db_root` must be non-null and valid for reads for `fs_block_db_root_len` bytes, and it must have an
1216
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1217
+ * operating system's preferred representation.
1218
+ * - The memory referenced by `fs_block_db_root` must not be mutated for the duration of the function call.
1219
+ * - The total size `fs_block_db_root_len` must be no larger than `isize::MAX`. See the safety
1220
+ * documentation of pointer::offset.
1221
+ */
1222
+ bool zcashlc_rewind_fs_block_cache_to_height(const uint8_t *fs_block_db_root,
1223
+ uintptr_t fs_block_db_root_len,
1224
+ int32_t height);
1225
+
1226
+ /**
1227
+ * Get the latest cached block height in the filesystem block cache
1228
+ *
1229
+ * Returns a non-negative block height, -1 if empty, or -2 if an error occurred.
1230
+ *
1231
+ * # Safety
1232
+ *
1233
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1234
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1235
+ * operating system's preferred representation.
1236
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
1237
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1238
+ * documentation of pointer::offset.
1239
+ * - `tx` must be non-null and valid for reads for `tx_len` bytes, and it must have an
1240
+ * alignment of `1`.
1241
+ * - The memory referenced by `tx` must not be mutated for the duration of the function call.
1242
+ * - The total size `tx_len` must be no larger than `isize::MAX`. See the safety
1243
+ * documentation of pointer::offset.
1244
+ */
1245
+ int32_t zcashlc_latest_cached_block_height(const uint8_t *fs_block_db_root,
1246
+ uintptr_t fs_block_db_root_len);
1247
+
1248
+ /**
1249
+ * Decrypts whatever parts of the specified transaction it can and stores them in db_data.
1250
+ *
1251
+ * # Safety
1252
+ *
1253
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1254
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1255
+ * operating system's preferred representation.
1256
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
1257
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1258
+ * documentation of pointer::offset.
1259
+ * - `tx` must be non-null and valid for reads for `tx_len` bytes, and it must have an
1260
+ * alignment of `1`.
1261
+ * - The memory referenced by `tx` must not be mutated for the duration of the function call.
1262
+ * - The total size `tx_len` must be no larger than `isize::MAX`. See the safety
1263
+ * documentation of pointer::offset.
1264
+ */
1265
+ int32_t zcashlc_decrypt_and_store_transaction(const uint8_t *db_data,
1266
+ uintptr_t db_data_len,
1267
+ const uint8_t *tx,
1268
+ uintptr_t tx_len,
1269
+ uint32_t _mined_height,
1270
+ uint32_t network_id);
1271
+
1272
+ /**
1273
+ * Frees an [`FfiBoxedSlice`].
1274
+ *
1275
+ * # Safety
1276
+ *
1277
+ * - `ptr` must be non-null and must point to a struct having the layout of
1278
+ * [`FfiBoxedSlice`]. See the safety documentation of [`FfiBoxedSlice`].
1279
+ */
1280
+ void zcashlc_free_boxed_slice(struct FfiBoxedSlice *ptr);
1281
+
1282
+ /**
1283
+ * Select transaction inputs, compute fees, and construct a proposal for a transaction
1284
+ * that can then be authorized and made ready for submission to the network with
1285
+ * `zcashlc_create_proposed_transaction`.
1286
+ *
1287
+ * # Safety
1288
+ *
1289
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1290
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1291
+ * operating system's preferred representation.
1292
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
1293
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1294
+ * documentation of pointer::offset.
1295
+ * - `to` must be non-null and must point to a null-terminated UTF-8 string.
1296
+ * - `memo` must either be null (indicating an empty memo or a transparent recipient) or point to a
1297
+ * 512-byte array.
1298
+ */
1299
+ struct FfiBoxedSlice *zcashlc_propose_transfer(const uint8_t *db_data,
1300
+ uintptr_t db_data_len,
1301
+ int32_t account,
1302
+ const char *to,
1303
+ int64_t value,
1304
+ const uint8_t *memo,
1305
+ uint32_t network_id,
1306
+ uint32_t min_confirmations,
1307
+ bool use_zip317_fees);
1308
+
1309
+ /**
1310
+ * Select transaction inputs, compute fees, and construct a proposal for a transaction
1311
+ * from a ZIP-321 payment URI that can then be authorized and made ready for submission to the
1312
+ * network with `zcashlc_create_proposed_transaction`.
1313
+ *
1314
+ * # Safety
1315
+ *
1316
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1317
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1318
+ * operating system's preferred representation.
1319
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
1320
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1321
+ * documentation of pointer::offset.
1322
+ * - `payment_uri` must be non-null and must point to a null-terminated UTF-8 string.
1323
+ * - `network_id` a u32. 0 for Testnet and 1 for Mainnet
1324
+ * - `min_confirmations` number of confirmations of the funds to spend
1325
+ * - `use_zip317_fees` `true`` to use ZIP-317 fees.
1326
+ */
1327
+ struct FfiBoxedSlice *zcashlc_propose_transfer_from_uri(const uint8_t *db_data,
1328
+ uintptr_t db_data_len,
1329
+ int32_t account,
1330
+ const char *payment_uri,
1331
+ uint32_t network_id,
1332
+ uint32_t min_confirmations,
1333
+ bool use_zip317_fees);
1334
+
1335
+ int32_t zcashlc_branch_id_for_height(int32_t height, uint32_t network_id);
1336
+
1337
+ /**
1338
+ * Frees strings returned by other zcashlc functions.
1339
+ *
1340
+ * # Safety
1341
+ *
1342
+ * - `s` should be a non-null pointer returned as a string by another zcashlc function.
1343
+ */
1344
+ void zcashlc_string_free(char *s);
1345
+
1346
+ /**
1347
+ * Select transaction inputs, compute fees, and construct a proposal for a shielding
1348
+ * transaction that can then be authorized and made ready for submission to the network
1349
+ * with `zcashlc_create_proposed_transaction`.
1350
+ *
1351
+ * # Safety
1352
+ *
1353
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
1354
+ * alignment of `1`. Its contents must be a string representing a valid system path in the
1355
+ * operating system's preferred representation.
1356
+ * - The memory referenced by `db_data` must not be mutated for the duration of the function call.
1357
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1358
+ * documentation of pointer::offset.
1359
+ * - `shielding_threshold` a non-negative shielding threshold amount in zatoshi
1360
+ */
1361
+ struct FfiBoxedSlice *zcashlc_propose_shielding(const uint8_t *db_data,
1362
+ uintptr_t db_data_len,
1363
+ int32_t account,
1364
+ const uint8_t *memo,
1365
+ uint64_t shielding_threshold,
1366
+ const char *transparent_receiver,
1367
+ uint32_t network_id,
1368
+ uint32_t min_confirmations,
1369
+ bool use_zip317_fees);
1370
+
1371
+ /**
1372
+ * Frees an array of FfiTxIds values as allocated by `zcashlc_create_proposed_transactions`.
1373
+ *
1374
+ * # Safety
1375
+ *
1376
+ * - `ptr` must be non-null and must point to a struct having the layout of [`FfiTxIds`].
1377
+ * See the safety documentation of [`FfiTxIds`].
1378
+ */
1379
+ void zcashlc_free_txids(struct FfiTxIds *ptr);
1380
+
1381
+ /**
1382
+ * Creates a transaction from the given proposal.
1383
+ *
1384
+ * Returns the row index of the newly-created transaction in the `transactions` table
1385
+ * within the data database. The caller can read the raw transaction bytes from the `raw`
1386
+ * column in order to broadcast the transaction to the network.
1387
+ *
1388
+ * Do not call this multiple times in parallel, or you will generate transactions that
1389
+ * double-spend the same notes.
1390
+ *
1391
+ * # Safety
1392
+ *
1393
+ * - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must
1394
+ * have an alignment of `1`. Its contents must be a string representing a valid system
1395
+ * path in the operating system's preferred representation.
1396
+ * - The memory referenced by `db_data` must not be mutated for the duration of the
1397
+ * function call.
1398
+ * - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
1399
+ * documentation of `pointer::offset`.
1400
+ * - `proposal_ptr` must be non-null and valid for reads for `proposal_len` bytes, and it
1401
+ * must have an alignment of `1`. Its contents must be an encoded Proposal protobuf.
1402
+ * - The memory referenced by `proposal_ptr` must not be mutated for the duration of the
1403
+ * function call.
1404
+ * - The total size `proposal_len` must be no larger than `isize::MAX`. See the safety
1405
+ * documentation of `pointer::offset`.
1406
+ * - `usk_ptr` must be non-null and must point to an array of `usk_len` bytes containing
1407
+ * a unified spending key encoded as returned from the `zcashlc_create_account` or
1408
+ * `zcashlc_derive_spending_key` functions.
1409
+ * - The memory referenced by `usk_ptr` must not be mutated for the duration of the
1410
+ * function call.
1411
+ * - The total size `usk_len` must be no larger than `isize::MAX`. See the safety
1412
+ * documentation of `pointer::offset`.
1413
+ * - `to` must be non-null and must point to a null-terminated UTF-8 string.
1414
+ * - `memo` must either be null (indicating an empty memo or a transparent recipient) or
1415
+ * point to a 512-byte array.
1416
+ * - `spend_params` must be non-null and valid for reads for `spend_params_len` bytes,
1417
+ * and it must have an alignment of `1`. Its contents must be the Sapling spend proving
1418
+ * parameters.
1419
+ * - The memory referenced by `spend_params` must not be mutated for the duration of the
1420
+ * function call.
1421
+ * - The total size `spend_params_len` must be no larger than `isize::MAX`. See the safety
1422
+ * documentation of `pointer::offset`.
1423
+ * - `output_params` must be non-null and valid for reads for `output_params_len` bytes,
1424
+ * and it must have an alignment of `1`. Its contents must be the Sapling output
1425
+ * proving parameters.
1426
+ * - The memory referenced by `output_params` must not be mutated for the duration of the
1427
+ * function call.
1428
+ * - The total size `output_params_len` must be no larger than `isize::MAX`. See the safety
1429
+ * documentation of pointer::offset.
1430
+ */
1431
+ struct FfiTxIds *zcashlc_create_proposed_transactions(const uint8_t *db_data,
1432
+ uintptr_t db_data_len,
1433
+ const uint8_t *proposal_ptr,
1434
+ uintptr_t proposal_len,
1435
+ const uint8_t *usk_ptr,
1436
+ uintptr_t usk_len,
1437
+ const uint8_t *spend_params,
1438
+ uintptr_t spend_params_len,
1439
+ const uint8_t *output_params,
1440
+ uintptr_t output_params_len,
1441
+ uint32_t network_id);