lotus-sdk
Version:
Central repository for several classes of tools for integrating with, and building for, the Lotusia ecosystem
111 lines • 4.16 kB
TypeScript
import { Opcode } from './opcode.js';
import { PublicKey } from './publickey.js';
import { Address } from './address.js';
import { Network } from './networks.js';
import { Signature } from './crypto/signature.js';
import { Chunk } from './chunk.js';
export interface ScriptData {
chunks: Chunk[];
_network?: Network;
}
export type ScriptInput = Buffer | string | ScriptData | PublicKey | Address;
export type ScriptType = 'p2pk' | 'p2pkh' | 'p2sh' | 'p2tr-commitment' | 'p2tr-state' | 'other';
export declare class Script {
chunks: Chunk[];
_network?: Network;
constructor(from?: ScriptInput);
set(obj: ScriptData): Script;
static fromBuffer(buffer: Buffer): Script;
static fromString(str: string): Script;
static fromASM(str: string): Script;
static fromHex(str: string): Script;
static fromAddress(address: Address | string): Script;
static buildMultisigOut(publicKeys: PublicKey[], threshold: number, opts?: {
noSorting?: boolean;
}): Script;
static buildPublicKeyHashOut(to: PublicKey | Address | string): Script;
static buildScriptHashOut(script: Script | Address): Script;
static buildMultisigIn(pubkeys: PublicKey[], threshold: number, signatures: Buffer[], opts?: {
noSorting?: boolean;
cachedMultisig?: Script;
checkBits?: Uint8Array;
signingMethod?: 'ecdsa' | 'schnorr';
}): Script;
static buildP2SHMultisigIn(pubkeys: PublicKey[], threshold: number, signatures: Buffer[], opts?: {
noSorting?: boolean;
cachedMultisig?: Script;
checkBits?: Uint8Array;
signingMethod?: 'ecdsa' | 'schnorr';
}): Script;
static buildWitnessMultisigOutFromScript(script: Script): Script;
static buildPublicKeyOut(pubkey: PublicKey): Script;
static buildDataOut(data: string | Buffer, encoding?: string): Script;
static buildPublicKeyIn(signature: Signature | Buffer, sigtype: number): Script;
static buildPublicKeyHashIn(publicKey: PublicKey, signature: Signature | Buffer, sigtype: number): Script;
static buildPayToTaproot(commitment: PublicKey | Buffer, state?: Buffer): Script;
add(chunk: Opcode | Buffer | number): Script;
toBuffer(): Buffer;
toString(): string;
toP2PKH(): string;
toP2SH(): string;
toASM(): string;
toHex(): string;
inspect(): string;
private _chunkToString;
isPayToPublicKeyHash(): boolean;
isPublicKeyHashOut(): boolean;
isPayToScriptHash(): boolean;
isScriptHashOut(): boolean;
isPayToTaproot(): boolean;
getData(): Buffer;
getAddressInfo(): Address | null;
private _getOutputAddressInfo;
private _getInputAddressInfo;
toAddress(network?: Network | string): Address | null;
checkMinimalPush(index: number): boolean;
isValid(): boolean;
clone(): Script;
isPublicKeyHashIn(): boolean;
getPublicKey(): Buffer;
getPublicKeyHash(): Buffer;
isPublicKeyOut(): boolean;
isPublicKeyIn(): boolean;
isScriptHashIn(): boolean;
isMultisigOut(): boolean;
private _isSmallIntOp;
isMultisigIn(): boolean;
isDataOut(): boolean;
isPushOnly(): boolean;
classify(): string;
classifyOutput(): string;
classifyInput(): string;
isStandard(): boolean;
getType(): ScriptType;
prepend(obj: Opcode | Buffer | number): Script;
equals(script: Script): boolean;
private _addByType;
private _insertAtPosition;
private _addOpcode;
private _addBuffer;
hasCodeseparators(): boolean;
removeCodeseparators(): Script;
findAndDelete(script: Script): Script;
getSignatureOperationsCount(accurate?: boolean): number;
private _decodeOP_N;
toScriptHashOut(): Script;
}
export declare const ScriptTypes: {
UNKNOWN: string;
PUBKEY_OUT: string;
PUBKEY_IN: string;
PUBKEYHASH_OUT: string;
PUBKEYHASH_IN: string;
SCRIPTHASH_OUT: string;
SCRIPTHASH_IN: string;
MULTISIG_OUT: string;
MULTISIG_IN: string;
DATA_OUT: string;
};
export declare function toAddress(script: Script, network: string): Address;
export declare function empty(): Script;
//# sourceMappingURL=script.d.ts.map