前面说了一些关于区块链生成钱包地址的方法说了一下, 那么该如何用代码去生成钱包地址呢? 之前我在做钱包的时候, 搜了很多资料, 很少有写如何去生成钱包地址, 当然英文资料也不多. 最后还是去gayhub里面看了开源钱包, 才搞清楚了一些方法. 我们这里使用的是bitcoinj来生成. 一般都是分几个步骤: 生成助记词, 根据助记词生成地址
When I was doing my wallet, there was a lot of information, very little writing about how to generate it, of course, in English. Finally, we went to gayhub to look at open-source wallets, and we used
首先我们这里使用的Android studio 3.0, 直接在app/build.gradle里面添加依赖 First we use Android station 3.0, add dependency directly to the app/build.gradle 先填坑, 生成助记词需要使用到MnemonicUtils这个类, 但是有坑, 加载助记词列表文件的方式在Android上面根本不行, 会导致Crash Fill the pits first, and the creation of assistive words would need to be used in the MnemonicUtils class, but there are pits, and the way the list files are loaded on Android is not working at all, which would lead to Crash. 懂的人都看出来了吧, 这是java的加载资源方式, 但是安卓需要做平台适配. 我们把en-mnemonic-word-list.txt这个文件放到assets之下, 然后用符合安卓的姿势加载. Good, 没问题了 We put the en-mnemonic-word-list.txt file under theasses, and then we put it in a position consistent with Andre. Good, it's fine. 生成助记词需要使用到MnemonicUtils这个类, 要生成助记词很简单, 需要如下代码生成助记词, 助记词的格式就是12个单词 Generating a word requires use in the MnemonicUtils class. To generate a word is simple, the following code is required to produce a word, which is in the form of 12 words. 先根据生成的助记词, 生成一些列的种, 运用了 BIP32确定性钱包算法(deterministic wallet algorithm) Generates a number of columns based on the derived assistive word, using the BIP32 deterministic wallet algorithm 下一篇文章我将介绍一下ETH的地址生成方式. 更多教程请访问爱去玩的个人专栏 In the next article, I will describe how ETH's address is generated. More lessons can be found at
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论