I have generated address see the below code..
'use strict'
var bip39 = require('bip39');
var bip32 = require('bip32');
var bitcoin = require('bitcoinjs-lib');
function getAddress (node, network) {
return bitcoin.payments.p2pkh({ pubkey: node.publicKey, network }).address
}
var mnemonic = bip39.generateMnemonic();
if (bip39.validateMnemonic(mnemonic)) {
console.log('\nThe mnemonic is \n' + mnemonic);
var seed = bip39.mnemonicToSeed(mnemonic);
var root = bip32.fromSeed(seed);
var dp = root.derivePath("m/140'/0'/0'/0/5");
console.log(dp.privateKey); // I used dp.privateKey but this not returning privatekey
console.log('\nThe Address is \n' + getAddress(dp));
} else {
}
Output:
$ node index.js
The mnemonic is
assume victory kiwi swarm furnace firm thumb exact dizzy crucial neglect certain
The Address is
1FYtPnUZZ2ZJL2fZ6XehGtkHfujUHkqK3T
Help me to get privatekey for this address 1FYtPnUZZ2ZJL2fZ6XehGtkHfujUHkqK3T
tell me what should I do for getting privatekey for the above address I have generated
I used dp.privateKey but this not returning privatekey
It works for me. I just copy pasted your code and it gives me the private key.
What version?
What environment?
By the way, your private key for 1FYtPnUZZ2ZJL2fZ6XehGtkHfujUHkqK3T is below.
Buffer.from('4dc8579ae9cb65a8afe146325007caec44a39997f248f9c9579d90937e783737', 'hex')
yeah thanks its working