DEV Community

ishwar
ishwar

Posted on

4 1

Create Bitcoin address | bitcoin HD wallet

/*
BIP39: Mnemonic code for generating deterministic keys , BIP39 - used to manage your recovery seed and recovery words. Abstract. This BIP describes the implementation of a mnemonic code or mnemonic sentence – a group of easy to remember words – for the generation of deterministic wallets. It consists of two parts: generating the mnemonic, and converting it into a binary seed
*/
let bip39 = require("bip39");

/*
A lightweight wallet implementation. At the moment it supports key creation and conversion between various formats.
To use BIP32 HD wallets, first include the hdkey submodule,
For the seed i suggest to use bip39.
*/
let hdkey = require('ethereumjs-wallet');

/*
bitcoinjs is a proven library and ecosystem for Bitcoin development using javascript.
*/
let bitcoin = require('bitcoinjs-lib');

let wallet_hdpath = "m/44'/0'/0'/0/0";
hdwallet =  bitcoin.HDNode.fromSeedBuffer(bip39.mnemonicToSeed(seed));
let wallet = hdwallet.derivePath(wallet_hdpath + index)
Enter fullscreen mode Exit fullscreen mode

Now from wallet you can get privatekey and address both

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay