diff options
| author | Adam Mathes <adam@adammathes.com> | 2026-02-13 21:34:48 -0800 |
|---|---|---|
| committer | Adam Mathes <adam@adammathes.com> | 2026-02-13 21:34:48 -0800 |
| commit | 76cb9c2a39d477a64824a985ade40507e3bbade1 (patch) | |
| tree | 41e997aa9c6f538d3a136af61dae9424db2005a9 /vanilla/node_modules/@exodus/bytes/bech32.d.ts | |
| parent | 819a39a21ac992b1393244a4c283bbb125208c69 (diff) | |
| download | neko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.gz neko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.bz2 neko-76cb9c2a39d477a64824a985ade40507e3bbade1.zip | |
feat(vanilla): add testing infrastructure and tests (NK-wjnczv)
Diffstat (limited to 'vanilla/node_modules/@exodus/bytes/bech32.d.ts')
| -rw-r--r-- | vanilla/node_modules/@exodus/bytes/bech32.d.ts | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/vanilla/node_modules/@exodus/bytes/bech32.d.ts b/vanilla/node_modules/@exodus/bytes/bech32.d.ts new file mode 100644 index 0000000..67d6476 --- /dev/null +++ b/vanilla/node_modules/@exodus/bytes/bech32.d.ts @@ -0,0 +1,76 @@ +/** + * Implements bech32 and bech32m from + * [BIP-0173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#specification) + * and [BIP-0350](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki#specification). + * + * ```js + * import { fromBech32, toBech32 } from '@exodus/bytes/bech32.js' + * import { fromBech32m, toBech32m } from '@exodus/bytes/bech32.js' + * import { getPrefix } from '@exodus/bytes/bech32.js' + * ``` + * + * @module @exodus/bytes/bech32.js + */ + +/// <reference types="node" /> + +import type { Uint8ArrayBuffer } from './array.js'; + +/** + * Result of decoding a bech32 or bech32m string + */ +export interface Bech32DecodeResult { + /** The human-readable prefix */ + prefix: string; + /** The decoded bytes */ + bytes: Uint8ArrayBuffer; +} + +/** + * Encode bytes to a bech32 string + * + * @param prefix - The human-readable prefix (e.g., 'bc' for Bitcoin) + * @param bytes - The input bytes to encode + * @param limit - Maximum length of the encoded string (default: 90) + * @returns The bech32 encoded string + */ +export function toBech32(prefix: string, bytes: Uint8Array, limit?: number): string; + +/** + * Decode a bech32 string to bytes + * + * @param string - The bech32 encoded string + * @param limit - Maximum length of the input string (default: 90) + * @returns The decoded prefix and bytes + */ +export function fromBech32(string: string, limit?: number): Bech32DecodeResult; + +/** + * Encode bytes to a bech32m string + * + * @param prefix - The human-readable prefix (e.g., 'bc' for Bitcoin) + * @param bytes - The input bytes to encode + * @param limit - Maximum length of the encoded string (default: 90) + * @returns The bech32m encoded string + */ +export function toBech32m(prefix: string, bytes: Uint8Array, limit?: number): string; + +/** + * Decode a bech32m string to bytes + * + * @param string - The bech32m encoded string + * @param limit - Maximum length of the input string (default: 90) + * @returns The decoded prefix and bytes + */ +export function fromBech32m(string: string, limit?: number): Bech32DecodeResult; + +/** + * Extract the prefix from a bech32 or bech32m string without full validation + * + * This is a quick check that skips most validation. + * + * @param string - The bech32/bech32m encoded string + * @param limit - Maximum length of the input string (default: 90) + * @returns The lowercase prefix + */ +export function getPrefix(string: string, limit?: number): string; |
