react-native-zcash 0.6.10 → 0.6.11

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 (150) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/2460000.json +8 -0
  3. package/ios/ZCashLightClientKit/Block/CompactBlockProcessor.swift +937 -425
  4. package/ios/ZCashLightClientKit/Block/Download/BlockDownloader.swift +17 -31
  5. package/ios/ZCashLightClientKit/Block/Download/BlockDownloaderService.swift +2 -2
  6. package/ios/ZCashLightClientKit/Block/Enhance/BlockEnhancer.swift +15 -46
  7. package/ios/ZCashLightClientKit/Block/FetchUnspentTxOutputs/UTXOFetcher.swift +15 -4
  8. package/ios/ZCashLightClientKit/Block/FilesystemStorage/FSCompactBlockRepository.swift +4 -4
  9. package/ios/ZCashLightClientKit/Block/Scan/BlockScanner.swift +35 -10
  10. package/ios/ZCashLightClientKit/Block/Utils/InternalSyncProgress.swift +200 -0
  11. package/ios/ZCashLightClientKit/Block/Validate/BlockValidator.swift +51 -0
  12. package/ios/ZCashLightClientKit/ClosureSynchronizer.swift +2 -1
  13. package/ios/ZCashLightClientKit/CombineSynchronizer.swift +5 -2
  14. package/ios/ZCashLightClientKit/Constants/ZcashSDK.swift +26 -13
  15. package/ios/ZCashLightClientKit/DAO/BlockDao.swift +112 -0
  16. package/ios/ZCashLightClientKit/DAO/TransactionDao.swift +42 -40
  17. package/ios/ZCashLightClientKit/DAO/UnspentTransactionOutputDao.swift +4 -13
  18. package/ios/ZCashLightClientKit/Entity/AccountEntity.swift +0 -9
  19. package/ios/ZCashLightClientKit/Entity/BlockProgress.swift +24 -0
  20. package/ios/ZCashLightClientKit/Entity/TransactionEntity.swift +10 -7
  21. package/ios/ZCashLightClientKit/Error/Sourcery/generateErrorCode.sh +1 -1
  22. package/ios/ZCashLightClientKit/Error/ZcashError.swift +12 -121
  23. package/ios/ZCashLightClientKit/Error/ZcashErrorCode.swift +5 -43
  24. package/ios/ZCashLightClientKit/Error/ZcashErrorCodeDefinition.swift +6 -72
  25. package/ios/ZCashLightClientKit/Initializer.swift +26 -47
  26. package/ios/ZCashLightClientKit/Metrics/SDKMetrics.swift +12 -0
  27. package/ios/ZCashLightClientKit/Model/Checkpoint.swift +0 -12
  28. package/ios/ZCashLightClientKit/Modules/Service/GRPC/LightWalletGRPCService.swift +0 -15
  29. package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/compact_formats.pb.swift +46 -150
  30. package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/proto/compact_formats.proto +16 -30
  31. package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/proto/service.proto +6 -32
  32. package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/service.grpc.swift +22 -259
  33. package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/service.pb.swift +7 -193
  34. package/ios/ZCashLightClientKit/Modules/Service/LightWalletService.swift +0 -8
  35. package/ios/ZCashLightClientKit/Providers/LatestBlocksDataProvider.swift +28 -18
  36. package/ios/ZCashLightClientKit/Repository/CompactBlockRepository.swift +1 -1
  37. package/ios/ZCashLightClientKit/Repository/TransactionRepository.swift +6 -2
  38. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2460000.json +8 -0
  39. package/ios/ZCashLightClientKit/Rust/ZcashRustBackend.swift +158 -293
  40. package/ios/ZCashLightClientKit/Rust/ZcashRustBackendWelding.swift +64 -58
  41. package/ios/ZCashLightClientKit/Rust/zcashlc.h +513 -619
  42. package/ios/ZCashLightClientKit/Synchronizer/ClosureSDKSynchronizer.swift +8 -2
  43. package/ios/ZCashLightClientKit/Synchronizer/CombineSDKSynchronizer.swift +15 -3
  44. package/ios/ZCashLightClientKit/Synchronizer/Dependencies.swift +30 -11
  45. package/ios/ZCashLightClientKit/Synchronizer/SDKSynchronizer.swift +50 -41
  46. package/ios/ZCashLightClientKit/Synchronizer.swift +65 -51
  47. package/ios/ZCashLightClientKit/Transaction/TransactionEncoder.swift +2 -2
  48. package/ios/ZCashLightClientKit/Transaction/WalletTransactionEncoder.swift +7 -7
  49. package/ios/ZCashLightClientKit/Utils/OSLogger.swift +3 -3
  50. package/ios/libzcashlc.xcframework/Info.plist +0 -4
  51. package/ios/libzcashlc.xcframework/ios-arm64/libzcashlc.a +0 -0
  52. package/ios/libzcashlc.xcframework/ios-arm64_x86_64-simulator/libzcashlc.a +0 -0
  53. package/package.json +1 -1
  54. package/ios/ZCashLightClientKit/Block/Actions/Action.swift +0 -98
  55. package/ios/ZCashLightClientKit/Block/Actions/ClearAlreadyScannedBlocksAction.swift +0 -35
  56. package/ios/ZCashLightClientKit/Block/Actions/ClearCacheAction.swift +0 -30
  57. package/ios/ZCashLightClientKit/Block/Actions/DownloadAction.swift +0 -67
  58. package/ios/ZCashLightClientKit/Block/Actions/EnhanceAction.swift +0 -97
  59. package/ios/ZCashLightClientKit/Block/Actions/FetchUTXOsAction.swift +0 -33
  60. package/ios/ZCashLightClientKit/Block/Actions/MigrateLegacyCacheDBAction.swift +0 -70
  61. package/ios/ZCashLightClientKit/Block/Actions/ProcessSuggestedScanRangesAction.swift +0 -60
  62. package/ios/ZCashLightClientKit/Block/Actions/RewindAction.swift +0 -48
  63. package/ios/ZCashLightClientKit/Block/Actions/SaplingParamsAction.swift +0 -33
  64. package/ios/ZCashLightClientKit/Block/Actions/ScanAction.swift +0 -95
  65. package/ios/ZCashLightClientKit/Block/Actions/UpdateChainTipAction.swift +0 -55
  66. package/ios/ZCashLightClientKit/Block/Actions/UpdateSubtreeRootsAction.swift +0 -58
  67. package/ios/ZCashLightClientKit/Block/Actions/ValidateServerAction.swift +0 -60
  68. package/ios/ZCashLightClientKit/Block/Utils/CompactBlockProgress.swift +0 -24
  69. package/ios/ZCashLightClientKit/Block/Utils/SyncControlData.swift +0 -25
  70. package/ios/ZCashLightClientKit/Extensions/Bool+ToData.swift +0 -15
  71. package/ios/ZCashLightClientKit/Extensions/Data+ToOtherTypes.swift +0 -18
  72. package/ios/ZCashLightClientKit/Extensions/Int+ToData.swift +0 -15
  73. package/ios/ZCashLightClientKit/Model/ScanProgress.swift +0 -29
  74. package/ios/ZCashLightClientKit/Model/ScanRange.swift +0 -31
  75. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2092500.json +0 -8
  76. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2095000.json +0 -8
  77. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2097500.json +0 -8
  78. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2102500.json +0 -8
  79. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2105000.json +0 -8
  80. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2107500.json +0 -8
  81. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2112500.json +0 -8
  82. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2115000.json +0 -8
  83. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2117500.json +0 -8
  84. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2122500.json +0 -8
  85. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2125000.json +0 -8
  86. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2127500.json +0 -8
  87. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2132500.json +0 -8
  88. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2135000.json +0 -8
  89. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2137500.json +0 -8
  90. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2142500.json +0 -8
  91. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2145000.json +0 -8
  92. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2147500.json +0 -8
  93. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2152500.json +0 -8
  94. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2155000.json +0 -8
  95. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2157500.json +0 -8
  96. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2162500.json +0 -8
  97. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2165000.json +0 -8
  98. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2167500.json +0 -8
  99. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2172500.json +0 -8
  100. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2175000.json +0 -8
  101. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2177500.json +0 -8
  102. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2182500.json +0 -8
  103. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2185000.json +0 -8
  104. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2187500.json +0 -8
  105. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2192500.json +0 -8
  106. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2195000.json +0 -8
  107. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2197500.json +0 -8
  108. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2202500.json +0 -8
  109. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2205000.json +0 -8
  110. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2207500.json +0 -8
  111. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2212500.json +0 -8
  112. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2215000.json +0 -8
  113. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2217500.json +0 -8
  114. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2222500.json +0 -8
  115. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2225000.json +0 -8
  116. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2227500.json +0 -8
  117. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2232500.json +0 -8
  118. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2235000.json +0 -8
  119. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2237500.json +0 -8
  120. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2242500.json +0 -8
  121. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2245000.json +0 -8
  122. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2247500.json +0 -8
  123. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2252500.json +0 -8
  124. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2255000.json +0 -8
  125. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2257500.json +0 -8
  126. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2262500.json +0 -8
  127. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2265000.json +0 -8
  128. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2267500.json +0 -8
  129. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2350000.json +0 -8
  130. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2360000.json +0 -8
  131. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2370000.json +0 -8
  132. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2380000.json +0 -8
  133. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2390000.json +0 -8
  134. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2400000.json +0 -8
  135. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2410000.json +0 -8
  136. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2420000.json +0 -8
  137. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2430000.json +0 -8
  138. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2440000.json +0 -8
  139. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2450000.json +0 -8
  140. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2460000.json +0 -8
  141. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2470000.json +0 -8
  142. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2480000.json +0 -8
  143. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2490000.json +0 -8
  144. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2500000.json +0 -8
  145. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2510000.json +0 -8
  146. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2520000.json +0 -8
  147. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2530000.json +0 -8
  148. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2540000.json +0 -8
  149. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2550000.json +0 -8
  150. package/ios/ZCashLightClientKit/Utils/ZcashFileManager.swift +0 -16
@@ -90,7 +90,6 @@ public class Initializer {
90
90
  struct URLs {
91
91
  let fsBlockDbRoot: URL
92
92
  let dataDbURL: URL
93
- let generalStorageURL: URL
94
93
  let spendParamsURL: URL
95
94
  let outputParamsURL: URL
96
95
  }
@@ -113,7 +112,6 @@ public class Initializer {
113
112
  let alias: ZcashSynchronizerAlias
114
113
  let endpoint: LightWalletEndpoint
115
114
  let fsBlockDbRoot: URL
116
- let generalStorageURL: URL
117
115
  let dataDbURL: URL
118
116
  let spendParamsURL: URL
119
117
  let outputParamsURL: URL
@@ -144,20 +142,13 @@ public class Initializer {
144
142
  /// - cacheDbURL: previous location of the cacheDb. If you don't know what a cacheDb is and you are adopting this SDK for the first time then
145
143
  /// just pass `nil` here.
146
144
  /// - fsBlockDbRoot: location of the compact blocks cache
147
- /// - generalStorageURL: Location of the directory where the SDK can store any information it needs. A directory doesn't have to exist. But the
148
- /// SDK must be able to write to this location after it creates this directory. It is suggested that this directory is
149
- /// a subdirectory of the `Documents` directory. If this information is stored in `Documents` then the system itself won't
150
- /// remove these data.
151
145
  /// - dataDbURL: Location of the data db
152
146
  /// - endpoint: the endpoint representing the lightwalletd instance you want to point to
153
147
  /// - spendParamsURL: location of the spend parameters
154
148
  /// - outputParamsURL: location of the output parameters
155
- /// - loggingPolicy: the `LoggingPolicy` for the logger
156
- /// - enableBackendTracing: this enables tracing for super detailed debugging. it will slow down everything 10 or 100x.
157
149
  convenience public init(
158
150
  cacheDbURL: URL?,
159
151
  fsBlockDbRoot: URL,
160
- generalStorageURL: URL,
161
152
  dataDbURL: URL,
162
153
  endpoint: LightWalletEndpoint,
163
154
  network: ZcashNetwork,
@@ -165,8 +156,7 @@ public class Initializer {
165
156
  outputParamsURL: URL,
166
157
  saplingParamsSourceURL: SaplingParamsSourceURL,
167
158
  alias: ZcashSynchronizerAlias = .default,
168
- loggingPolicy: LoggingPolicy = .default(.debug),
169
- enableBackendTracing: Bool = false
159
+ loggingPolicy: LoggingPolicy = .default(.debug)
170
160
  ) {
171
161
  let container = DIContainer()
172
162
 
@@ -176,7 +166,6 @@ public class Initializer {
176
166
  container: container,
177
167
  cacheDbURL: cacheDbURL,
178
168
  fsBlockDbRoot: fsBlockDbRoot,
179
- generalStorageURL: generalStorageURL,
180
169
  dataDbURL: dataDbURL,
181
170
  endpoint: endpoint,
182
171
  network: network,
@@ -184,8 +173,7 @@ public class Initializer {
184
173
  outputParamsURL: outputParamsURL,
185
174
  saplingParamsSourceURL: saplingParamsSourceURL,
186
175
  alias: alias,
187
- loggingPolicy: loggingPolicy,
188
- enableBackendTracing: enableBackendTracing
176
+ loggingPolicy: loggingPolicy
189
177
  )
190
178
 
191
179
  self.init(
@@ -206,7 +194,6 @@ public class Initializer {
206
194
  container: DIContainer,
207
195
  cacheDbURL: URL?,
208
196
  fsBlockDbRoot: URL,
209
- generalStorageURL: URL,
210
197
  dataDbURL: URL,
211
198
  endpoint: LightWalletEndpoint,
212
199
  network: ZcashNetwork,
@@ -214,8 +201,7 @@ public class Initializer {
214
201
  outputParamsURL: URL,
215
202
  saplingParamsSourceURL: SaplingParamsSourceURL,
216
203
  alias: ZcashSynchronizerAlias = .default,
217
- loggingPolicy: LoggingPolicy = .default(.debug),
218
- enableBackendTracing: Bool = false
204
+ loggingPolicy: LoggingPolicy = .default(.debug)
219
205
  ) {
220
206
  // It's not possible to fail from constructor. Technically it's possible but it can be pain for the client apps to handle errors thrown
221
207
  // from constructor. So `parsingError` is just stored in initializer and `SDKSynchronizer.prepare()` throw this error if it exists.
@@ -223,7 +209,6 @@ public class Initializer {
223
209
  container: container,
224
210
  cacheDbURL: cacheDbURL,
225
211
  fsBlockDbRoot: fsBlockDbRoot,
226
- generalStorageURL: generalStorageURL,
227
212
  dataDbURL: dataDbURL,
228
213
  endpoint: endpoint,
229
214
  network: network,
@@ -231,8 +216,7 @@ public class Initializer {
231
216
  outputParamsURL: outputParamsURL,
232
217
  saplingParamsSourceURL: saplingParamsSourceURL,
233
218
  alias: alias,
234
- loggingPolicy: loggingPolicy,
235
- enableBackendTracing: enableBackendTracing
219
+ loggingPolicy: loggingPolicy
236
220
  )
237
221
 
238
222
  self.init(
@@ -263,7 +247,6 @@ public class Initializer {
263
247
  self.cacheDbURL = cacheDbURL
264
248
  self.rustBackend = container.resolve(ZcashRustBackendWelding.self)
265
249
  self.fsBlockDbRoot = urls.fsBlockDbRoot
266
- self.generalStorageURL = urls.generalStorageURL
267
250
  self.dataDbURL = urls.dataDbURL
268
251
  self.endpoint = endpoint
269
252
  self.spendParamsURL = urls.spendParamsURL
@@ -295,7 +278,6 @@ public class Initializer {
295
278
  container: DIContainer,
296
279
  cacheDbURL: URL?,
297
280
  fsBlockDbRoot: URL,
298
- generalStorageURL: URL,
299
281
  dataDbURL: URL,
300
282
  endpoint: LightWalletEndpoint,
301
283
  network: ZcashNetwork,
@@ -303,13 +285,11 @@ public class Initializer {
303
285
  outputParamsURL: URL,
304
286
  saplingParamsSourceURL: SaplingParamsSourceURL,
305
287
  alias: ZcashSynchronizerAlias,
306
- loggingPolicy: LoggingPolicy = .default(.debug),
307
- enableBackendTracing: Bool = false
288
+ loggingPolicy: LoggingPolicy = .default(.debug)
308
289
  ) -> (URLs, ZcashError?) {
309
290
  let urls = URLs(
310
291
  fsBlockDbRoot: fsBlockDbRoot,
311
292
  dataDbURL: dataDbURL,
312
- generalStorageURL: generalStorageURL,
313
293
  spendParamsURL: spendParamsURL,
314
294
  outputParamsURL: outputParamsURL
315
295
  )
@@ -324,8 +304,7 @@ public class Initializer {
324
304
  alias: alias,
325
305
  networkType: network.networkType,
326
306
  endpoint: endpoint,
327
- loggingPolicy: loggingPolicy,
328
- enableBackendTracing: enableBackendTracing
307
+ loggingPolicy: loggingPolicy
329
308
  )
330
309
 
331
310
  return (updatedURLs, parsingError)
@@ -381,15 +360,10 @@ public class Initializer {
381
360
  return .failure(.initializerCantUpdateURLWithAlias(urls.outputParamsURL))
382
361
  }
383
362
 
384
- guard let updatedGeneralStorageURL = urls.generalStorageURL.updateLastPathComponent(with: alias) else {
385
- return .failure(.initializerCantUpdateURLWithAlias(urls.generalStorageURL))
386
- }
387
-
388
363
  return .success(
389
364
  URLs(
390
365
  fsBlockDbRoot: updatedFsBlockDbRoot,
391
366
  dataDbURL: updatedDataDbURL,
392
- generalStorageURL: updatedGeneralStorageURL,
393
367
  spendParamsURL: updatedSpendParamsURL,
394
368
  outputParamsURL: updateOutputParamsURL
395
369
  )
@@ -409,7 +383,7 @@ public class Initializer {
409
383
  /// - Parameter seed: ZIP-32 Seed bytes for the wallet that will be initialized
410
384
  /// - Throws: `InitializerError.dataDbInitFailed` if the creation of the dataDb fails
411
385
  /// `InitializerError.accountInitFailed` if the account table can't be initialized.
412
- func initialize(with seed: [UInt8]?, walletBirthday: BlockHeight, for walletMode: WalletInitMode) async throws -> InitializationResult {
386
+ func initialize(with seed: [UInt8]?, viewingKeys: [UnifiedFullViewingKey], walletBirthday: BlockHeight) async throws -> InitializationResult {
413
387
  try await storage.create()
414
388
 
415
389
  if case .seedRequired = try await rustBackend.initDataDb(seed: seed) {
@@ -417,22 +391,27 @@ public class Initializer {
417
391
  }
418
392
 
419
393
  let checkpoint = Checkpoint.birthday(with: walletBirthday, network: network)
394
+ do {
395
+ try await rustBackend.initBlocksTable(
396
+ height: Int32(checkpoint.height),
397
+ hash: checkpoint.hash,
398
+ time: checkpoint.time,
399
+ saplingTree: checkpoint.saplingTree
400
+ )
401
+ } catch ZcashError.rustInitBlocksTableDataDbNotEmpty {
402
+ // this is fine
403
+ } catch {
404
+ throw error
405
+ }
420
406
 
421
407
  self.walletBirthday = checkpoint.height
422
-
423
- // If there are no accounts it must be created, the default amount of accounts is 1
424
- if let seed, try accountRepository.getAll().isEmpty {
425
- var chainTip: UInt32?
426
-
427
- if walletMode == .restoreWallet {
428
- chainTip = UInt32(try await lightWalletService.latestBlockHeight())
429
- }
430
-
431
- _ = try await rustBackend.createAccount(
432
- seed: seed,
433
- treeState: checkpoint.treeState(),
434
- recoverUntil: chainTip
435
- )
408
+
409
+ do {
410
+ try await rustBackend.initAccountsTable(ufvks: viewingKeys)
411
+ } catch ZcashError.rustInitAccountsTableDataDbNotEmpty {
412
+ // this is fine
413
+ } catch {
414
+ throw error
436
415
  }
437
416
 
438
417
  return .success
@@ -32,6 +32,9 @@ import Foundation
32
32
  /// We encourage you to check`SDKMetricsTests` and other tests in the Test/PerformanceTests/ folder.
33
33
  public class SDKMetrics {
34
34
  public struct BlockMetricReport: Equatable {
35
+ public let startHeight: BlockHeight
36
+ public let progressHeight: BlockHeight
37
+ public let targetHeight: BlockHeight
35
38
  public let batchSize: Int
36
39
  public let startTime: TimeInterval
37
40
  public let endTime: TimeInterval
@@ -40,6 +43,7 @@ public class SDKMetrics {
40
43
 
41
44
  public enum Operation {
42
45
  case downloadBlocks
46
+ case validateBlocks
43
47
  case scanBlocks
44
48
  case enhancement
45
49
  case fetchUTXOs
@@ -71,6 +75,7 @@ public class SDKMetrics {
71
75
  /// `SDKMetrics` focuses deeply on sync process and metrics related to it. By default there are reports around
72
76
  /// block operations like download, validate, etc. This method pushes data on a stack for the specific operation.
73
77
  func pushProgressReport(
78
+ progress: BlockProgress,
74
79
  start: Date,
75
80
  end: Date,
76
81
  batchSize: Int,
@@ -79,6 +84,9 @@ public class SDKMetrics {
79
84
  guard isEnabled else { return }
80
85
 
81
86
  let blockMetricReport = BlockMetricReport(
87
+ startHeight: progress.startHeight,
88
+ progressHeight: progress.progressHeight,
89
+ targetHeight: progress.targetHeight,
82
90
  batchSize: batchSize,
83
91
  startTime: start.timeIntervalSinceReferenceDate,
84
92
  endTime: end.timeIntervalSinceReferenceDate
@@ -150,6 +158,7 @@ public class SDKMetrics {
150
158
  extension SDKMetrics {
151
159
  public struct CumulativeSummary: Equatable {
152
160
  public let downloadedBlocksReport: ReportSummary?
161
+ public let validatedBlocksReport: ReportSummary?
153
162
  public let scannedBlocksReport: ReportSummary?
154
163
  public let enhancementReport: ReportSummary?
155
164
  public let fetchUTXOsReport: ReportSummary?
@@ -168,6 +177,7 @@ extension SDKMetrics {
168
177
  /// independently. A `ReportSummary` is the result per `operation`, providing min, max and avg times.
169
178
  public func cumulativeSummary() -> CumulativeSummary {
170
179
  let downloadReport = summaryFor(reports: reports[.downloadBlocks])
180
+ let validateReport = summaryFor(reports: reports[.validateBlocks])
171
181
  let scanReport = summaryFor(reports: reports[.scanBlocks])
172
182
  let enhancementReport = summaryFor(reports: reports[.enhancement])
173
183
  let fetchUTXOsReport = summaryFor(reports: reports[.fetchUTXOs])
@@ -179,6 +189,7 @@ extension SDKMetrics {
179
189
 
180
190
  return CumulativeSummary(
181
191
  downloadedBlocksReport: downloadReport,
192
+ validatedBlocksReport: validateReport,
182
193
  scannedBlocksReport: scanReport,
183
194
  enhancementReport: enhancementReport,
184
195
  fetchUTXOsReport: fetchUTXOsReport,
@@ -206,6 +217,7 @@ extension SDKMetrics {
206
217
  cumulativeSummaries.forEach { summary in
207
218
  finalSummary = CumulativeSummary(
208
219
  downloadedBlocksReport: accumulate(left: finalSummary?.downloadedBlocksReport, right: summary.downloadedBlocksReport),
220
+ validatedBlocksReport: accumulate(left: finalSummary?.validatedBlocksReport, right: summary.validatedBlocksReport),
209
221
  scannedBlocksReport: accumulate(left: finalSummary?.scannedBlocksReport, right: summary.scannedBlocksReport),
210
222
  enhancementReport: accumulate(left: finalSummary?.enhancementReport, right: summary.enhancementReport),
211
223
  fetchUTXOsReport: accumulate(left: finalSummary?.fetchUTXOsReport, right: summary.fetchUTXOsReport),
@@ -71,18 +71,6 @@ extension Checkpoint: Decodable {
71
71
  }
72
72
  return height
73
73
  }
74
-
75
- public func treeState() -> TreeState {
76
- var ret = TreeState()
77
- ret.height = UInt64(height)
78
- ret.hash = hash
79
- ret.time = time
80
- ret.saplingTree = saplingTree
81
- if let tree = orchardTree {
82
- ret.orchardTree = tree
83
- }
84
- return ret
85
- }
86
74
  }
87
75
 
88
76
  public extension BlockHeight {
@@ -262,21 +262,6 @@ extension LightWalletGRPCService: LightWalletService {
262
262
  }
263
263
  }
264
264
  }
265
-
266
- func getSubtreeRoots(_ request: GetSubtreeRootsArg) -> AsyncThrowingStream<SubtreeRoot, Error> {
267
- let stream = compactTxStreamer.getSubtreeRoots(request)
268
- var iterator = stream.makeAsyncIterator()
269
-
270
- return AsyncThrowingStream() {
271
- do {
272
- guard let subtreeRoot = try await iterator.next() else { return nil }
273
- return subtreeRoot
274
- } catch {
275
- let serviceError = error.mapToServiceError()
276
- throw ZcashError.serviceSubtreeRootsStreamFailed(serviceError)
277
- }
278
- }
279
- }
280
265
 
281
266
  func closeConnection() {
282
267
  _ = channel.close()