How blockstream/green_ios works
This project is an iOS native wallet application—Blockstream Green—that lets users securely store, send, and receive Bitcoin. It is structured as a full-fledged mobile app integrating several specialized subsystems, including wallet core functionality from the shared gdk library, hardware wallet integration, lightning network support, notification services, and extensive UI components for a native iOS experience.
Main Components
• UI/Presentation Layer (“gaios”): This directory holds nearly all the user interface components (storyboards, view controllers, views, localization, etc.). It implements industry patterns such as MVC/MVVM.
• Core Business Logic (“core” and “gdk”): The “core” folder houses analytics, session, repositories, and models that represent the wallet’s internal state. “gdk” provides the cross-platform wallet library to handle core Bitcoin functionality such as accounts, transactions, network settings, and security.
• Hardware and External Integrations (“hw”, “greenaddress”, “lightning”): The “hw” directory supports integration with hardware wallets (e.g., Ledger and Jade), while “greenaddress” offers additional wallet-related utilities and “lightning” interfaces for the Lightning network.
• Notification and Background Services (“NotificationService”): This service module handles background tasks such as confirming transactions or updating swap statuses.
• Configuration and Build Tools (“configs”, “fastlane”, “tools”): These directories contain configuration files (xcconfig settings for development/production) and build/deployment scripts.
Relationships and Data Flows
• The core modules communicate with hardware integration modules (“hw”) and external integrations (“lightning”, “greenaddress”) to fetch or update wallet data.
• The NotificationService consumes events (e.g., confirmation of transactions) and interacts with the core to update state, while also using local configuration settings.
• Analytics and logging (found in “core/Countly” and “core/Managers/Logger.swift”) propagate usage events upward for remote monitoring.
• Build scripts and CI configuration files facilitate deployment and integration, but usually reside off to the side of the operational architecture.
Architectural Patterns
• MVC/MVVM Patterns: The project extensively uses view controllers, view models, and storyboards (especially in the “gaios” and “OnBoard” directories) to separate UI from business logic.
• Modular Design: The separation into distinct directories (UI, core wallet logic, hardware wallet integration, network communication, and notifications) shows a modular design. Each module’s responsibility is clearly delimited.
• Cross-Platform Integration: The use of gdk indicates that the wallet’s core functions are shared across platforms, with this iOS version focusing on native UI and experience.
Relevant Technologies, Frameworks, and Libraries
• Swift and Xcode: The entire project is built using Swift with Xcode projects (“gaios.xcodeproj”).
• External dependencies: gdk serves as the wallet’s core library; integrations with hardware wallet modules and lightning network components are present.
• Localization: Multiple localization directories (e.g., “en.lproj”, “de.lproj”, etc.) indicate a robust multi-language support strategy.
• Fastlane: Used for automated builds and deployments.
• CI/CD: GitHub Actions, GitLab CI configurations are included for continuous integration/deployment.
Capturing Essential Architectural Elements
• Out every major component as a node.
• Design patterns (MVC/MVVM) where appropriate by annotating components with their responsibilities.