Repository navigation
Architecture
Technical documentation of PoCX Wallet's internal architecture.
PoCX Wallet is built with a modular architecture separating core cryptographic functionality from the CLI interface and service management.
┌─────────────────────────────────────────────────────────────────┐
│ PocxWallet.Cli │
│ ┌─────────────┐ ┌─────────────────┐ ┌───────────────────────┐ │
│ │ Program │ │ WalletCommands │ │ DynamicServiceMenu │ │
│ │ (Entry) │ │ │ │ Builder │ │
│ └─────────────┘ └─────────────────┘ └───────────────────────┘ │
│ ┌─────────────┐ ┌─────────────────┐ ┌───────────────────────┐ │
│ │ Wallet │ │ ServiceDefiniti │ │ DockerService │ │
│ │ Manager │ │ onLoader │ │ Manager │ │
│ └─────────────┘ └─────────────────┘ └───────────────────────┘ │
├─────────────────────────────────────────────────────────────────┤
│ PocxWallet.Core │
│ ┌─────────────────┐ ┌─────────────────┐ ┌───────────────────┐ │
│ │ HDWallet │ │ Bech32Encoder │ │ VanityAddress │ │
│ │ (NBitcoin) │ │ │ │ Generator │ │
│ └─────────────────┘ └─────────────────┘ └───────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
Core cryptographic and wallet functionality.
PocxWallet.Core/
├── Address/
│ └── Bech32Encoder.cs # Custom Bech32 encoding for pocx prefix
├── Wallet/
│ └── HDWallet.cs # HD wallet implementation using NBitcoin
└── VanityAddress/
└── VanityAddressGenerator.cs # Multi-threaded vanity search
The main wallet class providing:
- Mnemonic generation (BIP39)
- Key derivation (BIP84 paths)
- Address generation (Bech32 with pocx prefix)
- WIF export
- Descriptor generation with checksums
Key Methods:
// Create new wallet
public static HDWallet CreateNew(WordCount wordCount, string? passphrase)
// Restore from mnemonic
public static HDWallet FromMnemonic(string mnemonic, string? passphrase)
// Derive PoCX address
public string GetPoCXAddress(uint account, uint index, bool testnet, bool change)
// Get descriptor with checksum
public string GetDescriptor(bool testnet, uint account, uint index)Custom Bech32 encoding supporting:
-
pocxprefix for mainnet -
tpocxprefix for testnet - Witness version 0 (P2WPKH)
Multi-threaded vanity address search:
- Uses all available CPU cores
- Progress reporting via IProgress
- Cancellation support
- Pattern matching on generated addresses
Command-line interface and service management.
PocxWallet.Cli/
├── Program.cs # Entry point and main menu
├── Commands/
│ └── WalletCommands.cs # All wallet menu handlers
├── Configuration/
│ ├── ServiceDefinition.cs # YAML model classes
│ ├── ServiceDefinitionLoader.cs # YAML loading/saving
│ ├── DynamicServiceMenuBuilder.cs # Dynamic menu generation
│ ├── WalletManager.cs # Multi-wallet persistence
│ └── CommandTemplateEngine.cs # Custom command processing
├── Services/
│ ├── DockerServiceManager.cs # Docker container operations
│ └── BackgroundServiceManager.cs # Background process tracking
└── Resources/
└── Strings.cs # UI strings for localization
Application entry point:
- Initializes services
- Loads
services.yaml - Runs main menu loop
- Handles graceful shutdown
Handles all wallet-related menus:
- Create (random, vanity)
- Import (from mnemonic, to node)
- Select/Switch
- Info queries
- Transaction operations
- Settings
Builds menus dynamically from services.yaml:
- Reads service definitions
- Generates menu structure
- Handles service actions (start/stop/logs)
- Parameter and settings management
Singleton managing multiple wallets:
- Load/save to
wallet.json - Active wallet tracking
- Legacy format migration
- Settings persistence
Docker container management:
- Container lifecycle (create, start, stop, remove)
- Log retrieval
- Command execution in containers
- Network management
User Input → WalletCommands.CreateRandomWalletAsync()
→ HDWallet.CreateNew()
→ NBitcoin.Mnemonic (generates entropy)
→ HDWallet.GetPoCXAddress()
→ Bech32Encoder.Encode()
→ WalletManager.AddWallet()
→ WalletManager.Save() → wallet.json
User Selection → DynamicServiceMenuBuilder.StartServiceAsync()
→ BuildCommand() (from parameters)
→ BuildVolumeMappings()
→ BuildPortMappings()
→ DockerServiceManager.StartContainerAsync()
→ docker run command
User Action → WalletCommands.ExecuteNodeCommandAsync()
→ Check node running status
→ DockerServiceManager.ExecInContainerAsync()
→ docker exec command
→ Parse and display output
Services are defined in services.yaml rather than hardcoded:
- Easy to add new services without code changes
- Parameter validation from schema
- Portable configuration
The wallet file supports multiple named wallets:
- One active wallet at a time
- Automatic legacy format migration
- Settings stored alongside wallets
Uses BIP84 (native SegWit) paths:
-
m/84'/0'/0'/0/0for mainnet -
m/84'/1'/0'/0/0for testnet - Compatible with modern Bitcoin wallets
Rich terminal UI using Spectre.Console:
- Selection prompts for menus
- Progress bars for long operations
- Panels for structured output
- Markup for colors
Default deployment via Docker:
- No build dependencies on host
- Consistent environment
- Easy updates via image pulls
| Package | Purpose |
|---|---|
| NBitcoin | Bitcoin cryptography |
| YamlDotNet | YAML parsing |
| Spectre.Console | Terminal UI |
| Service | Purpose |
|---|---|
| Docker | Container runtime |
| Bitcoin-PoCX Node | Blockchain operations |
| Electrs | Electrum protocol |
- Generated using NBitcoin's secure random
- Stored encrypted in wallet.json (user responsibility)
- Never transmitted over network
- Displayed once during creation
- Keys derived on-demand from mnemonic
- Never stored separately
- WIF export for node import only
- Services run in Docker containers
- Network isolation via Docker network
- Volume mounts for persistent data only
- Add service definition to
services.yaml - Define parameters, ports, volumes
- Service automatically appears in menu
Services can define custom commands:
command:
binary: "bitcoin-cli"
arguments: ["getblockchaininfo"]
show_output: trueAll UI strings centralized in Strings.cs:
- Can be extended for multiple languages
- Consistent formatting
PoCX Wallet is experimental software. Use at your own risk.
📖 Documentation • 🐛 Report Issue • 💻 Source Code