@ngraveio/ur-blockchain-commons
Version:
A JS implementation of Uniform Resources(UR) Registry specification from Blockchain Commons.
38 lines (37 loc) • 4.32 kB
TypeScript
/**
* Bitcoin Address Types Table
*
* | Address Type | Starts With | Version Byte (Mainnet) | Version Byte (Testnet) | Encoding Type | Prefix Application | Mainnet Example | Testnet Example |
* |-------------------------------------------|---------------------|------------------------------|------------------------------|---------------|------------------------------------------------------------------------------------|----------------------------------------------------------------------|----------------------------------------------------------------|
* | Pay-to-Public-Key (P2PK) | No address format | N/A | N/A | Script-based | No address prefix; directly uses public key in scripts. | No specific address; script usage only. | No specific address; script usage only. |
* | Pay-to-Public-Key-Hash (P2PKH) | 1 | 0x00 | 0x6F | Base58Check | Add the version byte (0x00 or 0x6F) before the hashed public key and checksum. | 18uWvCS2hqV6D5ehQtDJxrftrePAXGeevS | ms5e572mZ1eDKdeyfR6MpRqXHVv6kM6wAP |
* | Pay-to-Script-Hash (P2SH) | 3 | 0x05 | 0xC4 | Base58Check | Add the version byte (0x05 or 0xC4) before the script hash and checksum. | 3FymWfwDaGzsRWesK47nxFWPDiDmkC8GkR | 2MvJq3ieuKUiwvQP1WVQdfb5WB5fMStTkhH |
* | Pay-to-Witness-Public-Key-Hash (P2WPKH) | bc1q | Witness Version 0 (0x00) | Witness Version 0 (0x00) | Bech32 | Add the human-readable prefix (bc or tb) and encode the data with Bech32. | bc1q26mhhmkkddq9zd66fec6tac2lp07c7uuaurgtr | tb1q0mt7t7sjn777f4mgpk7u67a82aykkw3kq4kaad |
* | Pay-to-Witness-Script-Hash (P2WSH) | bc1q | Witness Version 0 (0x00) | Witness Version 0 (0x00) | Bech32 | Add the human-readable prefix (bc or tb) and encode the data with Bech32. | bc1q6axwlnwlky7jykqqwlrcjy2s6ragcwaesal0nfpv5pnwdmgu72es5kywz8 | tb1qwjnw4rf07n8wyerlnplyeecpfkw5q2puqn0vux04kqpdu689qx0qx6uqvj |
* | Pay-to-Taproot (P2TR) | bc1p | Witness Version 1 (0x01) | Witness Version 1 (0x01) | Bech32m | Add the human-readable prefix (bc or tb) and encode the data with Bech32m. | bc1p9cjtuu7rlytzgeuwtdy4fuflmpp00tmpwchr7xjdexs5la94frkqpmcs8f | tb1p34jjsay897lryzkc0fkxk9wruhvct6vnmknxxaxy75rxnpakqlqs56v2lh |
* | Pay-to-Multisig (P2MS) | No address format | N/A | N/A | Script-based | No address prefix; directly uses multisignature script. | No specific address; script usage only. | No specific address; script usage only. |
*/
interface DecodedAddress {
type: 0 | 60;
scriptType?: string;
network?: 'mainnet' | 'testnet';
payload: Uint8Array;
checksum?: number;
}
/**
* Decode a Bitcoin or Ethereum address into its components.
* @param address - The address to decode.
* @param network - Optional network for Ethereum (default: 'mainnet').
* @returns The decoded address components.
*/
export declare function decodeAddress(address: string, network?: 'mainnet' | 'testnet'): DecodedAddress;
/**
* Encode a Bitcoin or Ethereum address from its components.
* @param type - The BIP44 coin type.
* @param scriptType - The script type for Bitcoin addresses.
* @param network - The network type (mainnet or testnet).
* @param payload - The payload to encode.
* @returns The encoded address.
*/
export declare function encodeAddress(type: number, scriptType: string | undefined, network: 'mainnet' | 'testnet', payload: Uint8Array): string;
export {};