欢迎光临散文网 会员登陆 & 注册

多链钱包系统开发(方案及逻辑)丨多链钱包开发案例及源码

2023-02-27 16:14 作者:bili_28856027824  | 我要投稿

Is multi-chain wallet a multi-currency wallet? Multi-currency wallet:a wallet that supports multiple blockchain digital assets.Multiple blockchain digital assets can be a blockchain main chain and tokens set around the main chain protocol,or different digital assets on multiple blockchain main chains,so multi-chain wallets can also be said to be multi-currency wallets. NetworkParameters params=TestNet3Params.get(); DeterministicSeed seed=new DeterministicSeed(new SecureRandom(),128,"password",Utils.currentTimeSeconds()); Wallet wallet=Wallet.fromSeed(params,seed); DeterministicSeed的构造方法:开发需求I35模式7O98源码o7I8 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];案例分析及开发:mrsfu123 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; }

多链钱包系统开发(方案及逻辑)丨多链钱包开发案例及源码的评论 (共 条)

分享到微博请遵守国家法律