react-native-zcash 0.4.2 → 0.6.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 (157) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +6 -3
  3. package/android/build.gradle +5 -4
  4. package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/2230000.json +8 -0
  5. package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/2240000.json +8 -0
  6. package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/2250000.json +8 -0
  7. package/android/src/main/java/app/edge/rnzcash/RNZcashModule.kt +117 -122
  8. package/ios/RNZcash.m +1 -12
  9. package/ios/RNZcash.swift +127 -153
  10. package/ios/ZCashLightClientKit/Block/Actions/Action.swift +98 -0
  11. package/ios/ZCashLightClientKit/Block/Actions/ClearAlreadyScannedBlocksAction.swift +35 -0
  12. package/ios/ZCashLightClientKit/Block/Actions/ClearCacheAction.swift +30 -0
  13. package/ios/ZCashLightClientKit/Block/Actions/DownloadAction.swift +67 -0
  14. package/ios/ZCashLightClientKit/Block/Actions/EnhanceAction.swift +97 -0
  15. package/ios/ZCashLightClientKit/Block/Actions/FetchUTXOsAction.swift +33 -0
  16. package/ios/ZCashLightClientKit/Block/Actions/MigrateLegacyCacheDBAction.swift +70 -0
  17. package/ios/ZCashLightClientKit/Block/Actions/ProcessSuggestedScanRangesAction.swift +59 -0
  18. package/ios/ZCashLightClientKit/Block/Actions/RewindAction.swift +48 -0
  19. package/ios/ZCashLightClientKit/Block/Actions/SaplingParamsAction.swift +33 -0
  20. package/ios/ZCashLightClientKit/Block/Actions/ScanAction.swift +95 -0
  21. package/ios/ZCashLightClientKit/Block/Actions/UpdateChainTipAction.swift +55 -0
  22. package/ios/ZCashLightClientKit/Block/Actions/UpdateSubtreeRootsAction.swift +58 -0
  23. package/ios/ZCashLightClientKit/Block/Actions/ValidateServerAction.swift +60 -0
  24. package/ios/ZCashLightClientKit/Block/CompactBlockProcessor.swift +421 -937
  25. package/ios/ZCashLightClientKit/Block/Download/BlockDownloader.swift +31 -17
  26. package/ios/ZCashLightClientKit/Block/Download/BlockDownloaderService.swift +2 -2
  27. package/ios/ZCashLightClientKit/Block/Enhance/BlockEnhancer.swift +46 -15
  28. package/ios/ZCashLightClientKit/Block/FetchUnspentTxOutputs/UTXOFetcher.swift +4 -15
  29. package/ios/ZCashLightClientKit/Block/FilesystemStorage/FSCompactBlockRepository.swift +4 -4
  30. package/ios/ZCashLightClientKit/Block/Scan/BlockScanner.swift +10 -35
  31. package/ios/ZCashLightClientKit/Block/Utils/CompactBlockProgress.swift +24 -0
  32. package/ios/ZCashLightClientKit/Block/Utils/SyncControlData.swift +25 -0
  33. package/ios/ZCashLightClientKit/ClosureSynchronizer.swift +1 -2
  34. package/ios/ZCashLightClientKit/CombineSynchronizer.swift +2 -5
  35. package/ios/ZCashLightClientKit/Constants/ZcashSDK.swift +7 -25
  36. package/ios/ZCashLightClientKit/DAO/TransactionDao.swift +40 -42
  37. package/ios/ZCashLightClientKit/DAO/UnspentTransactionOutputDao.swift +13 -4
  38. package/ios/ZCashLightClientKit/Entity/AccountEntity.swift +9 -0
  39. package/ios/ZCashLightClientKit/Entity/TransactionEntity.swift +7 -10
  40. package/ios/ZCashLightClientKit/Error/Sourcery/generateErrorCode.sh +1 -1
  41. package/ios/ZCashLightClientKit/Error/ZcashError.swift +121 -12
  42. package/ios/ZCashLightClientKit/Error/ZcashErrorCode.swift +43 -5
  43. package/ios/ZCashLightClientKit/Error/ZcashErrorCodeDefinition.swift +72 -6
  44. package/ios/ZCashLightClientKit/Extensions/Bool+ToData.swift +15 -0
  45. package/ios/ZCashLightClientKit/Extensions/Data+ToOtherTypes.swift +18 -0
  46. package/ios/ZCashLightClientKit/Extensions/Int+ToData.swift +15 -0
  47. package/ios/ZCashLightClientKit/Initializer.swift +47 -26
  48. package/ios/ZCashLightClientKit/Metrics/SDKMetrics.swift +0 -12
  49. package/ios/ZCashLightClientKit/Model/Checkpoint.swift +12 -0
  50. package/ios/ZCashLightClientKit/Model/ScanProgress.swift +29 -0
  51. package/ios/ZCashLightClientKit/Model/ScanRange.swift +31 -0
  52. package/ios/ZCashLightClientKit/Modules/Service/GRPC/LightWalletGRPCService.swift +15 -0
  53. package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/compact_formats.pb.swift +150 -46
  54. package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/proto/compact_formats.proto +30 -16
  55. package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/proto/service.proto +32 -6
  56. package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/service.grpc.swift +259 -22
  57. package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/service.pb.swift +193 -7
  58. package/ios/ZCashLightClientKit/Modules/Service/LightWalletService.swift +8 -0
  59. package/ios/ZCashLightClientKit/Providers/LatestBlocksDataProvider.swift +18 -28
  60. package/ios/ZCashLightClientKit/Repository/CompactBlockRepository.swift +1 -1
  61. package/ios/ZCashLightClientKit/Repository/TransactionRepository.swift +2 -6
  62. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2092500.json +8 -0
  63. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2095000.json +8 -0
  64. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2097500.json +8 -0
  65. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2102500.json +8 -0
  66. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2105000.json +8 -0
  67. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2107500.json +8 -0
  68. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2112500.json +8 -0
  69. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2115000.json +8 -0
  70. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2117500.json +8 -0
  71. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2122500.json +8 -0
  72. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2125000.json +8 -0
  73. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2127500.json +8 -0
  74. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2132500.json +8 -0
  75. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2135000.json +8 -0
  76. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2137500.json +8 -0
  77. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2142500.json +8 -0
  78. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2145000.json +8 -0
  79. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2147500.json +8 -0
  80. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2152500.json +8 -0
  81. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2155000.json +8 -0
  82. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2157500.json +8 -0
  83. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2162500.json +8 -0
  84. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2165000.json +8 -0
  85. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2167500.json +8 -0
  86. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2172500.json +8 -0
  87. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2175000.json +8 -0
  88. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2177500.json +8 -0
  89. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2182500.json +8 -0
  90. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2185000.json +8 -0
  91. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2187500.json +8 -0
  92. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2192500.json +8 -0
  93. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2195000.json +8 -0
  94. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2197500.json +8 -0
  95. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2202500.json +8 -0
  96. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2205000.json +8 -0
  97. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2207500.json +8 -0
  98. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2212500.json +8 -0
  99. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2215000.json +8 -0
  100. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2217500.json +8 -0
  101. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2222500.json +8 -0
  102. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2225000.json +8 -0
  103. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2227500.json +8 -0
  104. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2230000.json +8 -0
  105. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2232500.json +8 -0
  106. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2235000.json +8 -0
  107. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2237500.json +8 -0
  108. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2240000.json +8 -0
  109. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2242500.json +8 -0
  110. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2245000.json +8 -0
  111. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2247500.json +8 -0
  112. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2250000.json +8 -0
  113. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2350000.json +8 -0
  114. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2360000.json +8 -0
  115. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2370000.json +8 -0
  116. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2380000.json +8 -0
  117. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2390000.json +8 -0
  118. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2400000.json +8 -0
  119. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2410000.json +8 -0
  120. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2420000.json +8 -0
  121. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2430000.json +8 -0
  122. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2440000.json +8 -0
  123. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2450000.json +8 -0
  124. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2460000.json +8 -0
  125. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2470000.json +8 -0
  126. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2480000.json +8 -0
  127. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2490000.json +8 -0
  128. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2500000.json +8 -0
  129. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2510000.json +8 -0
  130. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2520000.json +8 -0
  131. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2530000.json +8 -0
  132. package/ios/ZCashLightClientKit/Rust/ZcashRustBackend.swift +293 -158
  133. package/ios/ZCashLightClientKit/Rust/ZcashRustBackendWelding.swift +58 -64
  134. package/ios/ZCashLightClientKit/Rust/zcashlc.h +618 -512
  135. package/ios/ZCashLightClientKit/Synchronizer/ClosureSDKSynchronizer.swift +2 -8
  136. package/ios/ZCashLightClientKit/Synchronizer/CombineSDKSynchronizer.swift +3 -15
  137. package/ios/ZCashLightClientKit/Synchronizer/Dependencies.swift +11 -30
  138. package/ios/ZCashLightClientKit/Synchronizer/SDKSynchronizer.swift +41 -50
  139. package/ios/ZCashLightClientKit/Synchronizer.swift +51 -65
  140. package/ios/ZCashLightClientKit/Transaction/TransactionEncoder.swift +2 -2
  141. package/ios/ZCashLightClientKit/Transaction/WalletTransactionEncoder.swift +7 -7
  142. package/ios/ZCashLightClientKit/Utils/OSLogger.swift +3 -3
  143. package/ios/ZCashLightClientKit/Utils/ZcashFileManager.swift +16 -0
  144. package/ios/libzcashlc.xcframework/Info.plist +9 -5
  145. package/ios/libzcashlc.xcframework/ios-arm64/libzcashlc.a +0 -0
  146. package/ios/libzcashlc.xcframework/ios-arm64_x86_64-simulator/libzcashlc.a +0 -0
  147. package/lib/rnzcash.rn.js +8 -30
  148. package/lib/rnzcash.rn.js.map +1 -1
  149. package/lib/src/react-native.d.ts +3 -5
  150. package/lib/src/types.d.ts +19 -14
  151. package/package.json +1 -1
  152. package/src/react-native.ts +13 -21
  153. package/src/types.ts +26 -23
  154. package/ios/ZCashLightClientKit/Block/Utils/InternalSyncProgress.swift +0 -200
  155. package/ios/ZCashLightClientKit/Block/Validate/BlockValidator.swift +0 -51
  156. package/ios/ZCashLightClientKit/DAO/BlockDao.swift +0 -112
  157. package/ios/ZCashLightClientKit/Entity/BlockProgress.swift +0 -24
