Hello i’m new to bitcoin all i wish to know is the best way to generate tackle utilizing mnemonic seed?

let testnet =Bitcoin.networks.testnet;
let keypair =Bitcoin.ECPair.makeRandom({community:testnet});
let tackle=keypair.getAddress();
let privateKey=keypair.toWIF();
res.json("Public Tackle  "+ tackle+ "  "+privateKey)

Utilizing bitcoinjs-lib and bip39. You’ll be able to set up these with npm set up bitcoinjs-lib bip39 --save

const Bitcoin = require('bitcoinjs-lib');
const Bip39 = require('bip39');
const Bip32 = require('bip32');

operate getAddress (node, community) {
  return Bitcoin.funds.p2pkh({ pubkey: node.publicKey, community }).tackle

const mnemonic = `complete style cranium already make investments view turtle surge razor key subsequent 
buffalo venue canoe sheriff winner wash ten topic hamster scrap unit defend backyard`;

const seed = Bip39.mnemonicToSeed(mnemonic);

const root = Bip32.fromSeed(seed, Bitcoin.networks.bitcoin);

const child1 = root.derivePath("m/44'/0'/0'/0/0");
const child2 = root.deriveHardened(44).deriveHardened(0).deriveHardened(0).derive(0).derive(0);

console.log(getAddress(child1)); //1ENQm8nEP7sd6dqXbAMYZ4AuqcP8Y7AtR
console.log(getAddress(child2)); //1Hb6Z1uZ1RuZ6GXTvedQ2ETYKYsMc5qynN

You’ll be able to verify the code is working utilizing this web site. You may additionally wish to learn up a bit about BIP32, BIP39 and BIP44. An govt abstract under:

  • The BIP32 describes how one can generate new youngster keys programmatically from a single key and some different properties.

  • BIP39 defines a set of ordinary phrases used to imitate a key and the best way to remodel them again to the unique “seed” (the important thing from BIP32).

  • BIP44 specifies how it’s best to compute the kid keys from the guardian one. You’ll be able to see from my code that I used derivePath("m/44'/0'/0'/0/0"); in conformance of its specification.

Here is the whole code to run all the pieces out of your browser:

# name this {something}.sh
# when completed, run chmod +x *.sh
# then ./*.sh ought to execute the script 
# Create a ECDSA keypair to be used with crypto currencies
# The important thing can be derived from no matter seed phrase is entered by the person
# Copyright (c) 2019 B Tasker

learn -p "Enter a seed sentence: " seedphrase

# Derive a personal key
privkey=$(echo "$seedphrase" | openssl sha256 | reduce -d  -f2)

# Get a correct copy of the non-public key
privkeyfull=$(openssl ec -inform DER -in <(cat <(echo -n "302e0201010420") <(echo -n "$privkey") <(echo -n "a00706052b8104000a") | xxd -r -p) 2>/dev/null)

# Now begin creating the pub key 
longpub=$(openssl ec -inform DER -text -noout -in <(cat <(echo -n "302e0201010420") <(echo -n "$privkey") <(echo -n "a00706052b8104000a") | xxd -r -p) 2>/dev/null  | tail -6 | head -5 | sed 's/[ :]//g' | tr -d 'n' && echo)

# Create the compressed model
compub=$(echo -n "$longpub" | reduce -c1-66 | sed 's/^04/02/')

# Now RipeMD it:
hash256=$(echo "$compub" | xxd -r -p | openssl sha256 | reduce -d  -f2)
ripemd=$(echo "$hash256" | xxd -r -p | openssl ripemd160 | reduce -d  -f2)

# Now RipeMD the uncompressed :
hash256=$(echo "$longpub" | xxd -r -p | openssl sha256 | reduce -d  -f2)
ripemdunc=$(echo "$hash256" | xxd -r -p | openssl ripemd160 | reduce -d  -f2)

# And a model we are able to cross into OpenSSL if we have to
pubkeyfull=$(openssl ec -inform DER -in <(cat <(echo -n "302e0201010420") <(echo -n "e359ae12b3c49fa0d59d0947a97acc9d8595017205909a883501ae09d4ea1888") <(echo -n "a00706052b8104000a") | xxd -r -p) -pubout 2>/dev/null)

cat << EOM
Seed Phrase: 


Personal: $privkey
Lengthy public: $longpub
Compressed Public: $compub
RipeMD (Compressed) Public: $ripemd
RipeMD (Uncompressed) Public: $ripemdunc



Hold these protected