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
@@ -24,46 +24,6 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP
24
24
  typealias Version = _2
25
25
  }
26
26
 
27
- enum ShieldedProtocol: SwiftProtobuf.Enum {
28
- typealias RawValue = Int
29
- case sapling // = 0
30
- case orchard // = 1
31
- case UNRECOGNIZED(Int)
32
-
33
- init() {
34
- self = .sapling
35
- }
36
-
37
- init?(rawValue: Int) {
38
- switch rawValue {
39
- case 0: self = .sapling
40
- case 1: self = .orchard
41
- default: self = .UNRECOGNIZED(rawValue)
42
- }
43
- }
44
-
45
- var rawValue: Int {
46
- switch self {
47
- case .sapling: return 0
48
- case .orchard: return 1
49
- case .UNRECOGNIZED(let i): return i
50
- }
51
- }
52
-
53
- }
54
-
55
- #if swift(>=4.2)
56
-
57
- extension ShieldedProtocol: CaseIterable {
58
- // The compiler won't synthesize support with the UNRECOGNIZED case.
59
- static var allCases: [ShieldedProtocol] = [
60
- .sapling,
61
- .orchard,
62
- ]
63
- }
64
-
65
- #endif // swift(>=4.2)
66
-
67
27
  /// A BlockID message contains identifiers to select a block: a height or a
68
28
  /// hash. Specification by hash is not implemented, but may be in the future.