@@ -35,9 +35,11 @@ protocol ZcashRustBackendWelding {
35
35
  /// have been received by the currently-available account (in order to enable
36
36
  /// automated account recovery).
37
37
  /// - parameter seed: byte array of the zip32 seed
38
+ /// - parameter treeState: The TreeState Protobuf object for the height prior to the account birthday
39
+ /// - parameter recoverUntil: the fully-scanned height up to which the account will be treated as "being recovered"
38
40
  /// - Returns: The `UnifiedSpendingKey` structs for the number of accounts created
39
41
  /// - Throws: `rustCreateAccount`.
40
- func createAccount(seed: [UInt8]) async throws -> UnifiedSpendingKey
42
+ func createAccount(seed: [UInt8], treeState: TreeState, recoverUntil: UInt32?) async throws -> UnifiedSpendingKey
41
43
 
42
44
  /// Creates a transaction to the given address from the given account
43
45
  /// - Parameter usk: `UnifiedSpendingKey` for the account that controls the funds to be spent.
@@ -50,7 +52,7 @@ protocol ZcashRustBackendWelding {
50
52
  to address: String,
51
53
  value: Int64,
52
54
  memo: MemoBytes?
53
- ) async throws -> Int64
55
+ ) async throws -> Data
54
56
 
55
57
  /// Scans a transaction for any information that can be decrypted by the accounts in the wallet, and saves it to the wallet.
