import { type Coder, type TArg, type TRet } from '@scure/base'; import { type CustomScript, type OptScript, type ScriptType } from '@scure/btc-signer'; import * as P from 'micro-packed'; type Bytes = Uint8Array; /** * Ordinals inscription identifier coder. * @example * Encode the txid-and-index string form used to reference an inscription. * ```ts * InscriptionId.encode('0000000000000000000000000000000000000000000000000000000000000000i0'); * ``` */ export declare const InscriptionId: TRet>; /** Mapping of inscription tag names to their coders. */ export type TagCodersType = { /** Inscription pointer tag stored as an unsigned 64-bit integer. */ pointer: P.CoderType; /** MIME type for the inscription body. */ contentType: P.CoderType; /** Parent inscription reference. */ parent: P.Coder; /** CBOR metadata payload. */ metadata: P.CoderType; /** Secondary protocol name carried by the inscription. */ metaprotocol: P.CoderType; /** Content-Encoding value for the inscription body. */ contentEncoding: P.CoderType; /** Delegated inscription reference. */ delegate: P.Coder; /** Rune identifier stored as an unsigned 128-bit integer. */ rune: P.CoderType; /** Free-form note text. */ note: P.CoderType; }; declare const TagCoders: TagCodersType; /** Parsed ordinals tag bag. */ export type Tags = Partial<{ [K in keyof typeof TagCoders]: P.UnwrapCoder<(typeof TagCoders)[K]>; }> & { unknown?: [Bytes, Bytes][]; }; /** Parsed ordinals inscription payload. */ export type Inscription = { /** Parsed inscription tags. */ tags: Tags; /** Inscription body bytes. */ body: Bytes; /** Whether the inscription was parsed from a cursed envelope. */ cursed?: boolean; }; type OutOrdinalRevealType = { type: 'tr_ord_reveal'; pubkey: Bytes; inscriptions: Inscription[]; }; /** * Parses ordinals inscriptions from a script. * @param script - decoded bitcoin script * @param strict - require the exact reveal-script layout * @returns parsed inscriptions when the script contains valid envelopes * @throws If inscription tags or tag data are malformed inside the reveal script. {@link Error} * @throws On wrong argument types. {@link TypeError} * @throws On wrong argument ranges or values. {@link RangeError} * @example * Build a reveal script, then parse the inscriptions back out of the decoded script. * ```ts * import { parseInscriptions, p2tr_ord_reveal } from 'micro-ordinals'; * import { Script } from '@scure/btc-signer'; * import { pubSchnorr, randomPrivateKeyBytes } from '@scure/btc-signer/utils.js'; * const privKey = randomPrivateKeyBytes(); * const pubKey = pubSchnorr(privKey); * const reveal = p2tr_ord_reveal(pubKey, [ * { tags: { contentType: 'text/plain' }, body: new Uint8Array([1, 2, 3]) }, * ]); * parseInscriptions(Script.decode(reveal.script)); * ``` */ export declare function parseInscriptions(script: ScriptType, strict?: boolean): TRet; /** * Parse inscriptions from reveal tx input witness (tx.inputs[0].finalScriptWitness) * @param witness - reveal input witness stack * @returns parsed inscriptions when the witness contains a reveal script * @throws If the decoded reveal script contains malformed inscription tags. {@link Error} * @throws On wrong witness argument types. {@link TypeError} * @throws On wrong witness stack length. {@link RangeError} * @example * Reuse the reveal-script slot from a taproot witness and parse the inscription payload back out. * ```ts * import { parseWitness, p2tr_ord_reveal } from 'micro-ordinals'; * import { pubSchnorr, randomPrivateKeyBytes } from '@scure/btc-signer/utils.js'; * const privKey = randomPrivateKeyBytes(); * const pubKey = pubSchnorr(privKey); * const reveal = p2tr_ord_reveal(pubKey, [ * { tags: { contentType: 'text/plain' }, body: new Uint8Array([1, 2, 3]) }, * ]); * const dummySig = new Uint8Array([0]); * const dummyControlBlock = new Uint8Array([0]); * parseWitness([dummySig, reveal.script, dummyControlBlock]); * ``` */ export declare function parseWitness(witness: TArg): TRet; /** * Custom script codec for ordinals reveal scripts. * @example * Decode the custom ordinals reveal structure back out of a bitcoin script. * ```ts * import { OutOrdinalReveal, p2tr_ord_reveal } from 'micro-ordinals'; * import { Script } from '@scure/btc-signer'; * import { pubSchnorr, randomPrivateKeyBytes } from '@scure/btc-signer/utils.js'; * const privKey = randomPrivateKeyBytes(); * const pubKey = pubSchnorr(privKey); * const reveal = p2tr_ord_reveal(pubKey, [ * { tags: { contentType: 'text/plain' }, body: new Uint8Array([1, 2, 3]) }, * ]); * OutOrdinalReveal.encode(Script.decode(reveal.script)); * ``` */ export declare const OutOrdinalReveal: TRet & CustomScript>; /** * Create reveal transaction. Inscription created on spending output from this address by * revealing taproot script. * @param pubkey - x-only taproot public key * @param inscriptions - inscription payloads to embed in the reveal script * @returns taproot script tree fragment for `@scure/btc-signer` * @throws On wrong argument types. {@link TypeError} * @throws On wrong argument ranges or values. {@link RangeError} * @example * Build the taproot script fragment that will reveal the inscription payloads. * ```ts * import { p2tr_ord_reveal } from 'micro-ordinals'; * import { pubSchnorr, randomPrivateKeyBytes } from '@scure/btc-signer/utils.js'; * const privKey = randomPrivateKeyBytes(); * const pubKey = pubSchnorr(privKey); * p2tr_ord_reveal(pubKey, [ * { tags: { contentType: 'text/plain' }, body: new Uint8Array([1, 2, 3]) }, * ]); * ``` */ export declare function p2tr_ord_reveal(pubkey: TArg, inscriptions: TArg): TRet<{ type: 'tr'; script: Uint8Array; }>; export declare const __test__: any; export {}; //# sourceMappingURL=index.d.ts.map