react-native-zcash 0.3.4 → 0.3.5
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 +5 -0
- package/LICENSE +22 -0
- package/README.md +44 -44
- package/android/build.gradle +1 -1
- package/ios/RNZcash.m +0 -1
- package/ios/RNZcash.swift +14 -15
- package/ios/ZCashLightClientKit/Block/DatabaseStorage/CompactBlockStorage.swift +123 -0
- package/ios/ZCashLightClientKit/Block/DatabaseStorage/DatabaseMigrationManager.swift +222 -0
- package/ios/ZCashLightClientKit/Block/DatabaseStorage/StorageError.swift +22 -0
- package/ios/ZCashLightClientKit/Block/DatabaseStorage/StorageManager.swift +73 -0
- package/ios/ZCashLightClientKit/Block/Downloader/BlockDownloader.swift +240 -0
- package/ios/ZCashLightClientKit/Block/Downloader/CompactBlockDownloaderBuilder.swift +26 -0
- package/ios/ZCashLightClientKit/Block/Processor/CompactBlockDownloadOperation.swift +258 -0
- package/ios/ZCashLightClientKit/Block/Processor/CompactBlockEnhancementOperation.swift +157 -0
- package/ios/ZCashLightClientKit/Block/Processor/CompactBlockProcessor.swift +1454 -0
- package/ios/ZCashLightClientKit/Block/Processor/CompactBlockScanningOperation.swift +238 -0
- package/ios/ZCashLightClientKit/Block/Processor/CompactBlockValidationInformation.swift +66 -0
- package/ios/ZCashLightClientKit/Block/Processor/FetchUnspentTxOutputsOperation.swift +103 -0
- package/ios/ZCashLightClientKit/Block/Processor/FigureNextBatchOperation.swift +58 -0
- package/ios/ZCashLightClientKit/Block/Processor/ZcashOperation.swift +68 -0
- package/ios/ZCashLightClientKit/Constants/WalletBirthday+Constants.swift +58 -0
- package/ios/ZCashLightClientKit/Constants/WalletBirthday+mainnet.swift +20 -0
- package/ios/ZCashLightClientKit/Constants/WalletBirthday+testnet.swift +20 -0
- package/ios/ZCashLightClientKit/Constants/ZcashSDK.swift +245 -0
- package/ios/ZCashLightClientKit/DAO/BlockDao.swift +67 -0
- package/ios/ZCashLightClientKit/DAO/CompactBlockDAO.swift +24 -0
- package/ios/ZCashLightClientKit/DAO/NotesDao.swift +142 -0
- package/ios/ZCashLightClientKit/DAO/PagedTransactionDao.swift +62 -0
- package/ios/ZCashLightClientKit/DAO/PendingTransactionDao.swift +213 -0
- package/ios/ZCashLightClientKit/DAO/TransactionBuilder.swift +169 -0
- package/ios/ZCashLightClientKit/DAO/TransactionDao.swift +393 -0
- package/ios/ZCashLightClientKit/DAO/UnspentTransactionOutputDao.swift +188 -0
- package/ios/ZCashLightClientKit/Entity/AccountEntity.swift +201 -0
- package/ios/ZCashLightClientKit/Entity/CompactBlockEntity.swift +13 -0
- package/ios/ZCashLightClientKit/Entity/EncodedTransactionEntity.swift +26 -0
- package/ios/ZCashLightClientKit/Entity/PendingTransactionEntity.swift +205 -0
- package/ios/ZCashLightClientKit/Entity/ReceivedNoteEntity.swift +22 -0
- package/ios/ZCashLightClientKit/Entity/SentNoteEntity.swift +45 -0
- package/ios/ZCashLightClientKit/Entity/TransactionEntity.swift +161 -0
- package/ios/ZCashLightClientKit/Entity/UnspentTransactionOutputEntity.swift +17 -0
- package/ios/ZCashLightClientKit/Extensions/Data+Zcash.swift +17 -0
- package/ios/ZCashLightClientKit/Extensions/Data+internal.swift +35 -0
- package/ios/ZCashLightClientKit/Extensions/HexEncode.swift +41 -0
- package/ios/ZCashLightClientKit/Extensions/ZcashRust+Utils.swift +26 -0
- package/ios/ZCashLightClientKit/Extensions/ZcashSDK+extensions.swift +34 -0
- package/ios/ZCashLightClientKit/Initializer.swift +357 -0
- package/ios/ZCashLightClientKit/Model/WalletTypes.swift +108 -0
- package/ios/ZCashLightClientKit/Providers/ResourceProvider.swift +47 -0
- package/ios/ZCashLightClientKit/Repository/BlockRepository.swift +13 -0
- package/ios/ZCashLightClientKit/Repository/CompactBlockRepository.swift +75 -0
- package/ios/ZCashLightClientKit/Repository/NotesRepository.swift +16 -0
- package/ios/ZCashLightClientKit/Repository/PaginatedTransactionRepository.swift +35 -0
- package/ios/ZCashLightClientKit/Repository/PendingTransactionRepository.swift +19 -0
- package/ios/ZCashLightClientKit/Repository/TransactionRepository.swift +30 -0
- package/ios/ZCashLightClientKit/Repository/TransactionRepositoryBuilder.swift +24 -0
- package/ios/ZCashLightClientKit/Repository/UnspentTransactionOutputRepository.swift +18 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1000000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1010000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1020000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1030000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1040000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1050000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1060000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1070000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1080000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1090000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1100000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1110000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1120000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1130000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1140000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1150000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1160000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1170000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1180000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1190000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1200000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1210000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1220000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1230000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1240000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1250000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1260000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1270000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1280000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1290000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1300000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1310000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1320000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1330000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1340000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1350000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1360000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1370000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1380000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1390000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1400000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1410000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1420000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1430000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1440000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1450000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1460000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1470000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1480000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1490000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1500000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1510000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1520000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1530000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1540000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1550000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1560000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1570000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1580000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1590000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1600000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1610000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1620000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1630000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1640000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1650000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1660000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1670000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1680000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1690000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1700000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1710000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1720000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1730000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1740000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1750000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1760000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1770000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1780000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1790000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1800000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1810000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1820000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1830000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1840000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1850000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1860000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1870000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1880000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1890000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1900000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1910000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1920000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1930000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1940000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1950000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1960000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1970000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1980000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/1990000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2000000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2010000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2020000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2030000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2040000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2050000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2060000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2070000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2080000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2090000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2100000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2110000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2120000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2130000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2140000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2150000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2160000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/2170000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/419200.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/500000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/510000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/520000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/530000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/540000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/550000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/560000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/570000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/580000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/590000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/600000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/610000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/620000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/630000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/640000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/650000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/660000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/663150.json +8 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/670000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/680000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/690000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/700000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/710000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/720000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/730000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/740000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/750000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/760000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/770000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/780000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/790000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/800000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/810000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/820000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/830000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/840000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/850000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/860000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/870000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/880000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/890000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/900000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/910000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/920000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/930000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/940000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/950000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/960000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/970000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/980000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/mainnet/990000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1000000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1010000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1020000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1030000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1040000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1050000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1060000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1070000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1080000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1090000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1100000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1110000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1120000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1130000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1140000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1150000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1160000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1170000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1180000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1190000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1200000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1210000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1220000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1230000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1240000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1250000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1260000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1270000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1280000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1290000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1300000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1310000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1320000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1330000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1340000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1350000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1360000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1370000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1380000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1390000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1400000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1410000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1420000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1430000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1440000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1450000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1460000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1470000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1480000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1490000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1500000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1510000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1520000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1530000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1540000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1550000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1560000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1570000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1580000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1590000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1600000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1610000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1620000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1630000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1640000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1650000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1660000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1670000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1680000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1690000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1700000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1710000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1720000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1730000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1740000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1750000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1760000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1770000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1780000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1790000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1800000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1810000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1820000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1830000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1840000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1850000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/1860000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/280000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/290000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/300000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/310000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/320000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/330000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/340000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/350000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/360000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/370000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/380000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/390000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/400000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/410000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/420000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/430000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/440000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/450000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/460000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/470000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/480000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/490000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/500000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/510000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/520000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/530000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/540000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/550000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/560000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/570000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/580000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/590000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/600000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/610000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/620000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/630000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/640000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/650000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/660000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/670000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/680000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/690000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/700000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/710000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/720000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/730000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/740000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/750000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/760000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/770000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/780000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/790000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/800000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/810000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/820000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/830000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/840000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/850000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/860000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/870000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/880000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/890000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/900000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/910000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/920000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/930000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/940000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/950000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/960000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/970000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/980000.json +7 -0
- package/ios/ZCashLightClientKit/Resources/saplingtree-checkpoints/testnet/990000.json +7 -0
- package/ios/ZCashLightClientKit/Rust/ZcashRustBackend.swift +718 -0
- package/ios/ZCashLightClientKit/Rust/ZcashRustBackendWelding.swift +389 -0
- package/ios/ZCashLightClientKit/Rust/zcashlc.h +385 -0
- package/ios/ZCashLightClientKit/Service/LightWalletGRPCService.swift +551 -0
- package/ios/ZCashLightClientKit/Service/LightWalletService.swift +214 -0
- package/ios/ZCashLightClientKit/Service/Model/ZcashCompactBlock.swift +46 -0
- package/ios/ZCashLightClientKit/Service/ProtoBuf/Extensions/Protocolbuffer+Extensions.swift +50 -0
- package/ios/ZCashLightClientKit/Service/ProtoBuf/compact_formats.pb.swift +332 -0
- package/ios/ZCashLightClientKit/Service/ProtoBuf/proto/compact_formats.proto +56 -0
- package/ios/ZCashLightClientKit/Service/ProtoBuf/proto/service.proto +180 -0
- package/ios/ZCashLightClientKit/Service/ProtoBuf/service.grpc.swift +383 -0
- package/ios/ZCashLightClientKit/Service/ProtoBuf/service.pb.swift +1173 -0
- package/ios/ZCashLightClientKit/Synchronizer/SDKSynchronizer.swift +929 -0
- package/ios/ZCashLightClientKit/Synchronizer.swift +430 -0
- package/ios/ZCashLightClientKit/Tool/DerivationTool.swift +344 -0
- package/ios/ZCashLightClientKit/Transaction/PersistentTransactionManager.swift +339 -0
- package/ios/ZCashLightClientKit/Transaction/TransactionEncoder.swift +116 -0
- package/ios/ZCashLightClientKit/Transaction/TransactionManager.swift +42 -0
- package/ios/ZCashLightClientKit/Transaction/WalletTransactionEncoder.swift +216 -0
- package/ios/ZCashLightClientKit/Utils/Bundle+module.swift +30 -0
- package/ios/ZCashLightClientKit/Utils/LoggingProxy.swift +47 -0
- package/ios/ZCashLightClientKit/Utils/SaplingParameterDownloader.swift +124 -0
- package/ios/libzcashlc.xcframework/Info.plist +40 -0
- 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/react-native-zcash-Bridging-Header.h +2 -0
- package/ios/react-native-zcash.xcodeproj/project.pbxproj +1 -0
- package/lib/scripts/copyCheckpoints.d.ts +5 -0
- package/lib/scripts/updateSources.d.ts +1 -0
- package/package.json +20 -37
- package/react-native-zcash.podspec +17 -7
- package/ios/RNZcash-Bridging-Header.h +0 -6
- package/ios/RNZcash.xcodeproj/project.pbxproj +0 -271
- package/ios/RNZcash.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RNZcash.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/lib/src/browser.d.ts +0 -0
- package/lib/src/index.d.ts +0 -0
- package/lib/test/test.test.d.ts +0 -0
- package/scripts/copyCheckpoints.js +0 -12
- package/src/browser.ts +0 -36
- package/src/index.flow.js +0 -168
- package/src/index.ts +0 -1
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
//
|
|
2
|
+
// TransactionDao.swift
|
|
3
|
+
// ZcashLightClientKit
|
|
4
|
+
//
|
|
5
|
+
// Created by Francisco Gindre on 11/15/19.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import SQLite
|
|
10
|
+
|
|
11
|
+
struct Transaction: TransactionEntity, Decodable {
|
|
12
|
+
enum CodingKeys: String, CodingKey {
|
|
13
|
+
case id = "id_tx"
|
|
14
|
+
case transactionId = "txid"
|
|
15
|
+
case created
|
|
16
|
+
case transactionIndex = "tx_index"
|
|
17
|
+
case expiryHeight = "expiry_height"
|
|
18
|
+
case minedHeight = "block"
|
|
19
|
+
case raw
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var id: Int?
|
|
23
|
+
var transactionId: Data
|
|
24
|
+
var created: String?
|
|
25
|
+
var transactionIndex: Int?
|
|
26
|
+
var expiryHeight: BlockHeight?
|
|
27
|
+
var minedHeight: BlockHeight?
|
|
28
|
+
var raw: Data?
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
struct ConfirmedTransaction: ConfirmedTransactionEntity {
|
|
32
|
+
var toAddress: String?
|
|
33
|
+
var expiryHeight: BlockHeight?
|
|
34
|
+
var minedHeight: Int
|
|
35
|
+
var noteId: Int
|
|
36
|
+
var blockTimeInSeconds: TimeInterval
|
|
37
|
+
var transactionIndex: Int
|
|
38
|
+
var raw: Data?
|
|
39
|
+
var id: Int?
|
|
40
|
+
var value: Int
|
|
41
|
+
var memo: Data?
|
|
42
|
+
var rawTransactionId: Data?
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
class TransactionSQLDAO: TransactionRepository {
|
|
46
|
+
enum TableStructure {
|
|
47
|
+
static var id = Expression<Int>(Transaction.CodingKeys.id.rawValue)
|
|
48
|
+
static var transactionId = Expression<Blob>(Transaction.CodingKeys.transactionId.rawValue)
|
|
49
|
+
static var created = Expression<String?>(Transaction.CodingKeys.created.rawValue)
|
|
50
|
+
static var txIndex = Expression<Int?>(Transaction.CodingKeys.transactionIndex.rawValue)
|
|
51
|
+
static var expiryHeight = Expression<Int?>(Transaction.CodingKeys.expiryHeight.rawValue)
|
|
52
|
+
static var minedHeight = Expression<Int?>(Transaction.CodingKeys.minedHeight.rawValue)
|
|
53
|
+
static var raw = Expression<Blob?>(Transaction.CodingKeys.raw.rawValue)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var dbProvider: ConnectionProvider
|
|
57
|
+
var transactions = Table("transactions")
|
|
58
|
+
private var blockDao: BlockSQLDAO
|
|
59
|
+
|
|
60
|
+
init(dbProvider: ConnectionProvider) {
|
|
61
|
+
self.dbProvider = dbProvider
|
|
62
|
+
self.blockDao = BlockSQLDAO(dbProvider: dbProvider)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
func blockForHeight(_ height: BlockHeight) throws -> Block? {
|
|
66
|
+
try blockDao.block(at: height)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
func lastScannedHeight() throws -> BlockHeight {
|
|
70
|
+
try blockDao.latestBlockHeight()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
func isInitialized() throws -> Bool {
|
|
74
|
+
true
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
func findEncodedTransactionBy(txId: Int) -> EncodedTransaction? {
|
|
78
|
+
// try dbProvider
|
|
79
|
+
return nil
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
func countAll() throws -> Int {
|
|
83
|
+
try dbProvider.connection().scalar(transactions.count)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
func countUnmined() throws -> Int {
|
|
87
|
+
try dbProvider.connection().scalar(transactions.filter(TableStructure.minedHeight == nil).count)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
func findBy(id: Int) throws -> TransactionEntity? {
|
|
91
|
+
let query = transactions.filter(TableStructure.id == id).limit(1)
|
|
92
|
+
let sequence = try dbProvider.connection().prepare(query)
|
|
93
|
+
let entity: Transaction? = try sequence.map({ try $0.decode() }).first
|
|
94
|
+
return entity
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
func findBy(rawId: Data) throws -> TransactionEntity? {
|
|
98
|
+
let query = transactions.filter(TableStructure.transactionId == Blob(bytes: rawId.bytes)).limit(1)
|
|
99
|
+
let entity: Transaction? = try dbProvider.connection().prepare(query).map({ try $0.decode() }).first
|
|
100
|
+
return entity
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// MARK: - Queries
|
|
105
|
+
|
|
106
|
+
extension TransactionSQLDAO {
|
|
107
|
+
func findAllSentTransactions(offset: Int = 0, limit: Int = Int.max) throws -> [ConfirmedTransactionEntity]? {
|
|
108
|
+
try dbProvider.connection()
|
|
109
|
+
.run(
|
|
110
|
+
"""
|
|
111
|
+
SELECT
|
|
112
|
+
transactions.id_tx AS id,
|
|
113
|
+
transactions.block AS minedHeight,
|
|
114
|
+
transactions.tx_index AS transactionIndex,
|
|
115
|
+
transactions.txid AS rawTransactionId,
|
|
116
|
+
transactions.expiry_height AS expiryHeight,
|
|
117
|
+
transactions.raw AS raw,
|
|
118
|
+
sent_notes.address AS toAddress,
|
|
119
|
+
sent_notes.value AS value,
|
|
120
|
+
sent_notes.memo AS memo,
|
|
121
|
+
sent_notes.id_note AS noteId,
|
|
122
|
+
blocks.time AS blockTimeInSeconds
|
|
123
|
+
FROM transactions
|
|
124
|
+
INNER JOIN sent_notes
|
|
125
|
+
ON transactions.id_tx = sent_notes.tx
|
|
126
|
+
LEFT JOIN blocks
|
|
127
|
+
ON transactions.block = blocks.height
|
|
128
|
+
WHERE transactions.raw IS NOT NULL
|
|
129
|
+
AND minedheight > 0
|
|
130
|
+
|
|
131
|
+
ORDER BY block IS NOT NULL, height DESC, time DESC, txid DESC
|
|
132
|
+
LIMIT \(limit) OFFSET \(offset)
|
|
133
|
+
"""
|
|
134
|
+
)
|
|
135
|
+
.map { bindings -> ConfirmedTransactionEntity in
|
|
136
|
+
guard let transaction = TransactionBuilder.createConfirmedTransaction(from: bindings) else {
|
|
137
|
+
throw TransactionRepositoryError.malformedTransaction
|
|
138
|
+
}
|
|
139
|
+
return transaction
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
func findAllReceivedTransactions(offset: Int = 0, limit: Int = Int.max) throws -> [ConfirmedTransactionEntity]? {
|
|
144
|
+
try dbProvider.connection()
|
|
145
|
+
.run(
|
|
146
|
+
"""
|
|
147
|
+
SELECT
|
|
148
|
+
transactions.id_tx AS id,
|
|
149
|
+
transactions.block AS minedHeight,
|
|
150
|
+
transactions.tx_index AS transactionIndex,
|
|
151
|
+
transactions.txid AS rawTransactionId,
|
|
152
|
+
transactions.raw AS raw,
|
|
153
|
+
received_notes.value AS value,
|
|
154
|
+
received_notes.memo AS memo,
|
|
155
|
+
received_notes.id_note AS noteId,
|
|
156
|
+
blocks.time AS blockTimeInSeconds
|
|
157
|
+
|
|
158
|
+
FROM transactions
|
|
159
|
+
LEFT JOIN received_notes
|
|
160
|
+
ON transactions.id_tx = received_notes.tx
|
|
161
|
+
LEFT JOIN blocks
|
|
162
|
+
ON transactions.block = blocks.height
|
|
163
|
+
WHERE received_notes.is_change != 1
|
|
164
|
+
ORDER BY minedheight DESC, blocktimeinseconds DESC, id DESC
|
|
165
|
+
LIMIT \(limit) OFFSET \(offset)
|
|
166
|
+
"""
|
|
167
|
+
)
|
|
168
|
+
.map { bindings -> ConfirmedTransactionEntity in
|
|
169
|
+
guard let transaction = TransactionBuilder.createReceivedTransaction(from: bindings) else {
|
|
170
|
+
throw TransactionRepositoryError.malformedTransaction
|
|
171
|
+
}
|
|
172
|
+
return transaction
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
func findAll(offset: Int = 0, limit: Int = Int.max) throws -> [ConfirmedTransactionEntity]? {
|
|
177
|
+
try dbProvider.connection()
|
|
178
|
+
.run(
|
|
179
|
+
"""
|
|
180
|
+
SELECT
|
|
181
|
+
transactions.id_tx AS id,
|
|
182
|
+
transactions.block AS minedHeight,
|
|
183
|
+
transactions.tx_index AS transactionIndex,
|
|
184
|
+
transactions.txid AS rawTransactionId,
|
|
185
|
+
transactions.expiry_height AS expiryHeight,
|
|
186
|
+
transactions.raw AS raw,
|
|
187
|
+
sent_notes.address AS toAddress,
|
|
188
|
+
CASE
|
|
189
|
+
WHEN sent_notes.value IS NOT NULL THEN sent_notes.value
|
|
190
|
+
ELSE received_notes.value
|
|
191
|
+
end AS value,
|
|
192
|
+
CASE
|
|
193
|
+
WHEN sent_notes.memo IS NOT NULL THEN sent_notes.memo
|
|
194
|
+
ELSE received_notes.memo
|
|
195
|
+
end AS memo,
|
|
196
|
+
CASE
|
|
197
|
+
WHEN sent_notes.id_note IS NOT NULL THEN sent_notes.id_note
|
|
198
|
+
ELSE received_notes.id_note
|
|
199
|
+
end AS noteId,
|
|
200
|
+
blocks.time AS blockTimeInSeconds
|
|
201
|
+
FROM transactions
|
|
202
|
+
LEFT JOIN received_notes
|
|
203
|
+
ON transactions.id_tx = received_notes.tx
|
|
204
|
+
LEFT JOIN sent_notes
|
|
205
|
+
ON transactions.id_tx = sent_notes.tx
|
|
206
|
+
LEFT JOIN blocks
|
|
207
|
+
ON transactions.block = blocks.height
|
|
208
|
+
WHERE (sent_notes.address IS NULL AND received_notes.is_change != 1)
|
|
209
|
+
OR sent_notes.address IS NOT NULL
|
|
210
|
+
ORDER BY ( minedheight IS NOT NULL ),
|
|
211
|
+
minedheight DESC,
|
|
212
|
+
blocktimeinseconds DESC,
|
|
213
|
+
id DESC
|
|
214
|
+
LIMIT \(limit) OFFSET \(offset)
|
|
215
|
+
"""
|
|
216
|
+
)
|
|
217
|
+
.compactMap { TransactionBuilder.createConfirmedTransaction(from: $0) }
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
func findAll(from transaction: ConfirmedTransactionEntity?, limit: Int) throws -> [ConfirmedTransactionEntity]? {
|
|
221
|
+
guard let fromTransaction = transaction else {
|
|
222
|
+
return try findAll(offset: 0, limit: limit)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return try dbProvider.connection()
|
|
226
|
+
.run(
|
|
227
|
+
"""
|
|
228
|
+
SELECT transactions.id_tx AS id,
|
|
229
|
+
transactions.block AS minedHeight,
|
|
230
|
+
transactions.tx_index AS transactionIndex,
|
|
231
|
+
transactions.txid AS rawTransactionId,
|
|
232
|
+
transactions.expiry_height AS expiryHeight,
|
|
233
|
+
transactions.raw AS raw,
|
|
234
|
+
sent_notes.address AS toAddress,
|
|
235
|
+
CASE
|
|
236
|
+
WHEN sent_notes.value IS NOT NULL THEN sent_notes.value
|
|
237
|
+
ELSE received_notes.value
|
|
238
|
+
end AS value,
|
|
239
|
+
CASE
|
|
240
|
+
WHEN sent_notes.memo IS NOT NULL THEN sent_notes.memo
|
|
241
|
+
ELSE received_notes.memo
|
|
242
|
+
end AS memo,
|
|
243
|
+
CASE
|
|
244
|
+
WHEN sent_notes.id_note IS NOT NULL THEN sent_notes.id_note
|
|
245
|
+
ELSE received_notes.id_note
|
|
246
|
+
end AS noteId,
|
|
247
|
+
blocks.time AS blockTimeInSeconds
|
|
248
|
+
FROM transactions
|
|
249
|
+
LEFT JOIN received_notes
|
|
250
|
+
ON transactions.id_tx = received_notes.tx
|
|
251
|
+
LEFT JOIN sent_notes
|
|
252
|
+
ON transactions.id_tx = sent_notes.tx
|
|
253
|
+
LEFT JOIN blocks
|
|
254
|
+
ON transactions.block = blocks.height
|
|
255
|
+
WHERE (\(fromTransaction.blockTimeInSeconds), \(fromTransaction.transactionIndex)) > (blocktimeinseconds, transactionIndex) AND
|
|
256
|
+
(sent_notes.address IS NULL AND received_notes.is_change != 1)
|
|
257
|
+
OR sent_notes.address IS NOT NULL
|
|
258
|
+
ORDER BY ( minedheight IS NOT NULL ),
|
|
259
|
+
minedheight DESC,
|
|
260
|
+
blocktimeinseconds DESC,
|
|
261
|
+
id DESC
|
|
262
|
+
LIMIT \(limit)
|
|
263
|
+
"""
|
|
264
|
+
)
|
|
265
|
+
.compactMap { TransactionBuilder.createConfirmedTransaction(from: $0) }
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
func findTransactions(in range: BlockRange, limit: Int = Int.max) throws -> [TransactionEntity]? {
|
|
269
|
+
try dbProvider.connection()
|
|
270
|
+
.run(
|
|
271
|
+
"""
|
|
272
|
+
SELECT transactions.id_tx AS id,
|
|
273
|
+
transactions.block AS minedHeight,
|
|
274
|
+
transactions.tx_index AS transactionIndex,
|
|
275
|
+
transactions.txid AS rawTransactionId,
|
|
276
|
+
transactions.expiry_height AS expiryHeight,
|
|
277
|
+
transactions.raw AS raw
|
|
278
|
+
FROM transactions
|
|
279
|
+
WHERE \(range.start.height) <= minedheight
|
|
280
|
+
AND minedheight <= \(range.end.height)
|
|
281
|
+
ORDER BY ( minedheight IS NOT NULL ),
|
|
282
|
+
minedheight ASC,
|
|
283
|
+
id DESC
|
|
284
|
+
LIMIT \(limit)
|
|
285
|
+
"""
|
|
286
|
+
)
|
|
287
|
+
.compactMap { TransactionBuilder.createTransactionEntity(from: $0) }
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
func findConfirmedTransactions(in range: BlockRange, offset: Int = 0, limit: Int = Int.max) throws -> [ConfirmedTransactionEntity]? {
|
|
291
|
+
try dbProvider.connection()
|
|
292
|
+
.run(
|
|
293
|
+
"""
|
|
294
|
+
SELECT transactions.id_tx AS id,
|
|
295
|
+
transactions.block AS minedHeight,
|
|
296
|
+
transactions.tx_index AS transactionIndex,
|
|
297
|
+
transactions.txid AS rawTransactionId,
|
|
298
|
+
transactions.expiry_height AS expiryHeight,
|
|
299
|
+
transactions.raw AS raw,
|
|
300
|
+
sent_notes.address AS toAddress,
|
|
301
|
+
CASE
|
|
302
|
+
WHEN sent_notes.value IS NOT NULL THEN sent_notes.value
|
|
303
|
+
ELSE received_notes.value
|
|
304
|
+
end AS value,
|
|
305
|
+
CASE
|
|
306
|
+
WHEN sent_notes.memo IS NOT NULL THEN sent_notes.memo
|
|
307
|
+
ELSE received_notes.memo
|
|
308
|
+
end AS memo,
|
|
309
|
+
CASE
|
|
310
|
+
WHEN sent_notes.id_note IS NOT NULL THEN sent_notes.id_note
|
|
311
|
+
ELSE received_notes.id_note
|
|
312
|
+
end AS noteId,
|
|
313
|
+
blocks.time AS blockTimeInSeconds
|
|
314
|
+
FROM transactions
|
|
315
|
+
LEFT JOIN received_notes
|
|
316
|
+
ON transactions.id_tx = received_notes.tx
|
|
317
|
+
LEFT JOIN sent_notes
|
|
318
|
+
ON transactions.id_tx = sent_notes.tx
|
|
319
|
+
LEFT JOIN blocks
|
|
320
|
+
ON transactions.block = blocks.height
|
|
321
|
+
WHERE (\(range.start.height) <= minedheight
|
|
322
|
+
AND minedheight <= \(range.end.height)) AND
|
|
323
|
+
(sent_notes.address IS NULL AND received_notes.is_change != 1)
|
|
324
|
+
OR sent_notes.address IS NOT NULL
|
|
325
|
+
ORDER BY ( minedheight IS NOT NULL ),
|
|
326
|
+
minedheight DESC,
|
|
327
|
+
blocktimeinseconds DESC,
|
|
328
|
+
id DESC
|
|
329
|
+
LIMIT \(limit) OFFSET \(offset)
|
|
330
|
+
"""
|
|
331
|
+
)
|
|
332
|
+
.compactMap { TransactionBuilder.createConfirmedTransaction(from: $0) }
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
func findConfirmedTransactionBy(rawId: Data) throws -> ConfirmedTransactionEntity? {
|
|
336
|
+
try dbProvider.connection()
|
|
337
|
+
.run(
|
|
338
|
+
"""
|
|
339
|
+
SELECT transactions.id_tx AS id,
|
|
340
|
+
transactions.block AS minedHeight,
|
|
341
|
+
transactions.tx_index AS transactionIndex,
|
|
342
|
+
transactions.txid AS rawTransactionId,
|
|
343
|
+
transactions.expiry_height AS expiryHeight,
|
|
344
|
+
transactions.raw AS raw,
|
|
345
|
+
sent_notes.address AS toAddress,
|
|
346
|
+
CASE
|
|
347
|
+
WHEN sent_notes.value IS NOT NULL THEN sent_notes.value
|
|
348
|
+
ELSE received_notes.value
|
|
349
|
+
end AS value,
|
|
350
|
+
CASE
|
|
351
|
+
WHEN sent_notes.memo IS NOT NULL THEN sent_notes.memo
|
|
352
|
+
ELSE received_notes.memo
|
|
353
|
+
end AS memo,
|
|
354
|
+
CASE
|
|
355
|
+
WHEN sent_notes.id_note IS NOT NULL THEN sent_notes.id_note
|
|
356
|
+
ELSE received_notes.id_note
|
|
357
|
+
end AS noteId,
|
|
358
|
+
blocks.time AS blockTimeInSeconds
|
|
359
|
+
FROM transactions
|
|
360
|
+
LEFT JOIN received_notes
|
|
361
|
+
ON transactions.id_tx = received_notes.tx
|
|
362
|
+
LEFT JOIN sent_notes
|
|
363
|
+
ON transactions.id_tx = sent_notes.tx
|
|
364
|
+
LEFT JOIN blocks
|
|
365
|
+
ON transactions.block = blocks.height
|
|
366
|
+
WHERE minedheight >= 0
|
|
367
|
+
AND rawTransactionId == \(Blob(bytes: rawId.bytes)) AND
|
|
368
|
+
(sent_notes.address IS NULL AND received_notes.is_change != 1)
|
|
369
|
+
OR sent_notes.address IS NOT NULL
|
|
370
|
+
LIMIT 1
|
|
371
|
+
"""
|
|
372
|
+
)
|
|
373
|
+
.compactMap { TransactionBuilder.createConfirmedTransaction(from: $0) }
|
|
374
|
+
.first
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
extension Data {
|
|
379
|
+
init(blob: SQLite.Blob) {
|
|
380
|
+
let bytes = blob.bytes
|
|
381
|
+
self = Data(bytes: bytes, count: bytes.count)
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
var bytes: [UInt8] {
|
|
385
|
+
return [UInt8](self)
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
extension Array where Element == UInt8 {
|
|
390
|
+
var data: Data {
|
|
391
|
+
return Data(self)
|
|
392
|
+
}
|
|
393
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
//
|
|
2
|
+
// UnspentTransactionOutputDAO.swift
|
|
3
|
+
// ZcashLightClientKit
|
|
4
|
+
//
|
|
5
|
+
// Created by Francisco Gindre on 12/9/20.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
struct UTXO: Decodable, Encodable {
|
|
11
|
+
enum CodingKeys: String, CodingKey {
|
|
12
|
+
case id = "id_utxo"
|
|
13
|
+
case address
|
|
14
|
+
case prevoutTxId = "prevout_txid"
|
|
15
|
+
case prevoutIndex = "prevout_idx"
|
|
16
|
+
case script
|
|
17
|
+
case valueZat = "value_zat"
|
|
18
|
+
case height
|
|
19
|
+
case spentInTx = "spent_in_tx"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var id: Int?
|
|
23
|
+
var address: String
|
|
24
|
+
var prevoutTxId: Data
|
|
25
|
+
var prevoutIndex: Int
|
|
26
|
+
var script: Data
|
|
27
|
+
var valueZat: Int
|
|
28
|
+
var height: Int
|
|
29
|
+
var spentInTx: Int?
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
extension UTXO: UnspentTransactionOutputEntity {
|
|
33
|
+
var txid: Data {
|
|
34
|
+
get {
|
|
35
|
+
prevoutTxId
|
|
36
|
+
}
|
|
37
|
+
set {
|
|
38
|
+
prevoutTxId = newValue
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var index: Int {
|
|
43
|
+
get {
|
|
44
|
+
prevoutIndex
|
|
45
|
+
}
|
|
46
|
+
set {
|
|
47
|
+
prevoutIndex = newValue
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
extension UnspentTransactionOutputEntity {
|
|
53
|
+
/**
|
|
54
|
+
As UTXO, with id and spentIntTx set to __nil__
|
|
55
|
+
*/
|
|
56
|
+
func asUTXO() -> UTXO {
|
|
57
|
+
UTXO(
|
|
58
|
+
id: nil,
|
|
59
|
+
address: address,
|
|
60
|
+
prevoutTxId: txid,
|
|
61
|
+
prevoutIndex: index,
|
|
62
|
+
script: script,
|
|
63
|
+
valueZat: valueZat,
|
|
64
|
+
height: height,
|
|
65
|
+
spentInTx: nil
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
import SQLite
|
|
70
|
+
class UnspentTransactionOutputSQLDAO: UnspentTransactionOutputRepository {
|
|
71
|
+
enum TableColumns {
|
|
72
|
+
static var id = Expression<Int>("id_utxo")
|
|
73
|
+
static var address = Expression<String>("address")
|
|
74
|
+
static var txid = Expression<Blob>("prevout_txid")
|
|
75
|
+
static var index = Expression<Int>("prevout_idx")
|
|
76
|
+
static var script = Expression<Blob>("script")
|
|
77
|
+
static var valueZat = Expression<Int>("value_zat")
|
|
78
|
+
static var height = Expression<Int>("height")
|
|
79
|
+
static var spentInTx = Expression<Int?>("spent_in_tx")
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let table = Table("utxos")
|
|
83
|
+
|
|
84
|
+
var dbProvider: ConnectionProvider
|
|
85
|
+
|
|
86
|
+
init (dbProvider: ConnectionProvider) {
|
|
87
|
+
self.dbProvider = dbProvider
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
func createTableIfNeeded() throws {
|
|
91
|
+
let stringStatement =
|
|
92
|
+
"""
|
|
93
|
+
CREATE TABLE IF NOT EXISTS utxos (
|
|
94
|
+
id_utxo INTEGER PRIMARY KEY,
|
|
95
|
+
address TEXT NOT NULL,
|
|
96
|
+
prevout_txid BLOB NOT NULL,
|
|
97
|
+
prevout_idx INTEGER NOT NULL,
|
|
98
|
+
script BLOB NOT NULL,
|
|
99
|
+
value_zat INTEGER NOT NULL,
|
|
100
|
+
height INTEGER NOT NULL,
|
|
101
|
+
spent_in_tx INTEGER,
|
|
102
|
+
FOREIGN KEY (spent_in_tx) REFERENCES transactions(id_tx),
|
|
103
|
+
CONSTRAINT tx_outpoint UNIQUE (prevout_txid, prevout_idx)
|
|
104
|
+
)
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
try dbProvider.connection().run(stringStatement)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
func store(utxos: [UnspentTransactionOutputEntity]) throws {
|
|
111
|
+
do {
|
|
112
|
+
let db = try dbProvider.connection()
|
|
113
|
+
try dbProvider.connection().transaction {
|
|
114
|
+
for utxo in utxos.map({ $0 as? UTXO ?? $0.asUTXO() }) {
|
|
115
|
+
try db.run(table.insert(utxo))
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
} catch {
|
|
119
|
+
throw StorageError.transactionFailed(underlyingError: error)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
func clearAll(address: String?) throws {
|
|
124
|
+
if let tAddr = address {
|
|
125
|
+
do {
|
|
126
|
+
try dbProvider.connection().run(table.filter(TableColumns.address == tAddr).delete())
|
|
127
|
+
} catch {
|
|
128
|
+
throw StorageError.operationFailed
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
do {
|
|
132
|
+
try dbProvider.connection().run(table.delete())
|
|
133
|
+
} catch {
|
|
134
|
+
throw StorageError.operationFailed
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
func getAll(address: String?) throws -> [UnspentTransactionOutputEntity] {
|
|
140
|
+
if let tAddress = address {
|
|
141
|
+
let allTxs: [UTXO] = try dbProvider.connection()
|
|
142
|
+
.prepare(table.filter(TableColumns.address == tAddress))
|
|
143
|
+
.map { row in
|
|
144
|
+
try row.decode()
|
|
145
|
+
}
|
|
146
|
+
return allTxs
|
|
147
|
+
} else {
|
|
148
|
+
let allTxs: [UTXO] = try dbProvider.connection()
|
|
149
|
+
.prepare(table)
|
|
150
|
+
.map { row in
|
|
151
|
+
try row.decode()
|
|
152
|
+
}
|
|
153
|
+
return allTxs
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
func balance(address: String, latestHeight: BlockHeight) throws -> WalletBalance {
|
|
158
|
+
do {
|
|
159
|
+
let verified = try dbProvider.connection().scalar(
|
|
160
|
+
table.select(TableColumns.valueZat.sum)
|
|
161
|
+
.filter(TableColumns.address == address)
|
|
162
|
+
.filter(TableColumns.height <= latestHeight - ZcashSDK.defaultStaleTolerance)
|
|
163
|
+
) ?? 0
|
|
164
|
+
let total = try dbProvider.connection().scalar(
|
|
165
|
+
table.select(TableColumns.valueZat.sum)
|
|
166
|
+
.filter(TableColumns.address == address)
|
|
167
|
+
) ?? 0
|
|
168
|
+
|
|
169
|
+
return TransparentBalance(verified: Int64(verified), total: Int64(total), address: address)
|
|
170
|
+
} catch {
|
|
171
|
+
throw StorageError.operationFailed
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
struct TransparentBalance: WalletBalance {
|
|
177
|
+
var verified: Int64
|
|
178
|
+
var total: Int64
|
|
179
|
+
var address: String
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
enum UTXORepositoryBuilder {
|
|
183
|
+
static func build(initializer: Initializer) throws -> UnspentTransactionOutputRepository {
|
|
184
|
+
let dao = UnspentTransactionOutputSQLDAO(dbProvider: SimpleConnectionProvider(path: initializer.dataDbURL.path))
|
|
185
|
+
try dao.createTableIfNeeded()
|
|
186
|
+
return dao
|
|
187
|
+
}
|
|
188
|
+
}
|