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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@asylia/atlas

v0.0.2

Published

Bitcoin derivation standards library - TypeScript utilities for working with BIP standards, extended public keys, script types, and network configurations

Readme

@asylia/atlas

Bitcoin Derivation Standards Library - TypeScript utilities for working with BIP standards, extended public keys, script types, and network configurations

npm version License: MIT

🚀 Features

  • Type-Safe - Full TypeScript support with comprehensive type definitions (84 total exports)
  • Zero Dependencies - Lightweight and self-contained
  • Tree-Shakeable - Optimized for modern bundlers
  • Well-Documented - Extensive JSDoc comments and examples
  • Standards Compliant - Implements Bitcoin BIP standards (32, 44, 45, 48, 49, 84, 86) plus Electrum Legacy
  • Complete API - 6 modules with enums, types, maps, constants, and utility functions
    • Extended Public Key Prefixes (15 exports)
    • Network Types (9 exports)
    • Script Types (7 exports)
    • BIP Derivation Purposes (7 exports)
    • Derivation Path Variants (8 exports)
    • Standard Derivation Paths (38 exports)

📦 Installation

# npm
npm install @asylia/atlas

# pnpm
pnpm add @asylia/atlas

# yarn
yarn add @asylia/atlas

🔧 Usage

Complete Import Example

All available exports from the package (84 total exports):

import {
  // ============================================================================
  // Extended Public Key Prefixes (15 exports)
  // ============================================================================
  ExtendedPubKeyPrefix, // Enum
  type ExtendedPubKeyPrefixValue, // Type
  type ExtendedPubKeyDisplayLabel, // Type
  type ExtendedPubKeyNetworkClass, // Type
  type ExtendedPubKeyScriptType, // Type
  type Bip32VersionBytes, // Type
  ExtendedPubKeyDisplayMap, // Map
  ExtendedPubKeyNetworkMap, // Map
  ExtendedPubKeyScriptTypeMap, // Map
  ExtendedPubKeyBip32VersionMap, // Map
  isMainnetPrefix, // Function
  isTestnetPrefix, // Function
  getPrefixFromExtendedPublicKey, // Function
  guessScriptTypeFromPrefix, // Function
  getBip32VersionBytes, // Function

  // ============================================================================
  // Network Types (9 exports)
  // ============================================================================
  NetworkType, // Enum
  type NetworkTypeValue, // Type
  type NetworkTypeKey, // Type
  NetworkMap, // Map
  NetworkReverseMap, // Map
  networkKeyToValue, // Function
  networkValueToKey, // Function
  isMainnet, // Function
  isTestnetFamily, // Function

  // ============================================================================
  // Script Types (7 exports)
  // ============================================================================
  ScriptType, // Enum
  type ScriptTypeValue, // Type
  type ScriptTypeUppercaseKey, // Type
  ScriptTypeMap, // Map
  ScriptTypeReverseMap, // Map
  scriptTypeToValue, // Function
  scriptTypeFromValue, // Function

  // ============================================================================
  // BIP Derivation Purposes (7 exports)
  // ============================================================================
  DERIVATION_PURPOSE_PREFIX, // Constant
  DERIVATION_PURPOSE_LIST, // Constant
  ELECTRUM_LEGACY_PURPOSE, // Constant
  type DerivationPurposeNumber, // Type
  type DerivationPurposeLabel, // Type
  DerivationPurposeString, // Map
  DerivationPurposeNumberMap, // Map

  // ============================================================================
  // Derivation Path Variants (8 exports)
  // ============================================================================
  DERIVATION_VARIANTS, // Constant
  type DerivationVariant, // Type
  type DerivationPathIDMainnetValue, // Type
  type DerivationPathIDTestnetValue, // Type
  type DerivationPathIDRegtestValue, // Type
  DerivationPathIDMainnet, // Map
  DerivationPathIDTestnet, // Map
  DerivationPathIDRegtest, // Map

  // ============================================================================
  // Standard Derivation Paths (38 exports)
  // ============================================================================
  AccountIndex, // Enum
  ChangeIndex, // Enum
  AddressIndex, // Enum
  COIN_TYPE_MAINNET, // Constant
  COIN_TYPE_TESTNET, // Constant
  type CoinType, // Type
  type DerivationPathObject, // Type
  type DerivationPathString, // Type
  type StandardDerivationPath, // Type
  type StandardPathsBip44, // Type
  type StandardPathsBip49, // Type
  type StandardPathsBip84, // Type
  type StandardPathsBip86, // Type
  type LegacyPathsType, // Type
  type MultisigPathsType, // Type
  type HistoricalPathsType, // Type
  type PathsByNetworkMainnet, // Type
  type PathsByNetworkTestnet, // Type
  type PathsByNetworkRegtest, // Type
  STANDARD_PATHS_BIP44, // Map
  STANDARD_PATHS_BIP49, // Map
  STANDARD_PATHS_BIP84, // Map
  STANDARD_PATHS_BIP86, // Map
  LEGACY_PATHS, // Map
  MULTISIG_PATHS, // Map
  HISTORICAL_PATHS, // Map
  PATHS_BY_NETWORK_MAINNET, // Map
  PATHS_BY_NETWORK_TESTNET, // Map
  PATHS_BY_NETWORK_REGTEST, // Map
  buildDerivationPath, // Function
  parseDerivationPath, // Function
  getStandardPath, // Function
  getCoinTypeForNetwork, // Function
  getPathsForNetwork, // Function
  getCommonPathsForNetwork, // Function
  getLegacyPathsForNetwork, // Function
  getMultisigPathsForNetwork, // Function
  getAllPathsByNetwork, // Function
} from '@asylia/atlas';

