1 生成ETH钱包
ethAddrss = MnemonicToKey.ethAddress(seedCode, “”, ethKeyath);
keytext = EncodeUtil.encrypt3DES(seedCode,password);
} catch (Exception e) {
e.printStackTrace();
}
MnemonicToKey.java
public static String ethAddress(String seedCode,String passphrase,String strKeypath) throws Exception {
DeterministicKey key = getDeterministicKey(seedCode,passphrase,strKeypath);
BigInteger privKey = key.getPrivKey();
// Web3j
Credentials credentials = Credentials.create(privKey.toString(16));
}
2 生成BTC钱包
bip44Address = MnemonicToKey.btc44Address(seedCode, “”, params, btcKeyath);
bip49Address = MnemonicToKey.btc49Address(seedCode, “”, params, btcKeyath);
keytext = EncodeUtil.encrypt3DES(seedCode, password);
} catch (Exception e) {
e.printStackTrace();
}
MnemonicToKey.java
public static String btc49Address(String seedCode,String passphrase,NetworkParameters params,String
strKeypath) throws Exception
{
DeterministicKey key = getDeterministicKey(seedCode,passphrase,strKeypath); BigInteger privKey = key.getPrivKey(); ECKey ecKey = ECKey.fromPrivate(privKey); return getAddressAsString(ecKey,params);}public static String btc44Address(String seedCode,String passphrase,NetworkParameters params,String strKeypath) throws Exception { DeterministicKey key = getDeterministicKey(seedCode,passphrase,strKeypath); BigInteger privKey = key.getPrivKey(); ECKey ecKey = ECKey.fromPrivate(privKey); Address address = ecKey.toAddress(params); return address.toBase58();}