多链钱包就是多币种钱包吗?
多币种钱包:支持多种区块链数字资产的钱包。多种区块链数字资产可以是一条区块链主链及围绕该主链协议设置的代币,也可以是多种区块链主链上不同的数字资产,所以多链钱包也可以说是多币种钱包。
NetworkParameters params=TestNet3Params.get();
DeterministicSeed seed=new DeterministicSeed(new SecureRandom(),128,"password",Utils.currentTimeSeconds());
Wallet wallet=Wallet.fromSeed(params,seed);
DeterministicSeed的构造方法:
public DeterministicSeed(SecureRandom random,int bits,String passphrase,long creationTimeSeconds){
this(getEntropy(random,bits),checkNotNull(passphrase),creationTimeSeconds);
}
先来看看getEntropy函数
private static byte[]getEntropy(SecureRandom random,int bits){
checkArgument(bits<=MAX_SEED_ENTROPY_BITS,"requested entropy size too large");
byte[]seed=new byte[bits/8];
random.nextBytes(seed);
return seed;
}
可以看出通过getEntropy函数得到一个byte数组,然后作为参数传给构造方法2
public DeterministicSeed(byte[]entropy,String passphrase,long creationTimeSeconds){
//检查参数的正确性
checkArgument(entropy.length%4==0,"entropy size in bits not divisible by 32");
checkArgument(entropy.length*8>=DEFAULT_SEED_ENTROPY_BITS,"entropy size too small");
checkNotNull(passphrase);
try{
//生成助记词
this.mnemonicCode=MnemonicCode.INSTANCE.toMnemonic(entropy);
}catch(MnemonicException.MnemonicLengthException e){
//cannot happen
throw new RuntimeException(e);
}
//通过助记词生成种子,详情看“通过助记词生成种子”
this.seed=MnemonicCode.toSeed(mnemonicCode,passphrase);
this.encryptedMnemonicCode=null;
this.creationTimeSeconds=creationTimeSeconds;
}