react-native-zcash 0.6.14 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -0
- package/android/build.gradle +4 -4
- package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/2470000.json +8 -0
- package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/2480000.json +8 -0
- package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/2490000.json +8 -0
- package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/2500000.json +8 -0
- package/android/src/main/java/app/edge/rnzcash/RNZcashModule.kt +51 -9
- package/ios/RNZcash.m +8 -0
- package/ios/RNZcash.swift +66 -16
- package/ios/ZCashLightClientKit/Block/Actions/DownloadAction.swift +1 -1
- package/ios/ZCashLightClientKit/Block/Actions/EnhanceAction.swift +3 -1
- package/ios/ZCashLightClientKit/Block/Actions/FetchUTXOsAction.swift +1 -1
- package/ios/ZCashLightClientKit/Block/Actions/ProcessSuggestedScanRangesAction.swift +11 -2
- package/ios/ZCashLightClientKit/Block/Actions/RewindAction.swift +2 -2
- package/ios/ZCashLightClientKit/Block/Actions/ScanAction.swift +28 -11
- package/ios/ZCashLightClientKit/Block/Actions/UpdateChainTipAction.swift +4 -4
- package/ios/ZCashLightClientKit/Block/Actions/UpdateSubtreeRootsAction.swift +36 -7
- package/ios/ZCashLightClientKit/Block/Actions/ValidateServerAction.swift +1 -1
- package/ios/ZCashLightClientKit/Block/CompactBlockProcessor.swift +93 -51
- package/ios/ZCashLightClientKit/Block/Download/BlockDownloader.swift +0 -26
- package/ios/ZCashLightClientKit/Block/Enhance/BlockEnhancer.swift +5 -6
- package/ios/ZCashLightClientKit/Block/FetchUnspentTxOutputs/UTXOFetcher.swift +1 -11
- package/ios/ZCashLightClientKit/Block/SaplingParameters/SaplingParametersHandler.swift +6 -4
- package/ios/ZCashLightClientKit/Block/Scan/BlockScanner.swift +10 -12
- package/ios/ZCashLightClientKit/Checkpoint/BundleCheckpointSource.swift +38 -0
- package/ios/ZCashLightClientKit/Checkpoint/BundleCheckpointURLProvider.swift +40 -0
- package/ios/ZCashLightClientKit/{Constants/Checkpoint+Constants.swift → Checkpoint/Checkpoint+helpers.swift} +1 -33
- package/ios/ZCashLightClientKit/Checkpoint/CheckpointSource.swift +34 -0
- package/ios/ZCashLightClientKit/Checkpoint/CheckpointSourceFactory.swift +14 -0
- package/ios/ZCashLightClientKit/ClosureSynchronizer.swift +61 -6
- package/ios/ZCashLightClientKit/CombineSynchronizer.swift +63 -4
- package/ios/ZCashLightClientKit/Constants/ZcashSDK.swift +4 -0
- package/ios/ZCashLightClientKit/DAO/TransactionDao.swift +21 -33
- package/ios/ZCashLightClientKit/DAO/UnspentTransactionOutputDao.swift +0 -182
- package/ios/ZCashLightClientKit/Entity/AccountEntity.swift +0 -173
- package/ios/ZCashLightClientKit/Entity/TransactionEntity.swift +5 -2
- package/ios/ZCashLightClientKit/Error/Sourcery/generateErrorCode.sh +1 -1
- package/ios/ZCashLightClientKit/Error/ZcashError.swift +53 -1
- package/ios/ZCashLightClientKit/Error/ZcashErrorCode.swift +19 -1
- package/ios/ZCashLightClientKit/Error/ZcashErrorCodeDefinition.swift +32 -0
- package/ios/ZCashLightClientKit/Initializer.swift +8 -17
- package/ios/ZCashLightClientKit/Metrics/SDKMetrics.swift +103 -217
- package/ios/ZCashLightClientKit/Model/Proposal.swift +45 -0
- package/ios/ZCashLightClientKit/Model/ScanSummary.swift +14 -0
- package/ios/ZCashLightClientKit/Model/WalletSummary.swift +58 -0
- package/ios/ZCashLightClientKit/Model/WalletTypes.swift +0 -16
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/LightWalletGRPCService.swift +5 -3
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/proposal.pb.swift +934 -0
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/proto/proposal.proto +138 -0
- package/ios/ZCashLightClientKit/Modules/Service/LightWalletService.swift +2 -4
- package/ios/ZCashLightClientKit/Providers/LatestBlocksDataProvider.swift +9 -1
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2272500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2275000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2277500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2282500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2285000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2287500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2292500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2295000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2297500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2302500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2305000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2307500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2312500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2315000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2317500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2322500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2325000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2327500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2332500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2335000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2337500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2342500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2345000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2347500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2352500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2355000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2357500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2362500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2365000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2367500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2372500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2375000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2377500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2382500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2385000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2387500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2392500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2395000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2397500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2402500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2405000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2407500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2412500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2415000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2417500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2422500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2425000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2427500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2432500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2435000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2437500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2442500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2445000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2447500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2452500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2455000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2457500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2462500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2465000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2467500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2470000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2472500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2480000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2490000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2500000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2560000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2570000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2580000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2590000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2600000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2610000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2620000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2630000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2640000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2650000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2660000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2670000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2680000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2690000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2700000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2710000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2720000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2730000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2740000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2750000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2760000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2770000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2780000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2790000.json +8 -0
- package/ios/ZCashLightClientKit/Rust/ZcashKeyDerivationBackend.swift +1 -5
- package/ios/ZCashLightClientKit/Rust/ZcashRustBackend.swift +327 -153
- package/ios/ZCashLightClientKit/Rust/ZcashRustBackendWelding.swift +78 -36
- package/ios/ZCashLightClientKit/Rust/zcashlc.h +402 -118
- package/ios/ZCashLightClientKit/Synchronizer/ClosureSDKSynchronizer.swift +43 -14
- package/ios/ZCashLightClientKit/Synchronizer/CombineSDKSynchronizer.swift +52 -14
- package/ios/ZCashLightClientKit/Synchronizer/Dependencies.swift +10 -6
- package/ios/ZCashLightClientKit/Synchronizer/SDKSynchronizer.swift +220 -70
- package/ios/ZCashLightClientKit/Synchronizer.swift +105 -29
- package/ios/ZCashLightClientKit/Transaction/TransactionEncoder.swift +61 -32
- package/ios/ZCashLightClientKit/Transaction/WalletTransactionEncoder.swift +52 -61
- package/ios/ZCashLightClientKit/Utils/DBActor.swift +21 -0
- package/ios/ZCashLightClientKit/Utils/LoggingProxy.swift +5 -0
- package/ios/ZCashLightClientKit/Utils/OSLogger.swift +71 -14
- package/ios/libzcashlc.xcframework/ios-arm64/libzcashlc.a +0 -0
- package/ios/libzcashlc.xcframework/ios-arm64_x86_64-simulator/libzcashlc.a +0 -0
- package/lib/rnzcash.rn.js +21 -6
- package/lib/rnzcash.rn.js.map +1 -1
- package/lib/src/react-native.d.ts +2 -1
- package/lib/src/types.d.ts +9 -1
- package/package.json +1 -1
- package/react-native-zcash.podspec +1 -1
- package/src/react-native.ts +23 -4
- package/src/types.ts +10 -1
- package/ios/ZCashLightClientKit/Model/ScanProgress.swift +0 -29
- package/ios/ZCashLightClientKit/Repository/UnspentTransactionOutputRepository.swift +0 -16
- /package/ios/ZCashLightClientKit/{Model → Checkpoint}/Checkpoint.swift +0 -0
|
@@ -14,11 +14,6 @@ protocol AccountEntity {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
struct DbAccount: AccountEntity, Encodable, Decodable {
|
|
17
|
-
enum CodingKeys: String, CodingKey {
|
|
18
|
-
case account
|
|
19
|
-
case ufvk
|
|
20
|
-
}
|
|
21
|
-
|
|
22
17
|
let account: Int
|
|
23
18
|
let ufvk: String
|
|
24
19
|
}
|
|
@@ -38,171 +33,3 @@ extension DbAccount: Hashable {
|
|
|
38
33
|
return true
|
|
39
34
|
}
|
|
40
35
|
}
|
|
41
|
-
|
|
42
|
-
protocol AccountRepository {
|
|
43
|
-
func getAll() throws -> [AccountEntity]
|
|
44
|
-
func findBy(account: Int) throws -> AccountEntity?
|
|
45
|
-
func update(_ account: AccountEntity) throws
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
class AccountSQDAO: AccountRepository {
|
|
49
|
-
enum TableColums {
|
|
50
|
-
static let account = Expression<Int>("account")
|
|
51
|
-
static let extfvk = Expression<String>("ufvk")
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
let table = Table("accounts")
|
|
55
|
-
|
|
56
|
-
let dbProvider: ConnectionProvider
|
|
57
|
-
let logger: Logger
|
|
58
|
-
|
|
59
|
-
init(dbProvider: ConnectionProvider, logger: Logger) {
|
|
60
|
-
self.dbProvider = dbProvider
|
|
61
|
-
self.logger = logger
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/// - Throws:
|
|
65
|
-
/// - `accountDAOGetAllCantDecode` if account data fetched from the db can't be decoded to the `Account` object.
|
|
66
|
-
/// - `accountDAOGetAll` if sqlite query fetching account data failed.
|
|
67
|
-
func getAll() throws -> [AccountEntity] {
|
|
68
|
-
do {
|
|
69
|
-
globalDBLock.lock()
|
|
70
|
-
defer { globalDBLock.unlock() }
|
|
71
|
-
|
|
72
|
-
return try dbProvider.connection()
|
|
73
|
-
.prepare(table)
|
|
74
|
-
.map { row -> DbAccount in
|
|
75
|
-
do {
|
|
76
|
-
return try row.decode()
|
|
77
|
-
} catch {
|
|
78
|
-
throw ZcashError.accountDAOGetAllCantDecode(error)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
} catch {
|
|
82
|
-
if let error = error as? ZcashError {
|
|
83
|
-
throw error
|
|
84
|
-
} else {
|
|
85
|
-
throw ZcashError.accountDAOGetAll(error)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/// - Throws:
|
|
91
|
-
/// - `accountDAOFindByCantDecode` if account data fetched from the db can't be decoded to the `Account` object.
|
|
92
|
-
/// - `accountDAOFindBy` if sqlite query fetching account data failed.
|
|
93
|
-
func findBy(account: Int) throws -> AccountEntity? {
|
|
94
|
-
let query = table.filter(TableColums.account == account).limit(1)
|
|
95
|
-
do {
|
|
96
|
-
globalDBLock.lock()
|
|
97
|
-
defer { globalDBLock.unlock() }
|
|
98
|
-
|
|
99
|
-
return try dbProvider.connection()
|
|
100
|
-
.prepare(query)
|
|
101
|
-
.map {
|
|
102
|
-
do {
|
|
103
|
-
return try $0.decode() as DbAccount
|
|
104
|
-
} catch {
|
|
105
|
-
throw ZcashError.accountDAOFindByCantDecode(error)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
.first
|
|
109
|
-
} catch {
|
|
110
|
-
if let error = error as? ZcashError {
|
|
111
|
-
throw error
|
|
112
|
-
} else {
|
|
113
|
-
throw ZcashError.accountDAOFindBy(error)
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/// - Throws:
|
|
119
|
-
/// - `accountDAOUpdate` if sqlite query updating account failed.
|
|
120
|
-
/// - `accountDAOUpdatedZeroRows` if sqlite query updating account pass but it affects 0 rows.
|
|
121
|
-
func update(_ account: AccountEntity) throws {
|
|
122
|
-
guard let acc = account as? DbAccount else {
|
|
123
|
-
throw ZcashError.accountDAOUpdateInvalidAccount
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
let updatedRows: Int
|
|
127
|
-
do {
|
|
128
|
-
globalDBLock.lock()
|
|
129
|
-
defer { globalDBLock.unlock() }
|
|
130
|
-
|
|
131
|
-
updatedRows = try dbProvider.connection().run(table.filter(TableColums.account == acc.account).update(acc))
|
|
132
|
-
} catch {
|
|
133
|
-
throw ZcashError.accountDAOUpdate(error)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if updatedRows == 0 {
|
|
137
|
-
logger.error("attempted to update pending transactions but no rows were updated")
|
|
138
|
-
throw ZcashError.accountDAOUpdatedZeroRows
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
class CachingAccountDao: AccountRepository {
|
|
144
|
-
let dao: AccountRepository
|
|
145
|
-
lazy var cache: [Int: AccountEntity] = {
|
|
146
|
-
var accountCache: [Int: AccountEntity] = [:]
|
|
147
|
-
guard let all = try? dao.getAll() else {
|
|
148
|
-
return accountCache
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
for acc in all {
|
|
152
|
-
accountCache[acc.account] = acc
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return accountCache
|
|
156
|
-
}()
|
|
157
|
-
|
|
158
|
-
init(dao: AccountRepository) {
|
|
159
|
-
self.dao = dao
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
func getAll() throws -> [AccountEntity] {
|
|
163
|
-
guard cache.isEmpty else {
|
|
164
|
-
return cache.values.sorted(by: { $0.account < $1.account })
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
let all = try dao.getAll()
|
|
168
|
-
|
|
169
|
-
for acc in all {
|
|
170
|
-
cache[acc.account] = acc
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return all
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
func findBy(account: Int) throws -> AccountEntity? {
|
|
177
|
-
if let acc = cache[account] {
|
|
178
|
-
return acc
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
let acc = try dao.findBy(account: account)
|
|
182
|
-
cache[account] = acc
|
|
183
|
-
|
|
184
|
-
return acc
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
func update(_ account: AccountEntity) throws {
|
|
188
|
-
try dao.update(account)
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
enum AccountRepositoryBuilder {
|
|
193
|
-
static func build(dataDbURL: URL, readOnly: Bool = false, caching: Bool = false, logger: Logger) -> AccountRepository {
|
|
194
|
-
if caching {
|
|
195
|
-
return CachingAccountDao(
|
|
196
|
-
dao: AccountSQDAO(
|
|
197
|
-
dbProvider: SimpleConnectionProvider(path: dataDbURL.path, readonly: readOnly),
|
|
198
|
-
logger: logger
|
|
199
|
-
)
|
|
200
|
-
)
|
|
201
|
-
} else {
|
|
202
|
-
return AccountSQDAO(
|
|
203
|
-
dbProvider: SimpleConnectionProvider(path: dataDbURL.path, readonly: readOnly),
|
|
204
|
-
logger: logger
|
|
205
|
-
)
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
@@ -65,6 +65,7 @@ public enum ZcashTransaction {
|
|
|
65
65
|
public enum Pool {
|
|
66
66
|
case transaparent
|
|
67
67
|
case sapling
|
|
68
|
+
case orchard
|
|
68
69
|
case other(Int)
|
|
69
70
|
init(rawValue: Int) {
|
|
70
71
|
switch rawValue {
|
|
@@ -72,6 +73,8 @@ public enum ZcashTransaction {
|
|
|
72
73
|
self = .transaparent
|
|
73
74
|
case 2:
|
|
74
75
|
self = .sapling
|
|
76
|
+
case 3:
|
|
77
|
+
self = .orchard
|
|
75
78
|
default:
|
|
76
79
|
self = .other(rawValue)
|
|
77
80
|
}
|
|
@@ -101,8 +104,8 @@ extension ZcashTransaction.Output {
|
|
|
101
104
|
static let rawID = Expression<Blob>("txid")
|
|
102
105
|
static let pool = Expression<Int>("output_pool")
|
|
103
106
|
static let index = Expression<Int>("output_index")
|
|
104
|
-
static let toAccount = Expression<Int?>("
|
|
105
|
-
static let fromAccount = Expression<Int?>("
|
|
107
|
+
static let toAccount = Expression<Int?>("to_account_id")
|
|
108
|
+
static let fromAccount = Expression<Int?>("from_account_id")
|
|
106
109
|
static let toAddress = Expression<String?>("to_address")
|
|
107
110
|
static let value = Expression<Int64>("value")
|
|
108
111
|
static let isChange = Expression<Bool>("is_change")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated using Sourcery 2.
|
|
1
|
+
// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery
|
|
2
2
|
// DO NOT EDIT
|
|
3
3
|
|
|
4
4
|
/*
|
|
@@ -317,6 +317,31 @@ public enum ZcashError: Equatable, Error {
|
|
|
317
317
|
/// - `progress` value reported
|
|
318
318
|
/// ZRUST0055
|
|
319
319
|
case rustScanProgressOutOfRange(_ progress: String)
|
|
320
|
+
/// Error from rust layer when calling ZcashRustBackend.getWalletSummary
|
|
321
|
+
/// - `rustError` contains error generated by the rust layer.
|
|
322
|
+
/// ZRUST0056
|
|
323
|
+
case rustGetWalletSummary(_ rustError: String)
|
|
324
|
+
/// Error from rust layer when calling ZcashRustBackend.
|
|
325
|
+
/// - `rustError` contains error generated by the rust layer.
|
|
326
|
+
/// ZRUST0057
|
|
327
|
+
case rustProposeTransferFromURI(_ rustError: String)
|
|
328
|
+
/// Error from rust layer when calling ZcashRustBackend.
|
|
329
|
+
/// - `rustError` contains error generated by the rust layer.
|
|
330
|
+
/// ZRUST0058
|
|
331
|
+
case rustListAccounts(_ rustError: String)
|
|
332
|
+
/// Error from rust layer when calling ZcashRustBackend.rustIsSeedRelevantToAnyDerivedAccount
|
|
333
|
+
/// - `rustError` contains error generated by the rust layer.
|
|
334
|
+
/// ZRUST0059
|
|
335
|
+
case rustIsSeedRelevantToAnyDerivedAccount(_ rustError: String)
|
|
336
|
+
/// Unable to allocate memory required to write blocks when calling ZcashRustBackend.putOrchardSubtreeRoots
|
|
337
|
+
/// sourcery: code="ZRUST0060"
|
|
338
|
+
/// ZRUST0060
|
|
339
|
+
case rustPutOrchardSubtreeRootsAllocationProblem
|
|
340
|
+
/// Error from rust layer when calling ZcashRustBackend.putOrchardSubtreeRoots
|
|
341
|
+
/// - `rustError` contains error generated by the rust layer.
|
|
342
|
+
/// sourcery: code="ZRUST0061"
|
|
343
|
+
/// ZRUST0061
|
|
344
|
+
case rustPutOrchardSubtreeRoots(_ rustError: String)
|
|
320
345
|
/// SQLite query failed when fetching all accounts from the database.
|
|
321
346
|
/// - `sqliteError` is error produced by SQLite library.
|
|
322
347
|
/// ZADAO0001
|
|
@@ -562,6 +587,9 @@ public enum ZcashError: Equatable, Error {
|
|
|
562
587
|
/// Getting the `supportedSyncAlgorithm` failed but it's supposed to always provide some value.
|
|
563
588
|
/// ZCBPEO0021
|
|
564
589
|
case compactBlockProcessorSupportedSyncAlgorithm
|
|
590
|
+
/// Put Orchard subtree roots to the DB failed.
|
|
591
|
+
/// ZCBPEO0022
|
|
592
|
+
case compactBlockProcessorPutOrchardSubtreeRoots(_ error: Error)
|
|
565
593
|
/// The synchronizer is unprepared.
|
|
566
594
|
/// ZSYNCO0001
|
|
567
595
|
case synchronizerNotPrepared
|
|
@@ -580,6 +608,12 @@ public enum ZcashError: Equatable, Error {
|
|
|
580
608
|
/// Indicates that this Synchronizer is disconnected from its lightwalletd server.
|
|
581
609
|
/// ZSYNCO0006
|
|
582
610
|
case synchronizerDisconnected
|
|
611
|
+
/// The attempt to switch endpoints failed. Check that the hostname and port are correct, and are formatted as <hostname>:<port>.
|
|
612
|
+
/// ZSYNCO0007
|
|
613
|
+
case synchronizerServerSwitch
|
|
614
|
+
/// The spending key does not belong to the wallet.
|
|
615
|
+
/// ZSYNCO0008
|
|
616
|
+
case synchronizerSpendingKeyDoesNotBelongToTheWallet
|
|
583
617
|
|
|
584
618
|
public var message: String {
|
|
585
619
|
switch self {
|
|
@@ -665,6 +699,12 @@ public enum ZcashError: Equatable, Error {
|
|
|
665
699
|
case .rustMaxScannedHeight: return "Error from rust layer when calling ZcashRustBackend.maxScannedHeight"
|
|
666
700
|
case .rustLatestCachedBlockHeight: return "Error from rust layer when calling ZcashRustBackend.latestCachedBlockHeight"
|
|
667
701
|
case .rustScanProgressOutOfRange: return "Rust layer's call ZcashRustBackend.getScanProgress returned values that after computation are outside of allowed range 0-100%."
|
|
702
|
+
case .rustGetWalletSummary: return "Error from rust layer when calling ZcashRustBackend.getWalletSummary"
|
|
703
|
+
case .rustProposeTransferFromURI: return "Error from rust layer when calling ZcashRustBackend."
|
|
704
|
+
case .rustListAccounts: return "Error from rust layer when calling ZcashRustBackend."
|
|
705
|
+
case .rustIsSeedRelevantToAnyDerivedAccount: return "Error from rust layer when calling ZcashRustBackend.rustIsSeedRelevantToAnyDerivedAccount"
|
|
706
|
+
case .rustPutOrchardSubtreeRootsAllocationProblem: return "Unable to allocate memory required to write blocks when calling ZcashRustBackend.putOrchardSubtreeRoots"
|
|
707
|
+
case .rustPutOrchardSubtreeRoots: return "Error from rust layer when calling ZcashRustBackend.putOrchardSubtreeRoots"
|
|
668
708
|
case .accountDAOGetAll: return "SQLite query failed when fetching all accounts from the database."
|
|
669
709
|
case .accountDAOGetAllCantDecode: return "Fetched accounts from SQLite but can't decode them."
|
|
670
710
|
case .accountDAOFindBy: return "SQLite query failed when seaching for accounts in the database."
|
|
@@ -743,12 +783,15 @@ public enum ZcashError: Equatable, Error {
|
|
|
743
783
|
case .compactBlockProcessorPutSaplingSubtreeRoots: return "Put sapling subtree roots to the DB failed."
|
|
744
784
|
case .compactBlockProcessorLastScannedHeight: return "Getting the `lastScannedHeight` failed but it's supposed to always provide some value."
|
|
745
785
|
case .compactBlockProcessorSupportedSyncAlgorithm: return "Getting the `supportedSyncAlgorithm` failed but it's supposed to always provide some value."
|
|
786
|
+
case .compactBlockProcessorPutOrchardSubtreeRoots: return "Put Orchard subtree roots to the DB failed."
|
|
746
787
|
case .synchronizerNotPrepared: return "The synchronizer is unprepared."
|
|
747
788
|
case .synchronizerSendMemoToTransparentAddress: return "Memos can't be sent to transparent addresses."
|
|
748
789
|
case .synchronizerShieldFundsInsuficientTransparentFunds: return "There is not enough transparent funds to cover fee for the shielding."
|
|
749
790
|
case .synchronizerLatestUTXOsInvalidTAddress: return "LatestUTXOs for the address failed, invalid t-address."
|
|
750
791
|
case .synchronizerRewindUnknownArchorHeight: return "Rewind failed, unknown archor height"
|
|
751
792
|
case .synchronizerDisconnected: return "Indicates that this Synchronizer is disconnected from its lightwalletd server."
|
|
793
|
+
case .synchronizerServerSwitch: return "The attempt to switch endpoints failed. Check that the hostname and port are correct, and are formatted as <hostname>:<port>."
|
|
794
|
+
case .synchronizerSpendingKeyDoesNotBelongToTheWallet: return "The spending key does not belong to the wallet."
|
|
752
795
|
}
|
|
753
796
|
}
|
|
754
797
|
|
|
@@ -836,6 +879,12 @@ public enum ZcashError: Equatable, Error {
|
|
|
836
879
|
case .rustMaxScannedHeight: return .rustMaxScannedHeight
|
|
837
880
|
case .rustLatestCachedBlockHeight: return .rustLatestCachedBlockHeight
|
|
838
881
|
case .rustScanProgressOutOfRange: return .rustScanProgressOutOfRange
|
|
882
|
+
case .rustGetWalletSummary: return .rustGetWalletSummary
|
|
883
|
+
case .rustProposeTransferFromURI: return .rustProposeTransferFromURI
|
|
884
|
+
case .rustListAccounts: return .rustListAccounts
|
|
885
|
+
case .rustIsSeedRelevantToAnyDerivedAccount: return .rustIsSeedRelevantToAnyDerivedAccount
|
|
886
|
+
case .rustPutOrchardSubtreeRootsAllocationProblem: return .rustPutOrchardSubtreeRootsAllocationProblem
|
|
887
|
+
case .rustPutOrchardSubtreeRoots: return .rustPutOrchardSubtreeRoots
|
|
839
888
|
case .accountDAOGetAll: return .accountDAOGetAll
|
|
840
889
|
case .accountDAOGetAllCantDecode: return .accountDAOGetAllCantDecode
|
|
841
890
|
case .accountDAOFindBy: return .accountDAOFindBy
|
|
@@ -914,12 +963,15 @@ public enum ZcashError: Equatable, Error {
|
|
|
914
963
|
case .compactBlockProcessorPutSaplingSubtreeRoots: return .compactBlockProcessorPutSaplingSubtreeRoots
|
|
915
964
|
case .compactBlockProcessorLastScannedHeight: return .compactBlockProcessorLastScannedHeight
|
|
916
965
|
case .compactBlockProcessorSupportedSyncAlgorithm: return .compactBlockProcessorSupportedSyncAlgorithm
|
|
966
|
+
case .compactBlockProcessorPutOrchardSubtreeRoots: return .compactBlockProcessorPutOrchardSubtreeRoots
|
|
917
967
|
case .synchronizerNotPrepared: return .synchronizerNotPrepared
|
|
918
968
|
case .synchronizerSendMemoToTransparentAddress: return .synchronizerSendMemoToTransparentAddress
|
|
919
969
|
case .synchronizerShieldFundsInsuficientTransparentFunds: return .synchronizerShieldFundsInsuficientTransparentFunds
|
|
920
970
|
case .synchronizerLatestUTXOsInvalidTAddress: return .synchronizerLatestUTXOsInvalidTAddress
|
|
921
971
|
case .synchronizerRewindUnknownArchorHeight: return .synchronizerRewindUnknownArchorHeight
|
|
922
972
|
case .synchronizerDisconnected: return .synchronizerDisconnected
|
|
973
|
+
case .synchronizerServerSwitch: return .synchronizerServerSwitch
|
|
974
|
+
case .synchronizerSpendingKeyDoesNotBelongToTheWallet: return .synchronizerSpendingKeyDoesNotBelongToTheWallet
|
|
923
975
|
}
|
|
924
976
|
}
|
|
925
977
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated using Sourcery 2.
|
|
1
|
+
// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery
|
|
2
2
|
// DO NOT EDIT
|
|
3
3
|
|
|
4
4
|
/*
|
|
@@ -173,6 +173,18 @@ public enum ZcashErrorCode: String {
|
|
|
173
173
|
case rustLatestCachedBlockHeight = "ZRUST0054"
|
|
174
174
|
/// Rust layer's call ZcashRustBackend.getScanProgress returned values that after computation are outside of allowed range 0-100%.
|
|
175
175
|
case rustScanProgressOutOfRange = "ZRUST0055"
|
|
176
|
+
/// Error from rust layer when calling ZcashRustBackend.getWalletSummary
|
|
177
|
+
case rustGetWalletSummary = "ZRUST0056"
|
|
178
|
+
/// Error from rust layer when calling ZcashRustBackend.
|
|
179
|
+
case rustProposeTransferFromURI = "ZRUST0057"
|
|
180
|
+
/// Error from rust layer when calling ZcashRustBackend.
|
|
181
|
+
case rustListAccounts = "ZRUST0058"
|
|
182
|
+
/// Error from rust layer when calling ZcashRustBackend.rustIsSeedRelevantToAnyDerivedAccount
|
|
183
|
+
case rustIsSeedRelevantToAnyDerivedAccount = "ZRUST0059"
|
|
184
|
+
/// Unable to allocate memory required to write blocks when calling ZcashRustBackend.putOrchardSubtreeRoots
|
|
185
|
+
case rustPutOrchardSubtreeRootsAllocationProblem = "ZRUST0060"
|
|
186
|
+
/// Error from rust layer when calling ZcashRustBackend.putOrchardSubtreeRoots
|
|
187
|
+
case rustPutOrchardSubtreeRoots = "ZRUST0061"
|
|
176
188
|
/// SQLite query failed when fetching all accounts from the database.
|
|
177
189
|
case accountDAOGetAll = "ZADAO0001"
|
|
178
190
|
/// Fetched accounts from SQLite but can't decode them.
|
|
@@ -329,6 +341,8 @@ public enum ZcashErrorCode: String {
|
|
|
329
341
|
case compactBlockProcessorLastScannedHeight = "ZCBPEO0020"
|
|
330
342
|
/// Getting the `supportedSyncAlgorithm` failed but it's supposed to always provide some value.
|
|
331
343
|
case compactBlockProcessorSupportedSyncAlgorithm = "ZCBPEO0021"
|
|
344
|
+
/// Put Orchard subtree roots to the DB failed.
|
|
345
|
+
case compactBlockProcessorPutOrchardSubtreeRoots = "ZCBPEO0022"
|
|
332
346
|
/// The synchronizer is unprepared.
|
|
333
347
|
case synchronizerNotPrepared = "ZSYNCO0001"
|
|
334
348
|
/// Memos can't be sent to transparent addresses.
|
|
@@ -341,4 +355,8 @@ public enum ZcashErrorCode: String {
|
|
|
341
355
|
case synchronizerRewindUnknownArchorHeight = "ZSYNCO0005"
|
|
342
356
|
/// Indicates that this Synchronizer is disconnected from its lightwalletd server.
|
|
343
357
|
case synchronizerDisconnected = "ZSYNCO0006"
|
|
358
|
+
/// The attempt to switch endpoints failed. Check that the hostname and port are correct, and are formatted as <hostname>:<port>.
|
|
359
|
+
case synchronizerServerSwitch = "ZSYNCO0007"
|
|
360
|
+
/// The spending key does not belong to the wallet.
|
|
361
|
+
case synchronizerSpendingKeyDoesNotBelongToTheWallet = "ZSYNCO0008"
|
|
344
362
|
}
|
|
@@ -344,6 +344,29 @@ enum ZcashErrorDefinition {
|
|
|
344
344
|
/// - `progress` value reported
|
|
345
345
|
// sourcery: code="ZRUST0055"
|
|
346
346
|
case rustScanProgressOutOfRange(_ progress: String)
|
|
347
|
+
/// Error from rust layer when calling ZcashRustBackend.getWalletSummary
|
|
348
|
+
/// - `rustError` contains error generated by the rust layer.
|
|
349
|
+
// sourcery: code="ZRUST0056"
|
|
350
|
+
case rustGetWalletSummary(_ rustError: String)
|
|
351
|
+
/// Error from rust layer when calling ZcashRustBackend.
|
|
352
|
+
/// - `rustError` contains error generated by the rust layer.
|
|
353
|
+
// sourcery: code="ZRUST0057"
|
|
354
|
+
case rustProposeTransferFromURI(_ rustError: String)
|
|
355
|
+
/// Error from rust layer when calling ZcashRustBackend.
|
|
356
|
+
/// - `rustError` contains error generated by the rust layer.
|
|
357
|
+
// sourcery: code="ZRUST0058"
|
|
358
|
+
case rustListAccounts(_ rustError: String)
|
|
359
|
+
/// Error from rust layer when calling ZcashRustBackend.rustIsSeedRelevantToAnyDerivedAccount
|
|
360
|
+
/// - `rustError` contains error generated by the rust layer.
|
|
361
|
+
// sourcery: code="ZRUST0059"
|
|
362
|
+
case rustIsSeedRelevantToAnyDerivedAccount(_ rustError: String)
|
|
363
|
+
/// Unable to allocate memory required to write blocks when calling ZcashRustBackend.putOrchardSubtreeRoots
|
|
364
|
+
/// sourcery: code="ZRUST0060"
|
|
365
|
+
case rustPutOrchardSubtreeRootsAllocationProblem
|
|
366
|
+
/// Error from rust layer when calling ZcashRustBackend.putOrchardSubtreeRoots
|
|
367
|
+
/// - `rustError` contains error generated by the rust layer.
|
|
368
|
+
/// sourcery: code="ZRUST0061"
|
|
369
|
+
case rustPutOrchardSubtreeRoots(_ rustError: String)
|
|
347
370
|
|
|
348
371
|
// MARK: - Account DAO
|
|
349
372
|
|
|
@@ -638,6 +661,9 @@ enum ZcashErrorDefinition {
|
|
|
638
661
|
/// Getting the `supportedSyncAlgorithm` failed but it's supposed to always provide some value.
|
|
639
662
|
// sourcery: code="ZCBPEO0021"
|
|
640
663
|
case compactBlockProcessorSupportedSyncAlgorithm
|
|
664
|
+
/// Put Orchard subtree roots to the DB failed.
|
|
665
|
+
// sourcery: code="ZCBPEO0022"
|
|
666
|
+
case compactBlockProcessorPutOrchardSubtreeRoots(_ error: Error)
|
|
641
667
|
|
|
642
668
|
// MARK: - SDKSynchronizer
|
|
643
669
|
|
|
@@ -659,4 +685,10 @@ enum ZcashErrorDefinition {
|
|
|
659
685
|
/// Indicates that this Synchronizer is disconnected from its lightwalletd server.
|
|
660
686
|
// sourcery: code="ZSYNCO0006"
|
|
661
687
|
case synchronizerDisconnected
|
|
688
|
+
/// The attempt to switch endpoints failed. Check that the hostname and port are correct, and are formatted as <hostname>:<port>.
|
|
689
|
+
// sourcery: code="ZSYNCO0007"
|
|
690
|
+
case synchronizerServerSwitch
|
|
691
|
+
/// The spending key does not belong to the wallet.
|
|
692
|
+
// sourcery: code="ZSYNCO0008"
|
|
693
|
+
case synchronizerSpendingKeyDoesNotBelongToTheWallet
|
|
662
694
|
}
|
|
@@ -111,18 +111,17 @@ public class Initializer {
|
|
|
111
111
|
|
|
112
112
|
let container: DIContainer
|
|
113
113
|
let alias: ZcashSynchronizerAlias
|
|
114
|
-
|
|
114
|
+
var endpoint: LightWalletEndpoint
|
|
115
115
|
let fsBlockDbRoot: URL
|
|
116
116
|
let generalStorageURL: URL
|
|
117
117
|
let dataDbURL: URL
|
|
118
118
|
let spendParamsURL: URL
|
|
119
119
|
let outputParamsURL: URL
|
|
120
120
|
let saplingParamsSourceURL: SaplingParamsSourceURL
|
|
121
|
-
|
|
121
|
+
var lightWalletService: LightWalletService
|
|
122
122
|
let transactionRepository: TransactionRepository
|
|
123
|
-
let accountRepository: AccountRepository
|
|
124
123
|
let storage: CompactBlockRepository
|
|
125
|
-
|
|
124
|
+
var blockDownloaderService: BlockDownloaderService
|
|
126
125
|
let network: ZcashNetwork
|
|
127
126
|
let logger: Logger
|
|
128
127
|
let rustBackend: ZcashRustBackendWelding
|
|
@@ -272,24 +271,14 @@ public class Initializer {
|
|
|
272
271
|
self.alias = alias
|
|
273
272
|
self.lightWalletService = container.resolve(LightWalletService.self)
|
|
274
273
|
self.transactionRepository = container.resolve(TransactionRepository.self)
|
|
275
|
-
self.accountRepository = AccountRepositoryBuilder.build(
|
|
276
|
-
dataDbURL: urls.dataDbURL,
|
|
277
|
-
readOnly: true,
|
|
278
|
-
caching: true,
|
|
279
|
-
logger: container.resolve(Logger.self)
|
|
280
|
-
)
|
|
281
274
|
self.storage = container.resolve(CompactBlockRepository.self)
|
|
282
275
|
self.blockDownloaderService = container.resolve(BlockDownloaderService.self)
|
|
283
276
|
self.network = network
|
|
284
|
-
self.walletBirthday =
|
|
277
|
+
self.walletBirthday = container.resolve(CheckpointSource.self).saplingActivation.height
|
|
285
278
|
self.urlsParsingError = urlsParsingError
|
|
286
279
|
self.logger = container.resolve(Logger.self)
|
|
287
280
|
}
|
|
288
281
|
|
|
289
|
-
private static func makeLightWalletServiceFactory(endpoint: LightWalletEndpoint) -> LightWalletServiceFactory {
|
|
290
|
-
return LightWalletServiceFactory(endpoint: endpoint)
|
|
291
|
-
}
|
|
292
|
-
|
|
293
282
|
// swiftlint:disable:next function_parameter_count
|
|
294
283
|
private static func setup(
|
|
295
284
|
container: DIContainer,
|
|
@@ -416,12 +405,14 @@ public class Initializer {
|
|
|
416
405
|
return .seedRequired
|
|
417
406
|
}
|
|
418
407
|
|
|
419
|
-
let
|
|
408
|
+
let checkpointSource = container.resolve(CheckpointSource.self)
|
|
409
|
+
|
|
410
|
+
let checkpoint = checkpointSource.birthday(for: walletBirthday)
|
|
420
411
|
|
|
421
412
|
self.walletBirthday = checkpoint.height
|
|
422
413
|
|
|
423
414
|
// If there are no accounts it must be created, the default amount of accounts is 1
|
|
424
|
-
if let seed, try
|
|
415
|
+
if let seed, try await rustBackend.listAccounts().isEmpty {
|
|
425
416
|
var chainTip: UInt32?
|
|
426
417
|
|
|
427
418
|
if walletMode == .restoreWallet {
|