/** * Inscription Parser Service * * Wrapper around micro-ordinals library for parsing inscriptions from * Bitcoin transaction witness data and scripts. * * micro-ordinals API: * - parseWitness(witness: Bytes[]): Inscription[] | undefined * - parseInscriptions(script: ScriptType, strict?: boolean): Inscription[] | undefined * * Reference: https://github.com/paulmillr/micro-ordinals */ import { type Inscription } from "micro-ordinals"; import type { Network } from "../config/networks.js"; /** * Parsed inscription with metadata */ export interface ParsedInscription { /** * Content type (e.g., "text/plain", "image/png") */ contentType?: string; /** * Inscription body as bytes */ body: Uint8Array; /** * Inscription body as UTF-8 string (if text content) */ bodyText?: string; /** * Inscription body as base64 (for binary content) */ bodyBase64: string; /** * Whether this is a cursed inscription */ cursed?: boolean; /** * Pointer tag (if present) */ pointer?: bigint; /** * Metaprotocol (if present) */ metaprotocol?: string; /** * Content encoding (if present, e.g., "br" for Brotli) */ contentEncoding?: string; /** * Metadata (if present) */ metadata?: any; /** * Rune tag (if present) */ rune?: bigint; /** * Note tag (if present) */ note?: string; /** * All tags from the inscription (raw, may contain Coder objects) */ rawTags: Inscription["tags"]; } /** * Inscription Parser Service */ export declare class InscriptionParser { private readonly network; private readonly mempoolApiUrl; constructor(network: Network); /** * Parse inscriptions from transaction witness data * * This is the primary method for extracting inscriptions from reveal transactions. * The witness data is typically in the first input of a reveal transaction. * * @param witness - Array of hex-encoded witness elements * @returns Array of parsed inscriptions, or undefined if no inscriptions found * * @example * ```typescript * const parser = new InscriptionParser('mainnet'); * const inscriptions = parser.parseWitness(tx.vin[0].witness); * if (inscriptions) { * console.log(`Found ${inscriptions.length} inscriptions`); * } * ``` */ parseWitness(witness: string[]): ParsedInscription[] | undefined; /** * Fetch a transaction and parse inscriptions from its witness data * * This is a convenience method that fetches a transaction from mempool.space * and extracts inscriptions from the first input's witness data (typical for * reveal transactions). * * @param txid - Transaction ID * @returns Array of parsed inscriptions, or undefined if no inscriptions found * @throws Error if transaction fetch fails * * @example * ```typescript * const parser = new InscriptionParser('mainnet'); * const inscriptions = await parser.getInscriptionsFromTx(revealTxid); * if (inscriptions) { * inscriptions.forEach(i => { * console.log(`Type: ${i.contentType}, Size: ${i.body.length} bytes`); * }); * } * ``` */ getInscriptionsFromTx(txid: string): Promise; } /** * Create an inscription parser for the given network */ export declare function createInscriptionParser(network: Network): InscriptionParser; //# sourceMappingURL=inscription-parser.d.ts.map