69
29
  struct BlockID {
@@ -144,7 +104,7 @@ struct TxFilter {
144
104
  fileprivate var _block: BlockID? = nil
145
105
  }
146
106
 
147
- /// RawTransaction contains the complete transaction data. It also optionally includes
107
+ /// RawTransaction contains the complete transaction data. It also optionally includes
148
108
  /// the block height in which the transaction was included, or, when returned
149
109
  /// by GetMempoolStream(), the latest block height.
150
110
  struct RawTransaction {
@@ -366,7 +326,6 @@ struct TreeState {
366
326
  /// "main" or "test"
367
327
  var network: String = String()
368
328
 
369
- /// block height
370
329
  var height: UInt64 = 0
371
330
 
372
331
  /// block id
@@ -376,48 +335,7 @@ struct TreeState {
376
335
  var time: UInt32 = 0
377
336
 
378
337
  /// sapling commitment tree state
379
- var saplingTree: String = String()
380
-
381
- /// orchard commitment tree state
382
- var orchardTree: String = String()
383
-
384
- var unknownFields = SwiftProtobuf.UnknownStorage()
385
-
386
- init() {}
387
- }
388
-
389
- struct GetSubtreeRootsArg {
390
- // SwiftProtobuf.Message conformance is added in an extension below. See the
391
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
392
- // methods supported on all messages.
393
-
394
- /// Index identifying where to start returning subtree roots
395
- var startIndex: UInt32 = 0
396
-
397
- /// Shielded protocol to return subtree roots for
398
- var shieldedProtocol: ShieldedProtocol = .sapling
399
-
400
- /// Maximum number of entries to return, or 0 for all entries.
401
- var maxEntries: UInt32 = 0
402
-
403
- var unknownFields = SwiftProtobuf.UnknownStorage()
404
-
405
- init() {}
406
- }
407
-
408
- struct SubtreeRoot {
409
- // SwiftProtobuf.Message conformance is added in an extension below. See the
410
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
411
- // methods supported on all messages.
412
-
413
- /// The 32-byte Merkle root of the subtree.
414
- var rootHash: Data = Data()
415
-
416
- /// The hash of the block that completed this subtree.
417
- var completingBlockHash: Data = Data()
418
-
419
- /// The height of the block that completed this subtree in the main chain.
420
- var completingBlockHeight: UInt64 = 0
338
+ var tree: String = String()
421
339
 
422
340
  var unknownFields = SwiftProtobuf.UnknownStorage()
423
341
 
@@ -478,7 +396,6 @@ struct GetAddressUtxosReplyList {
478
396
  }
479
397
 
480
398
  #if swift(>=5.5) && canImport(_Concurrency)
481
- extension ShieldedProtocol: @unchecked Sendable {}
482
399
  extension BlockID: @unchecked Sendable {}
483
400
  extension BlockRange: @unchecked Sendable {}
484
401
  extension TxFilter: @unchecked Sendable {}
@@ -495,8 +412,6 @@ extension AddressList: @unchecked Sendable {}
495
412
  extension Balance: @unchecked Sendable {}
496
413
  extension Exclude: @unchecked Sendable {}
497
414
  extension TreeState: @unchecked Sendable {}
498
- extension GetSubtreeRootsArg: @unchecked Sendable {}
499
- extension SubtreeRoot: @unchecked Sendable {}
500
415
  extension GetAddressUtxosArg: @unchecked Sendable {}
501
416
  extension GetAddressUtxosReply: @unchecked Sendable {}
502
417
  extension GetAddressUtxosReplyList: @unchecked Sendable {}
@@ -506,13 +421,6 @@ extension GetAddressUtxosReplyList: @unchecked Sendable {}
506
421
 
507
422
  fileprivate let _protobuf_package = "cash.z.wallet.sdk.rpc"
508
423
 
509
- extension ShieldedProtocol: SwiftProtobuf._ProtoNameProviding {
510
- static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
511
- 0: .same(proto: "sapling"),
512
- 1: .same(proto: "orchard"),
513
- ]
514
- }
515
-
516
424
  extension BlockID: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
517
425
  static let protoMessageName: String = _protobuf_package + ".BlockID"
518
426
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
@@ -1112,8 +1020,7 @@ extension TreeState: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation
1112
1020
  2: .same(proto: "height"),
1113
1021
  3: .same(proto: "hash"),
1114
1022
  4: .same(proto: "time"),
1115
- 5: .same(proto: "saplingTree"),
1116
- 6: .same(proto: "orchardTree"),
1023
+ 5: .same(proto: "tree"),
1117
1024
  ]
1118
1025
 
1119
1026
  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
@@ -1126,8 +1033,7 @@ extension TreeState: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation
1126
1033
  case 2: try { try decoder.decodeSingularUInt64Field(value: &self.height) }()
1127
1034
  case 3: try { try decoder.decodeSingularStringField(value: &self.hash) }()
1128
1035
  case 4: try { try decoder.decodeSingularUInt32Field(value: &self.time) }()
1129
- case 5: try { try decoder.decodeSingularStringField(value: &self.saplingTree) }()
1130
- case 6: try { try decoder.decodeSingularStringField(value: &self.orchardTree) }()
1036
+ case 5: try { try decoder.decodeSingularStringField(value: &self.tree) }()
1131
1037
  default: break
1132
1038
  }
1133
1039
  }
@@ -1146,11 +1052,8 @@ extension TreeState: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation
1146
1052
  if self.time != 0 {
1147
1053
  try visitor.visitSingularUInt32Field(value: self.time, fieldNumber: 4)
1148
1054
  }
1149
- if !self.saplingTree.isEmpty {
1150
- try visitor.visitSingularStringField(value: self.saplingTree, fieldNumber: 5)
1151
- }
1152
- if !self.orchardTree.isEmpty {
1153
- try visitor.visitSingularStringField(value: self.orchardTree, fieldNumber: 6)
1055
+ if !self.tree.isEmpty {
1056
+ try visitor.visitSingularStringField(value: self.tree, fieldNumber: 5)
1154
1057
  }
1155
1058
  try unknownFields.traverse(visitor: &visitor)
1156
1059
  }
@@ -1160,96 +1063,7 @@ extension TreeState: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation
1160
1063
  if lhs.height != rhs.height {return false}
1161
1064
  if lhs.hash != rhs.hash {return false}
1162
1065
  if lhs.time != rhs.time {return false}