56
58
  /// - parameter tx: the transaction to decrypt
@@ -89,14 +91,10 @@ protocol ZcashRustBackendWelding {
89
91
  /// - `rustGetNextAvailableAddressInvalidAddress` if generated unified address isn't valid.
90
92
  func getNextAvailableAddress(account: Int32) async throws -> UnifiedAddress
91
93
 
92
- /// Get received memo from note.
93
- /// - parameter idNote: note_id of note where the memo is located
94
- func getReceivedMemo(idNote: Int64) async -> Memo?
95
-
96
- /// Get sent memo from note.
97
- /// - parameter idNote: note_id of note where the memo is located
98
- /// - Returns: a `Memo` if any
99
- func getSentMemo(idNote: Int64) async -> Memo?
94
+ /// Get memo from note.
95
+ /// - parameter txId: ID of transaction containing the note
96
+ /// - parameter outputIndex: output index of note
97
+ func getMemo(txId: Data, outputIndex: UInt16) async throws -> Memo?
100
98
 
101
99
  /// Get the verified cached transparent balance for the given address
102
100
  /// - parameter account; the account index to query
@@ -105,14 +103,6 @@ protocol ZcashRustBackendWelding {
105
103
  /// - `rustGetTransparentBalance` if rust layer returns error.
106
104
  func getTransparentBalance(account: Int32) async throws -> Int64
107
105
 
108
- /// Initialize the accounts table from a set of unified full viewing keys.
109
- /// - Note: this function should only be used when restoring an existing seed phrase. when creating a new wallet, use `createAccount()` instead.
110
- /// - Parameter ufvks: an array of UnifiedFullViewingKeys
111
- /// - Throws:
112
- /// - `rustInitAccountsTableViewingKeyCotainsNullBytes` if any of the key in `ufvks` contains null bytes before end.
113
- /// - `rustInitAccountsTableViewingKeyIsInvalid` if any of the key in `ufvks` isn't valid.
114
- func initAccountsTable(ufvks: [UnifiedFullViewingKey]) async throws
115
-
116
106
  /// Initializes the data db. This will performs any migrations needed on the sqlite file
117
107
  /// provided. Some migrations might need that callers provide the seed bytes.
118
108
  /// - Parameter seed: ZIP-32 compliant seed bytes for this wallet
@@ -122,23 +112,6 @@ protocol ZcashRustBackendWelding {
122
112
  /// Throws `rustInitDataDb` if rust layer returns error.
123
113
  func initDataDb(seed: [UInt8]?) async throws -> DbInitResult
124
114
 
125
- /// Initialize the blocks table from a given checkpoint (heigh, hash, time, saplingTree and networkType).
126
- /// - parameter height: represents the block height of the given checkpoint
127
- /// - parameter hash: hash of the merkle tree
128
- /// - parameter time: in milliseconds from reference
129
- /// - parameter saplingTree: hash of the sapling tree
130
- /// - Throws:
131
- /// - `rustInitBlocksTableHashContainsNullBytes` if `hash` contains null bytes before end.
132
- /// - `rustInitBlocksTableSaplingTreeContainsNullBytes` if `saplingTree` contains null bytes before end.
133
- /// - `rustInitBlocksTableDataDbNotEmpty` if data DB is not empty.
134
- /// - `rustInitBlocksTable` if rust layer returns error.
135
- func initBlocksTable(
136
- height: Int32,
137
- hash: String,
138
- time: UInt32,
139
- saplingTree: String
140
- ) async throws
141
-
142
115
  /// Returns a list of the transparent receivers for the diversified unified addresses that have
143
116
  /// been allocated for the provided account.
144
117
  /// - parameter account: index of the given account
@@ -159,26 +132,6 @@ protocol ZcashRustBackendWelding {
159
132
  /// - `rustGetVerifiedTransparentBalance` if rust layer returns error.
160
133
  func getVerifiedTransparentBalance(account: Int32) async throws -> Int64
161
134
 
162
- /// Checks that the scanned blocks in the data database, when combined with the recent
163
- /// `CompactBlock`s in the cache database, form a valid chain.
164
- /// This function is built on the core assumption that the information provided in the
165
- /// cache database is more likely to be accurate than the previously-scanned information.
166
- /// This follows from the design (and trust) assumption that the `lightwalletd` server
167
- /// provides accurate block information as of the time it was requested.
168
- /// - parameter fsBlockDbRoot: `URL` pointing to the filesystem root directory where the fsBlock cache is.
169
- /// this directory is expected to contain a `/blocks` sub-directory with the blocks stored in the convened filename
170
- /// format `{height}-{hash}-block`. This directory has must be granted both write and read permissions.
171
- /// - parameter dbData: location of the data db file
172
- /// - parameter networkType: the network type
173
- /// - parameter limit: a limit to validate a fixed number of blocks instead of the whole cache.
174
- /// - Throws:
175
- /// - `rustValidateCombinedChainValidationFailed` if there was an error during validation unrelated to chain validity.
176
- /// - `rustValidateCombinedChainInvalidChain(upperBound)` if the combined chain is invalid. `upperBound` is the height of the highest invalid
177
- /// block(on the assumption that the highest block in the cache database is correct).
178
- ///
179
- /// - Important: This function does not mutate either of the databases.
180
- func validateCombinedChain(limit: UInt32) async throws
181
-
182
135
  /// Resets the state of the database to only contain block and transaction information up to the given height. clears up all derived data as well
183
136
  /// - parameter height: height to rewind to.
184
137
  /// - Throws: `rustRewindToHeight` if rust layer returns error.
@@ -190,21 +143,62 @@ protocol ZcashRustBackendWelding {
190
143
  /// - Throws: `rustRewindCacheToHeight` if rust layer returns error.
191
144
  func rewindCacheToHeight(height: Int32) async throws
192
145
 
146
+ func putSaplingSubtreeRoots(startIndex: UInt64, roots: [SubtreeRoot]) async throws
147
+
148
+ /// Updates the wallet's view of the blockchain.
149
+ ///
150
+ /// This method is used to provide the wallet with information about the state of the blockchain,
151
+ /// and detect any previously scanned data that needs to be re-validated before proceeding with
152
+ /// scanning. It should be called at wallet startup prior to calling `suggestScanRanges`
153
+ /// in order to provide the wallet with the information it needs to correctly prioritize scanning
154
+ /// operations.
155
+ func updateChainTip(height: Int32) async throws
156
+
157
+ /// Returns the height to which the wallet has been fully scanned.
158
+ ///
159
+ /// This is the height for which the wallet has fully trial-decrypted this and all
160
+ /// preceding blocks beginning with the wallet's birthday height.
161
+ func fullyScannedHeight() async throws -> BlockHeight?
162
+
163
+ /// Returns the maximum height that the wallet has scanned.
164
+ ///
165
+ /// If the wallet is fully synced, this will be equivalent to `fullyScannedHeight`;
166
+ /// otherwise the maximal scanned height is likely to be greater than the fully scanned
167
+ /// height due to the fact that out-of-order scanning can leave gaps.
168
+ func maxScannedHeight() async throws -> BlockHeight?
169
+
170
+ /// Returns the scan progress derived from the current wallet state.
171
+ func getScanProgress() async throws -> ScanProgress?
172
+
173
+ /// Returns a list of suggested scan ranges based upon the current wallet state.
174
+ ///
175
+ /// This method should only be used in cases where the `CompactBlock` data that will be
176
+ /// made available to `scanBlocks` for the requested block ranges includes note
177
+ /// commitment tree size information for each block; or else the scan is likely to fail if
178
+ /// notes belonging to the wallet are detected.
179
+ func suggestScanRanges() async throws -> [ScanRange]
180
+
193
181
  /// Scans new blocks added to the cache for any transactions received by the tracked
194
- /// accounts.
195
- /// This function pays attention only to cached blocks with heights greater than the
196
- /// highest scanned block in `db_data`. Cached blocks with lower heights are not verified
197
- /// against previously-scanned blocks. In particular, this function **assumes** that the
198
- /// caller is handling rollbacks.
182
+ /// accounts, while checking that they form a valid chan.
183
+ ///
184
+ /// This function is built on the core assumption that the information provided in the
185
+ /// block cache is more likely to be accurate than the previously-scanned information.
186
+ /// This follows from the design (and trust) assumption that the `lightwalletd` server
187
+ /// provides accurate block information as of the time it was requested.
188
+ ///
189
+ /// This function **assumes** that the caller is handling rollbacks.
190
+ ///
199
191
  /// For brand-new light client databases, this function starts scanning from the Sapling
200
192
  /// activation height. This height can be fast-forwarded to a more recent block by calling
201
193
  /// [`initBlocksTable`] before this function.
194
+ ///
202
195
  /// Scanned blocks are required to be height-sequential. If a block is missing from the
203
196
  /// cache, an error will be signalled.
204
197
  ///
205
- /// - parameter limit: scan up to limit blocks. pass 0 to set no limit.
198
+ /// - parameter fromHeight: scan starting from the given height.
199
+ /// - parameter limit: scan up to limit blocks.
206
200
  /// - Throws: `rustScanBlocks` if rust layer returns error.
207
- func scanBlocks(limit: UInt32) async throws
201
+ func scanBlocks(fromHeight: Int32, limit: UInt32) async throws
208
202
 
209
203
  /// Upserts a UTXO into the data db database
210
204
  /// - parameter txid: the txid bytes for the UTXO
@@ -229,7 +223,7 @@ protocol ZcashRustBackendWelding {
229
223
  usk: UnifiedSpendingKey,
230
224
  memo: MemoBytes?,
231
225
  shieldingThreshold: Zatoshi
232
- ) async throws -> Int64
226
+ ) async throws -> Data
233
227
 
234
228
  /// Gets the consensus branch id for the given height
235
229
  /// - Parameter height: the height you what to know the branch id for
@@ -252,5 +246,5 @@ protocol ZcashRustBackendWelding {
252
246
  /// this directory is expected to contain a `/blocks` sub-directory with the blocks stored in the convened filename
253
247
  /// format `{height}-{hash}-block`. This directory has must be granted both write and read permissions.
254
248
  /// - Returns `BlockHeight` of the latest cached block or `.empty` if no blocks are stored.
255
- func latestCachedBlockHeight() async -> BlockHeight
249
+ func latestCachedBlockHeight() async throws -> BlockHeight
256
250
  }