react-native-zcash 0.9.13 → 0.10.1-beta.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.
Files changed (277) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/android/build.gradle +6 -6
  3. package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/3130000.json +8 -0
  4. package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/3140000.json +8 -0
  5. package/android/src/main/java/app/edge/rnzcash/RNZcashModule.kt +126 -69
  6. package/ios/RNZcash.m +0 -5
  7. package/ios/RNZcash.swift +153 -104
  8. package/ios/ZCashLightClientKit/Account/Account.swift +48 -0
  9. package/ios/ZCashLightClientKit/Account/AccountMetadataKey.swift +96 -0
  10. package/ios/ZCashLightClientKit/Block/Actions/ScanAction.swift +23 -4
  11. package/ios/ZCashLightClientKit/Block/Actions/UpdateChainTipAction.swift +6 -2
  12. package/ios/ZCashLightClientKit/Block/Actions/UpdateSubtreeRootsAction.swift +4 -2
  13. package/ios/ZCashLightClientKit/Block/Actions/ValidateServerAction.swift +4 -1
  14. package/ios/ZCashLightClientKit/Block/CompactBlockProcessor.swift +83 -16
  15. package/ios/ZCashLightClientKit/Block/Download/BlockDownloader.swift +4 -2
  16. package/ios/ZCashLightClientKit/Block/Download/BlockDownloaderService.swift +22 -19
  17. package/ios/ZCashLightClientKit/Block/Enhance/BlockEnhancer.swift +50 -19
  18. package/ios/ZCashLightClientKit/Block/FetchUnspentTxOutputs/UTXOFetcher.swift +5 -3
  19. package/ios/ZCashLightClientKit/Block/SaplingParameters/SaplingParametersHandler.swift +22 -5
  20. package/ios/ZCashLightClientKit/Block/Scan/BlockScanner.swift +2 -1
  21. package/ios/ZCashLightClientKit/Block/Utils/CompactBlockProgress.swift +5 -3
  22. package/ios/ZCashLightClientKit/Checkpoint/BundleCheckpointSource.swift +88 -0
  23. package/ios/ZCashLightClientKit/Checkpoint/CheckpointSource.swift +4 -0
  24. package/ios/ZCashLightClientKit/ClosureSynchronizer.swift +52 -21
  25. package/ios/ZCashLightClientKit/CombineSynchronizer.swift +49 -27
  26. package/ios/ZCashLightClientKit/Constants/ZcashSDK.swift +8 -2
  27. package/ios/ZCashLightClientKit/DAO/BlockDao.swift +65 -0
  28. package/ios/ZCashLightClientKit/DAO/TransactionDao.swift +86 -1
  29. package/ios/ZCashLightClientKit/Entity/AccountEntity.swift +4 -4
  30. package/ios/ZCashLightClientKit/Entity/Pczt.swift +10 -0
  31. package/ios/ZCashLightClientKit/Entity/SentNoteEntity.swift +2 -2
  32. package/ios/ZCashLightClientKit/Entity/TransactionEntity.swift +40 -16
  33. package/ios/ZCashLightClientKit/Error/Sourcery/generateErrorCode.sh +1 -1
  34. package/ios/ZCashLightClientKit/Error/ZcashError.swift +182 -14
  35. package/ios/ZCashLightClientKit/Error/ZcashErrorCode.swift +63 -5
  36. package/ios/ZCashLightClientKit/Error/ZcashErrorCodeDefinition.swift +122 -12
  37. package/ios/ZCashLightClientKit/Initializer.swift +49 -14
  38. package/ios/ZCashLightClientKit/Metrics/SDKMetrics.swift +15 -6
  39. package/ios/ZCashLightClientKit/Model/SingleUseTransparentAddress.swift +29 -0
  40. package/ios/ZCashLightClientKit/Model/TransactionDataRequest.swift +83 -2
  41. package/ios/ZCashLightClientKit/Model/WalletSummary.swift +21 -4
  42. package/ios/ZCashLightClientKit/Model/WalletTypes.swift +38 -8
  43. package/ios/ZCashLightClientKit/Modules/Service/GRPC/LightWalletGRPCService.swift +177 -45
  44. package/ios/ZCashLightClientKit/Modules/Service/LightWalletService.swift +63 -16
  45. package/ios/ZCashLightClientKit/Modules/Service/Tor/LightWalletGRPCServiceOverTor.swift +273 -0
  46. package/ios/ZCashLightClientKit/Providers/LatestBlocksDataProvider.swift +5 -2
  47. package/ios/ZCashLightClientKit/Repository/TransactionRepository.swift +2 -0
  48. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2675000.json +8 -0
  49. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2677500.json +8 -0
  50. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2682500.json +8 -0
  51. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2685000.json +8 -0
  52. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2687500.json +8 -0
  53. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2692500.json +8 -0
  54. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2695000.json +8 -0
  55. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2697500.json +8 -0
  56. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2702500.json +8 -0
  57. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2705000.json +8 -0
  58. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2707500.json +8 -0
  59. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2712500.json +8 -0
  60. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2715000.json +8 -0
  61. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2717500.json +8 -0
  62. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2722500.json +8 -0
  63. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2725000.json +8 -0
  64. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2727500.json +8 -0
  65. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2732500.json +8 -0
  66. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2735000.json +8 -0
  67. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2737500.json +8 -0
  68. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2742500.json +8 -0
  69. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2745000.json +8 -0
  70. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2747500.json +8 -0
  71. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2752500.json +8 -0
  72. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2755000.json +8 -0
  73. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2757500.json +8 -0
  74. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2762500.json +8 -0
  75. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2765000.json +8 -0
  76. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2767500.json +8 -0
  77. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2772500.json +8 -0
  78. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2775000.json +8 -0
  79. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2777500.json +8 -0
  80. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2782500.json +8 -0
  81. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2785000.json +8 -0
  82. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2787500.json +8 -0
  83. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2792500.json +8 -0
  84. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2795000.json +8 -0
  85. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2797500.json +8 -0
  86. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2802500.json +8 -0
  87. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2805000.json +8 -0
  88. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2807500.json +8 -0
  89. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2812500.json +8 -0
  90. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2815000.json +8 -0
  91. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2817500.json +8 -0
  92. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2822500.json +8 -0
  93. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2825000.json +8 -0
  94. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2827500.json +8 -0
  95. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2832500.json +8 -0
  96. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2835000.json +8 -0
  97. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2837500.json +8 -0
  98. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2842500.json +8 -0
  99. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2845000.json +8 -0
  100. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2847500.json +8 -0
  101. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2852500.json +8 -0
  102. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2855000.json +8 -0
  103. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2857500.json +8 -0
  104. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2862500.json +8 -0
  105. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2865000.json +8 -0
  106. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2867500.json +8 -0
  107. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2872500.json +8 -0
  108. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2875000.json +8 -0
  109. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2877500.json +8 -0
  110. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2882500.json +8 -0
  111. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2885000.json +8 -0
  112. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2887500.json +8 -0
  113. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2892500.json +8 -0
  114. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2895000.json +8 -0
  115. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2897500.json +8 -0
  116. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2902500.json +8 -0
  117. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2905000.json +8 -0
  118. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2907500.json +8 -0
  119. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2912500.json +8 -0
  120. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2915000.json +8 -0
  121. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2917500.json +8 -0
  122. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2922500.json +8 -0
  123. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2925000.json +8 -0
  124. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2927500.json +8 -0
  125. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2932500.json +8 -0
  126. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2935000.json +8 -0
  127. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2937500.json +8 -0
  128. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2942500.json +8 -0
  129. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2945000.json +8 -0
  130. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2947500.json +8 -0
  131. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2952500.json +8 -0
  132. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2955000.json +8 -0
  133. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2957500.json +8 -0
  134. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2962500.json +8 -0
  135. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2965000.json +8 -0
  136. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2967500.json +8 -0
  137. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2972500.json +8 -0
  138. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2975000.json +8 -0
  139. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2977500.json +8 -0
  140. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2982500.json +8 -0
  141. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2985000.json +8 -0
  142. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2987500.json +8 -0
  143. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2992500.json +8 -0
  144. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2995000.json +8 -0
  145. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2997500.json +8 -0
  146. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3002500.json +8 -0
  147. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3005000.json +8 -0
  148. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3007500.json +8 -0
  149. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3012500.json +8 -0
  150. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3015000.json +8 -0
  151. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3017500.json +8 -0
  152. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3022500.json +8 -0
  153. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3025000.json +8 -0
  154. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3027500.json +8 -0
  155. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3032500.json +8 -0
  156. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3035000.json +8 -0
  157. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3037500.json +8 -0
  158. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3042500.json +8 -0
  159. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3045000.json +8 -0
  160. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3047500.json +8 -0
  161. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3052500.json +8 -0
  162. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3055000.json +8 -0
  163. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3057500.json +8 -0
  164. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3062500.json +8 -0
  165. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3065000.json +8 -0
  166. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3067500.json +8 -0
  167. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3072500.json +8 -0
  168. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3075000.json +8 -0
  169. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3077500.json +8 -0
  170. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3082500.json +8 -0
  171. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3085000.json +8 -0
  172. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3087500.json +8 -0
  173. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3092500.json +8 -0
  174. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3095000.json +8 -0
  175. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3097500.json +8 -0
  176. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3102500.json +8 -0
  177. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3105000.json +8 -0
  178. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3107500.json +8 -0
  179. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3112500.json +8 -0
  180. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3115000.json +8 -0
  181. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3117500.json +8 -0
  182. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3122500.json +8 -0
  183. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3125000.json +8 -0
  184. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3127500.json +8 -0
  185. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3130000.json +8 -0
  186. package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3140000.json +8 -0
  187. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3010000.json +8 -0
  188. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3020000.json +8 -0
  189. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3030000.json +8 -0
  190. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3040000.json +8 -0
  191. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3050000.json +8 -0
  192. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3060000.json +8 -0
  193. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3070000.json +8 -0
  194. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3080000.json +8 -0
  195. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3090000.json +8 -0
  196. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3100000.json +8 -0
  197. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3110000.json +8 -0
  198. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3120000.json +8 -0
  199. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3130000.json +8 -0
  200. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3140000.json +8 -0
  201. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3150000.json +8 -0
  202. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3160000.json +8 -0
  203. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3170000.json +8 -0
  204. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3180000.json +8 -0
  205. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3190000.json +8 -0
  206. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3200000.json +8 -0
  207. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3210000.json +8 -0
  208. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3220000.json +8 -0
  209. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3230000.json +8 -0
  210. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3240000.json +8 -0
  211. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3250000.json +8 -0
  212. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3260000.json +8 -0
  213. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3270000.json +8 -0
  214. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3280000.json +8 -0
  215. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3290000.json +8 -0
  216. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3300000.json +8 -0
  217. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3310000.json +8 -0
  218. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3320000.json +8 -0
  219. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3330000.json +8 -0
  220. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3340000.json +8 -0
  221. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3350000.json +8 -0
  222. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3360000.json +8 -0
  223. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3370000.json +8 -0
  224. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3380000.json +8 -0
  225. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3390000.json +8 -0
  226. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3400000.json +8 -0
  227. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3410000.json +8 -0
  228. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3420000.json +8 -0
  229. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3430000.json +8 -0
  230. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3440000.json +8 -0
  231. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3450000.json +8 -0
  232. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3460000.json +8 -0
  233. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3470000.json +8 -0
  234. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3480000.json +8 -0
  235. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3490000.json +8 -0
  236. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3500000.json +8 -0
  237. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3510000.json +8 -0
  238. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3520000.json +8 -0
  239. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3530000.json +8 -0
  240. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3540000.json +8 -0
  241. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3550000.json +8 -0
  242. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3560000.json +8 -0
  243. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3570000.json +8 -0
  244. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3580000.json +8 -0
  245. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3590000.json +8 -0
  246. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3600000.json +8 -0
  247. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3610000.json +8 -0
  248. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3620000.json +8 -0
  249. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3630000.json +8 -0
  250. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3640000.json +8 -0
  251. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3650000.json +8 -0
  252. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3660000.json +8 -0
  253. package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3670000.json +8 -0
  254. package/ios/ZCashLightClientKit/Rust/ZcashKeyDerivationBackend.swift +89 -10
  255. package/ios/ZCashLightClientKit/Rust/ZcashKeyDerivationBackendWelding.swift +39 -3
  256. package/ios/ZCashLightClientKit/Rust/ZcashRustBackend.swift +532 -74
  257. package/ios/ZCashLightClientKit/Rust/ZcashRustBackendWelding.swift +97 -14
  258. package/ios/ZCashLightClientKit/Synchronizer/ClosureSDKSynchronizer.swift +104 -28
  259. package/ios/ZCashLightClientKit/Synchronizer/CombineSDKSynchronizer.swift +105 -31
  260. package/ios/ZCashLightClientKit/Synchronizer/Dependencies.swift +36 -9
  261. package/ios/ZCashLightClientKit/Synchronizer/SDKSynchronizer.swift +401 -175
  262. package/ios/ZCashLightClientKit/Synchronizer.swift +192 -69
  263. package/ios/ZCashLightClientKit/Tool/DerivationTool.swift +69 -12
  264. package/ios/ZCashLightClientKit/Tor/TorClient.swift +502 -11
  265. package/ios/ZCashLightClientKit/Transaction/TransactionEncoder.swift +10 -6
  266. package/ios/ZCashLightClientKit/Transaction/WalletTransactionEncoder.swift +24 -9
  267. package/ios/ZCashLightClientKit/Utils/SDKFlags.swift +71 -0
  268. package/ios/libzcashlc.xcframework/Info.plist +5 -5
  269. package/ios/libzcashlc.xcframework/ios-arm64/libzcashlc.a +0 -0
  270. package/ios/libzcashlc.xcframework/ios-arm64_x86_64-simulator/libzcashlc.a +0 -0
  271. package/ios/zcashlc.h +1640 -378
  272. package/lib/rnzcash.rn.js.map +1 -1
  273. package/lib/src/react-native.d.ts +2 -2
  274. package/lib/src/types.d.ts +2 -0
  275. package/package.json +1 -1
  276. package/src/react-native.ts +2 -3
  277. package/src/types.ts +2 -0