1163
- if lhs.saplingTree != rhs.saplingTree {return false}
1164
- if lhs.orchardTree != rhs.orchardTree {return false}
1165
- if lhs.unknownFields != rhs.unknownFields {return false}
1166
- return true
1167
- }
1168
- }
1169
-
1170
- extension GetSubtreeRootsArg: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
1171
- static let protoMessageName: String = _protobuf_package + ".GetSubtreeRootsArg"
1172
- static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1173
- 1: .same(proto: "startIndex"),
1174
- 2: .same(proto: "shieldedProtocol"),
1175
- 3: .same(proto: "maxEntries"),
1176
- ]
1177
-
1178
- mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
1179
- while let fieldNumber = try decoder.nextFieldNumber() {
1180
- // The use of inline closures is to circumvent an issue where the compiler
1181
- // allocates stack space for every case branch when no optimizations are
1182
- // enabled. https://github.com/apple/swift-protobuf/issues/1034
1183
- switch fieldNumber {
1184
- case 1: try { try decoder.decodeSingularUInt32Field(value: &self.startIndex) }()
1185
- case 2: try { try decoder.decodeSingularEnumField(value: &self.shieldedProtocol) }()
1186
- case 3: try { try decoder.decodeSingularUInt32Field(value: &self.maxEntries) }()
1187
- default: break
1188
- }
1189
- }
1190
- }
1191
-
1192
- func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
1193
- if self.startIndex != 0 {
1194
- try visitor.visitSingularUInt32Field(value: self.startIndex, fieldNumber: 1)
1195
- }
1196
- if self.shieldedProtocol != .sapling {
1197
- try visitor.visitSingularEnumField(value: self.shieldedProtocol, fieldNumber: 2)
1198
- }
1199
- if self.maxEntries != 0 {
1200
- try visitor.visitSingularUInt32Field(value: self.maxEntries, fieldNumber: 3)
1201
- }
1202
- try unknownFields.traverse(visitor: &visitor)
1203
- }
1204
-
1205
- static func ==(lhs: GetSubtreeRootsArg, rhs: GetSubtreeRootsArg) -> Bool {
1206
- if lhs.startIndex != rhs.startIndex {return false}
1207
- if lhs.shieldedProtocol != rhs.shieldedProtocol {return false}
1208
- if lhs.maxEntries != rhs.maxEntries {return false}
1209
- if lhs.unknownFields != rhs.unknownFields {return false}
1210
- return true
1211
- }
1212
- }
1213
-
1214
- extension SubtreeRoot: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
1215
- static let protoMessageName: String = _protobuf_package + ".SubtreeRoot"
1216
- static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1217
- 2: .same(proto: "rootHash"),
1218
- 3: .same(proto: "completingBlockHash"),
1219
- 4: .same(proto: "completingBlockHeight"),
1220
- ]
1221
-
1222
- mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
1223
- while let fieldNumber = try decoder.nextFieldNumber() {
1224
- // The use of inline closures is to circumvent an issue where the compiler
1225
- // allocates stack space for every case branch when no optimizations are
1226
- // enabled. https://github.com/apple/swift-protobuf/issues/1034
1227
- switch fieldNumber {
1228
- case 2: try { try decoder.decodeSingularBytesField(value: &self.rootHash) }()
1229
- case 3: try { try decoder.decodeSingularBytesField(value: &self.completingBlockHash) }()
1230
- case 4: try { try decoder.decodeSingularUInt64Field(value: &self.completingBlockHeight) }()
1231
- default: break
1232
- }
1233
- }
1234
- }
1235
-
1236
- func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
1237
- if !self.rootHash.isEmpty {
1238
- try visitor.visitSingularBytesField(value: self.rootHash, fieldNumber: 2)
1239
- }
1240
- if !self.completingBlockHash.isEmpty {
1241
- try visitor.visitSingularBytesField(value: self.completingBlockHash, fieldNumber: 3)
1242
- }
1243
- if self.completingBlockHeight != 0 {
1244
- try visitor.visitSingularUInt64Field(value: self.completingBlockHeight, fieldNumber: 4)
1245
- }
1246
- try unknownFields.traverse(visitor: &visitor)
1247
- }
1248
-
1249
- static func ==(lhs: SubtreeRoot, rhs: SubtreeRoot) -> Bool {
1250
- if lhs.rootHash != rhs.rootHash {return false}
1251
- if lhs.completingBlockHash != rhs.completingBlockHash {return false}
1252
- if lhs.completingBlockHeight != rhs.completingBlockHeight {return false}
1066
+ if lhs.tree != rhs.tree {return false}
1253
1067
  if lhs.unknownFields != rhs.unknownFields {return false}
1254
1068
  return true
1255
1069
  }
