UNPKG

@scrypt-inc/bitcoinjs-lib

Version:
64 lines (63 loc) 3.1 kB
import { OPS } from './ops.js'; import { Stack } from './payments/index.js'; import * as scriptNumber from './script_number.js'; import * as scriptSignature from './script_signature.js'; export { OPS }; export declare function isPushOnly(value: Stack | Uint8Array): boolean; export declare function isScriptHashOut(value: Uint8Array): boolean; export declare function countNonPushOnlyOPs(value: Stack): number; export declare function asMinimalOP(buffer: Uint8Array): number | void; /** * Compiles an array of chunks into a Buffer. * * @param chunks - The array of chunks to compile. * @returns The compiled Buffer. * @throws Error if the compilation fails. */ export declare function compile(chunks: Uint8Array | Stack): Uint8Array; export declare function decompile(buffer: Uint8Array | Array<number | Uint8Array>, fRequireMinimal?: boolean): Array<number | Uint8Array> | null; /** * Comes from bitcoind's script interpreter CheckMinimalPush function * @returns {boolean} if the chunk {i} is the smallest way to push that particular data. */ export declare function checkMinimalPush(opcodenum: number, buf: Uint8Array): boolean; /** * Converts the given chunks into an ASM (Assembly) string representation. * If the chunks parameter is a Buffer, it will be decompiled into a Stack before conversion. * @param chunks - The chunks to convert into ASM. * @returns The ASM string representation of the chunks. */ export declare function toASM(chunks: Uint8Array | Array<number | Uint8Array>): string; /** * Converts an ASM string to a Buffer. * @param asm The ASM string to convert. * @returns The converted Buffer. */ export declare function fromASM(asm: string): Uint8Array; /** * Converts the given chunks into a stack of buffers. * * @param chunks - The chunks to convert. * @returns The stack of buffers. */ export declare function toStack(chunks: Uint8Array | Array<number | Uint8Array>): Uint8Array[]; export declare function isCanonicalPubKey(buffer: Uint8Array): boolean; export declare function isUncompressedPubkey(buffer: Uint8Array): boolean; export declare function isDefinedHashType(hashType: number): boolean; export declare function isCanonicalScriptSignature(buffer: Uint8Array): boolean; export declare function isMinimalPush(opcodenum: number, buf: Uint8Array): boolean; export declare function createWitnessProgram(buf: Uint8Array): false | { version: number; program: Uint8Array; }; /** * Analogous to bitcoind's FindAndDelete. Find and delete equivalent chunks, * typically used with push data chunks. Note that this will find and delete * not just the same data, but the same data with the same push data op as * produced by default. i.e., if a pushdata in a tx does not use the minimal * pushdata op, then when you try to remove the data it is pushing, it will not * be removed, because they do not use the same pushdata op. */ export declare function findAndDelete(script: Array<number | Uint8Array>, subScript: Uint8Array): number; export declare const number: typeof scriptNumber; export declare const signature: typeof scriptSignature;