分析开源钱包
从中选取更优的资源包,作为自己的钱包的基础。
- Geth本身提供的资源包
- Geth资源包下载地址,iOS怎么使用这个资源的问题链接
- 结论:资源包太大iOS版本的Framework 88M,提供了一些基本功能,导入私钥,生成地址,存储私钥,签名等。但是不提供连接节点的功能。理论上他提供了我们需要的基础功能,但是资源包太大,得不偿失。
- 接第一条的说。ethereum-wallet 完全原生的以太钱包。原生是因为使用的是以太坊官方提供的开发包进行的开发,官方资源包地址。
1. 核心 使用的是以太坊官方开发的资源包 Geth。这个资源包提供了,导入jsonKey用于恢复地址,生成一个新的地址,备份地址,生成签名,连接节点等功能,不提供12个关键字的备份方式。 2. 交易的发送 提供连接其他节点的能力,可以将交易发送给其他节点进行打包操作。但是如果想要查询某些信息,例如余额,交易详情,当前地址的nounce等信息,需要连接一个全节点进行查询。例如:https://etherscan.io/ , 使用其提供的自定义接口查询或者使用其开启的JsonRPC接口进行查询。或者使用https://infura.io/ 这个全节点的 JsonRPC的服务进行查询。 3. 核心代码 核心是 Geth, 这个工程在这个的基础上进行的开发与封装
-
EthersWallet-ios
1. 核心 [ethers.objc](https://github.com/ethers-io/ethers.objc)一个这个作者自己写的资源库,用于这些核心的功能。签名,生成地址,导入地址,提供12个关键字和json的方式进行备份。预写了网络请求,以etherscan和infura为可选项的配置,同时支持主网和测试网络的切换。等功能 核心算法库是TrezorCrypto (作者提取其中部分算法以及对部分算法内部实现做了调整)。此库地址的生成是先生成12 key, 然后在由此生成地址。 补充:通过自己对合约的理解,也可以调用智能合约。但是这些功能并没有合并进入这个核心库,而是作为工具类保存在工程中。 2. 交易的发送 与一个全节点且提供JsonRPC接口的网站通过JsonRPC接口进行数据的查询与交易的发送。例如:https://etherscan.io/ , 使用其提供的自定义接口查询或者使用其开启的JsonRPC接口进行查询。或者使用https://infura.io/ 这个全节点的 JsonRPC的服务进行查询。 3. 核心代码 核心代码就是[ethers.objc](https://github.com/ethers-io/ethers.objc)这个OC的资源库,这个库通过一个C的算法库,提供核心功能的处理。
-
trust-wallet-ios, 主要功能: dapp浏览器,钱包(eth以及erc20代币,etc, go, poa, clo这些币的相关操作)
1. 核心 - [trust-core](https://github.com/TrustWallet/trust-core)一个trust自己写的资源库,用于这些核心的功能。其中的核心算法库同样是TrezorCrypto,这次作者直接完整导入,未做特殊处理。此库地址的生成是首先使用苹果的Security库生成私钥,然后根据私钥在生成地址。同样提供签名,生成地址,导入地址,提供备份和助记词。但是这个库支持调用智能合约。预写了对智能合约的解析和函数调用。同时支持btc的相关操作。 - [trust-keystore](https://github.com/TrustWallet/trust-keystore)一个在trust-core基础上再次封装的库,提供管理钱包(即管理多个地址)的功能。也就是多地址管理功能,提供对地址的增删改查功能。存储的时候结合CryptoSwift算法库,进行数据的加密存储。 2. 交易的发送 与一个全节点且提供JsonRPC接口的网站通过JsonRPC接口进行数据的查询与交易的发送。trust Eth即相关代币使用https://infura.io/ 这个全节点的 JsonRPC的服务进行查询。 3. 核心代码 核心代码就是[trust-core]或者[trust-keystore]。
-
EthereumKit, 支持ERC20交易,签名,地址管理。
1. 核心 - 唯一导入的库[CryptoEthereumSwift](https://github.com/yuzushioh/CryptoEthereumSwift)一个iOS框架的以太坊加密实现。 - 这个库导入的核心算法库openssl,secp256k1以及[CryptoSwift](https://github.com/krzyzanowskim/CryptoSwift), CryptoSwift是一个在Swift中实现, 且不断增长的标准和安全加密算法集合。 - 此库助记词的的生成是首先使用苹果的Security库生成随机16byte的data,然后根据这个data在生成助记词。 2. 交易的发送 与一个全节点且提供JsonRPC接口的网站通过JsonRPC接口进行数据的查询与交易的发送。https://api.etherscan.io/ 这个全节点的 JsonRPC的服务进行查询。 3. 核心代码 核心代码就是[trust-core]或者[trust-keystore]。
研究过程中遇到的问题
- make makefile
目录下终端执行命令: make makefile 错误提示需要: sudo gem install bundler (即需要提前安装bundler问题) bundle的介绍: [bundle官网](https://bundler.io/v1.16/#getting-started) 暂未安装这个资源
- pod instal
pod install /*遇到undefined method use_modular_headers!*/ 原因是use_modular_headers! 这个是CocoaPods 1.5版本及以后 才可以使用的语法 [对这条命令的解释](https://kuaibao.qq.com/s/20180622G1B80E00?refer=cp_1026) 所以如果想要使用,需要升级CocoaPods
- sudo gem install cocoapods
一 Could not find a valid gem 'cocoapods' (>= 0), here is why: Unable to download data from https://gems.ruby-china.org/ 直译就是不能从这个网站获取资源,浏览器打开网站,看到了提示,说换名字了, 从.org改为了.com 所以需要删除之前的更新为最新的具体如下: gem source -l >> https://gems.ruby-china.org/ gem source --add https://gems.ruby-china.com/ --remove https://gems.ruby-china.org/ >> https://gems.ruby-china.com/ added to sources https://gems.ruby-china.org/ removed from sources gem source -l >> https://gems.ruby-china.com/ 二 当安装xcodeproj-1.6.0.gem时: Operation not permitted - /usr/bin/xcodeproj 原因如: [Operation not permitted](https://www.jianshu.com/p/8ed817a2d569) 解决就是换个命令: sudo gem install -n /usr/local/bin cocoapods 好了。
- pod repo update
[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down 以为没网,结果有。以为github.com挂了,结果没挂,所以其他原因了。 据说这个原因:[github公告](https://blog.github.com/2018-02-23-weak-cryptographic-standards-removed/) 据说解决方案:[一个blog](https://blog.csdn.net/jiajiayouba/article/details/79814177) brew update brew install ruby sudo gem install -n /usr/local/bin cocoapods 三个依次执行即可,最后一个即使你刚更新了,也要再来一次 最后的log***************************** bogon:~ zsk$ brew update ==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.3.7.leopard_64.bottle.tar.gz ######################################################################## 100.0% ==> Pouring portable-ruby-2.3.7.leopard_64.bottle.tar.gz ==> Homebrew is run entirely by unpaid volunteers. Please consider donating: https://github.com/Homebrew/brew#donations Updated 4 taps (ethereum/ethereum, homebrew/cask, homebrew/core, homebrew/services). ==> New Formulae libgit2 ************ ==> Renamed Formulae rebar@3 -> rebar3 ==> Deleted Formulae boot2docker ghc@8.0 node@4 boot2docker-completion gnupg@2.0 dirmngr gpg-agent Error: Permission denied @ rb_file_s_symlink - (../../../Homebrew/Library/Taps/homebrew/homebrew-services/completions/zsh/_brew_services, /usr/local/share/zsh/site-functions/_brew_services) bogon:~ zsk$ brew install ruby Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/cask). No changes to formulae. Error: Permission denied @ rb_file_s_symlink - (../../../Homebrew/Library/Taps/homebrew/homebrew-services/completions/zsh/_brew_services, /usr/local/share/zsh/site-functions/_brew_services) ==> Installing dependencies for ruby: libyaml, openssl, readline ==> Installing ruby dependency: libyaml ==> Downloading https://homebrew.bintray.com/bottles/libyaml-0.2.1.sierra.bottle ######################################################################## 100.0% ==> Pouring libyaml-0.2.1.sierra.bottle.tar.gz 🍺 /usr/local/Cellar/libyaml/0.2.1: 9 files, 299.6KB ==> Installing ruby dependency: openssl ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2p.sierra.bottl ######################################################################## 100.0% ==> Pouring openssl-1.0.2p.sierra.bottle.tar.gz ==> Caveats A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), place .pem files in /usr/local/etc/openssl/certs and run /usr/local/opt/openssl/bin/c_rehash openssl is keg-only, which means it was not symlinked into /usr/local, because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. If you need to have openssl first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile For compilers to find openssl you may need to set: export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include" For pkg-config to find openssl you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig" ==> Summary 🍺 /usr/local/Cellar/openssl/1.0.2p: 1,793 files, 12.3MB ==> Installing ruby dependency: readline ==> Downloading https://homebrew.bintray.com/bottles/readline-7.0.5.sierra.bottl ######################################################################## 100.0% ==> Pouring readline-7.0.5.sierra.bottle.tar.gz ==> Caveats readline is keg-only, which means it was not symlinked into /usr/local, because macOS provides the BSD libedit library, which shadows libreadline. In order to prevent conflicts when programs look for libreadline we are defaulting this GNU Readline installation to keg-only. For compilers to find readline you may need to set: export LDFLAGS="-L/usr/local/opt/readline/lib" export CPPFLAGS="-I/usr/local/opt/readline/include" ==> Summary 🍺 /usr/local/Cellar/readline/7.0.5: 46 files, 1.5MB ==> Installing ruby ==> Downloading https://homebrew.bintray.com/bottles/ruby-2.5.1.sierra.bottle.ta ######################################################################## 100.0% ==> Pouring ruby-2.5.1.sierra.bottle.tar.gz ==> Caveats Emacs Lisp files have been installed to: /usr/local/share/emacs/site-lisp/ruby ==> Summary 🍺 /usr/local/Cellar/ruby/2.5.1: 16,227 files, 27.5MB ==> Caveats ==> openssl A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), place .pem files in /usr/local/etc/openssl/certs and run /usr/local/opt/openssl/bin/c_rehash openssl is keg-only, which means it was not symlinked into /usr/local, because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. If you need to have openssl first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile For compilers to find openssl you may need to set: export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include" For pkg-config to find openssl you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig" ==> readline readline is keg-only, which means it was not symlinked into /usr/local, because macOS provides the BSD libedit library, which shadows libreadline. In order to prevent conflicts when programs look for libreadline we are defaulting this GNU Readline installation to keg-only. For compilers to find readline you may need to set: export LDFLAGS="-L/usr/local/opt/readline/lib" export CPPFLAGS="-I/usr/local/opt/readline/include" ==> ruby Emacs Lisp files have been installed to: /usr/local/share/emacs/site-lisp/ruby bogon:~ zsk$ ruby -v ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16] bogon:~ zsk$ pod repo update Updating spec repo `master` [!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down bogon:~ zsk$ sudo gem install -n /usr/local/bin cocoapods Password: Fetching: concurrent-ruby-1.0.5.gem (100%) Successfully installed concurrent-ruby-1.0.5 Fetching: i18n-0.9.5.gem (100%) Successfully installed i18n-0.9.5 Fetching: thread_safe-0.3.6.gem (100%) Successfully installed thread_safe-0.3.6 Fetching: tzinfo-1.2.5.gem (100%) Successfully installed tzinfo-1.2.5 Fetching: activesupport-4.2.10.gem (100%) Successfully installed activesupport-4.2.10 Fetching: nap-1.1.0.gem (100%) Successfully installed nap-1.1.0 Fetching: fuzzy_match-2.0.4.gem (100%) Successfully installed fuzzy_match-2.0.4 Fetching: cocoapods-core-1.5.3.gem (100%) Successfully installed cocoapods-core-1.5.3 Fetching: claide-1.0.2.gem (100%) Successfully installed claide-1.0.2 Fetching: cocoapods-deintegrate-1.0.2.gem (100%) Successfully installed cocoapods-deintegrate-1.0.2 Fetching: cocoapods-downloader-1.2.1.gem (100%) Successfully installed cocoapods-downloader-1.2.1 Fetching: cocoapods-plugins-1.0.0.gem (100%) Successfully installed cocoapods-plugins-1.0.0 Fetching: cocoapods-search-1.0.0.gem (100%) Successfully installed cocoapods-search-1.0.0 Fetching: cocoapods-stats-1.0.0.gem (100%) Successfully installed cocoapods-stats-1.0.0 Fetching: netrc-0.11.0.gem (100%) Successfully installed netrc-0.11.0 Fetching: cocoapods-trunk-1.3.1.gem (100%) Successfully installed cocoapods-trunk-1.3.1 Fetching: cocoapods-try-1.1.0.gem (100%) Successfully installed cocoapods-try-1.1.0 Fetching: molinillo-0.6.6.gem (100%) Successfully installed molinillo-0.6.6 Fetching: atomos-0.1.3.gem (100%) Successfully installed atomos-0.1.3 Fetching: CFPropertyList-3.0.0.gem (100%) Successfully installed CFPropertyList-3.0.0 Fetching: colored2-3.1.2.gem (100%) Successfully installed colored2-3.1.2 Fetching: nanaimo-0.2.6.gem (100%) Successfully installed nanaimo-0.2.6 Fetching: xcodeproj-1.6.0.gem (100%) Successfully installed xcodeproj-1.6.0 Fetching: escape-0.0.4.gem (100%) Successfully installed escape-0.0.4 Fetching: fourflusher-2.0.1.gem (100%) Successfully installed fourflusher-2.0.1 Fetching: gh_inspector-1.1.3.gem (100%) Successfully installed gh_inspector-1.1.3 Fetching: ruby-macho-1.2.0.gem (100%) Successfully installed ruby-macho-1.2.0 Fetching: cocoapods-1.5.3.gem (100%) Successfully installed cocoapods-1.5.3 Parsing documentation for concurrent-ruby-1.0.5 Installing ri documentation for concurrent-ruby-1.0.5 Parsing documentation for i18n-0.9.5 Installing ri documentation for i18n-0.9.5 Parsing documentation for thread_safe-0.3.6 Installing ri documentation for thread_safe-0.3.6 Parsing documentation for tzinfo-1.2.5 Installing ri documentation for tzinfo-1.2.5 Parsing documentation for activesupport-4.2.10 Installing ri documentation for activesupport-4.2.10 Parsing documentation for nap-1.1.0 Installing ri documentation for nap-1.1.0 Parsing documentation for fuzzy_match-2.0.4 Installing ri documentation for fuzzy_match-2.0.4 Parsing documentation for cocoapods-core-1.5.3 Installing ri documentation for cocoapods-core-1.5.3 Parsing documentation for claide-1.0.2 Installing ri documentation for claide-1.0.2 Parsing documentation for cocoapods-deintegrate-1.0.2 Installing ri documentation for cocoapods-deintegrate-1.0.2 Parsing documentation for cocoapods-downloader-1.2.1 Installing ri documentation for cocoapods-downloader-1.2.1 Parsing documentation for cocoapods-plugins-1.0.0 Installing ri documentation for cocoapods-plugins-1.0.0 Parsing documentation for cocoapods-search-1.0.0 Installing ri documentation for cocoapods-search-1.0.0 Parsing documentation for cocoapods-stats-1.0.0 Installing ri documentation for cocoapods-stats-1.0.0 Parsing documentation for netrc-0.11.0 Installing ri documentation for netrc-0.11.0 Parsing documentation for cocoapods-trunk-1.3.1 Installing ri documentation for cocoapods-trunk-1.3.1 Parsing documentation for cocoapods-try-1.1.0 Installing ri documentation for cocoapods-try-1.1.0 Parsing documentation for molinillo-0.6.6 Installing ri documentation for molinillo-0.6.6 Parsing documentation for atomos-0.1.3 Installing ri documentation for atomos-0.1.3 Parsing documentation for CFPropertyList-3.0.0 Installing ri documentation for CFPropertyList-3.0.0 Parsing documentation for colored2-3.1.2 Installing ri documentation for colored2-3.1.2 Parsing documentation for nanaimo-0.2.6 Installing ri documentation for nanaimo-0.2.6 Parsing documentation for xcodeproj-1.6.0 Installing ri documentation for xcodeproj-1.6.0 Parsing documentation for escape-0.0.4 Installing ri documentation for escape-0.0.4 Parsing documentation for fourflusher-2.0.1 Installing ri documentation for fourflusher-2.0.1 Parsing documentation for gh_inspector-1.1.3 Installing ri documentation for gh_inspector-1.1.3 Parsing documentation for ruby-macho-1.2.0 Installing ri documentation for ruby-macho-1.2.0 Parsing documentation for cocoapods-1.5.3 Installing ri documentation for cocoapods-1.5.3 Done installing documentation for concurrent-ruby, i18n, thread_safe, tzinfo, activesupport, nap, fuzzy_match, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, netrc, cocoapods-trunk, cocoapods-try, molinillo, atomos, CFPropertyList, colored2, nanaimo, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods after 20 seconds 28 gems installed
- brew update
Permission denied @ rb_file_s_symlink - (../../../Homebrew/Library/Taps/homebrew/homebrew-services/completions/zsh/_brew_services, /usr/local/share/zsh/site-functions/_brew_services) 这个资源没权限处理 但是brew 已经是最新版本,所以不处理这个问题 /Users/zsk/Downloads/web3swift-master/Example/web3swiftExample/Pods/SipHash/SipHash/Primitive Types.swift:16:21: Cannot invoke initializer for type 'UnsafeRawBufferPointer' with an argument list of type '(rebasing: Slice<UnsafeRawBufferPointer>)'
- Swift的各种报错
1. 升级操作系统至最新 2. 升级Xcode到最新 3. 大部分问题已经解决了,按照工程要求重新编译即可
- 编译报错缺少.git文件
fatal: Not a git repository (or any of the parent directories): .git Command /bin/sh failed with exit code 128 工程是直接下载的zip, 然后解压出来的。 直接clone 一个工程下来。然后运行,解决问题
- 直接提示缺少某些资源的
warning: Skipping Icon versioning, you need to install ImageMagick and ghostscript (fonts) first, you can use brew to simplify process: brew install imagemagick brew install ghostscript Command /bin/sh failed with exit code 255 按照提示安装软件即可 例如:终端下 brew install imagemagick brew install ghostscript