@@ -180,7 +180,6 @@ protocol LightWalletService: AnyObject {
180
180
  func fetchTransaction(txId: Data) async throws -> ZcashTransaction.Fetched
181
181
 
182
182
  /// - Throws: `serviceFetchUTXOsFailed` when GRPC call fails.
183
- // sourcery: mockedName="fetchUTXOsSingle"
184
183
  func fetchUTXOs(for tAddress: String, height: BlockHeight) -> AsyncThrowingStream<UnspentTransactionOutputEntity, Error>
185
184
 
186
185
  /// - Throws: `serviceFetchUTXOsFailed` when GRPC call fails.
@@ -193,11 +192,4 @@ protocol LightWalletService: AnyObject {
193
192
  ) -> AsyncThrowingStream<ZcashCompactBlock, Error>
194
193
 
195
194
  func closeConnection()
196
-
197
- /// Returns a stream of information about roots of subtrees of the Sapling and Orchard
198
- /// note commitment trees.
199
- ///
200
- /// - Parameters:
201
- /// - request: Request to send to GetSubtreeRoots.
202
- func getSubtreeRoots(_ request: GetSubtreeRootsArg) -> AsyncThrowingStream<SubtreeRoot, Error>
203
195
  }
@@ -8,52 +8,62 @@
8
8
  import Foundation
9
9
 
10
10
  protocol LatestBlocksDataProvider {
11
- var fullyScannedHeight: BlockHeight { get async }
12
- var maxScannedHeight: BlockHeight { get async }
11
+ var latestScannedHeight: BlockHeight { get async }
12
+ var latestScannedTime: TimeInterval { get async }
13
13
  var latestBlockHeight: BlockHeight { get async }
14
14
  var walletBirthday: BlockHeight { get async }
15
15
 
16
16
  func updateScannedData() async
17
17
  func updateBlockData() async
18
18
  func updateWalletBirthday(_ walletBirthday: BlockHeight) async
19
- func update(_ latestBlockHeight: BlockHeight) async
19
+ func updateLatestScannedHeight(_ latestScannedHeight: BlockHeight) async
20
+ func updateLatestScannedTime(_ latestScannedTime: TimeInterval) async
20
21
  }
21
22
 
