Skip to content

Instantly share code, notes, and snippets.

@fkfk
Last active June 7, 2019 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fkfk/9a9041462c007994f12e20809c5f077c to your computer and use it in GitHub Desktop.
Save fkfk/9a9041462c007994f12e20809c5f077c to your computer and use it in GitHub Desktop.
const {
bip32,
payments
} = require('bitcoinjs-lib')
const mnemonic = require('./external/mnemonic.js') // https://github.com/ggozad/mnemonic.js
const buffer = require("safe-buffer")
const words = "like like like like like like like like like like like like" // your mnemonic
const network = {
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 50,
scriptHash: 55,
wif: 178
}
const seed = mnemonic.fromWords(words.split(" "))
const seedBuf = Buffer.from(seed.toHex(), 'hex')
const node = bip32.fromSeed(seedBuf, network)
console.log(payments.p2pkh({
pubkey: node.deriveHardened(0).derive(0).derive(0).publicKey,
network: node.network
}).address)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment