我使用web3j来创建我的以太wallet.the代码,就像向下一样
import org.web3j.crypto.Bip39Wallet;
import org.web3j.crypto.Credentials;
import org.web3j.crypto.ECKeyPair;
import org.web3j.crypto.WalletUtils;
wallet = WalletUtils.generateBip39Wallet(password, new File(keystorePath));
// keystore's file name
String keystoreFileName = wallet.getFilename();
// my mnemonic
String mnemonic = wallet.getMnemonic();我可以用这个代码得到我的地址
Credentials credentials = WalletUtils.loadBip39Credentials(password, mnemonic);
String address = credentials.getAddress();我可以这样导入我的钱包:
Credentials credentials = WalletUtils.loadBip39Credentials(password, mnemonic);但在这种情况下,我需要密码和助记符,我如何在没有密码的情况下通过助记符导入或恢复我的钱包,因为一些钱包应用程序就像metamask或imtoken,它们不需要我创建钱包的旧密码,并且可以重置新密码。
换句话说,恢复或导入钱包只需要助记符,我是如何通过web3j做到这一点的
是不是每个人都可以通过web3j.thank u来告诉我怎么做。
发布于 2018-08-31 10:34:24
您可以简单地传递一个空字符串作为密码:
// generate
wallet = WalletUtils.generateBip39Wallet("", tempDir);
// restore using WalletUtils
Credentials credentials = WalletUtils.loadBip39Credentials("", wallet.getMnemonic());
// or using constructor (and empty dummy file)
File tempFile = Files.createTempFile(null, null).toFile();
wallet = new Bip39Wallet(tempFile.getName(), wallet.getMnemonic());https://stackoverflow.com/questions/52107608
复制相似问题