Hello i’m new to bitcoin all i need to know is how you can generate handle utilizing mnemonic seed?

let testnet =Bitcoin.networks.testnet;
let keypair =Bitcoin.ECPair.makeRandom({community:testnet});
let handle=keypair.getAddress();
let privateKey=keypair.toWIF();
res.json("Public Tackle  "+ handle+ "  "+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');

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

const mnemonic = `whole style cranium already make investments view turtle surge razor key subsequent 
buffalo venue canoe sheriff winner wash ten topic hamster scrap unit protect 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 test the code is working utilizing this web site. You may additionally need to learn up a little bit about BIP32, BIP39 and BIP44. An government abstract beneath:

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

  • BIP39 defines a set of normal phrases used to imitate a key and how you can rework them again to the unique “seed” (the important thing from BIP32).

  • BIP44 specifies how you must compute the kid keys from the dad or mum 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.

This is the whole code to run every thing 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 shall be derived from no matter seed phrase is entered by the consumer
# 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 go 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: 


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



Hold these secure