Extended Public Key Prefixes

Work with xpub, ypub, zpub, and other extended public key prefixes:

import {
  // Enum
  ExtendedPubKeyPrefix,

  // Types
  type ExtendedPubKeyPrefixValue,
  type ExtendedPubKeyDisplayLabel,
  type ExtendedPubKeyNetworkClass,
  type ExtendedPubKeyScriptType,
  type Bip32VersionBytes,

  // Maps
  ExtendedPubKeyDisplayMap,
  ExtendedPubKeyNetworkMap,
  ExtendedPubKeyScriptTypeMap,
  ExtendedPubKeyBip32VersionMap,

  // Functions
  isMainnetPrefix,
  isTestnetPrefix,
  guessScriptTypeFromPrefix,
  getBip32VersionBytes,
} from '@asylia/atlas';

// Use enum values
const xpub = ExtendedPubKeyPrefix.XPUB; // 'xpub'
const zpub = ExtendedPubKeyPrefix.ZPUB; // 'zpub'
const trpub = ExtendedPubKeyPrefix.TRPUB; // 'trpub'

// Extract prefix from extended public key string
const xpubString = 'xpub6CzbQ5BLF2mngsMXijEf...';
const detectedPrefix = getPrefixFromExtendedPublicKey(xpubString);
console.log(detectedPrefix); // 'xpub'

// Check if a prefix is mainnet/testnet
const isMainnet = isMainnetPrefix('xpub'); // true
const isTestnet = isTestnetPrefix('tpub'); // true

// Get script type from prefix
const scriptType = guessScriptTypeFromPrefix('zpub'); // 'p2wpkh' (Native SegWit)

// Get network from prefix
const network = ExtendedPubKeyNetworkMap[ExtendedPubKeyPrefix.YPUB]; // 'MAINNET'

// Get display label
const label = ExtendedPubKeyDisplayMap[ExtendedPubKeyPrefix.ZPUB]; // 'Zpub'

// Get BIP32 version bytes for serialization
const zpubVersions = ExtendedPubKeyBip32VersionMap.zpub;
console.log(zpubVersions.public.toString(16)); // '4b24746'
console.log(zpubVersions.private.toString(16)); // '4b2430c'

// Or use the helper function
const versions = getBip32VersionBytes('zpub');
if (versions) {
  console.log('Public:', versions.public.toString(16));
  console.log('Private:', versions.private.toString(16));
}

BIP32 Version Bytes

Access BIP32 version bytes for extended key serialization:

import {
  ExtendedPubKeyBip32VersionMap,
  getBip32VersionBytes,
  type Bip32VersionBytes,
} from '@asylia/atlas';

// Get version bytes directly from the map
const xpubVersions = ExtendedPubKeyBip32VersionMap.xpub;
console.log(xpubVersions.public); // 0x0488b21e (76067358)
console.log(xpubVersions.private); // 0x0488ade4 (76066276)

// All mainnet version bytes
const mainnetVersions = {
  xpub: ExtendedPubKeyBip32VersionMap.xpub, // Legacy (BIP44)
  ypub: ExtendedPubKeyBip32VersionMap.ypub, // Nested SegWit (BIP49)
  zpub: ExtendedPubKeyBip32VersionMap.zpub, // Native SegWit (BIP84)
  trpub: ExtendedPubKeyBip32VersionMap.trpub, // Taproot (BIP86)
};

// All testnet version bytes
const testnetVersions = {
  tpub: ExtendedPubKeyBip32VersionMap.tpub, // Legacy (BIP44)
  upub: ExtendedPubKeyBip32VersionMap.upub, // Nested SegWit (BIP49)
  vpub: ExtendedPubKeyBip32VersionMap.vpub, // Native SegWit (BIP84)
  trpubt: ExtendedPubKeyBip32VersionMap.trpubt, // Taproot (BIP86)
};

