npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dashincubator/base58check

v1.4.1

Published

Base58Check & WIF for PubKeyHash and PrivateKeys

Downloads

50

Readme

@dashincubator/base58check

Base58Check & WIF for Public Key Hash addresses and Private Keys

Usage

Can convert Public Key Hashes and Private Keys between Hex, Base58Check, and WIF.

CLI

npm install -g @dashincubator/base58check
# base58check <key> [version]

base58check XfMBLVNyzPxEELVUUsg7AJAHWKiV9do7Pj
# {
#   "version": "4c",
#   "pubKeyHash": "3320974335dc4888b501e965fe5ff3c4421c09c4"
# }

base58check 3320974335dc4888b501e965fe5ff3c4421c09c4 4c
# XfMBLVNyzPxEELVUUsg7AJAHWKiV9do7Pj

Node.js

npm install --save @dashincubator/base58check
let Base58Check = require("base58check").Base58Check;

let b58c = Base58Check.create();

// Public Key Hash
let pkh = `XfMBLVNyzPxEELVUUsg7AJAHWKiV9do7Pj`;
let parts = await b58c.verify(pkh);
/*
    {
      "version": "4c",
      "pubKeyHash": "3320974335dc4888b501e965fe5ff3c4421c09c4",
      "check": "9e5443ee"
    }
 */

// Private Key
let wif = "XE7KZ98bqtbomihJqkuRzi6DusLAXegQFBmnATDAUVSCxtcbigHb";
let parts = await b58c.verify(wif);
/*
    {
      "version": "cc",
      "privateKey": "543519e8a781d6986377df6ec18c76fceb270697f16f204408af72edc4fe70de",
      "compressed": true,
      "check": "24aeb2e6"
    }
 */

// Extended Public Key
let xpub = `xpub6EtdcAi4VMbZRDgSaA1WmrqB8asuswgz1toia3YULccxyJXYqdxwqFgeEexVxr8ytJPHZYTrhbYJjqaFumih45awabyaHwUmCvXbGf7sujG`;
let parts = await b58c.decode(xpub); // TODO checksum not checked
/*
    {
      "version": "0488b21e",
      "pubKeyHash": "04832a89a60000000091dbdc89637be3d19851998ba2fac7f85b03b28a65de5c284899e7608f25ee4f0238eddc6cf0b2e8a1bae318affe3661cc071d13c9ad95e77a331a91b58a1b3a7f",
      "check": "c1edc9ce"
    }
 */

// Extended Public Key
let xprv = `xprvA1WUDWFxdE5UGW1XNTnkZnd3K6bdidZBTtzvtEQziBpS3N8tajC4QKyRLmas7DK4HXK76wSXgMV1uV6RbKyM5f4uu1VmguEhAqvzQwr2mrC`;
let parts = await b58c.decode(xprv); // TODO checksum not checked
/*
    {
      "version": "0488ade4",
      "xprv": "04832a89a60000000091dbdc89637be3d19851998ba2fac7f85b03b28a65de5c284899e7608f25ee4f0079842279eca681d40ccc86c6c618f783f4d4339c2431e4ed29e57c7b73be0c69",
      "check": "e986668d"
    }
 */

Options

You can enforce your instance of Base58Check to verify and generate a particular version of coin, or to use a different Base58 dictionary.

Base58Check.create({
  pubKeyHashVersion: `4c`, // Dash (`00` for Bitcoin)
  privateKeyVersion: `cc`, // Dash (`80` for Bitcoin)
  dictionary: `123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`,
});

Base58Check Summary

  • 1 byte Version
  • 16 bytes "Compressed" Public Key Hash
  • 4 bytes Checksum
XxJ7EZT2VyJ821LeAzoT9aDDSuempCikd3

4c ed060e9316ea54396038b7ef703c0616025ddc55 03368b2e

{
  version: '4c',
  pubKeyHash: 'ed060e9316ea54396038b7ef703c0616025ddc55',
  check: '03368b2e'
}

WIF (Wallet Import Format)

  • 1 byte Version
  • 32 bytes Private Key
  • 1 byte (Optional) Has Compressed Public Key
  • 4 bytes Checksum
XJxvA5cC4zi3DYeMVUgHunF3nt5UajjXAvJaHnZRMunPNjyKmGfB

cc e51245e19bfc59800445c91d6623a8225f5e521d339fca2a5bbe71fb973dac0f (01) 90d16dc2

{
  version: 'cc',
  privateKey: 'e51245e19bfc59800445c91d6623a8225f5e521d339fca2a5bbe71fb973dac0f',
  compressed: true,
  check: '90d16dc2'
}