MIT License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

项目背景与痛点

非托管钱包这件事,说起来简单,做起来是工程地狱。用户要的是「一个 App 管好我所有资产,私钥还在我自己手里」,而开发者面对的是:每接一条链,就多一整套密码学栈、序列化格式、节点协议和手续费模型。Monero 更是硬骨头——C++ 代码库庞大、依赖复杂,想把它的钱包逻辑塞进移动端,社区里能跑通的方案屈指可数。

cake-tech/cake_wallet 的核心价值就在这儿:它用一套 Flutter 代码库,同时支撑 Cake Wallet(多币种)和 Monero.com(Monero 单币种)两个产品。前者面向「一站式资产面板」的需求,后者面向隐私币铁杆用户,砍掉多余链路降低攻击面。这种「同源双品牌」的做法,背后是相当克制的架构设计,而不是把两个 App 各写一遍。

核心技术揭秘

项目采用典型的三层切分:data 负责网络、存储与原生库调用,domain 承载实体与业务规则,presentation 是 Flutter 的 Widget 与状态层。依赖注入用 get_it,状态管理已从早期的 Provider 迁移到 Riverpod,副作用与异步流被收拢到 Provider 图里,UI 层基本不做业务判断。

真正决定成败的是币种抽象层。每条链实现同一个 WalletBase 接口——连接、同步、余额、构造交易、广播,语义统一,上层 WalletService 只做门面调度。这套抽象的好处是新增链路时 UI 几乎无感;代价是抽象泄漏,比如 Monero 的「未确认输出」和 EVM 的「nonce 竞争」根本不是一回事,只能在具体实现里各自消化。

Monero 的接入方式是全文最值得看的部分:项目维护了 monero_c,把 Monero 的 C++ 核心交叉编译成各平台原生库(Android、iOS、macOS、Linux、Windows),Dart 侧通过 dart:ffi 直接调用。私钥运算、区块扫描、交易构建全部在原生层完成,Dart 只负责传指针、取结果。这是它能既保住 Monero 的完整能力、又维持 Flutter 单代码库的根本原因。相应地,网络层也按链分流:Monero 走 daemon RPC,比特币走 Electrum 协议,EVM 链走 JSON-RPC,全部可以挂到 Tor / I2P 传输层之后,隐私币用户默认获得更强的匿名性。

graph TD A[Flutter UI 层] --> B[Riverpod 状态管理] B --> C[WalletService 门面] C --> D[WalletBase 抽象接口] D --> E[Monero 钱包实现] D --> F[比特币钱包实现] D --> G[EVM 钱包实现] E --> H[monero_c 原生绑定] H --> I[Monero C++ 核心] F --> J[Electrum 服务器集群] G --> K[EVM RPC 节点] I --> L[Tor / I2P 传输层] J --> L K --> L L --> M[区块链网络]

功能亮点与差异

第一是开源可审计。种子派生、交易构造、地址生成这些敏感路径全部在仓库里,用户和审计方可以自己验,这在移动钱包里并不常见。

第二是内置兑换聚合。ChangeNOW、SideShift、ThorChain 等通道被做成统一入口,用户不必把币提到交易所就能换仓,这对非托管钱包的实用性提升是决定性的——虽然这部分依赖第三方 API,属于「半透明」地带。

第三是隐私传输默认化。Tor 不是可选项而是能力之一,配合 Monero 的环签名,形成了从网络层到交易层的完整匿名链路,这是 Trust Wallet 这类多链产品不会去做的事。

第四是双产品线的克制裁剪。Monero.com 用配置开关砍掉非 Monero 模块,包体和攻击面同时缩小,维护成本却没有翻倍。

应用场景与落地建议

适合的场景很明确:面向终端用户的非托管多链钱包、隐私交易工具、需要内置兑换能力的资产管理 App。

上生产前有几件事必须想清楚。节点策略:Electrum 服务器和 Monero daemon 的可用性直接决定体验,自建或做多源故障转移是必修课。后台同步:移动端要靠平台后台任务和前台服务维持扫描进度,电量与唤醒策略没调好,用户会立刻感知到。交叉编译链:monero_c 的原生库构建是长期维护负担,CI 和签名配置要提前规划。安全细节:种子加密存储、生物识别解锁、剪贴板与截屏防护、内存中敏感数据的及时清理,这些在 FFI 边界上尤其容易出错。合规边界:内置兑换通道的 KYC 归属、各司法辖区的钱包监管差异,需要产品侧提前拉齐。

不建议把它当成服务端钱包库来用——它的设计前提是「单设备、用户自持、UI 驱动」,脱离这个前提去复用,收益很低。

综合评价

优点:分层清晰,币种抽象有纪律;用 FFI 绕开 Flutter 的密码学短板,是务实且经过验证的解法;开源、活跃、双品牌策略把工程复用做到了极致。

缺点:Flutter 带来的包体与启动开销不可忽视;原生库构建链对贡献者门槛偏高;多链抽象在边缘语义上仍有泄漏,新增链路的实际成本比接口看起来要高;第三方兑换与支付集成属于不可审计部分,削弱了「全开源」的纯粹性。

一句话总结:它是目前少有的、把「隐私币 + 多链 + 非托管 + 移动端」四件事同时做成的开源工程,架构值得借鉴,但复刻它的成本主要在原生层,而不在 Flutter 层。

关于

GitHub 原始描述(英文)

The open source repository for Cake Wallet, a noncustodial multi-currency wallet, and Monero.com, a noncustodial Monero-only wallet. Need help? Check out https://docs.cakewallet.com

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
2867
价值分
1313
活跃状态
活跃

语言占比

Batchfile
C
C++
CMake
Dart
Dockerfile
Go
Inno Setup
Java
Kotlin
Nix
Objective-C
PowerShell
Ruby
Shell
Swift

Release

README

logo

Cake Wallet

Cake Wallet is an open-source, non-custodial, and private multi-currency crypto wallet for Android, iOS, macOS, and Linux.

Cake Wallet includes support for several cryptocurrencies, including:

  • Monero (XMR)
  • Bitcoin (BTC)
  • Ethereum (ETH)
  • Litecoin (LTC)
  • Bitcoin Cash (BCH)
  • Polygon (POL)
  • Base (BASE)
  • Arbitrum (ARB)
  • Solana (SOL)
  • Tron (TRX)
  • Nano (XNO)
  • Zano (ZANO)
  • Decred (DCR)
  • Wownero (WOW)

Features

App-Wide Features

  • Completely noncustodial. Your keys, your coins.
  • Built-in exchange for dozens of pairs
  • Easily pay cryptocurrency invoices with fixed rate exchanges
  • Buy cryptocurrency (BTC/LTC/XMR/ETH) with credit/debit/bank
  • Sell cryptocurrency by bank transfer
  • Scan QR codes for easy cryptocurrency transfers
  • Create several wallets
  • Select your own custom nodes/servers
  • Address book
  • Backup to an external location or iCloud
  • Send to OpenAlias, Unstoppable Domains, Yats, and FIO Crypto Handles
  • Set desired network fee level
  • Store local transaction notes
  • Extremely simple user experience
  • Convenient exchange and sending templates for recurring payments
  • Create donation links and invoices in the receive screen
  • Robust privacy settings (eg: Tor-only connections)
  • Robust security settings (eg: Cake 2FA)

Monero Specific Features

  • The Monero view key is retained on the device for maximum privacy
  • Full support for Monero subaddresses and accounts
  • Specify restore height for faster syncing
  • Specify multiple recipients for batch sending
  • Optionally set Monero nodes as trusted for faster syncing
  • Specify a proxy for Monero nodes, compatible with Tor and i2p

Bitcoin Specific Features

  • Bitcoin coin control (specify specific outputs to spend)
  • Automatically generate new addresses
  • Specify multiple recipients for batch sending