// Use the helper function with error handling
function getVersionBytesForPrefix(prefix: string) {
  const versions = getBip32VersionBytes(prefix as any);
  if (versions) {
    return {
      publicHex: '0x' + versions.public.toString(16),
      privateHex: '0x' + versions.private.toString(16),
    };
  }
  return null;
}

const zpubHex = getVersionBytesForPrefix('zpub');
// { publicHex: '0x4b24746', privateHex: '0x4b2430c' }

// Format version bytes for use in extended key serialization
const formatVersionBytes = (versions: Bip32VersionBytes) => {
  const publicBytes = Buffer.allocUnsafe(4);
  const privateBytes = Buffer.allocUnsafe(4);
  publicBytes.writeUInt32BE(versions.public, 0);
  privateBytes.writeUInt32BE(versions.private, 0);
  return { publicBytes, privateBytes };
};

const zpubBytes = formatVersionBytes(ExtendedPubKeyBip32VersionMap.zpub);
// publicBytes: <Buffer 04 b2 47 46>
// privateBytes: <Buffer 04 b2 43 0c>

What are BIP32 Version Bytes?

Version bytes are 4-byte integers prepended to extended keys during serialization. They identify:

  • The network (mainnet vs testnet)
  • The derivation purpose (BIP44, BIP49, BIP84, BIP86)
  • The address type that will be generated (P2PKH, P2WPKH, etc.)

When an extended key is serialized to Base58Check format (xpub/xprv string), the version bytes are the first 4 bytes of the payload, which then get encoded into the final string. Different version bytes result in different prefixes (xpub, ypub, zpub, etc.).

Version Bytes Reference:

| Prefix | Network | Purpose | Public Version | Private Version | | --------- | ------- | ------------------- | -------------- | --------------- | | xpub/xprv | Mainnet | BIP44 Legacy | 0x0488b21e | 0x0488ade4 | | ypub/yprv | Mainnet | BIP49 Nested SegWit | 0x049d7cb2 | 0x049d7878 | | zpub/zprv | Mainnet | BIP84 Native SegWit | 0x04b24746 | 0x04b2430c | | trpub | Mainnet | BIP86 Taproot | 0x0488b21e | 0x0488ade4 | | tpub/tprv | Testnet | BIP44 Legacy | 0x043587cf | 0x04358394 | | upub/uprv | Testnet | BIP49 Nested SegWit | 0x044a5262 | 0x044a4e28 | | vpub/vprv | Testnet | BIP84 Native SegWit | 0x045f1cf6 | 0x045f18bc | | trpubt | Testnet | BIP86 Taproot | 0x043587cf | 0x04358394 |

Note: Taproot prefixes (trpub/trpubt) reuse the same version bytes as xpub/tpub because BIP86 wasn't originally part of the extended key prefix specification.

Network Types

Handle Bitcoin network types (mainnet, testnet, regtest):

import {
  // Enum
  NetworkType,

  // Types
  type NetworkTypeValue,
  type NetworkTypeKey,

  // Maps
  NetworkMap,
  NetworkReverseMap,

  // Functions
  networkKeyToValue,
  networkValueToKey,
  isMainnet,
  isTestnetFamily,
} from '@asylia/atlas';

// Use enum values
const mainnet = NetworkType.MAINNET; // 'mainnet'
const testnet = NetworkType.TESTNET; // 'testnet'
const regtest = NetworkType.REGTEST; // 'regtest'

// Convert between formats
const value = networkKeyToValue('MAINNET'); // 'mainnet'
const key = networkValueToKey('testnet'); // 'TESTNET'

// Check network type
const isMain = isMainnet('mainnet'); // true
const isTest = isTestnetFamily('testnet'); // true
const isReg = isTestnetFamily('regtest'); // true

// Use maps
const networkValue = NetworkMap.MAINNET; // 'mainnet'
const networkKey = NetworkReverseMap.mainnet; // 'MAINNET'

Script Types

Work with different Bitcoin script types:

import {
  // Enum
  ScriptType,

  // Types
  type ScriptTypeValue,
  type ScriptTypeUppercaseKey,

  // Maps
  ScriptTypeMap,
  ScriptTypeReverseMap,

  // Functions
  scriptTypeToValue,
  scriptTypeFromValue,
} from '@asylia/atlas';

// Use enum values
const legacyScript = ScriptType.P2PKH; // 'p2pkh'
const nestedSegwit = ScriptType.P2SH_P2WPKH; // 'p2sh-p2wpkh'
const segwitScript = ScriptType.P2WPKH; // 'p2wpkh'
const taprootScript = ScriptType.P2TR; // 'p2tr'
const multisigScript = ScriptType.P2SH_MULTISIG; // 'p2sh-multisig'
const wshScript = ScriptType.P2WSH; // 'p2wsh'
const wshP2shScript = ScriptType.P2WSH_P2SH; // 'p2wsh-p2sh'

// Convert between formats
const value = scriptTypeToValue('P2WPKH'); // 'p2wpkh'
const key = scriptTypeFromValue('p2tr'); // 'P2TR'

// Use maps
const scriptValue = ScriptTypeMap.P2WPKH; // 'p2wpkh'
const scriptKey = ScriptTypeReverseMap['p2wpkh']; // 'P2WPKH'

BIP Derivation Purposes

Access BIP standard numbers and labels:

import {
  // Constants
  DERIVATION_PURPOSE_PREFIX,
  DERIVATION_PURPOSE_LIST,

  // Types
  type DerivationPurposeNumber,
  type DerivationPurposeLabel,

  // Maps
  DerivationPurposeString,
  DerivationPurposeNumberMap,
} from '@asylia/atlas';

// Get all supported BIP numbers
const bips = DERIVATION_PURPOSE_LIST; // [44, 45, 48, 49, 84, 86]

// Get the prefix
const prefix = DERIVATION_PURPOSE_PREFIX; // 'BIP'

// Use BIP labels
const bip44 = DerivationPurposeString.BIP_44; // 'BIP_44'
const bip49 = DerivationPurposeString.BIP_49; // 'BIP_49'
const bip84 = DerivationPurposeString.BIP_84; // 'BIP_84'
const bip86 = DerivationPurposeString.BIP_86; // 'BIP_86'
const bip45 = DerivationPurposeString.BIP_45; // 'BIP_45'
const bip48 = DerivationPurposeString.BIP_48; // 'BIP_48'

// Convert label to number
const number44 = DerivationPurposeNumberMap.BIP_44; // 44
const number84 = DerivationPurposeNumberMap.BIP_84; // 84
const number86 = DerivationPurposeNumberMap.BIP_86; // 86

Standard Derivation Paths

Work with Bitcoin derivation paths in both string and object formats:

import {
  // Enums
  AccountIndex,
  ChangeIndex,
  AddressIndex,

  // Constants
  COIN_TYPE_MAINNET,
  COIN_TYPE_TESTNET,

  // Types
  type CoinType,
  type DerivationPathObject,
  type DerivationPathString,
  type StandardDerivationPath,

  // Standard path maps
  STANDARD_PATHS_BIP44,
  STANDARD_PATHS_BIP49,
  STANDARD_PATHS_BIP84,
  STANDARD_PATHS_BIP86,

  // Functions
  buildDerivationPath,
  parseDerivationPath,
  getStandardPath,
  getCoinTypeForNetwork,
} from '@asylia/atlas';

// Use enum values for type-safe indices
const account = AccountIndex.ACCOUNT_0; // 0
const receive = ChangeIndex.RECEIVE; // 0
const change = ChangeIndex.CHANGE; // 1
const address = AddressIndex.ADDRESS_0; // 0

// Build a custom derivation path
const customPath = buildDerivationPath(
  84, // BIP84 (Native SegWit)
  COIN_TYPE_MAINNET,
  AccountIndex.ACCOUNT_0,
  ChangeIndex.RECEIVE,
  AddressIndex.ADDRESS_5
);
console.log(customPath.path); // "m/84'/0'/0'/0/5"
console.log(customPath.components.purpose); // 84
console.log(customPath.components.addressIndex); // 5

// Parse an existing derivation path
const parsed = parseDerivationPath("m/84'/0'/0'/0/0");
console.log(parsed.purpose); // 84
console.log(parsed.coinType); // 0
console.log(parsed.account); // 0
console.log(parsed.change); // 0
console.log(parsed.addressIndex); // 0

// Get standard path with defaults
const standardPath = getStandardPath(84, 'MAINNET');
console.log(standardPath.path); // "m/84'/0'/0'/0/0"

// Get standard path with custom values
const customStandard = getStandardPath(
  86, // BIP86 (Taproot)
  'TESTNET',
  AccountIndex.ACCOUNT_1,
  ChangeIndex.CHANGE,
  AddressIndex.ADDRESS_10
);
console.log(customStandard.path); // "m/86'/1'/1'/1/10"

// Use pre-defined standard paths for BIP84 (Native SegWit)
const firstReceive = STANDARD_PATHS_BIP84.FIRST_RECEIVE_MAINNET;
console.log(firstReceive.path); // "m/84'/0'/0'/0/0"

const firstChange = STANDARD_PATHS_BIP84.FIRST_CHANGE_MAINNET;
console.log(firstChange.path); // "m/84'/0'/0'/1/0"

const secondAccount = STANDARD_PATHS_BIP84.SECOND_ACCOUNT_MAINNET;
console.log(secondAccount.path); // "m/84'/0'/1'/0/0"

