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

@swan-bitcoin/xpub-cli

v0.1.3

Published

Command-line wrapper around @swan-bitcoin/xpub-lib

Downloads

30

Readme

Swan's Address Derivation CLI

A small command-line tool to derive and validate bitcoin addresses from extended public keys. Supports xpub, ypub, and zpub extended public keys and their testnet equivalents. Support for legacy, SegWit, and native SegWit (bech32) addresses. Uses @swan-bitcoin/xpub-lib under the hood.

Basic Example

$ xpub derive xpub6CQtk4bkfG1d4UTWNBwmWGP95gjvTvEKZhm74CxLfbd4XqXY5wkyaUvLoWyy6Le24VxCqg2nASLu2xhNaDh5FhFDf8ndUUgbm8q1VDqCipy

bc1qcksx27qlksr2cy3pnwdw0mnm94c5cm0vz3jh6e

Address derivation defaults to native SegWit (bech32) addresses, i.e. the derivation purpose is set to 84 (p2wpkh) by default. Set the --purpose accordingly if you want to derive legacy or wrapped SegWit addresses.

The sub-commands xpub derive and xpub validate are explained in more detail below.

derive: Address Derivation

The xpub derive command requires an extended public key (extPubKey) as an input.

Usage: xpub derive [options] [extPubKey]

Use --testnet to derive from testnet extended public keys (tpub, upub, vpub) and generate testnet addresses.

$ xpub derive -t tpubDCZv1xNTnmwmXe3BBMyXekiVreY853jFeC8k9AaEAqCDYi1ZTSTLH3uQonwCTRk9jL1SFu1cLNbDY76YtcDR8n2inSMwBEAdZs37EpYS9px

tb1qynjqnqvuwqys8l0jkuzmjuntj6ar4cyaeqwwk3

Options

Run xpub derive --help to see all options.

  • -p, --purpose <purpose> - derivation purpose which dictates the address type. Can be 'p2pkh', 'p2sh', or 'p2wpkh' (default: "p2wpkh")
  • -n, --addressCount <addressCount> - number of addresses to generate (default: 1)
  • -c, --accountNumber <accountNumber> - the account number as defined in BIP 44 (default: 0)
  • -i, --keyIndex <keyIndex> - index of the address to generate (ignored if addressCount is set) (default: 0)
  • -t, --testnet - use testnet

Advanced Example

The following example derives the first three SegWit (p2sh) addresses of account 5 for the extended public key ypub6XF...4wa. Note that account numbers start at 0, so the account with number 5 will be shown as "Account Nr. 6" (or similar) in most wallets.

$ xpub derive ypub6XFA3jGfowZ6umedCYjPiMUeFetNQYDpUpHKqbrE3bzwawLmLbvYCYaUpiwZ6FHwU951b9dLd6hSvFJwHv763vvpXUV44PW62rtesm5g4wa -n3 -c5 --purpose p2sh

[
  {
    path: "m/49'/0'/5'/0/0",
    address: '3PEpUeFZUWJPrbdKGzaNeEpekSPpSbVSzL'
  },
  {
    path: "m/49'/0'/5'/0/1",
    address: '3AedcVmzeoUF4tHkzDHM6wp7WLoo668KwT'
  },
  {
    path: "m/49'/0'/5'/0/2",
    address: '3BpPnS79WUzRQMG2DCNUKHgSKCaNoAMPCu'
  }
]

validate: Validation

The xpub validate command takes an encoded bitcoin address or an extended public key as an input.

Usage: xpub validate [options] [encoded]
$ xpub validate xpub6CCHViYn5VzKSmKD9cK9LBDPz9wBLV7owXJcNDioETNvhqhVtj3ABnVUERN9aV1RGTX9YpyPHnC4Ekzjnr7TZthsJRBiXA4QCeXNHEwxLab

validate will terminate without error if the extended public key or address is valid. If invalid, validate will fail with exit code 1.

Use --verbose to generate output and --testnet to validate testnet keys and addresses.

$ xpub validate --testnet tb1qynjqnqvuwqys8l0jkuzmjuntj6ar4cyaeqwwk3 --verbose

valid tb1qynjqnqvuwqys8l0jkuzmjuntj6ar4cyaeqwwk3

The validate command doesn't discriminate between extended public keys and addresses. You need to pass --check-address or --check-ext to do a validation that is exclusive.

$ xpub validate --check-ext --testnet tb1qynjqnqvuwqys8l0jkuzmjuntj6ar4cyaeqwwk3 --verbose

invalid extPubKey tb1qynjqnqvuwqys8l0jkuzmjuntj6ar4cyaeqwwk3

Options

Run xpub validate --help to see all options.

  • -a, --check-address - check bitcoin address for validity
  • -x, --check-ext - check extended public key for validity
  • -t, --testnet - use testnet
  • -v, --verbose - verbose output

License: MIT