GithubHelp home page GithubHelp logo

create-xpub's Introduction

create-xpub

Create a BIP32 extended public key

Build Status Coverage Status npm tippin.me

Creates a Base58 encoded extended public key (xpub) for use in a BIP32 hierarchical deterministic wallet.

Install

npm install create-xpub

Usage

You should familiarise yourself with BIP32 to understand what these arguments represent.

const createXpub = require('create-xpub');

const xpub = createXpub({
  depth: 3,
  childNumber: 2147483648,
  chainCode: '84cf7d9029cdd9fcadbb3717fd92ec0db7d7d9787c57c13c08fc887c389b566b',
  publicKey: '048bcdcf59f046b13f1eb35b608d1211265fde8cc44fc7a5a7f7107c5cf238095328a0e0d7be17c7d3e48490e8c6433af6d2c3dacc687f3fecaa98a3d05f17de97'
});
// => 'xpub6CgMcBZk66ayM9ESh7QtBmRKJbsa6rBeBH2k4aQZQJGossryP5r2N2nQS4hBMG1wb8igPoH53bxtzTBaeMqJkbu8bxsih1gGkoAn23Nr8VP'

Pass in version bytes for a different network:

const createXpub = require('create-xpub');

const tpub = createXpub({
  networkVersion: createXpub.testnet,
  depth: 3,
  childNumber: 2147483648,
  chainCode: '84cf7d9029cdd9fcadbb3717fd92ec0db7d7d9787c57c13c08fc887c389b566b',
  publicKey: '048bcdcf59f046b13f1eb35b608d1211265fde8cc44fc7a5a7f7107c5cf238095328a0e0d7be17c7d3e48490e8c6433af6d2c3dacc687f3fecaa98a3d05f17de97'
});
// => 'tpubDD3z8RPRoNYRcwRJ9JPyPgkgdiyE6Eghiud3R8ThkD2hdAXgTJh7WUTEg6mxskyBP3Fb1NnwahnwgdgC3DgYe3MRfZd2NYLWLkmBn7UWZXk'

Tip

If you're working with ledgerjs you can pass the output of getWalletPublicKey() almost directly in.

API

createXpub(options)

Returns a Base58 encoded extended public key.

options

Type: Object

An object containing the following properties of the derivation path.

Consult BIP32 for an in-depth explanation on these properties.

networkVersion

Type: number
Default: 0x0488B21E (mainnet)

Network version bytes.

depth

Type: number
Default: undefined

The depth of the derived key.

childNumber

Type: number
Default: undefined

The child number.

chainCode

Type: string
Default: undefined

The chain code.

publicKey

Type: string
Default: undefined

The public key in compressed or uncompressed form.

createXpub.mainnet

Mainnet (xpub) version bytes: 0x0488B21E

createXpub.testnet

Testnet (tpub) version bytes: 0x043587CF

License

MIT © Luke Childs

create-xpub's People

Contributors

lukechilds avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.