// Use pre-defined standard paths for BIP86 (Taproot)
const taprootPath = STANDARD_PATHS_BIP86.FIRST_RECEIVE_MAINNET;
console.log(taprootPath.path); // "m/86'/0'/0'/0/0"
console.log(taprootPath.components.purpose); // 86

// Get coin type for a network
const mainnetCoin = getCoinTypeForNetwork('MAINNET'); // 0
const testnetCoin = getCoinTypeForNetwork('testnet'); // 1
const regtestCoin = getCoinTypeForNetwork('REGTEST'); // 1

// Iterate through address indices
for (let i = AddressIndex.ADDRESS_0; i <= AddressIndex.ADDRESS_9; i++) {
  const path = buildDerivationPath(
    84,
    COIN_TYPE_MAINNET,
    AccountIndex.ACCOUNT_0,
    ChangeIndex.RECEIVE,
    i
  );
  console.log(path.path); // m/84'/0'/0'/0/0, m/84'/0'/0'/0/1, ...
}

Legacy and Historical Derivation Paths

Work with legacy formats like Electrum Legacy and BIP32 basic paths:

import { LEGACY_PATHS, MULTISIG_PATHS, HISTORICAL_PATHS } from '@asylia/atlas';

// Electrum Legacy paths (m/0'/change/index format)
const electrumReceive = LEGACY_PATHS.ELECTRUM_LEGACY_FIRST_RECEIVE;
console.log(electrumReceive.path); // "m/0'/0/0"

const electrumChange = LEGACY_PATHS.ELECTRUM_LEGACY_FIRST_CHANGE;
console.log(electrumChange.path); // "m/0'/1/0"

// BIP32 basic paths
const bip32Receive = LEGACY_PATHS.BIP32_BASIC_FIRST_RECEIVE;
console.log(bip32Receive.path); // "m/0'/0/0"

const bip32NonHardened = LEGACY_PATHS.BIP32_NON_HARDENED;
console.log(bip32NonHardened.path); // "m/0/0/0"

// Multi-signature paths
// BIP45 (m/45'/cosigner/change/index)
const bip45 = MULTISIG_PATHS.BIP45_COSIGNER_0_RECEIVE_MAINNET;
console.log(bip45.path); // "m/45'/0/0/0"

// BIP48 with P2WSH-P2SH (script_type=1)
const bip48WshP2sh = MULTISIG_PATHS.BIP48_P2WSH_P2SH_RECEIVE_MAINNET;
console.log(bip48WshP2sh.path); // "m/48'/0'/0'/1'/0/0"

// BIP48 with P2WSH (script_type=2)
const bip48Wsh = MULTISIG_PATHS.BIP48_P2WSH_RECEIVE_MAINNET;
console.log(bip48Wsh.path); // "m/48'/0'/0'/2'/0/0"

// Access all historical paths at once
const allHistorical = HISTORICAL_PATHS;
console.log(Object.keys(allHistorical)); // All legacy and multisig paths

Network-Based Path Filtering

Get all paths for a specific network:

import {
  PATHS_BY_NETWORK_MAINNET,
  PATHS_BY_NETWORK_TESTNET,
  PATHS_BY_NETWORK_REGTEST,
  getPathsForNetwork,
  getCommonPathsForNetwork,
  getLegacyPathsForNetwork,
  getMultisigPathsForNetwork,
  getAllPathsByNetwork,
} from '@asylia/atlas';

// Get all mainnet paths using the map
const mainnetPaths = PATHS_BY_NETWORK_MAINNET;
console.log(mainnetPaths.BIP84_FIRST_RECEIVE_MAINNET.path); // "m/84'/0'/0'/0/0"

// Or use the function to get paths as an array
const allMainnetPaths = getPathsForNetwork('MAINNET');
console.log(allMainnetPaths.length); // All mainnet paths

const testnetPaths = getPathsForNetwork('testnet');
console.log(testnetPaths.length); // All testnet paths

// Get only common/standard paths (BIP44, 49, 84, 86)
const commonMainnet = getCommonPathsForNetwork('MAINNET');
console.log(commonMainnet.length); // 15 paths (3 for each BIP + second account)

// Get only legacy paths
const legacyPaths = getLegacyPathsForNetwork('MAINNET');
console.log(legacyPaths.length); // Electrum and BIP32 paths

// Get only multisig paths
const multisigMainnet = getMultisigPathsForNetwork('MAINNET');
// Returns BIP45 and BIP48 mainnet paths

const multisigTestnet = getMultisigPathsForNetwork('TESTNET');
// Returns BIP45 and BIP48 testnet paths

// Get all paths grouped by network
const groupedPaths = getAllPathsByNetwork();
console.log(groupedPaths.mainnet.length); // All mainnet paths
console.log(groupedPaths.testnet.length); // All testnet paths
console.log(groupedPaths.regtest.length); // All regtest paths

