bitcoinjs / bip39

JavaScript implementation of Bitcoin BIP39: Mnemonic code for generating deterministic keys
ISC License
1.11k stars 447 forks source link

Why doesn't the address console #157

Closed 0completist closed 3 years ago

0completist commented 3 years ago
var _seed = bip39.generateMnemonic();
console.log("助记词:", _seed)
var _pass = "123456" // 这是用户自定义密码PIN

var seed = bip39.mnemonicToSeedSync(_seed, _pass)

var root = bip32.fromSeed(seed)

var child0 = root.derivePath("m/44'/0'/0'/0/0");
console.log("私钥", child0.privateKey.toString('hex'));
console.log("公钥", child0.publicKey.toString('hex'));

var seedHex = bip39.mnemonicToSeedHex(_seed, _pass)
var hroot = bitcoin.HDNode.fromSeedHex(seedHex)
var hchild0 = hroot.derivePath("m/44'/0'/0'/0/0");
console.log("地址:", hchild0.getAddress())

consle result: 助记词: cage april ostrich mobile apology another universe engine soldier tortoise stage attend 私钥 c3ff3ba7c5a0136a0b488f8dbba453b9c3658947fdd6cabd1f07d75da07d9de9 公钥 02670eb376a57083a48ca3266b4d8c67e2c989d39dcd20654572f13f1bb40e866c

The address was not printed

junderw commented 3 years ago

What version of bip39 / bip32 / bitcoinjs-lib are you using?