How 595014049/lol works
Project type and purpose
• This is a backend microservice written in Go that provides an offline wallet signing service (ECDSA and EdDSA) exposed over gRPC/CLI.
• It supports multiple blockchain protocols (Bitcoin, Ethereum, Solana) through modular chain adaptors.
• It persists keys in LevelDB and can optionally integrate with an HSM or software-based SSM key manager.
File structure
• Top-level binaries in cmd/wallet-sign-server (main.go, cli.go) launch either RPC or CLI mode.
• chain/ contains protocol-specific adapters (bitcoin/, ethereum/, solana/).
• services/rpc implements the gRPC server endpoint.
• common/ holds shared utilities (CLI app framework, retries, interrupts).
• hsm/ and ssm/ contain hardware and software key management implementations.
• leveldb/ is the on-disk key store.
• protobuf/ defines the wallet.proto and generated gRPC code.
• chaindispatcher/ routes sign requests to the correct chain adapter.
• config/ and config.yml for configuration loading.
Key README insights
• The service runs as “wallet-sign-server rpc” after loading config.yml.
• It listens on host/port, loads credentials, key names and path, and enables/disables HSM.
• Chains are registered based on config.
Main components
a. Entrypoints
• CLI/REST/gRPC interface (cmd/wallet-sign-server)
b. RPC Server layer (services/rpc)
c. Dispatcher (chaindispatcher)
d. Chain Adaptors (chain/bitcoin, chain/ethereum, chain/solana)
e. Key Manager
• HSM module (hsm/)
• SSM module (ssm/)
f. Storage layer (LevelDB under leveldb/)
g. Configuration loader (config/)
h. Shared Utilities (common/)
i. Protobuf definitions (protobuf/ and generated code)
Relationships and data flow
1. Client → CLI/gRPC stub (protobuf wallet.proto)
2. gRPC server (services/rpc) validates request & calls Dispatcher
3. Dispatcher selects appropriate Chain Adapter
4. Chain Adapter invokes sign operation using Key Manager (HSM or SSM)
5. Key Manager fetches private key from LevelDB, performs crypto
6. Signed payload returned back up chain: Adapter → Dispatcher → gRPC stub → Client
7. LevelDB persists any key-related metadata (“common retry” may be used)
Architectural patterns & tech highlights
• Hexagonal (ports/adapters) pattern: chain adapters plug into a common dispatcher interface.
• gRPC (protobuf) for the RPC API.
• Plugin-like Key Manager abstraction: HSM vs SSM.
• Embedded LevelDB for local key persistence.
• CLI framework for standalone/offline use.
Detail
• Configuration component reading config.yml.
• Call out common utilities (retry, lifecycle) as side-bars or sub-modules.
• Dual path through HSM vs SSM.