// Filter and display specific paths
const mainnetCommon = getCommonPathsForNetwork('MAINNET');
mainnetCommon.forEach((path) => {
  console.log(`${path.components.purpose}: ${path.path}`);
  // 44: m/44'/0'/0'/0/0
  // 44: m/44'/0'/0'/1/0
  // 49: m/49'/0'/0'/0/0
  // ...
});

Derivation Path Variants

Combine BIP standards, script types, and networks:

import {
  // Constants
  DERIVATION_VARIANTS,

  // Types
  type DerivationVariant,
  type DerivationPathIDMainnetValue,
  type DerivationPathIDTestnetValue,
  type DerivationPathIDRegtestValue,

  // Network-specific maps
  DerivationPathIDMainnet,
  DerivationPathIDTestnet,
  DerivationPathIDRegtest,
} from '@asylia/atlas';

// Get all variants (without network)
const variants = DERIVATION_VARIANTS;
// [
//   'ELECTRUM_LEGACY_P2PKH',
//   'BIP_44_P2PKH',
//   'BIP_49_P2SH-P2WPKH',
//   'BIP_84_P2WPKH',
//   'BIP_86_P2TR',
//   'BIP_45_P2SH-MULTISIG',
//   'BIP_48_P2WSH-P2SH',
//   'BIP_48_P2WSH'
// ]

// Access mainnet derivation path IDs
const mainnetLegacy = DerivationPathIDMainnet.BIP_44_P2PKH_MAINNET;
const mainnetNestedSegwit = DerivationPathIDMainnet.BIP_49_P2SH_P2WPKH_MAINNET;
const mainnetSegwit = DerivationPathIDMainnet.BIP_84_P2WPKH_MAINNET;
const mainnetTaproot = DerivationPathIDMainnet.BIP_86_P2TR_MAINNET;

// Access testnet derivation path IDs
const testnetLegacy = DerivationPathIDTestnet.BIP_44_P2PKH_TESTNET;
const testnetSegwit = DerivationPathIDTestnet.BIP_84_P2WPKH_TESTNET;
const testnetTaproot = DerivationPathIDTestnet.BIP_86_P2TR_TESTNET;

// Access regtest derivation path IDs
const regtestLegacy = DerivationPathIDRegtest.BIP_44_P2PKH_REGTEST;
const regtestSegwit = DerivationPathIDRegtest.BIP_84_P2WPKH_REGTEST;

📚 API Reference

Extended Public Key Module

| Export | Type | Description | | ---------------------------------- | -------- | --------------------------------------------------------- | | ExtendedPubKeyPrefix | Enum | All extended public key prefixes (xpub, ypub, zpub, etc.) | | ExtendedPubKeyPrefixValue | Type | Union type of all prefix values | | ExtendedPubKeyDisplayLabel | Type | Union type of display labels | | ExtendedPubKeyNetworkClass | Type | Union type of network classifications | | ExtendedPubKeyScriptType | Type | Union type of script types for prefixes | | Bip32VersionBytes | Type | Interface for BIP32 version bytes (public/private) | | ExtendedPubKeyDisplayMap | Map | Prefix → Display label (e.g., "xpub" → "Xpub") | | ExtendedPubKeyNetworkMap | Map | Prefix → Network type (e.g., "xpub" → "MAINNET") | | ExtendedPubKeyScriptTypeMap | Map | Prefix → Script type (e.g., "zpub" → "p2wpkh") | | ExtendedPubKeyBip32VersionMap | Map | Prefix → BIP32 version bytes for serialization | | isMainnetPrefix() | Function | Check if prefix is mainnet | | isTestnetPrefix() | Function | Check if prefix is testnet | | getPrefixFromExtendedPublicKey() | Function | Extract and identify prefix from extended public key | | guessScriptTypeFromPrefix() | Function | Get script type from prefix | | getBip32VersionBytes() | Function | Get BIP32 version bytes for a prefix |

Total Exports: 15 (1 enum, 5 types, 4 maps, 5 functions)

Network Module

| Export | Type | Description | | --------------------- | -------- | ----------------------------------------------- | | NetworkType | Enum | All network types (MAINNET, TESTNET, REGTEST) | | NetworkTypeValue | Type | Union type of lowercase network values | | NetworkTypeKey | Type | Union type of uppercase network keys | | NetworkMap | Map | Network key → Network value (MAINNET → mainnet) | | NetworkReverseMap | Map | Network value → Network key (mainnet → MAINNET) | | networkKeyToValue() | Function | Convert MAINNET → mainnet | | networkValueToKey() | Function | Convert mainnet → MAINNET | | isMainnet() | Function | Check if network is mainnet | | isTestnetFamily() | Function | Check if network is testnet/regtest |

Total Exports: 9 (1 enum, 2 types, 2 maps, 4 functions)

Script Type Module