Ethereum Specific Features

  • Store ETH and all ERC-20 tokens
  • Add custom tokens by contract address
  • Enable or disable Etherscan for transaction history

Litecoin Specific Features

  • Litecoin coin control (specify specific outputs to spend)
  • Automatically generate new addresses
  • Specify multiple recipients for batch sending

Monero.com by Cake Wallet for Android and iOS

Open Source Monero-Only Wallet

Exchanging to/from other assets is also supported.

APK Verification

APK releases on GitHub, Accrescent, and F-Droid use the same key. They can easily be verified using apksigner or AppVerifier.

See below for Cake Wallet’s SHA-256 signing certificate hash:

com.cakewallet.cake_wallet
C5:40:53:AB:0F:10:D9:54:17:62:A3:DA:76:65:AE:3D:BA:5E:7C:74:3A:B4:F1:08:A5:34:9D:62:AC:10:6E:F5

Support

We have 24/7 free support. Please contact [email protected]

We have excellent user guides, which are also open-source and open for contributions: https://docs.cakewallet.com

Build Instructions

More instructions to follow

For instructions on how to build for Android: please view file howto-build-android.md

Contributing

Improving translations

Edit the applicable strings_XX.arb file in res/values/ and open a pull request with the changes.

Current list of language files:

  • English
  • Spanish
  • French
  • German
  • Italian
  • Portuguese
  • Dutch
  • Polish
  • Croatian
  • Russian
  • Ukrainian
  • Hindi
  • Japanese
  • Chinese
  • Korean
  • Thai
  • Arabic
  • Turkish
  • Burmese
  • Urdu
  • Bulgarian
  • Czech
  • Indonesian
  • Hausa
  • Yoruba

Add a new language

  1. Create a new strings_XX.arb file in res/values/, replacing XX with the language’s ISO 639-1 code.

  2. Edit the strings in this file, replacing XXX below with the translation for each string.

"welcome": "Welcome to", -> "welcome": "XXX",

  1. For strings where there is a variable, denoted by a $ symbol and braces, such as ${status}, the string in braces should not be translated. For example, when editing line 106:

“time” : “${minutes}m ${seconds}s”

The only parts to be translated, if needed, are the values m and s after the variables.

  1. Add the language to lib/entities/language_service.dart under both supportedLocales and localeCountryCode. Use the name of the language in the local language and in English in parentheses after for supportedLocales. Use the ISO 3166-1 alpha-3 code for localeCountryCode. You must choose one country, so choose the country with the most native speakers of this language or is otherwise best associated with this language.

  2. Add a relevant flag to assets/images/flags/XXXX.png, replacing XXXX with the 3 letters localeCountryCode. The image must be 42x26 pixels with 3 pixels of transparent margin on all 4 sides. You can resize the flag with paint.net to 36x20 pixels, expand the canvas to 42x26 pixels with the flag anchored in the middle, and then manually delete the 3 pixels on each side to make it transparent. Or you can use another program like Photoshop.

  3. Add the new language code to tool/utils/translation/translation_constants.dart

Add a new fiat currency

  1. Check with Cake Wallet support to see if the desired new fiat currency is available through our fiat API. Not all fiat currencies are.

  2. If the currency is associated strongly with a specific issuing country, map the ISO 4217 currency code with the applicable ISO 3166-1 alpha-3 code in lib/entities/fiat_currency.dart. If the currency is used in a whole region or organization, then map with a reasonable interpretation of this (eg: eur countryCode for EUR symbol).

  3. Add the raw mapping underneath in lib/entities/fiat_currency.dart following the same format as the others.

  4. Add a flag of the issuing country or organization to assets/images/flags/XXXX.png, replacing XXXX with the ISO 3166-1 alpha-3 code used above (eg: usa.png, eur.png). Do not add this if the flag with the same name already exists. The image must be 42x26 pixels with a 3 pixels of transparent margin on all 4 sides.


Copyright © 2018-2023 Cake Labs LLC

评论

暂无评论