22
23
  actor LatestBlocksDataProviderImpl: LatestBlocksDataProvider {
23
24
  let service: LightWalletService
24
- let rustBackend: ZcashRustBackendWelding
25
+ let transactionRepository: TransactionRepository
25
26
 
26
27
  // Valid values are stored here after Synchronizer's `prepare` is called.
27
- private(set) var fullyScannedHeight: BlockHeight = .zero
28
- private(set) var maxScannedHeight: BlockHeight = .zero
28
+ private(set) var latestScannedHeight: BlockHeight = .zero
29
+ private(set) var latestScannedTime: TimeInterval = 0.0
29
30
  // Valid value is stored here after block processor's `nextState` is called.
30
31
  private(set) var latestBlockHeight: BlockHeight = .zero
31
32
  // Valid values are stored here after Synchronizer's `prepare` is called.
32
33
  private(set) var walletBirthday: BlockHeight = .zero
33
34
 
34
- init(service: LightWalletService, rustBackend: ZcashRustBackendWelding) {
35
+ init(service: LightWalletService, transactionRepository: TransactionRepository) {
35
36
  self.service = service
36
- self.rustBackend = rustBackend
37
+ self.transactionRepository = transactionRepository
37
38
  }
38
39
 
40
+ /// Call of this function is potentially dangerous and can result in `database lock` errors.
41
+ /// Typical use is outside of a sync process. Example: Synchronizer's prepare function, call there is a safe one.
42
+ /// The update of `latestScannedHeight` and `latestScannedTime` during the syncing is done via
43
+ /// appropriate `updateX()` methods inside `BlockScanner` so `transactionRepository` is omitted.
39
44
  func updateScannedData() async {
40
- fullyScannedHeight = (try? await rustBackend.fullyScannedHeight()) ?? walletBirthday
41
- maxScannedHeight = (try? await rustBackend.maxScannedHeight()) ?? walletBirthday
45
+ latestScannedHeight = (try? await transactionRepository.lastScannedHeight()) ?? walletBirthday
46
+ if let time = try? await transactionRepository.blockForHeight(latestScannedHeight)?.time {
47
+ latestScannedTime = TimeInterval(time)
48
+ }
42
49
  }
43
-
50
+
44
51
  func updateBlockData() async {
45
- if let newLatestBlockHeight = try? await service.latestBlockHeight() {
46
- await update(newLatestBlockHeight)
52
+ if let newLatestBlockHeight = try? await service.latestBlockHeight(),
53
+ latestBlockHeight < newLatestBlockHeight {
54
+ latestBlockHeight = newLatestBlockHeight
47
55
  }
48
56
  }
49
-
57
+
50
58
  func updateWalletBirthday(_ walletBirthday: BlockHeight) async {
51
59
  self.walletBirthday = walletBirthday
52
60
  }
53
61
 
54
- func update(_ newLatestBlockHeight: BlockHeight) async {
55
- if latestBlockHeight < newLatestBlockHeight {
56
- latestBlockHeight = newLatestBlockHeight
57
- }
62
+ func updateLatestScannedHeight(_ latestScannedHeight: BlockHeight) async {
63
+ self.latestScannedHeight = latestScannedHeight
64
+ }
65
+
66
+ func updateLatestScannedTime(_ latestScannedTime: TimeInterval) async {
67
+ self.latestScannedTime = latestScannedTime
58
68
  }
59
69
  }
@@ -15,7 +15,7 @@ protocol CompactBlockRepository {
15
15
  /**
16
16
  Gets the height of the highest block that is currently stored.
17
17
  */
18
- func latestHeight() async throws -> BlockHeight
18
+ func latestHeight() async -> BlockHeight
19
19
 
20
20
  /**
21
21
  Write the given blocks to this store, which may be anything from an in-memory cache to a DB.
@@ -11,7 +11,11 @@ protocol TransactionRepository {
11
11
  func closeDBConnection()
12
12
  func countAll() async throws -> Int
13
13
  func countUnmined() async throws -> Int
14
+ func blockForHeight(_ height: BlockHeight) async throws -> Block?
15
+ func lastScannedHeight() async throws -> BlockHeight
16
+ func lastScannedBlock() async throws -> Block?
14
17
  func isInitialized() async throws -> Bool
18
+ func find(id: Int) async throws -> ZcashTransaction.Overview
15
19
  func find(rawID: Data) async throws -> ZcashTransaction.Overview
16
20
  func find(offset: Int, limit: Int, kind: TransactionKind) async throws -> [ZcashTransaction.Overview]
17
21
  func find(in range: CompactBlockRange, limit: Int, kind: TransactionKind) async throws -> [ZcashTransaction.Overview]
@@ -20,6 +24,6 @@ protocol TransactionRepository {
20
24
  func findReceived(offset: Int, limit: Int) async throws -> [ZcashTransaction.Overview]
21
25
  func findSent(offset: Int, limit: Int) async throws -> [ZcashTransaction.Overview]
22
26
  func findMemos(for transaction: ZcashTransaction.Overview) async throws -> [Memo]
23
- func getRecipients(for rawID: Data) async throws -> [TransactionRecipient]
24
- func getTransactionOutputs(for rawID: Data) async throws -> [ZcashTransaction.Output]
27
+ func getRecipients(for id: Int) async throws -> [TransactionRecipient]
28
+ func getTransactionOutputs(for id: Int) async throws -> [ZcashTransaction.Output]
25
29
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "network": "main",
3
+ "height": "2460000",
4
+ "hash": "0000000000a80564b9debb0924e78c72e71219113926631b18247182df16d0e1",
5
+ "time": 1712280596,
6
+ "saplingTree": "014219aac068b520e9bb0875efaf8f6b9d4b5cb87cbe436a3eb7dd1c6aadd25872013cffa5b64a9f7cf9d88d75c0335a76c2a7cc36970e33a5e4c14928dd0122f3241a00014b8c1f93bc144b0e9a4f4e993032a6594df6be5c46da8cebb4d79680c9a9df29000000018755b473c246b7ffed524cf0f847f64881e0a8c328b8a9c2a306d8e757b0f12101e1c12dc145c0ac8887a1972db6d116aeb2aec56b74fd2d1512ddf110e08fd53000000189e127b6ffb369c16447e4f812ec20a50df4446ebdea3d1b5f998f3da3b62616000001067187080be7f0b7273e4331b7505d7c985974c9c461fa602d80cc999289432501e3644c42c5d7ecd832a2c662dcd397824930ebe37b37bc61ec5af84f724c2571000132c525343fc4ebe79ab6515e9d9fceb916d920394bad5926a1afe7f46badef420001d1b36bbba8e6e1be8f09baf2b829bafc4ccd89ad25fb730d2b8a995b60fc3a6701d8ccea507421a590ed38116b834189cdc22421b4764179fa4e364803dfa66d56018cf6f5034a55fed59d1d832620916a43c756d2379e50ef9440fc4c3e7a29aa2300011619f99023a69bb647eab2d2aa1a73c3673c74bb033c3c4930eacda19e6fd93b0000000160272b134ca494b602137d89e528c751c06d3ef4a87a45f33af343c15060cc1e",
7
+ "orchardTree": "01fb149d0df15c527e6835fb5d390cbeda1f145d686f65122265ce135189c1572f001f016b7b5ab212d482bd440dc01b56a8ddb971f47977cd20a19fceed6ac80e5f562a0108312ad01321d0add9aaf53c53ffddd7517d26abecfb7abbf38f5e9619e8573a01442421c12b4765419f3fa597869b0796d67f10d71bbeb268d779840984b11f1d01aabedb668b408751bf9aecbcf1fbc01b20422ebc854ce2ff46f44f4afb7dd11d0115c625f23c8821eead1f11c18262b58febe7d93acba6ce1f7909c611a0de7f1a000001bb42696ce5ace721acb713867320296bbb729d697610d9525bec9f5864f1d20a00000000000001be7e4675134c4441539879962acf4c9ce2523471c82f11a2bfe90d910e5ac11901d386508c9fabdc60836bfe3c7251fcbdd4617180a804d40fa29dc25fb9c0aa3401cf3bf92f69798e68555548afcce1648add1fb2548d64fa9a1ec22a3e26e7890101e637281deb58dff0c44ba13149b784a95da1b493005efd057e6f4ac20ef5d81d000001cc2dcaa338b312112db04b435a706d63244dd435238f0aa1e9e1598d35470810012dcc4273c8a0ed2337ecf7879380a07e7d427c7f9d82e538002bd1442978402c01daf63debf5b40df902dae98dadc029f281474d190cddecef1b10653248a234150001e2bca6a8d987d668defba89dc082196a922634ed88e065c669e526bb8815ee1b000000000000"
8
+ }