| Export | Type | Description | | ------------------------ | -------- | -------------------------------------------- | | ScriptType | Enum | All script types (P2PKH, P2WPKH, P2TR, etc.) | | ScriptTypeValue | Type | Union type of lowercase script values | | ScriptTypeUppercaseKey | Type | Union type of uppercase script keys | | ScriptTypeMap | Map | Script key → Script value (P2WPKH → p2wpkh) | | ScriptTypeReverseMap | Map | Script value → Script key (p2wpkh → P2WPKH) | | scriptTypeToValue() | Function | Convert P2WPKH → p2wpkh | | scriptTypeFromValue() | Function | Convert p2wpkh → P2WPKH |

Total Exports: 7 (1 enum, 2 types, 2 maps, 2 functions)

Purpose Module

| Export | Type | Description | | ---------------------------- | -------- | ----------------------------------------------------------- | | DERIVATION_PURPOSE_PREFIX | Constant | 'BIP' prefix string | | DERIVATION_PURPOSE_LIST | Constant | Array of supported BIP numbers [32, 44, 45, 48, 49, 84, 86] | | ELECTRUM_LEGACY_PURPOSE | Constant | Special purpose value (0) for Electrum Legacy wallets | | DerivationPurposeNumber | Type | Union type of valid BIP numbers | | DerivationPurposeLabel | Type | Union type of BIP labels | | DerivationPurposeString | Map | BIP labels (BIP_32, BIP_44, BIP_49, etc.) | | DerivationPurposeNumberMap | Map | Label → Number (BIP_44 → 44) |

Total Exports: 7 (3 constants, 2 types, 2 maps)

Variant Module

| Export | Type | Description | | ------------------------------ | -------- | ------------------------------------ | | DERIVATION_VARIANTS | Constant | Array of all BIP+Script combinations | | DerivationVariant | Type | Union type of derivation variants | | DerivationPathIDMainnetValue | Type | Union type of mainnet derivation IDs | | DerivationPathIDTestnetValue | Type | Union type of testnet derivation IDs | | DerivationPathIDRegtestValue | Type | Union type of regtest derivation IDs | | DerivationPathIDMainnet | Map | Mainnet derivation path IDs | | DerivationPathIDTestnet | Map | Testnet derivation path IDs | | DerivationPathIDRegtest | Map | Regtest derivation path IDs |

Total Exports: 8 (1 constant, 4 types, 3 maps)

DerivationPath Module

| Export | Type | Description | | ------------------------------ | -------- | ---------------------------------------------------------------- | | AccountIndex | Enum | Account indices (0-19) following BIP44 account discovery | | ChangeIndex | Enum | Change indices (RECEIVE=0, CHANGE=1) | | AddressIndex | Enum | Address indices (0-19) following gap limit | | COIN_TYPE_MAINNET | Constant | Bitcoin mainnet coin type (0) | | COIN_TYPE_TESTNET | Constant | Bitcoin testnet coin type (1) | | CoinType | Type | Union type of coin types (0 | 1) | | DerivationPathObject | Type | Object representation of a derivation path | | DerivationPathString | Type | String representation of a derivation path | | StandardDerivationPath | Type | Complete path with both string and object representations | | StandardPathsBip44 | Type | Type of the BIP44 standard paths map | | StandardPathsBip49 | Type | Type of the BIP49 standard paths map | | StandardPathsBip84 | Type | Type of the BIP84 standard paths map | | StandardPathsBip86 | Type | Type of the BIP86 standard paths map | | LegacyPathsType | Type | Type of the legacy paths map | | MultisigPathsType | Type | Type of the multisig paths map | | HistoricalPathsType | Type | Type of the historical paths map | | PathsByNetworkMainnet | Type | Type of mainnet paths collection | | PathsByNetworkTestnet | Type | Type of testnet paths collection | | PathsByNetworkRegtest | Type | Type of regtest paths collection | | STANDARD_PATHS_BIP44 | Map | Pre-defined standard paths for BIP44 (Legacy) | | STANDARD_PATHS_BIP49 | Map | Pre-defined standard paths for BIP49 (Nested SegWit) | | STANDARD_PATHS_BIP84 | Map | Pre-defined standard paths for BIP84 (Native SegWit) | | STANDARD_PATHS_BIP86 | Map | Pre-defined standard paths for BIP86 (Taproot) | | LEGACY_PATHS | Map | Legacy paths (Electrum, BIP32 basic) | | MULTISIG_PATHS | Map | Multi-signature paths (BIP45, BIP48) | | HISTORICAL_PATHS | Map | All legacy and multisig paths combined | | PATHS_BY_NETWORK_MAINNET | Map | All derivation paths for mainnet | | PATHS_BY_NETWORK_TESTNET | Map | All derivation paths for testnet | | PATHS_BY_NETWORK_REGTEST | Map | All derivation paths for regtest | | buildDerivationPath() | Function | Build a derivation path from individual components | | parseDerivationPath() | Function | Parse a derivation path string into components | | getStandardPath() | Function | Get a standard derivation path for a BIP and network | | getCoinTypeForNetwork() | Function | Get the appropriate coin type for a network | | getPathsForNetwork() | Function | Get all derivation paths for a specific network | | getCommonPathsForNetwork() | Function | Get only common/standard paths for a network (BIP44, 49, 84, 86) | | getLegacyPathsForNetwork() | Function | Get only legacy/historical paths for a network | | getMultisigPathsForNetwork() | Function | Get only multi-signature paths for a network | | getAllPathsByNetwork() | Function | Get all paths grouped by network (mainnet, testnet, regtest) |

