0.4.2 • Published 9 years ago

bip32-path v0.4.2

Weekly downloads
6,251
License
MIT
Repository
github
Last release
9 years ago

BIP32 Path

Bitcoin BIP32 ("HD Wallet") path helpers.

There are multiple path representations being used by different implementations. These includes:

  • m/44'/0'/0'/0/0 where the apostrophe means hardened key
  • m/44h/0h/0h/0/0 where the letter h means hardened key
  • and a binary representation predominantly used by Trezor & compatible wallets and some software tools, such as bitcoinjs-lib

Some useful links:

API

  • BIPPath.fromString(path, reqRoot) - creates an instance from a path written as text. Set reqRoot to true if the m/ prefix is mandatory.
  • BIPPath.fromPathArray(path) - creates an instance from a binary path array
  • new BIPPath(path) - alias for BIPPath.fromPathArray(path)
  • <bippath>.toString(noRoot, oldStyle) - returns a text encoded path. Set to noRoot to true to omit the m/ prefix. Set oldStyle true to use h instead of ' for marking hardened nodes.
  • <bippath>.toPathArray() - returns a binary path array
  • BIPPath.validateString(path, reqRoot) - returns true if the input is a valid path string
  • BIPPath.validatePathArray(path) - returns true if the input is a valid binary path array

Binary path arrays contain each node as a separate number, where hardened nodes are marked by setting the 32th bit: m/44'/1/1/0 corresponds to [ 0x8000002c, 1, 1, 0 ]

Examples

var bippath = require('bip32-path')

bippath.fromPathArray([0x8000002c, 1, 1, 0]).toString() // m/44'/1/1/0

bippath.fromString("m/44'/0'/0'").toString(false, true) // m/44h/0h/0h

bippath.fromString("m/44h/0h/0'").toString(true) // 44'/0'/0'

bippath.fromString("m/44'/0'/0'").toPathArray() // [ 0x8000002c, 0x80000000, 0x80000000 ]
kapilteztest2ledgerjs-hw-app-ergo@everything-registry/sub-chunk-1237hw-app-bananosymbol-ledger-typescriptweb-hd-sdk@camino/avalanche-wallet-sdkillumrecusandaeimaginea-aepp-sdkhw-app-ckbhw-app-ckb-testhw-app-cschw-app-dfihw-app-iotahw-app-nanhw-app-nanohw-app-nano-xrohw-app-unohw-app-xtzledger-ergo-jsledger-bitcoinledger-bitcoin-babylonledger-xtzledgerhw-app-bitcoin-new-js@vite/ledgerjs-hw-app-vite@vutr/purser-trezor@zalastax/nolb-bip@zee-ava/axia-wallet-sdk@zee-ava/hd-wallet-axia@teleportdao/ledgerhw-bitcoin-client-js@teleportdao/ledgerhw-ledger-bitcoin-client-js@terradharitri/hw-app-drtardor@hardfork/trezor-wallet-provider@ecanna/ecanna-wallet-sdk@aeternity/hd-wallet@codewarriorr/hw-app-btcv@codewarriorr/live-common@colony/purser-trezor@coinflect/hw-app-coinflect@coti-io/ledger-sdksolutavitae@backpacker69/hw-app-btc@blooo/hw-app-acre@blooo/hw-app-klaytn@blooo/hw-app-velas@blooo/hw-app-vtb@bloks/ledger@bhagyaraj_1208117/hw-app@casinocoin/ledger@c4tplatform/avalanche-wallet-sdk@c4tplatform/camino-wallet-sdkzabo-connect-utilszswjs-ledger-signature-provider@infinitebrahmanuniverse/nolb-bip@ledgerhq/hw-app-btc@ledgerhq/hw-app-cosmos@ledgerhq/hw-app-elrond@ledgerhq/hw-app-algorand@ledgerhq/hw-app-xrp@ledgerhq/hw-app-solana@ledgerhq/hw-app-str@ledgerhq/hw-app-helium@ledgerhq/hw-app-icon@ledgerhq/hw-app-polkadot@ledgerhq/live-common@loon3/hw-app-btc@levino/trezor-wallet-provider@linkdesu/hw-app-ckb@moonstake/conseiljs@savannah-labs/savannah-wallet-sdk@pontem/hw-app-aptos@pocketbitcoin/hw-app-btc@pollum-io/sysweb3-keyringnumbatxperferendisquibusdamrerumcupiditateconseiljs-ledgersignerdhealth-walletdpos-ledger-apiecanna-wallet-sdkeosjs-ledger-signature-providerezchain-wallet-sdkflare-wallet-sdk@avalabs/avalanche-wallet-sdk@avalabs/core-wallets-sdk@axia-systems/hd-wallet@axia-systems/wallet-sdk@axiaglobal/wallet-sdk@axiaglobal/hd-wallet@deltalabs/eosjs-ledger-signature-provider@luxfi/hw-app-lux@luxfi/wallet-sdk@magickbase/hw-app-ckb@factoid.org/hw-app-fct@jafri/ledger-bitcoin@fluent-wallet/hw-app-conflux@area/purser-trezor@dcomm-tech/wallet-sdk@daonomic/trezor-wallet-provider
0.4.2

9 years ago