|
| 1 | +# DashSync iOS |
| 2 | + |
| 3 | +DashSync is a lightweight blockchain client library for iOS/macOS that enables applications to interact with the Dash cryptocurrency network. It supports both Dash Core Network (Layer 1) and Dash Platform (Layer 2). |
| 4 | + |
| 5 | +## Quick Reference |
| 6 | + |
| 7 | +- **Language**: Objective-C with C/C++/Rust interop |
| 8 | +- **Build System**: Xcode + CocoaPods |
| 9 | +- **Deployment**: iOS 13.0+, macOS 10.15+ |
| 10 | +- **Pod Name**: `DashSyncPod` |
| 11 | + |
| 12 | +## Build Requirements |
| 13 | + |
| 14 | +```bash |
| 15 | +# Install Rust |
| 16 | +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh |
| 17 | +rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim |
| 18 | + |
| 19 | +# Install protobuf and grpc |
| 20 | +brew install protobuf grpc cmake |
| 21 | +``` |
| 22 | + |
| 23 | +## Common Commands |
| 24 | + |
| 25 | +```bash |
| 26 | +# Run example project |
| 27 | +cd Example && pod install && open DashSync.xcworkspace |
| 28 | + |
| 29 | +# Run tests |
| 30 | +cd Example && xcodebuild test -workspace DashSync.xcworkspace -scheme DashSync-Example -destination 'platform=iOS Simulator,name=iPhone 15' |
| 31 | + |
| 32 | +# Update pods |
| 33 | +cd Example && pod update |
| 34 | +``` |
| 35 | + |
| 36 | +## Project Structure |
| 37 | + |
| 38 | +``` |
| 39 | +DashSync/ |
| 40 | +├── DashSync/shared/ # Main framework source (cross-platform) |
| 41 | +│ ├── Models/ # Core domain models (24 subdirectories) |
| 42 | +│ ├── Libraries/ # Utility libraries |
| 43 | +│ └── DashSync.xcdatamodeld/ # Core Data model (83 entities) |
| 44 | +├── DashSync/iOS/ # iOS-specific code |
| 45 | +├── DashSync/macOS/ # macOS-specific code |
| 46 | +├── Example/ # Reference app and tests |
| 47 | +├── Scripts/ # Build utilities |
| 48 | +└── ChainResources/ # Blockchain data files |
| 49 | +``` |
| 50 | + |
| 51 | +## Architecture |
| 52 | + |
| 53 | +### Two-Layer Design |
| 54 | +- **Layer 1 (Core)**: Traditional blockchain - transactions, blocks, masternodes |
| 55 | +- **Layer 2 (Platform)**: Decentralized apps - identities, documents, contracts |
| 56 | + |
| 57 | +### Model-Manager Pattern |
| 58 | +- **Models**: Data structures (`DSChain`, `DSWallet`, `DSTransaction`) |
| 59 | +- **Managers**: Service coordinators (`DSChainManager`, `DSPeerManager`) |
| 60 | + |
| 61 | +### Key Managers |
| 62 | +| Manager | Purpose | |
| 63 | +|---------|---------| |
| 64 | +| `DSChainsManager` | Multi-chain coordinator (singleton) | |
| 65 | +| `DSChainManager` | Single chain operations | |
| 66 | +| `DSPeerManager` | P2P network connectivity | |
| 67 | +| `DSTransactionManager` | Transaction pool | |
| 68 | +| `DSMasternodeManager` | Masternode lists & quorums | |
| 69 | +| `DSIdentitiesManager` | Blockchain identities | |
| 70 | +| `DSGovernanceSyncManager` | Governance data sync | |
| 71 | + |
| 72 | +### Persistence |
| 73 | +- **Core Data** with SQLite backend |
| 74 | +- 83 entity definitions in `DashSync.xcdatamodeld` |
| 75 | +- Custom transformers in `Models/Persistence/Transformers/` |
| 76 | + |
| 77 | +## Code Conventions |
| 78 | + |
| 79 | +### Naming |
| 80 | +- All classes prefixed with `DS` (e.g., `DSChain`, `DSWallet`) |
| 81 | +- Entities suffixed with `Entity` (e.g., `DSChainEntity`) |
| 82 | +- Managers suffixed with `Manager` (e.g., `DSPeerManager`) |
| 83 | + |
| 84 | +### File Organization |
| 85 | +- Public headers in main directory |
| 86 | +- `+Protected.h` files for subclass-accessible interfaces |
| 87 | +- Categories in `Categories/` subdirectories |
| 88 | + |
| 89 | +### Notifications |
| 90 | +Event-driven via `NSNotificationCenter`: |
| 91 | +- `DSChainBlocksDidFinishSyncingNotification` |
| 92 | +- `DSWalletBalanceDidChangeNotification` |
| 93 | +- `DSPeerManagerConnectedPeersDidChangeNotification` |
| 94 | + |
| 95 | +## Key Classes |
| 96 | + |
| 97 | +### Chain & Sync |
| 98 | +- `DSChain` (3,562 lines) - Central blockchain state manager |
| 99 | +- `DSBlock`, `DSMerkleBlock` - Block representations |
| 100 | +- `DSChainLock` - Chain lock mechanism |
| 101 | + |
| 102 | +### Wallet |
| 103 | +- `DSWallet` - HD wallet management |
| 104 | +- `DSAccount` - Account within wallet |
| 105 | +- `DSBIP39Mnemonic` - Mnemonic seed handling |
| 106 | +- `DSDerivationPath` - BIP32/44 key derivation |
| 107 | + |
| 108 | +### Transactions |
| 109 | +- `DSTransaction` - Base transaction class |
| 110 | +- `DSCoinbaseTransaction` - Mining rewards |
| 111 | +- `DSProviderRegistrationTransaction` - Masternode registration |
| 112 | +- `DSQuorumCommitmentTransaction` - Quorum operations |
| 113 | +- `DSCreditFundingTransaction` - Platform funding |
| 114 | + |
| 115 | +### Identity & Platform |
| 116 | +- `DSBlockchainIdentity` - Dash Platform identity |
| 117 | +- `DSBlockchainInvitation` - Contact requests |
| 118 | +- `DPContract` - Platform smart contracts |
| 119 | +- `DPDocument` - Platform documents |
| 120 | + |
| 121 | +### Privacy |
| 122 | +- `DSCoinJoinManager` - CoinJoin mixing coordination |
| 123 | +- `DSCoinJoinWrapper` - Protocol implementation |
| 124 | + |
| 125 | +## Network Support |
| 126 | + |
| 127 | +| Network | Purpose | |
| 128 | +|---------|---------| |
| 129 | +| Mainnet | Production Dash network | |
| 130 | +| Testnet | Testing environment | |
| 131 | +| Devnet | Development chains | |
| 132 | +| Regnet | Local regression testing | |
| 133 | + |
| 134 | +## Testing |
| 135 | + |
| 136 | +Tests located in `Example/Tests/`: |
| 137 | +- `DSChainTests.m` - Chain operations |
| 138 | +- `DSTransactionTests.m` - Transaction handling |
| 139 | +- `DSDeterministicMasternodeListTests.m` - Masternode lists |
| 140 | +- `DSCoinJoinSessionTest.m` - Privacy mixing |
| 141 | +- `DSDIP14Tests.m` - DIP compliance |
| 142 | + |
| 143 | +## CI/CD Workflows |
| 144 | + |
| 145 | +- `build.yml` - Main CI pipeline |
| 146 | +- `test.yml` - Unit tests |
| 147 | +- `lint.yml` - Code linting |
| 148 | +- `coverage.yml` - Code coverage |
| 149 | +- `syncTestMainnet.yml` / `syncTestTestnet.yml` - Network sync tests |
| 150 | + |
| 151 | +## Dependencies |
| 152 | + |
| 153 | +Key CocoaPods: |
| 154 | +- **DashSharedCore** - Rust-based cryptographic primitives |
| 155 | +- **CocoaLumberjack** - Logging framework |
| 156 | +- **DAPI-GRPC** - Decentralized API protocol |
| 157 | +- **TinyCborObjc** - CBOR serialization |
| 158 | + |
| 159 | +## Localization |
| 160 | + |
| 161 | +Supports 15+ languages: en, de, es, ja, zh-Hans, zh-Hant-TW, uk, bg, el, it, cs, sk, ko, pl, tr, vi |
| 162 | + |
| 163 | +## Development Workflow |
| 164 | + |
| 165 | +### Commit Policy |
| 166 | +- **DO NOT commit changes until the user has tested them** |
| 167 | +- Wait for explicit approval before creating commits |
| 168 | +- This applies to all code changes, especially logging and behavioral modifications |
| 169 | + |
| 170 | +### Related Repositories |
| 171 | +- **DashJ** (Android equivalent): https://github.com/dashpay/dashj |
| 172 | +- **Dash Wallet Android**: https://github.com/dashpay/dash-wallet |
| 173 | + |
| 174 | +## External Resources |
| 175 | + |
| 176 | +- [Dash Core Specs](https://dashcore.readme.io/docs) |
| 177 | +- [Dash Improvement Proposals](https://github.com/dashpay/dips) |
| 178 | +- [Developer Discord](https://discord.com/channels/484546513507188745/614505310593351735) |
0 commit comments