react-native-zcash 0.9.13 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/android/build.gradle +6 -6
- package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/3130000.json +8 -0
- package/android/src/main/java/app/edge/rnzcash/RNZcashModule.kt +126 -69
- package/ios/RNZcash.m +0 -5
- package/ios/RNZcash.swift +153 -104
- package/ios/ZCashLightClientKit/Account/Account.swift +48 -0
- package/ios/ZCashLightClientKit/Account/AccountMetadataKey.swift +96 -0
- package/ios/ZCashLightClientKit/Block/Actions/ScanAction.swift +23 -4
- package/ios/ZCashLightClientKit/Block/Actions/UpdateChainTipAction.swift +6 -2
- package/ios/ZCashLightClientKit/Block/Actions/UpdateSubtreeRootsAction.swift +4 -2
- package/ios/ZCashLightClientKit/Block/Actions/ValidateServerAction.swift +4 -1
- package/ios/ZCashLightClientKit/Block/CompactBlockProcessor.swift +83 -16
- package/ios/ZCashLightClientKit/Block/Download/BlockDownloader.swift +4 -2
- package/ios/ZCashLightClientKit/Block/Download/BlockDownloaderService.swift +22 -19
- package/ios/ZCashLightClientKit/Block/Enhance/BlockEnhancer.swift +50 -19
- package/ios/ZCashLightClientKit/Block/FetchUnspentTxOutputs/UTXOFetcher.swift +5 -3
- package/ios/ZCashLightClientKit/Block/SaplingParameters/SaplingParametersHandler.swift +22 -5
- package/ios/ZCashLightClientKit/Block/Scan/BlockScanner.swift +2 -1
- package/ios/ZCashLightClientKit/Block/Utils/CompactBlockProgress.swift +5 -3
- package/ios/ZCashLightClientKit/Checkpoint/BundleCheckpointSource.swift +88 -0
- package/ios/ZCashLightClientKit/Checkpoint/CheckpointSource.swift +4 -0
- package/ios/ZCashLightClientKit/ClosureSynchronizer.swift +52 -21
- package/ios/ZCashLightClientKit/CombineSynchronizer.swift +49 -27
- package/ios/ZCashLightClientKit/Constants/ZcashSDK.swift +8 -2
- package/ios/ZCashLightClientKit/DAO/BlockDao.swift +65 -0
- package/ios/ZCashLightClientKit/DAO/TransactionDao.swift +86 -1
- package/ios/ZCashLightClientKit/Entity/AccountEntity.swift +4 -4
- package/ios/ZCashLightClientKit/Entity/Pczt.swift +10 -0
- package/ios/ZCashLightClientKit/Entity/SentNoteEntity.swift +2 -2
- package/ios/ZCashLightClientKit/Entity/TransactionEntity.swift +40 -16
- package/ios/ZCashLightClientKit/Error/Sourcery/generateErrorCode.sh +1 -1
- package/ios/ZCashLightClientKit/Error/ZcashError.swift +182 -14
- package/ios/ZCashLightClientKit/Error/ZcashErrorCode.swift +63 -5
- package/ios/ZCashLightClientKit/Error/ZcashErrorCodeDefinition.swift +122 -12
- package/ios/ZCashLightClientKit/Initializer.swift +49 -14
- package/ios/ZCashLightClientKit/Metrics/SDKMetrics.swift +15 -6
- package/ios/ZCashLightClientKit/Model/SingleUseTransparentAddress.swift +29 -0
- package/ios/ZCashLightClientKit/Model/TransactionDataRequest.swift +83 -2
- package/ios/ZCashLightClientKit/Model/WalletSummary.swift +21 -4
- package/ios/ZCashLightClientKit/Model/WalletTypes.swift +38 -8
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/LightWalletGRPCService.swift +177 -45
- package/ios/ZCashLightClientKit/Modules/Service/LightWalletService.swift +63 -16
- package/ios/ZCashLightClientKit/Modules/Service/Tor/LightWalletGRPCServiceOverTor.swift +273 -0
- package/ios/ZCashLightClientKit/Providers/LatestBlocksDataProvider.swift +5 -2
- package/ios/ZCashLightClientKit/Repository/TransactionRepository.swift +2 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2675000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2677500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2682500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2685000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2687500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2692500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2695000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2697500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2702500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2705000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2707500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2712500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2715000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2717500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2722500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2725000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2727500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2732500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2735000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2737500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2742500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2745000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2747500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2752500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2755000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2757500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2762500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2765000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2767500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2772500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2775000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2777500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2782500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2785000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2787500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2792500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2795000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2797500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2802500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2805000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2807500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2812500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2815000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2817500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2822500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2825000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2827500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2832500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2835000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2837500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2842500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2845000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2847500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2852500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2855000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2857500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2862500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2865000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2867500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2872500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2875000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2877500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2882500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2885000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2887500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2892500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2895000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2897500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2902500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2905000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2907500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2912500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2915000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2917500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2922500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2925000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2927500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2932500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2935000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2937500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2942500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2945000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2947500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2952500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2955000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2957500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2962500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2965000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2967500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2972500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2975000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2977500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2982500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2985000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2987500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2992500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2995000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2997500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3002500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3005000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3007500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3012500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3015000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3017500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3022500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3025000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3027500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3032500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3035000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3037500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3042500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3045000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3047500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3052500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3055000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3057500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3062500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3065000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3067500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3072500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3075000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3077500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3082500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3085000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3087500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3092500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3095000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3097500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3102500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3105000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3107500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3112500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3115000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3117500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3122500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3125000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3127500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/3130000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3010000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3020000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3030000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3040000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3050000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3060000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3070000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3080000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3090000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3100000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3110000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3120000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3130000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3140000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3150000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3160000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3170000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3180000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3190000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3200000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3210000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3220000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3230000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3240000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3250000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3260000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3270000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3280000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3290000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3300000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3310000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3320000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3330000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3340000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3350000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3360000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3370000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3380000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3390000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3400000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3410000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3420000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3430000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3440000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3450000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3460000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3470000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3480000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3490000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3500000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3510000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3520000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3530000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3540000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3550000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3560000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3570000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3580000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3590000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3600000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3610000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3620000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3630000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3640000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3650000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3660000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/3670000.json +8 -0
- package/ios/ZCashLightClientKit/Rust/ZcashKeyDerivationBackend.swift +89 -10
- package/ios/ZCashLightClientKit/Rust/ZcashKeyDerivationBackendWelding.swift +39 -3
- package/ios/ZCashLightClientKit/Rust/ZcashRustBackend.swift +532 -74
- package/ios/ZCashLightClientKit/Rust/ZcashRustBackendWelding.swift +97 -14
- package/ios/ZCashLightClientKit/Synchronizer/ClosureSDKSynchronizer.swift +104 -28
- package/ios/ZCashLightClientKit/Synchronizer/CombineSDKSynchronizer.swift +105 -31
- package/ios/ZCashLightClientKit/Synchronizer/Dependencies.swift +36 -9
- package/ios/ZCashLightClientKit/Synchronizer/SDKSynchronizer.swift +401 -175
- package/ios/ZCashLightClientKit/Synchronizer.swift +192 -69
- package/ios/ZCashLightClientKit/Tool/DerivationTool.swift +69 -12
- package/ios/ZCashLightClientKit/Tor/TorClient.swift +502 -11
- package/ios/ZCashLightClientKit/Transaction/TransactionEncoder.swift +10 -6
- package/ios/ZCashLightClientKit/Transaction/WalletTransactionEncoder.swift +24 -9
- package/ios/ZCashLightClientKit/Utils/SDKFlags.swift +71 -0
- package/ios/libzcashlc.xcframework/Info.plist +5 -5
- package/ios/libzcashlc.xcframework/ios-arm64/libzcashlc.a +0 -0
- package/ios/libzcashlc.xcframework/ios-arm64_x86_64-simulator/libzcashlc.a +0 -0
- package/ios/zcashlc.h +1640 -378
- package/lib/rnzcash.rn.js.map +1 -1
- package/lib/src/react-native.d.ts +2 -2
- package/lib/src/types.d.ts +2 -0
- package/package.json +1 -1
- package/src/react-native.ts +2 -3
- package/src/types.ts +2 -0
|
@@ -31,4 +31,8 @@ protocol CheckpointSource {
|
|
|
31
31
|
/// - Note: When the user knows the exact height of the first received funds for a wallet,
|
|
32
32
|
/// the effective birthday of that wallet is `transaction.height - 1`.
|
|
33
33
|
func birthday(for height: BlockHeight) -> Checkpoint
|
|
34
|
+
|
|
35
|
+
/// Takes a given date and finds out the closes checkpoint's height for it.
|
|
36
|
+
/// Each checkpoint has a timestamp stored so it can be used for the calculations.
|
|
37
|
+
func estimateBirthdayHeight(for date: Date) -> BlockHeight
|
|
34
38
|
}
|
|
@@ -22,23 +22,27 @@ public protocol ClosureSynchronizer {
|
|
|
22
22
|
var stateStream: AnyPublisher<SynchronizerState, Never> { get }
|
|
23
23
|
var eventStream: AnyPublisher<SynchronizerEvent, Never> { get }
|
|
24
24
|
|
|
25
|
+
// swiftlint:disable:next function_parameter_count
|
|
25
26
|
func prepare(
|
|
26
27
|
with seed: [UInt8]?,
|
|
27
28
|
walletBirthday: BlockHeight,
|
|
28
29
|
for walletMode: WalletInitMode,
|
|
30
|
+
name: String,
|
|
31
|
+
keySource: String?,
|
|
29
32
|
completion: @escaping (Result<Initializer.InitializationResult, Error>) -> Void
|
|
30
33
|
)
|
|
31
34
|
|
|
32
35
|
func start(retry: Bool, completion: @escaping (Error?) -> Void)
|
|
33
36
|
func stop()
|
|
34
37
|
|
|
35
|
-
func getSaplingAddress(
|
|
36
|
-
func getUnifiedAddress(
|
|
37
|
-
func getTransparentAddress(
|
|
38
|
+
func getSaplingAddress(accountUUID: AccountUUID, completion: @escaping (Result<SaplingAddress, Error>) -> Void)
|
|
39
|
+
func getUnifiedAddress(accountUUID: AccountUUID, completion: @escaping (Result<UnifiedAddress, Error>) -> Void)
|
|
40
|
+
func getTransparentAddress(accountUUID: AccountUUID, completion: @escaping (Result<TransparentAddress, Error>) -> Void)
|
|
41
|
+
func getCustomUnifiedAddress(accountUUID: AccountUUID, receivers: Set<ReceiverType>, completion: @escaping (Result<UnifiedAddress, Error>) -> Void)
|
|
38
42
|
|
|
39
43
|
/// Creates a proposal for transferring funds to the given recipient.
|
|
40
44
|
///
|
|
41
|
-
/// - Parameter
|
|
45
|
+
/// - Parameter accountUUID: the account from which to transfer funds.
|
|
42
46
|
/// - Parameter recipient: the recipient's address.
|
|
43
47
|
/// - Parameter amount: the amount to send in Zatoshi.
|
|
44
48
|
/// - Parameter memo: an optional memo to include as part of the proposal's transactions. Use `nil` when sending to transparent receivers otherwise the function will throw an error.
|
|
@@ -46,7 +50,7 @@ public protocol ClosureSynchronizer {
|
|
|
46
50
|
/// If `prepare()` hasn't already been called since creation of the synchronizer instance or since the last wipe then this method throws
|
|
47
51
|
/// `SynchronizerErrors.notPrepared`.
|
|
48
52
|
func proposeTransfer(
|
|
49
|
-
|
|
53
|
+
accountUUID: AccountUUID,
|
|
50
54
|
recipient: Recipient,
|
|
51
55
|
amount: Zatoshi,
|
|
52
56
|
memo: Memo?,
|
|
@@ -55,7 +59,7 @@ public protocol ClosureSynchronizer {
|
|
|
55
59
|
|
|
56
60
|
/// Creates a proposal for shielding any transparent funds received by the given account.
|
|
57
61
|
///
|
|
58
|
-
/// - Parameter
|
|
62
|
+
/// - Parameter accountUUID: the account from which to shield funds.
|
|
59
63
|
/// - Parameter shieldingThreshold: the minimum transparent balance required before a proposal will be created.
|
|
60
64
|
/// - Parameter memo: an optional memo to include as part of the proposal's transactions.
|
|
61
65
|
/// - Parameter transparentReceiver: a specific transparent receiver within the account
|
|
@@ -69,7 +73,7 @@ public protocol ClosureSynchronizer {
|
|
|
69
73
|
/// If `prepare()` hasn't already been called since creation of the synchronizer instance or since the last wipe then this method throws
|
|
70
74
|
/// `SynchronizerErrors.notPrepared`.
|
|
71
75
|
func proposeShielding(
|
|
72
|
-
|
|
76
|
+
accountUUID: AccountUUID,
|
|
73
77
|
shieldingThreshold: Zatoshi,
|
|
74
78
|
memo: Memo,
|
|
75
79
|
transparentReceiver: TransparentAddress?,
|
|
@@ -93,23 +97,46 @@ public protocol ClosureSynchronizer {
|
|
|
93
97
|
completion: @escaping (Result<AsyncThrowingStream<TransactionSubmitResult, Error>, Error>) -> Void
|
|
94
98
|
)
|
|
95
99
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
toAddress: Recipient,
|
|
101
|
-
memo: Memo?,
|
|
102
|
-
completion: @escaping (Result<ZcashTransaction.Overview, Error>) -> Void
|
|
100
|
+
func createPCZTFromProposal(
|
|
101
|
+
accountUUID: AccountUUID,
|
|
102
|
+
proposal: Proposal,
|
|
103
|
+
completion: @escaping (Result<Pczt, Error>) -> Void
|
|
103
104
|
)
|
|
104
105
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
func redactPCZTForSigner(
|
|
107
|
+
pczt: Pczt,
|
|
108
|
+
completion: @escaping (Result<Pczt, Error>) -> Void
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
func PCZTRequiresSaplingProofs(
|
|
112
|
+
pczt: Pczt,
|
|
113
|
+
completion: @escaping (Bool) -> Void
|
|
111
114
|
)
|
|
112
115
|
|
|
116
|
+
func addProofsToPCZT(
|
|
117
|
+
pczt: Pczt,
|
|
118
|
+
completion: @escaping (Result<Pczt, Error>) -> Void
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
func createTransactionFromPCZT(
|
|
122
|
+
pcztWithProofs: Pczt,
|
|
123
|
+
pcztWithSigs: Pczt,
|
|
124
|
+
completion: @escaping (Result<AsyncThrowingStream<TransactionSubmitResult, Error>, Error>) -> Void
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
func listAccounts(completion: @escaping (Result<[Account], Error>) -> Void)
|
|
128
|
+
|
|
129
|
+
// swiftlint:disable:next function_parameter_count
|
|
130
|
+
func importAccount(
|
|
131
|
+
ufvk: String,
|
|
132
|
+
seedFingerprint: [UInt8]?,
|
|
133
|
+
zip32AccountIndex: Zip32AccountIndex?,
|
|
134
|
+
purpose: AccountPurpose,
|
|
135
|
+
name: String,
|
|
136
|
+
keySource: String?,
|
|
137
|
+
completion: @escaping (Result<AccountUUID, Error>) -> Void
|
|
138
|
+
) async throws
|
|
139
|
+
|
|
113
140
|
func clearedTransactions(completion: @escaping ([ZcashTransaction.Overview]) -> Void)
|
|
114
141
|
func sentTranscations(completion: @escaping ([ZcashTransaction.Overview]) -> Void)
|
|
115
142
|
func receivedTransactions(completion: @escaping ([ZcashTransaction.Overview]) -> Void)
|
|
@@ -127,10 +154,14 @@ public protocol ClosureSynchronizer {
|
|
|
127
154
|
|
|
128
155
|
func refreshUTXOs(address: TransparentAddress, from height: BlockHeight, completion: @escaping (Result<RefreshedUTXOs, Error>) -> Void)
|
|
129
156
|
|
|
130
|
-
func
|
|
157
|
+
func getAccountsBalances(_ completion: @escaping (Result<[AccountUUID: AccountBalance], Error>) -> Void)
|
|
131
158
|
|
|
132
159
|
func refreshExchangeRateUSD()
|
|
133
160
|
|
|
161
|
+
func estimateBirthdayHeight(for date: Date, completion: @escaping (BlockHeight) -> Void)
|
|
162
|
+
|
|
163
|
+
func httpRequestOverTor(for request: URLRequest, retryLimit: UInt8, completion: @escaping (Result<(data: Data, response: HTTPURLResponse), Error>) -> Void)
|
|
164
|
+
|
|
134
165
|
/*
|
|
135
166
|
It can be missleading that these two methods are returning Publisher even this protocol is closure based. Reason is that Synchronizer doesn't
|
|
136
167
|
provide different implementations for these two methods. So Combine it is even here.
|
|
@@ -25,19 +25,22 @@ public protocol CombineSynchronizer {
|
|
|
25
25
|
func prepare(
|
|
26
26
|
with seed: [UInt8]?,
|
|
27
27
|
walletBirthday: BlockHeight,
|
|
28
|
-
for walletMode: WalletInitMode
|
|
28
|
+
for walletMode: WalletInitMode,
|
|
29
|
+
name: String,
|
|
30
|
+
keySource: String?
|
|
29
31
|
) -> SinglePublisher<Initializer.InitializationResult, Error>
|
|
30
32
|
|
|
31
33
|
func start(retry: Bool) -> CompletablePublisher<Error>
|
|
32
34
|
func stop()
|
|
33
35
|
|
|
34
|
-
func getSaplingAddress(
|
|
35
|
-
func getUnifiedAddress(
|
|
36
|
-
func getTransparentAddress(
|
|
36
|
+
func getSaplingAddress(accountUUID: AccountUUID) -> SinglePublisher<SaplingAddress, Error>
|
|
37
|
+
func getUnifiedAddress(accountUUID: AccountUUID) -> SinglePublisher<UnifiedAddress, Error>
|
|
38
|
+
func getTransparentAddress(accountUUID: AccountUUID) -> SinglePublisher<TransparentAddress, Error>
|
|
39
|
+
func getCustomUnifiedAddress(accountUUID: AccountUUID, receivers: Set<ReceiverType>) -> SinglePublisher<UnifiedAddress, Error>
|
|
37
40
|
|
|
38
41
|
/// Creates a proposal for transferring funds to the given recipient.
|
|
39
42
|
///
|
|
40
|
-
/// - Parameter
|
|
43
|
+
/// - Parameter accountUUID: the account from which to transfer funds.
|
|
41
44
|
/// - Parameter recipient: the recipient's address.
|
|
42
45
|
/// - Parameter amount: the amount to send in Zatoshi.
|
|
43
46
|
/// - Parameter memo: an optional memo to include as part of the proposal's transactions. Use `nil` when sending to transparent receivers otherwise the function will throw an error.
|
|
@@ -45,7 +48,7 @@ public protocol CombineSynchronizer {
|
|
|
45
48
|
/// If `prepare()` hasn't already been called since creation of the synchronizer instance or since the last wipe then this method throws
|
|
46
49
|
/// `SynchronizerErrors.notPrepared`.
|
|
47
50
|
func proposeTransfer(
|
|
48
|
-
|
|
51
|
+
accountUUID: AccountUUID,
|
|
49
52
|
recipient: Recipient,
|
|
50
53
|
amount: Zatoshi,
|
|
51
54
|
memo: Memo?
|
|
@@ -53,7 +56,7 @@ public protocol CombineSynchronizer {
|
|
|
53
56
|
|
|
54
57
|
/// Creates a proposal for shielding any transparent funds received by the given account.
|
|
55
58
|
///
|
|
56
|
-
/// - Parameter
|
|
59
|
+
/// - Parameter accountUUID: the account from which to shield funds.
|
|
57
60
|
/// - Parameter shieldingThreshold: the minimum transparent balance required before a proposal will be created.
|
|
58
61
|
/// - Parameter memo: an optional memo to include as part of the proposal's transactions.
|
|
59
62
|
/// - Parameter transparentReceiver: a specific transparent receiver within the account
|
|
@@ -67,7 +70,7 @@ public protocol CombineSynchronizer {
|
|
|
67
70
|
/// If `prepare()` hasn't already been called since creation of the synchronizer instance or since the last wipe then this method throws
|
|
68
71
|
/// `SynchronizerErrors.notPrepared`.
|
|
69
72
|
func proposeShielding(
|
|
70
|
-
|
|
73
|
+
accountUUID: AccountUUID,
|
|
71
74
|
shieldingThreshold: Zatoshi,
|
|
72
75
|
memo: Memo,
|
|
73
76
|
transparentReceiver: TransparentAddress?
|
|
@@ -89,30 +92,45 @@ public protocol CombineSynchronizer {
|
|
|
89
92
|
spendingKey: UnifiedSpendingKey
|
|
90
93
|
) -> SinglePublisher<AsyncThrowingStream<TransactionSubmitResult, Error>, Error>
|
|
91
94
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
func
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
shieldingThreshold: Zatoshi
|
|
109
|
-
) -> SinglePublisher<ZcashTransaction.Overview, Error>
|
|
95
|
+
func createPCZTFromProposal(
|
|
96
|
+
accountUUID: AccountUUID,
|
|
97
|
+
proposal: Proposal
|
|
98
|
+
) -> SinglePublisher<Pczt, Error>
|
|
99
|
+
|
|
100
|
+
func redactPCZTForSigner(
|
|
101
|
+
pczt: Pczt
|
|
102
|
+
) -> SinglePublisher<Pczt, Error>
|
|
103
|
+
|
|
104
|
+
func PCZTRequiresSaplingProofs(
|
|
105
|
+
pczt: Pczt
|
|
106
|
+
) -> SinglePublisher<Bool, Never>
|
|
107
|
+
|
|
108
|
+
func addProofsToPCZT(
|
|
109
|
+
pczt: Pczt
|
|
110
|
+
) -> SinglePublisher<Pczt, Error>
|
|
110
111
|
|
|
112
|
+
func createTransactionFromPCZT(
|
|
113
|
+
pcztWithProofs: Pczt,
|
|
114
|
+
pcztWithSigs: Pczt
|
|
115
|
+
) -> SinglePublisher<AsyncThrowingStream<TransactionSubmitResult, Error>, Error>
|
|
116
|
+
|
|
111
117
|
func proposefulfillingPaymentURI(
|
|
112
118
|
_ uri: String,
|
|
113
|
-
|
|
119
|
+
accountUUID: AccountUUID
|
|
114
120
|
) -> SinglePublisher<Proposal, Error>
|
|
115
121
|
|
|
122
|
+
func listAccounts() -> SinglePublisher<[Account], Error>
|
|
123
|
+
|
|
124
|
+
// swiftlint:disable:next function_parameter_count
|
|
125
|
+
func importAccount(
|
|
126
|
+
ufvk: String,
|
|
127
|
+
seedFingerprint: [UInt8]?,
|
|
128
|
+
zip32AccountIndex: Zip32AccountIndex?,
|
|
129
|
+
purpose: AccountPurpose,
|
|
130
|
+
name: String,
|
|
131
|
+
keySource: String?
|
|
132
|
+
) async throws -> SinglePublisher<AccountUUID, Error>
|
|
133
|
+
|
|
116
134
|
var allTransactions: SinglePublisher<[ZcashTransaction.Overview], Never> { get }
|
|
117
135
|
var sentTransactions: SinglePublisher<[ZcashTransaction.Overview], Never> { get }
|
|
118
136
|
var receivedTransactions: SinglePublisher<[ZcashTransaction.Overview], Never> { get }
|
|
@@ -131,6 +149,10 @@ public protocol CombineSynchronizer {
|
|
|
131
149
|
|
|
132
150
|
func refreshExchangeRateUSD()
|
|
133
151
|
|
|
152
|
+
func estimateBirthdayHeight(for date: Date) -> SinglePublisher<BlockHeight, Error>
|
|
153
|
+
|
|
154
|
+
func httpRequestOverTor(for request: URLRequest, retryLimit: UInt8) -> SinglePublisher<(data: Data, response: HTTPURLResponse), Error>
|
|
155
|
+
|
|
134
156
|
func rewind(_ policy: RewindPolicy) -> CompletablePublisher<Error>
|
|
135
157
|
func wipe() -> CompletablePublisher<Error>
|
|
136
158
|
}
|
|
@@ -11,7 +11,7 @@ public protocol ZcashNetwork {
|
|
|
11
11
|
var constants: NetworkConstants.Type { get }
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
public enum NetworkType {
|
|
14
|
+
public enum NetworkType: Equatable, Codable, Hashable {
|
|
15
15
|
case mainnet
|
|
16
16
|
case testnet
|
|
17
17
|
|
|
@@ -136,7 +136,7 @@ public enum ZcashSDK {
|
|
|
136
136
|
/// The Url that is used by default in zcashd.
|
|
137
137
|
/// We'll want to make this externally configurable, rather than baking it into the SDK but
|
|
138
138
|
/// this will do for now, since we're using a cloudfront URL that already redirects.
|
|
139
|
-
public static let cloudParameterURL = "https://z.cash/downloads/"
|
|
139
|
+
public static let cloudParameterURL = "https://download.z.cash/downloads/"
|
|
140
140
|
|
|
141
141
|
/// File name for the sapling spend params
|
|
142
142
|
public static let spendParamFilename = "sapling-spend.params"
|
|
@@ -219,3 +219,9 @@ public enum ZcashSDKTestnetConstants: NetworkConstants {
|
|
|
219
219
|
|
|
220
220
|
public static let defaultDbNamePrefix = "ZcashSdk_testnet_"
|
|
221
221
|
}
|
|
222
|
+
|
|
223
|
+
/// Used when importing an account `importAccount(..., purpose: AccountPurpose)`
|
|
224
|
+
public enum AccountPurpose: UInt32, Equatable {
|
|
225
|
+
case spending = 0
|
|
226
|
+
case viewOnly
|
|
227
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// BlockDao.swift
|
|
2
|
+
// ZcashLightClientKit
|
|
3
|
+
//
|
|
4
|
+
// Created by Lukas Korba on 2025-01-25.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
import SQLite
|
|
9
|
+
|
|
10
|
+
protocol BlockDao {
|
|
11
|
+
func block(at height: BlockHeight) throws -> Block?
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
struct Block: Codable {
|
|
15
|
+
enum CodingKeys: String, CodingKey {
|
|
16
|
+
case height
|
|
17
|
+
case time
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
enum TableStructure {
|
|
21
|
+
static let height = SQLite.Expression<Int>(Block.CodingKeys.height.rawValue)
|
|
22
|
+
static let time = SQLite.Expression<Int>(Block.CodingKeys.time.rawValue)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let height: BlockHeight
|
|
26
|
+
let time: Int
|
|
27
|
+
|
|
28
|
+
static let table = Table("blocks")
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class BlockSQLDAO: BlockDao {
|
|
32
|
+
let dbProvider: ConnectionProvider
|
|
33
|
+
let table: Table
|
|
34
|
+
let height = SQLite.Expression<Int>("height")
|
|
35
|
+
|
|
36
|
+
init(dbProvider: ConnectionProvider) {
|
|
37
|
+
self.dbProvider = dbProvider
|
|
38
|
+
self.table = Table("Blocks")
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// - Throws:
|
|
42
|
+
/// - `blockDAOCantDecode` if block data loaded from DB can't be decoded to `Block` object.
|
|
43
|
+
/// - `blockDAOBlock` if sqlite query to load block metadata failed.
|
|
44
|
+
func block(at height: BlockHeight) throws -> Block? {
|
|
45
|
+
do {
|
|
46
|
+
return try dbProvider
|
|
47
|
+
.connection()
|
|
48
|
+
.prepare(Block.table.filter(Block.TableStructure.height == height).limit(1))
|
|
49
|
+
.map {
|
|
50
|
+
do {
|
|
51
|
+
return try $0.decode()
|
|
52
|
+
} catch {
|
|
53
|
+
throw ZcashError.blockDAOCantDecode(error)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
.first
|
|
57
|
+
} catch {
|
|
58
|
+
if let error = error as? ZcashError {
|
|
59
|
+
throw error
|
|
60
|
+
} else {
|
|
61
|
+
throw ZcashError.blockDAOBlock(error)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -8,20 +8,53 @@
|
|
|
8
8
|
import Foundation
|
|
9
9
|
import SQLite
|
|
10
10
|
|
|
11
|
+
extension Connection {
|
|
12
|
+
func debugQuery(_ sql: String) -> String {
|
|
13
|
+
do {
|
|
14
|
+
let rows = try self.prepare(sql)
|
|
15
|
+
var result = ""
|
|
16
|
+
|
|
17
|
+
for row in rows {
|
|
18
|
+
let stringRow = row.map { value -> String in
|
|
19
|
+
if let value {
|
|
20
|
+
return "\(value)"
|
|
21
|
+
}
|
|
22
|
+
return "NULL"
|
|
23
|
+
}
|
|
24
|
+
.joined(separator: " | ")
|
|
25
|
+
|
|
26
|
+
result = "\(result)\n\(stringRow)"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return result.isEmpty ? "No results" : result
|
|
30
|
+
} catch {
|
|
31
|
+
return "Error: \(error)"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
11
36
|
class TransactionSQLDAO: TransactionRepository {
|
|
12
37
|
enum NotesTableStructure {
|
|
13
38
|
static let transactionID = SQLite.Expression<Int>("tx")
|
|
14
39
|
static let memo = SQLite.Expression<Blob>("memo")
|
|
15
40
|
}
|
|
16
41
|
|
|
42
|
+
enum UserMetadata {
|
|
43
|
+
static let txid = SQLite.Expression<Blob>("txid")
|
|
44
|
+
static let memoCount = SQLite.Expression<Int>("memo_count")
|
|
45
|
+
static let memo = SQLite.Expression<String>("memo")
|
|
46
|
+
}
|
|
47
|
+
|
|
17
48
|
let dbProvider: ConnectionProvider
|
|
18
49
|
|
|
50
|
+
private let blockDao: BlockSQLDAO
|
|
19
51
|
private let transactionsView = View("v_transactions")
|
|
20
52
|
private let txOutputsView = View("v_tx_outputs")
|
|
21
53
|
private let traceClosure: ((String) -> Void)?
|
|
22
54
|
|
|
23
55
|
init(dbProvider: ConnectionProvider, traceClosure: ((String) -> Void)? = nil) {
|
|
24
56
|
self.dbProvider = dbProvider
|
|
57
|
+
self.blockDao = BlockSQLDAO(dbProvider: dbProvider)
|
|
25
58
|
self.traceClosure = traceClosure
|
|
26
59
|
}
|
|
27
60
|
|
|
@@ -38,7 +71,49 @@ class TransactionSQLDAO: TransactionRepository {
|
|
|
38
71
|
func isInitialized() async throws -> Bool {
|
|
39
72
|
true
|
|
40
73
|
}
|
|
74
|
+
|
|
75
|
+
func resolveMissingBlockTimes(for transactions: [ZcashTransaction.Overview]) async throws -> [ZcashTransaction.Overview] {
|
|
76
|
+
var transactionsCopy = transactions
|
|
77
|
+
|
|
78
|
+
for i in 0..<transactions.count {
|
|
79
|
+
let transaction = transactions[i]
|
|
80
|
+
|
|
81
|
+
guard transaction.blockTime == nil else {
|
|
82
|
+
continue
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if let expiryHeight = transaction.expiryHeight {
|
|
86
|
+
if let block = try await blockForHeight(expiryHeight) {
|
|
87
|
+
transactionsCopy[i].blockTime = TimeInterval(block.time)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return transactionsCopy
|
|
93
|
+
}
|
|
41
94
|
|
|
95
|
+
@DBActor
|
|
96
|
+
func fetchTxidsWithMemoContaining(searchTerm: String) async throws -> [Data] {
|
|
97
|
+
let query = transactionsView
|
|
98
|
+
.join(txOutputsView, on: transactionsView[UserMetadata.txid] == txOutputsView[UserMetadata.txid])
|
|
99
|
+
.filter(transactionsView[UserMetadata.memoCount] > 0)
|
|
100
|
+
.filter(txOutputsView[UserMetadata.memo].like("%\(searchTerm)%"))
|
|
101
|
+
|
|
102
|
+
var txids: [Data] = []
|
|
103
|
+
for row in try connection().prepare(query) {
|
|
104
|
+
let txidBlob = try row.get(txOutputsView[UserMetadata.txid])
|
|
105
|
+
let txid = Data(blob: txidBlob)
|
|
106
|
+
txids.append(txid)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return txids
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@DBActor
|
|
113
|
+
func blockForHeight(_ height: BlockHeight) async throws -> Block? {
|
|
114
|
+
try blockDao.block(at: height)
|
|
115
|
+
}
|
|
116
|
+
|
|
42
117
|
@DBActor
|
|
43
118
|
func countAll() async throws -> Int {
|
|
44
119
|
do {
|
|
@@ -71,7 +146,9 @@ class TransactionSQLDAO: TransactionRepository {
|
|
|
71
146
|
.filterQueryFor(kind: kind)
|
|
72
147
|
.limit(limit, offset: offset)
|
|
73
148
|
|
|
74
|
-
|
|
149
|
+
let transactions: [ZcashTransaction.Overview] = try await execute(query) { try ZcashTransaction.Overview(row: $0) }
|
|
150
|
+
|
|
151
|
+
return try await resolveMissingBlockTimes(for: transactions)
|
|
75
152
|
}
|
|
76
153
|
|
|
77
154
|
func find(in range: CompactBlockRange, limit: Int, kind: TransactionKind) async throws -> [ZcashTransaction.Overview] {
|
|
@@ -197,6 +274,14 @@ class TransactionSQLDAO: TransactionRepository {
|
|
|
197
274
|
}
|
|
198
275
|
}
|
|
199
276
|
}
|
|
277
|
+
|
|
278
|
+
func debugDatabase(sql: String) -> String {
|
|
279
|
+
guard let connection = try? connection() else {
|
|
280
|
+
return "Connection failed"
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return connection.debugQuery(sql)
|
|
284
|
+
}
|
|
200
285
|
}
|
|
201
286
|
|
|
202
287
|
private extension View {
|
|
@@ -9,24 +9,24 @@ import Foundation
|
|
|
9
9
|
import SQLite
|
|
10
10
|
|
|
11
11
|
protocol AccountEntity {
|
|
12
|
-
var
|
|
12
|
+
var accountIndex: Zip32AccountIndex { get }
|
|
13
13
|
var ufvk: String { get }
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
struct DbAccount: AccountEntity, Encodable, Decodable {
|
|
17
|
-
let
|
|
17
|
+
let accountIndex: Zip32AccountIndex
|
|
18
18
|
let ufvk: String
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
extension DbAccount: Hashable {
|
|
22
22
|
func hash(into hasher: inout Hasher) {
|
|
23
|
-
hasher.combine(
|
|
23
|
+
hasher.combine(accountIndex.index)
|
|
24
24
|
hasher.combine(ufvk)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
static func == (lhs: Self, rhs: Self) -> Bool {
|
|
28
28
|
guard
|
|
29
|
-
lhs.
|
|
29
|
+
lhs.accountIndex == rhs.accountIndex,
|
|
30
30
|
lhs.ufvk == rhs.ufvk
|
|
31
31
|
else { return false }
|
|
32
32
|
|
|
@@ -11,9 +11,9 @@ protocol SentNoteEntity {
|
|
|
11
11
|
var id: Int { get }
|
|
12
12
|
var transactionId: Int { get }
|
|
13
13
|
var outputIndex: Int { get }
|
|
14
|
-
var fromAccount:
|
|
14
|
+
var fromAccount: AccountId { get }
|
|
15
15
|
var toAddress: String? { get }
|
|
16
|
-
var toAccount:
|
|
16
|
+
var toAccount: AccountId? { get }
|
|
17
17
|
var value: Int { get }
|
|
18
18
|
var memo: Data? { get }
|
|
19
19
|
}
|