Total Exports: 38 (3 enums, 2 constants, 16 types, 9 maps, 9 functions)

🌍 Supported Standards

Extended Public Key Prefixes

Mainnet:

  • xpub - Legacy (BIP44, P2PKH)
  • ypub - Nested SegWit (BIP49, P2SH-P2WPKH)
  • zpub - Native SegWit (BIP84, P2WPKH)
  • trpub - Taproot (BIP86, P2TR)

Testnet:

  • tpub - Legacy (BIP44, P2PKH)
  • upub - Nested SegWit (BIP49, P2SH-P2WPKH)
  • vpub - Native SegWit (BIP84, P2WPKH)
  • trpubt - Taproot (BIP86, P2TR)

BIP Standards

  • BIP32 - Hierarchical Deterministic Wallets (basic derivation)
  • BIP44 - Legacy addresses (P2PKH)
  • BIP45 - Multi-signature addresses (P2SH)
  • BIP48 - Multi-signature with different script types (P2WSH-P2SH, P2WSH)
  • BIP49 - Nested SegWit addresses (P2SH-P2WPKH)
  • BIP84 - Native SegWit addresses (P2WPKH)
  • BIP86 - Taproot addresses (P2TR)
  • Electrum Legacy - Historical Electrum wallet format (m/0'/change/index)

Script Types

  • P2PKH - Pay to Public Key Hash (Legacy)
  • P2SH-P2WPKH - Nested SegWit
  • P2WPKH - Native SegWit
  • P2TR - Taproot
  • P2SH-MULTISIG - Multi-signature (Legacy)
  • P2WSH-P2SH - Wrapped Witness Script Hash
  • P2WSH - Native Witness Script Hash

Derivation Paths

Standard Paths by BIP:

  • BIP32 (Basic): m/account'/change/addressIndex

    • Example: m/0'/0/0 (First receiving address)
  • BIP44 (Legacy): m/44'/coinType'/account'/change/addressIndex

    • Example: m/44'/0'/0'/0/0 (First mainnet receiving address)
  • BIP45 (Multisig): m/45'/cosigner/change/addressIndex

    • Example: m/45'/0/0/0 (Cosigner 0, first receiving address)
  • BIP48 (Multisig Scripts): m/48'/coinType'/account'/scriptType'/change/addressIndex

    • Example: m/48'/0'/0'/2'/0/0 (P2WSH first receiving address)
    • scriptType: 1 = P2WSH-P2SH, 2 = P2WSH
  • BIP49 (Nested SegWit): m/49'/coinType'/account'/change/addressIndex

    • Example: m/49'/0'/0'/0/0 (First mainnet receiving address)
  • BIP84 (Native SegWit): m/84'/coinType'/account'/change/addressIndex

    • Example: m/84'/0'/0'/0/0 (First mainnet receiving address)
  • BIP86 (Taproot): m/86'/coinType'/account'/change/addressIndex

    • Example: m/86'/0'/0'/0/0 (First mainnet receiving address)
  • Electrum Legacy: m/0'/change/addressIndex

    • Example: m/0'/0/0 (First receiving address)
    • Example: m/0'/1/0 (First change address)

Path Components:

  • purpose: BIP number (32, 44, 45, 48, 49, 84, 86) - determines address type
  • coinType: 0 for mainnet, 1 for testnet/regtest
  • account: Account index (hardened) - segregates different purposes
  • change: 0 for receive addresses, 1 for change addresses
  • addressIndex: Sequential address index (non-hardened)
  • scriptType (BIP48 only): 1 for P2WSH-P2SH, 2 for P2WSH
  • cosigner (BIP45 only): Cosigner index for multi-signature setups

🛠️ Development

# Install dependencies
pnpm install

# Build the package
pnpm run build

# Run type checking
pnpm run typecheck

# Watch mode for development
pnpm run dev

📄 License

MIT © Asylia.io - Made by Asylian21 (David Zita)

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📞 Support


Made with ❤️ by Asylian21 (David Zita)