@@ -24,10 +24,51 @@ enum RustLogging: String {
24
24
  case trace
25
25
  }
26
26
 
27
+ /// A description of the policy that is used to determine what notes are available for spending,
28
+ /// based upon the number of confirmations (the number of blocks in the chain since and including
29
+ /// the block in which a note was produced.)
30
+ ///
31
+ /// See [`ZIP 315`] for details including the definitions of "trusted" and "untrusted" notes.
32
+ ///
33
+ /// # Note
34
+ ///
35
+ /// `trusted` and `untrusted` are both meant to be non-zero values.
36
+ /// `0` will be treated as a request for a default value.
37
+ ///
38
+ /// [`ZIP 315`]: https://zips.z.cash/zip-0315
39
+ public struct SwiftConfirmationsPolicy {
40
+ /// NonZero, zero for default
41
+ let trusted: UInt32
42
+ /// NonZero, zero for default; if this is set to zero, `trusted` must also be set to zero
43
+ let untrusted: UInt32
44
+ let allowZeroConfShielding: Bool
45
+
46
+ init(trusted: UInt32 = 3, untrusted: UInt32 = 10, allowZeroConfShielding: Bool = true) {
47
+ self.trusted = trusted
48
+ self.untrusted = untrusted
49
+ self.allowZeroConfShielding = allowZeroConfShielding
50
+ }
51
+
52
+ public static func defaultTransferPolicy() -> Self {
53
+ SwiftConfirmationsPolicy.init()
54
+ }
55
+
56
+ public static func defaultShieldingPolicy() -> Self {
57
+ SwiftConfirmationsPolicy.init(trusted: 1, untrusted: 1, allowZeroConfShielding: true)
58
+ }
59
+
60
+ public func toBackend() -> ConfirmationsPolicy {
61
+ var libzcashlcConfirmationsPolicy = ConfirmationsPolicy()
62
+ libzcashlcConfirmationsPolicy.trusted = self.trusted
63
+ libzcashlcConfirmationsPolicy.untrusted = self.untrusted
64
+ libzcashlcConfirmationsPolicy.allow_zero_conf_shielding = self.allowZeroConfShielding
65
+ return libzcashlcConfirmationsPolicy
66
+ }
67
+ }
68
+
27
69
  struct ZcashRustBackend: ZcashRustBackendWelding {
28
- let minimumConfirmations: UInt32 = 10
29
- let minimumShieldingConfirmations: UInt32 = 1
30
- let useZIP317Fees = true
70
+ let confirmationsPolicy: SwiftConfirmationsPolicy = SwiftConfirmationsPolicy.defaultTransferPolicy()
71
+ let shieldingConfirmationsPolicy: SwiftConfirmationsPolicy = SwiftConfirmationsPolicy.defaultShieldingPolicy()
31
72
 
32
73
  let dbData: (String, UInt)
33
74
  let fsBlockDbRoot: (String, UInt)
@@ -36,6 +77,7 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
36
77
  let keyDeriving: ZcashKeyDerivationBackendWelding
37
78
 
38
79
  let networkType: NetworkType
80
+ let sdkFlags: SDKFlags
39
81
 
40
82
  static var rustInitialized = false
41
83
 
@@ -57,7 +99,8 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
57
99
  spendParamsPath: URL,
58
100
  outputParamsPath: URL,
59
101
  networkType: NetworkType,
60
- logLevel: RustLogging = RustLogging.off
102
+ logLevel: RustLogging = RustLogging.off,
103
+ sdkFlags: SDKFlags
61
104
  ) {
62
105
  self.dbData = dbData.osStr()
63
106
  self.fsBlockDbRoot = fsBlockDbRoot.osPathStr()
@@ -65,6 +108,7 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
65
108
  self.outputParamsPath = outputParamsPath.osPathStr()
66
109
  self.networkType = networkType
67
110
  self.keyDeriving = ZcashKeyDerivationBackend(networkType: networkType)
111
+ self.sdkFlags = sdkFlags
68
112
 
69
113
  if !Self.rustInitialized {
70
114
  Self.rustInitialized = true
@@ -73,7 +117,7 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
73
117
  }
74
118
 
75
119
  @DBActor
76
- func listAccounts() async throws -> [Int32] {
120
+ func listAccounts() async throws -> [Account] {
77
121
  let accountsPtr = zcashlc_list_accounts(
78
122
  dbData.0,
79
123
  dbData.1,
@@ -86,18 +130,103 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
86
130
 
87
131
  defer { zcashlc_free_accounts(accountsPtr) }
88
132
 
89
- var accounts: [Int32] = []
133
+ var accounts: [Account] = []
90
134
 
91
135
  for i in (0 ..< Int(accountsPtr.pointee.len)) {
92
- let account = accountsPtr.pointee.ptr.advanced(by: i).pointee
93
- accounts.append(Int32(account.account_index))
136
+ let accountUUIDPtr = accountsPtr.pointee.ptr.advanced(by: i).pointee
137
+ let accountUUID = AccountUUID(id: accountUUIDPtr.uuidArray)
138
+
139
+ let account = try await getAccount(for: accountUUID)
140
+
141
+ accounts.append(account)
94
142
  }
95
143
 
96
144
  return accounts
97
145
  }
98
146
 
99
147
  @DBActor
100
- func createAccount(seed: [UInt8], treeState: TreeState, recoverUntil: UInt32?) async throws -> UnifiedSpendingKey {
148
+ func getAccount(
149
+ for accountUUID: AccountUUID
150
+ ) async throws -> Account {
151
+ let accountPtr: UnsafeMutablePointer<FfiAccount>? = zcashlc_get_account(
152
+ dbData.0,
153
+ dbData.1,
154
+ networkType.networkId,
155
+ accountUUID.id
156
+ )
157
+
158
+ guard let accountPtr else {
159
+ throw ZcashError.rustImportAccountUfvk(lastErrorMessage(fallback: "`getAccount` failed with unknown error"))
160
+ }
161
+
162
+ defer { zcashlc_free_account(accountPtr) }
163
+
164
+ guard let validAccount = accountPtr.pointee.unsafeToAccount() else {
165
+ throw ZcashError.rustUUIDAccountNotFound(lastErrorMessage(fallback: "`getAccount` failed with unknown error"))
166
+ }
167
+
168
+ return validAccount
169
+ }
170
+
171
+ // swiftlint:disable:next function_parameter_count
172
+ @DBActor func importAccount(
173
+ ufvk: String,
174
+ seedFingerprint: [UInt8]?,
175
+ zip32AccountIndex: Zip32AccountIndex?,
176
+ treeState: TreeState,
177
+ recoverUntil: UInt32?,
178
+ purpose: AccountPurpose,
179
+ name: String,
180
+ keySource: String?
181
+ ) async throws -> AccountUUID {
182
+ var rUntil: Int64 = -1
183
+
184
+ if let recoverUntil {
185
+ rUntil = Int64(recoverUntil)
186
+ }
187
+
188
+ let treeStateBytes = try treeState.serializedData(partial: false).bytes
189
+
190
+ var kSource: [CChar]?
191
+
192
+ if let keySource {
193
+ kSource = [CChar](keySource.utf8CString)
194
+ }
195
+
196
+ let index: UInt32 = zip32AccountIndex?.index ?? UINT32_MAX
197
+
198
+ let uuidPtr = zcashlc_import_account_ufvk(
199
+ dbData.0,
200
+ dbData.1,
201
+ [CChar](ufvk.utf8CString),
202
+ treeStateBytes,
203
+ UInt(treeStateBytes.count),
204
+ rUntil,
205
+ networkType.networkId,
206
+ purpose.rawValue,
207
+ [CChar](name.utf8CString),
208
+ kSource,
209
+ seedFingerprint,
210
+ index
211
+ )
212
+
213
+ guard let uuidPtr else {
214
+ throw ZcashError.rustImportAccountUfvk(lastErrorMessage(fallback: "`importAccount` failed with unknown error"))
215
+ }
216
+
217
+ defer { zcashlc_free_ffi_uuid(uuidPtr) }
218
+
219
+ return uuidPtr.pointee.unsafeToAccountUUID()
220
+ }
221
+
222
+ @DBActor
223
+ func createAccount(
224
+ seed: [UInt8],
225
+ treeState: TreeState,
226
+ recoverUntil: UInt32?,
227
+ name: String,
228
+ keySource: String?
229
+ ) async throws -> UnifiedSpendingKey {
101
230
  var rUntil: Int64 = -1
102
231
 
103
232
  if let recoverUntil {
@@ -106,6 +235,12 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
106
235
 
107
236
  let treeStateBytes = try treeState.serializedData(partial: false).bytes
108
237
 
238
+ var kSource: [CChar]?
239
+
240
+ if let keySource {
241
+ kSource = [CChar](keySource.utf8CString)
242
+ }
243
+
109
244
  let ffiBinaryKeyPtr = zcashlc_create_account(
110
245
  dbData.0,
111
246
  dbData.1,
@@ -114,7 +249,9 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
114
249
  treeStateBytes,
115
250
  UInt(treeStateBytes.count),
116
251
  rUntil,
117
- networkType.networkId
252
+ networkType.networkId,
253
+ [CChar](name.utf8CString),
254
+ kSource
118
255
  )
119
256
 
120
257
  guard let ffiBinaryKeyPtr else {
@@ -149,7 +286,7 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
149
286
 
150
287
  @DBActor
151
288
  func proposeTransfer(
152
- account: Int32,
289
+ accountUUID: AccountUUID,
153
290
  to address: String,
154
291
  value: Int64,
155
292
  memo: MemoBytes?
@@ -157,13 +294,12 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
157
294
  let proposal = zcashlc_propose_transfer(
158
295
  dbData.0,
159
296
  dbData.1,
160
- account,
297
+ accountUUID.id,
161
298
  [CChar](address.utf8CString),
162
299
  value,
163
300
  memo?.bytes,
164
301
  networkType.networkId,
165
- minimumConfirmations,
166
- useZIP317Fees
302
+ confirmationsPolicy.toBackend()
167
303
  )
168
304
 
169
305
  guard let proposal else {
@@ -172,7 +308,7 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
172
308
 
173
309
  defer { zcashlc_free_boxed_slice(proposal) }
174
310
 
175
- return try FfiProposal(contiguousBytes: Data(
311
+ return try FfiProposal(serializedData: Data(
176
312
  bytes: proposal.pointee.ptr,
177
313
  count: Int(proposal.pointee.len)
178
314
  ))
@@ -181,16 +317,15 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
181
317
  @DBActor
182
318
  func proposeTransferFromURI(
183
319
  _ uri: String,
184
- account: Int32
320
+ accountUUID: AccountUUID
185
321
  ) async throws -> FfiProposal {
186
322
  let proposal = zcashlc_propose_transfer_from_uri(
187
323
  dbData.0,
188
324
  dbData.1,
189
- account,
325
+ accountUUID.id,
190
326
  [CChar](uri.utf8CString),
191
327
  networkType.networkId,
192
- minimumConfirmations,
193
- useZIP317Fees
328
+ confirmationsPolicy.toBackend()
194
329
  )
195
330
 
196
331
  guard let proposal else {
@@ -199,34 +334,187 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
199
334
 
200
335
  defer { zcashlc_free_boxed_slice(proposal) }
201
336
 
202
- return try FfiProposal(contiguousBytes: Data(
337
+ return try FfiProposal(serializedData: Data(
203
338
  bytes: proposal.pointee.ptr,
204
339
  count: Int(proposal.pointee.len)
205
340
  ))
206
341
  }
342
+
343
+ @DBActor
344
+ func createPCZTFromProposal(
345
+ accountUUID: AccountUUID,
346
+ proposal: FfiProposal
347
+ ) async throws -> Pczt {
348
+ let proposalBytes = try proposal.serializedData(partial: false).bytes
349
+
350
+ let pcztPtr = proposalBytes.withUnsafeBufferPointer { proposalPtr in
351
+ zcashlc_create_pczt_from_proposal(
352
+ dbData.0,
353
+ dbData.1,
354
+ networkType.networkId,
355
+ proposalPtr.baseAddress,
356
+ UInt(proposalBytes.count),
357
+ accountUUID.id
358
+ )
359
+ }
360
+
361
+ guard let pcztPtr else {
362
+ throw ZcashError.rustCreatePCZTFromProposal(lastErrorMessage(fallback: "`createPCZTFromProposal` failed with unknown error"))
363
+ }
364
+
365
+ defer { zcashlc_free_boxed_slice(pcztPtr) }
366
+
367
+ return Pczt(
368
+ bytes: pcztPtr.pointee.ptr,
369
+ count: Int(pcztPtr.pointee.len)
370
+ )
371
+ }
372
+
373
+ func redactPCZTForSigner(pczt: Pczt) async throws -> Pczt {
374
+ let pcztPtr: UnsafeMutablePointer<FfiBoxedSlice>? = pczt.withUnsafeBytes { buffer in
375
+ guard let bufferPtr = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
376
+ return nil
377
+ }
378
+
379
+ return zcashlc_redact_pczt_for_signer(
380
+ bufferPtr,
381
+ UInt(pczt.count)
382
+ )
383
+ }
384
+
385
+ guard let pcztPtr else {
386
+ throw ZcashError.rustRedactPCZTForSigner(lastErrorMessage(fallback: "`redactPCZTForSigner` failed with unknown error"))
387
+ }
388
+
389
+ defer { zcashlc_free_boxed_slice(pcztPtr) }
390
+
391
+ return Pczt(
392
+ bytes: pcztPtr.pointee.ptr,
393
+ count: Int(pcztPtr.pointee.len)
394
+ )
395
+ }
396
+
397
+ func PCZTRequiresSaplingProofs(pczt: Pczt) async -> Bool {
398
+ return pczt.withUnsafeBytes { buffer in
399
+ guard let bufferPtr = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
400
+ // Return `false` here so the caller proceeds to `addProofsToPCZT` and
401
+ // gets the same error.
402
+ return false
403
+ }
404
+
405
+ return zcashlc_pczt_requires_sapling_proofs(
406
+ bufferPtr,
407
+ UInt(pczt.count)
408
+ )
409
+ }
410
+ }
411
+
412
+ func addProofsToPCZT(
413
+ pczt: Pczt
414
+ ) async throws -> Pczt {
415
+ let pcztPtr: UnsafeMutablePointer<FfiBoxedSlice>? = pczt.withUnsafeBytes { buffer in
416
+ guard let bufferPtr = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
417
+ return nil
418
+ }
419
+
420
+ return zcashlc_add_proofs_to_pczt(
421
+ bufferPtr,
422
+ UInt(pczt.count),
423
+ spendParamsPath.0,
424
+ spendParamsPath.1,
425
+ outputParamsPath.0,
426
+ outputParamsPath.1
427
+ )
428
+ }
429
+
430
+ guard let pcztPtr else {
431
+ throw ZcashError.rustAddProofsToPCZT(lastErrorMessage(fallback: "`addProofsToPCZT` failed with unknown error"))
432
+ }
433
+
434
+ defer { zcashlc_free_boxed_slice(pcztPtr) }
435
+
436
+ return Pczt(
437
+ bytes: pcztPtr.pointee.ptr,
438
+ count: Int(pcztPtr.pointee.len)
439
+ )
440
+ }
207
441
 
208
442
  @DBActor
209
- func decryptAndStoreTransaction(txBytes: [UInt8], minedHeight: UInt32?) async throws {
210
- let result = zcashlc_decrypt_and_store_transaction(
211
- dbData.0,
212
- dbData.1,
213
- txBytes,
214
- UInt(txBytes.count),
215
- Int64(minedHeight ?? 0),
216
- networkType.networkId
443
+ func extractAndStoreTxFromPCZT(
444
+ pcztWithProofs: Pczt,
445
+ pcztWithSigs: Pczt
446
+ ) async throws -> Data {
447
+ let txidPtr: UnsafeMutablePointer<FfiBoxedSlice>? = pcztWithProofs.withUnsafeBytes { pcztWithProofsBuffer in
448
+ guard let pcztWithProofsBufferPtr = pcztWithProofsBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
449
+ return nil
450
+ }
451
+
452
+ return pcztWithSigs.withUnsafeBytes { pcztWithSigsBuffer in
453
+ guard let pcztWithSigsBufferPtr = pcztWithSigsBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
454
+ return nil
455
+ }
456
+
457
+ return zcashlc_extract_and_store_from_pczt(
458
+ dbData.0,
459
+ dbData.1,
460
+ networkType.networkId,
461
+ pcztWithProofsBufferPtr,
462
+ UInt(pcztWithProofs.count),
463
+ pcztWithSigsBufferPtr,
464
+ UInt(pcztWithSigs.count),
465
+ spendParamsPath.0,
466
+ spendParamsPath.1,
467
+ outputParamsPath.0,
468
+ outputParamsPath.1
469
+ )
470
+ }
471
+ }
472
+
473
+ guard let txidPtr else {
474
+ throw ZcashError.rustExtractAndStoreTxFromPCZT(lastErrorMessage(fallback: "`extractAndStoreTxFromPCZT` failed with unknown error"))
475
+ }
476
+
477
+ guard txidPtr.pointee.len == 32 else {
478
+ throw ZcashError.rustTxidPtrIncorrectLength(lastErrorMessage(fallback: "`extractAndStoreTxFromPCZT` failed with unknown error"))
479
+ }
480
+
481
+ defer { zcashlc_free_boxed_slice(txidPtr) }
482
+
483
+ return Data(
484
+ bytes: txidPtr.pointee.ptr,
485
+ count: Int(txidPtr.pointee.len)
217
486
  )
487
+ }
488
+
489
+ @DBActor
490
+ func decryptAndStoreTransaction(txBytes: [UInt8], minedHeight: UInt32?) async throws -> Data {
491
+ var contiguousTxidBytes = ContiguousArray<UInt8>(Data(count: 32))
492
+
493
+ let result = contiguousTxidBytes.withUnsafeMutableBufferPointer { txidBytePtr in
494
+ zcashlc_decrypt_and_store_transaction(
495
+ dbData.0,
496
+ dbData.1,
497
+ txBytes,
498
+ UInt(txBytes.count),
499
+ Int64(minedHeight ?? 0),
500
+ networkType.networkId,
501
+ txidBytePtr.baseAddress
502
+ )
503
+ }
218
504
 
219
505
  guard result != 0 else {
220
506
  throw ZcashError.rustDecryptAndStoreTransaction(lastErrorMessage(fallback: "`decryptAndStoreTransaction` failed with unknown error"))
221
507
  }
508
+
509
+ return Data(contiguousTxidBytes)
222
510
  }
223
511
 
224
512
  @DBActor
225
- func getCurrentAddress(account: Int32) async throws -> UnifiedAddress {
513
+ func getCurrentAddress(accountUUID: AccountUUID) async throws -> UnifiedAddress {
226
514
  let addressCStr = zcashlc_get_current_address(
227
515
  dbData.0,
228
516
  dbData.1,
229
- account,
517
+ accountUUID.id,
230
518
  networkType.networkId
231
519
  )
232
520
 
@@ -244,12 +532,13 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
244
532
  }
245
533
 
246
534
  @DBActor
247
- func getNextAvailableAddress(account: Int32) async throws -> UnifiedAddress {
535
+ func getNextAvailableAddress(accountUUID: AccountUUID, receiverFlags: UInt32) async throws -> UnifiedAddress {
248
536
  let addressCStr = zcashlc_get_next_available_address(
249
537
  dbData.0,
250
538
  dbData.1,
251
- account,
252
- networkType.networkId
539
+ accountUUID.id,
540
+ networkType.networkId,
541
+ receiverFlags
253
542
  )
254
543
 
255
544
  guard let addressCStr else {
@@ -284,22 +573,18 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
284
573
  }
285
574
 
286
575
  @DBActor
287
- func getTransparentBalance(account: Int32) async throws -> Int64 {
288
- guard account >= 0 else {
289
- throw ZcashError.rustGetTransparentBalanceNegativeAccount(Int(account))
290
- }
291
-
576
+ func getTransparentBalance(accountUUID: AccountUUID) async throws -> Int64 {
292
577
  let balance = zcashlc_get_total_transparent_balance_for_account(
293
578
  dbData.0,
294
579
  dbData.1,
295
580
  networkType.networkId,
296
- account
581
+ accountUUID.id
297
582
  )
298
583
 
299
584
  guard balance >= 0 else {
300
585
  throw ZcashError.rustGetTransparentBalance(
301
- Int(account),
302
- lastErrorMessage(fallback: "Error getting Total Transparent balance from account \(account)")
586
+ accountUUID,
587
+ lastErrorMessage(fallback: "Error getting Total Transparent balance from accountUUID \(accountUUID.id)")
303
588
  )
304
589
  }
305
590
 
@@ -307,23 +592,19 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
307
592
  }
308
593
 
309
594
  @DBActor
310
- func getVerifiedTransparentBalance(account: Int32) async throws -> Int64 {
311
- guard account >= 0 else {
312
- throw ZcashError.rustGetVerifiedTransparentBalanceNegativeAccount(Int(account))
313
- }
314
-
595
+ func getVerifiedTransparentBalance(accountUUID: AccountUUID) async throws -> Int64 {
315
596
  let balance = zcashlc_get_verified_transparent_balance_for_account(
316
597
  dbData.0,
317
598
  dbData.1,
318
599
  networkType.networkId,
319
- account,
320
- minimumShieldingConfirmations
600
+ accountUUID.id,
601
+ shieldingConfirmationsPolicy.toBackend()
321
602
  )
322
603
 
323
604
  guard balance >= 0 else {
324
605
  throw ZcashError.rustGetVerifiedTransparentBalance(
325
- Int(account),
326
- lastErrorMessage(fallback: "Error getting verified transparent balance from account \(account)")
606
+ accountUUID,
607
+ lastErrorMessage(fallback: "Error getting verified transparent balance from accountUUID \(accountUUID.id)")
327
608
  )
328
609
  }
329
610
 
@@ -427,11 +708,11 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
427
708
  }
428
709
 
429
710
  @DBActor
430
- func listTransparentReceivers(account: Int32) async throws -> [TransparentAddress] {
711
+ func listTransparentReceivers(accountUUID: AccountUUID) async throws -> [TransparentAddress] {
431
712
  let encodedKeysPtr = zcashlc_list_transparent_receivers(
432
713
  dbData.0,
433
714
  dbData.1,
434
- account,
715
+ accountUUID.id,
435
716
  networkType.networkId
436
717
  )
437
718
 
@@ -486,7 +767,7 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
486
767
 
487
768
  @DBActor
488
769
  func rewindToHeight(height: BlockHeight) async throws -> RewindResult {
489
- var safeRewindHeight: Int64 = -1;
770
+ var safeRewindHeight: Int64 = -1
490
771
  let result = zcashlc_rewind_to_height(dbData.0, dbData.1, UInt32(height), networkType.networkId, &safeRewindHeight)
491
772
 
492
773
  if result >= 0 {
@@ -658,7 +939,7 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
658
939
 
659
940
  @DBActor
660
941
  func getWalletSummary() async throws -> WalletSummary? {
661
- let summaryPtr = zcashlc_get_wallet_summary(dbData.0, dbData.1, networkType.networkId, minimumConfirmations)
942
+ let summaryPtr = zcashlc_get_wallet_summary(dbData.0, dbData.1, networkType.networkId, confirmationsPolicy.toBackend())
662
943
 
663
944
  guard let summaryPtr else {
664
945
  throw ZcashError.rustGetWalletSummary(lastErrorMessage(fallback: "`getWalletSummary` failed with unknown error"))
@@ -670,17 +951,42 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
670
951
  return nil
671
952
  }
672
953
 
673
- var accountBalances: [UInt32: AccountBalance] = [:]
954
+ var accountBalances: [AccountUUID: AccountBalance] = [:]
674
955
 
675
956
  for i in (0 ..< Int(summaryPtr.pointee.account_balances_len)) {
676
957
  let accountBalance = summaryPtr.pointee.account_balances.advanced(by: i).pointee
677
- accountBalances[accountBalance.account_id] = accountBalance.toAccountBalance()
958
+ accountBalances[AccountUUID(id: accountBalance.uuidArray)] = accountBalance.toAccountBalance()
959
+ }
960
+
961
+ // Modify spendable `accountBalances` if chainTip hasn't been updated yet
962
+ if await !sdkFlags.chainTipUpdated {
963
+ accountBalances.forEach { key, _ in
964
+ if let accountBalance = accountBalances[key] {
965
+ accountBalances[key] = AccountBalance(
966
+ saplingBalance: PoolBalance(
967
+ spendableValue: .zero,
968
+ changePendingConfirmation: accountBalance.saplingBalance.changePendingConfirmation,
969
+ valuePendingSpendability: accountBalance.saplingBalance.valuePendingSpendability
970
+ + accountBalance.saplingBalance.spendableValue
971
+ ),
972
+ orchardBalance: PoolBalance(
973
+ spendableValue: .zero,
974
+ changePendingConfirmation: accountBalance.orchardBalance.changePendingConfirmation,
975
+ valuePendingSpendability: accountBalance.orchardBalance.valuePendingSpendability
976
+ + accountBalance.orchardBalance.spendableValue
977
+ ),
978
+ unshielded: .zero,
979
+ awaitingResolution: accountBalance.unshielded
980
+ )
981
+ }
982
+ }
678
983
  }
679
984
 
680
985
  return WalletSummary(
681
986
  accountBalances: accountBalances,
682
987
  chainTipHeight: BlockHeight(summaryPtr.pointee.chain_tip_height),
683
988
  fullyScannedHeight: BlockHeight(summaryPtr.pointee.fully_scanned_height),
989
+ recoveryProgress: summaryPtr.pointee.recovery_progress?.pointee.toScanProgress(),
684
990
  scanProgress: summaryPtr.pointee.scan_progress?.pointee.toScanProgress(),
685
991
  nextSaplingSubtreeIndex: UInt32(summaryPtr.pointee.next_sapling_subtree_index),
686
992
  nextOrchardSubtreeIndex: UInt32(summaryPtr.pointee.next_orchard_subtree_index)
@@ -750,7 +1056,7 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
750
1056
 
751
1057
  @DBActor
752
1058
  func proposeShielding(
753
- account: Int32,
1059
+ accountUUID: AccountUUID,
754
1060
  memo: MemoBytes?,
755
1061
  shieldingThreshold: Zatoshi,
756
1062
  transparentReceiver: String?
@@ -758,13 +1064,12 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
758
1064
  let proposal = zcashlc_propose_shielding(
759
1065
  dbData.0,
760
1066
  dbData.1,
761
- account,
1067
+ accountUUID.id,
762
1068
  memo?.bytes,
763
1069
  UInt64(shieldingThreshold.amount),
764
1070
  transparentReceiver.map { [CChar]($0.utf8CString) },
765
1071
  networkType.networkId,
766
- minimumShieldingConfirmations,
767
- useZIP317Fees
1072
+ shieldingConfirmationsPolicy.toBackend()
768
1073
  )
769
1074
 
770
1075
  guard let proposal else {
@@ -774,10 +1079,10 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
774
1079
  defer { zcashlc_free_boxed_slice(proposal) }
775
1080
 
776
1081
  guard proposal.pointee.ptr != nil else {
777
- throw ZcashError.rustShieldFunds(lastErrorMessage(fallback: "Failed with nil pointer."))
1082
+ return nil
778
1083
  }
779
1084
 
780
- return try FfiProposal(contiguousBytes: Data(
1085
+ return try FfiProposal(serializedData: Data(
781
1086
  bytes: proposal.pointee.ptr,
782
1087
  count: Int(proposal.pointee.len)
783
1088
  ))
@@ -834,8 +1139,8 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
834
1139
  return branchId
835
1140
  }
836
1141
 
837
- @DBActor
838
- func transactionDataRequests() async throws -> [TransactionDataRequest] {
1142
+ // swiftlint:disable:next cyclomatic_complexity
1143
+ @DBActor func transactionDataRequests() async throws -> [TransactionDataRequest] {
839
1144
  let tDataRequestsPtr = zcashlc_transaction_data_requests(
840
1145
  dbData.0,
841
1146
  dbData.1,
@@ -859,15 +1164,47 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
859
1164
  tDataRequest = TransactionDataRequest.getStatus(FfiTxId(tuple: tDataRequestPtr.get_status).array)
860
1165
  } else if tDataRequestPtr.tag == 1 {
861
1166
  tDataRequest = TransactionDataRequest.enhancement(FfiTxId(tuple: tDataRequestPtr.enhancement).array)
862
- } else if tDataRequestPtr.tag == 2, let address = String(validatingUTF8: tDataRequestPtr.spends_from_address.address) {
863
- let end = tDataRequestPtr.spends_from_address.block_range_end
1167
+ } else if tDataRequestPtr.tag == 2, let address = String(validatingUTF8: tDataRequestPtr.transactions_involving_address.address) {
1168
+ let end = tDataRequestPtr.transactions_involving_address.block_range_end
864
1169
  let blockRangeEnd: UInt32? = end > UInt32.max || end == -1 ? nil : UInt32(end)
865
-
866
- tDataRequest = TransactionDataRequest.spendsFromAddress(
867
- SpendsFromAddress(
1170
+
1171
+ let ffiRequestAt = tDataRequestPtr.transactions_involving_address.request_at
1172
+ let requestAt: Date? = if ffiRequestAt == -1 {
1173
+ nil
1174
+ } else if ffiRequestAt >= 0 {
1175
+ Date(timeIntervalSince1970: TimeInterval(ffiRequestAt))
1176
+ } else {
1177
+ throw ZcashError.rustTransactionDataRequests("Invalid request_at")
1178
+ }
1179
+
1180
+ let ffiTxStatusFilter = tDataRequestPtr.transactions_involving_address.tx_status_filter
1181
+ let txStatusFilter = if ffiTxStatusFilter == TransactionStatusFilter_Mined {
1182
+ TransactionStatusFilter.mined
1183
+ } else if ffiTxStatusFilter == TransactionStatusFilter_Mempool {
1184
+ TransactionStatusFilter.mempool
1185
+ } else if ffiTxStatusFilter == TransactionStatusFilter_All {
1186
+ TransactionStatusFilter.all
1187
+ } else {
1188
+ throw ZcashError.rustTransactionDataRequests("Invalid tx_status_filter")
1189
+ }
1190
+
1191
+ let ffiOutputStatusFilter = tDataRequestPtr.transactions_involving_address.output_status_filter
1192
+ let outputStatusFilter = if ffiOutputStatusFilter == OutputStatusFilter_Unspent {
1193
+ OutputStatusFilter.unspent
1194
+ } else if ffiOutputStatusFilter == OutputStatusFilter_All {
1195
+ OutputStatusFilter.all
1196
+ } else {
1197
+ throw ZcashError.rustTransactionDataRequests("Invalid output_status_filter")
1198
+ }
1199
+
1200
+ tDataRequest = TransactionDataRequest.transactionsInvolvingAddress(
1201
+ TransactionsInvolvingAddress(
868
1202
  address: address,
869
- blockRangeStart: tDataRequestPtr.spends_from_address.block_range_start,
870
- blockRangeEnd: blockRangeEnd
1203
+ blockRangeStart: tDataRequestPtr.transactions_involving_address.block_range_start,
1204
+ blockRangeEnd: blockRangeEnd,
1205
+ requestAt: requestAt,
1206
+ txStatusFilter: txStatusFilter,
1207
+ outputStatusFilter: outputStatusFilter
871
1208
  )
872
1209
  )
873
1210
  }
@@ -903,6 +1240,35 @@ struct ZcashRustBackend: ZcashRustBackendWelding {
903
1240
  transactionStatus
904
1241
  )
905
1242
  }
1243
+
1244
+ @DBActor
1245
+ func fixWitnesses() async {
1246
+ zcashlc_fix_witnesses(dbData.0, dbData.1, networkType.networkId)
1247
+ }
1248
+
1249
+ @DBActor
1250
+ func getSingleUseTransparentAddress(accountUUID: AccountUUID) async throws -> SingleUseTransparentAddress {
1251
+ let singleUseTaddrPtr = zcashlc_get_single_use_taddr(
1252
+ dbData.0,
1253
+ dbData.1,
1254
+ networkType.networkId,
1255
+ accountUUID.id
1256
+ )
1257
+
1258
+ guard let singleUseTaddrPtr else {
1259
+ throw ZcashError.rustGetSingleUseTransparentAddress(
1260
+ lastErrorMessage(fallback: "`getSingleUseTransparentAddress` failed with unknown error")
1261
+ )
1262
+ }
1263
+
1264
+ defer { zcashlc_free_single_use_taddr(singleUseTaddrPtr) }
1265
+
1266
+ return SingleUseTransparentAddress(
1267
+ address: String(cString: singleUseTaddrPtr.pointee.address),
1268
+ gapPosition: singleUseTaddrPtr.pointee.gap_position,
1269
+ gapLimit: singleUseTaddrPtr.pointee.gap_limit
1270
+ )
1271
+ }
906
1272
  }
907
1273
 
908
1274
  private extension ZcashRustBackend {
@@ -958,7 +1324,94 @@ extension String {
958
1324
  }
959
1325
  }
960
1326
 
1327
+ extension FfiAddress {
1328
+ /// converts an [`FfiAddress`] into a [`UnifiedAddress`]
1329
+ /// - Note: This does not check that the converted value actually holds a valid UnifiedAddress
1330
+ func unsafeToUnifiedAddress(_ networkType: NetworkType) -> UnifiedAddress {
1331
+ .init(validatedEncoding: String(cString: address), networkType: networkType)
1332
+ }
1333
+ }
1334
+
1335
+ extension FfiAccount {
1336
+ var uuidArray: [UInt8] {
1337
+ withUnsafeBytes(of: uuid_bytes) { buf in
1338
+ [UInt8](buf)
1339
+ }
1340
+ }
1341
+
1342
+ var seedFingerprintArray: [UInt8] {
1343
+ withUnsafeBytes(of: seed_fingerprint) { buf in
1344
+ [UInt8](buf)
1345
+ }
1346
+ }
1347
+
1348
+ /// converts an [`FfiAccount`] into a [`Account`]
1349
+ /// - Note: This does not check that the converted value actually holds a valid Account
1350
+ func unsafeToAccount() -> Account? {
1351
+ // Invalid UUID check
1352
+ guard uuidArray != [UInt8](repeating: 0, count: 16) else {
1353
+ return nil
1354
+ }
1355
+
1356
+ // Invalid ZIP 32 account index
1357
+ if hd_account_index == UInt32.max {
1358
+ return .init(
1359
+ id: AccountUUID(id: uuidArray),
1360
+ name: account_name != nil ? String(cString: account_name) : nil,
1361
+ keySource: key_source != nil ? String(cString: key_source) : nil,
1362
+ seedFingerprint: nil,
1363
+ hdAccountIndex: nil,
1364
+ ufvk: nil
1365
+ )
1366
+ }
1367
+
1368
+ let ufvkTyped = ufvk.map { UnifiedFullViewingKey(validatedEncoding: String(cString: $0)) }
1369
+
1370
+ // Valid ZIP32 account index
1371
+ return .init(
1372
+ id: AccountUUID(id: uuidArray),
1373
+ name: account_name != nil ? String(cString: account_name) : nil,
1374
+ keySource: key_source != nil ? String(cString: key_source) : nil,
1375
+ seedFingerprint: seedFingerprintArray,
1376
+ hdAccountIndex: Zip32AccountIndex(hd_account_index),
1377
+ ufvk: ufvkTyped
1378
+ )
1379
+ }
1380
+ }
1381
+
1382
+ extension FfiBoxedSlice {
1383
+ /// converts an [`FfiBoxedSlice`] into a [`UnifiedSpendingKey`]
1384
+ /// - Note: This does not check that the converted value actually holds a valid USK
1385
+ func unsafeToUnifiedSpendingKey(network: NetworkType) -> UnifiedSpendingKey {
1386
+ .init(
1387
+ network: network,
1388
+ bytes: self.ptr.toByteArray(length: Int(self.len))
1389
+ )
1390
+ }
1391
+ }
1392
+
1393
+ extension FfiUuid {
1394
+ var uuidArray: [UInt8] {
1395
+ withUnsafeBytes(of: self.uuid_bytes) { buf in
1396
+ [UInt8](buf)
1397
+ }
1398
+ }
1399
+
1400
+ /// converts an [`FfiUuid`] into a [`AccountUUID`]
1401
+ func unsafeToAccountUUID() -> AccountUUID {
1402
+ .init(
1403
+ id: self.uuidArray
1404
+ )
1405
+ }
1406
+ }
1407
+
961
1408
  extension FFIBinaryKey {
1409
+ var uuidArray: [UInt8] {
1410
+ withUnsafeBytes(of: self.account_uuid) { buf in
1411
+ [UInt8](buf)
1412
+ }
1413
+ }
1414
+
962
1415
  /// converts an [`FFIBinaryKey`] into a [`UnifiedSpendingKey`]
963
1416
  /// - Note: This does not check that the converted value actually holds a valid USK
964
1417
  func unsafeToUnifiedSpendingKey(network: NetworkType) -> UnifiedSpendingKey {
@@ -966,8 +1419,7 @@ extension FFIBinaryKey {
966
1419
  network: network,
967
1420
  bytes: self.encoding.toByteArray(
968
1421
  length: Int(self.encoding_len)
969
- ),
970
- account: self.account_id
1422
+ )
971
1423
  )
972
1424
  }
973
1425
  }
@@ -1013,6 +1465,12 @@ extension FfiBalance {
1013
1465
  }
1014
1466
 
1015
1467
  extension FfiAccountBalance {
1468
+ var uuidArray: [UInt8] {
1469
+ withUnsafeBytes(of: self.account_uuid) { buf in
1470
+ [UInt8](buf)
1471
+ }
1472
+ }
1473
+
1016
1474
  /// Converts an [`FfiAccountBalance`] into a [`AccountBalance`].
1017
1475
  func toAccountBalance() -> AccountBalance {
1018
1476
  .init(
@@ -1033,7 +1491,7 @@ extension FfiScanProgress {
1033
1491
  }
1034
1492
  }
1035
1493
 
1036
- // swiftlint:disable large_tuple line_length
1494
+ // swiftlint:disable large_tuple line_length file_length
1037
1495
  struct FfiTxId {
1038
1496
  var tuple: (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8)
1039
1497
  var array: [UInt8] {