Skip to main content

TxHashPreimageUtils

@opcat-labs/scrypt-ts-opcat v1.0.4


@opcat-labs/scrypt-ts-opcat / TxHashPreimageUtils

Class: TxHashPreimageUtils

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txHashPreimageUtils.ts:15

Utility class for working with transaction hash preimages in Bitcoin smart contracts. Provides methods to:

  • Calculate transaction hash from preimage data
  • Extract individual input/output byte strings from preimage

Extends​

Constructors​

new TxHashPreimageUtils()​

new TxHashPreimageUtils(...args): TxHashPreimageUtils

Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:32

Parameters​

args​

...SupportedParamType[]

Returns​

TxHashPreimageUtils

Inherited from​

SmartContractLib.constructor

Properties​

args​

args: any[] = []

Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:31

Inherited from​

SmartContractLib.args


artifact​

static artifact: Artifact

Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:16

Inherited from​

SmartContractLib.artifact


stateType?​

static optional stateType: string

Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:17

Inherited from​

SmartContractLib.stateType

Methods​

getInputByteString()​

static getInputByteString(txHashPreimage, inputIndex): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txHashPreimageUtils.ts:46

Extracts the byte string of a specific input from the transaction hash preimage.

Parameters​

txHashPreimage​

TxHashPreimage

The transaction hash preimage containing input data.

inputIndex​

bigint

The index of the input to extract.

Returns​

ByteString

The byte string representing the specified input.


getOutputByteString()​

static getOutputByteString(txHashPreimage, outputIndex): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txHashPreimageUtils.ts:57

Extracts the byte string of a specific output from the transaction hash preimage.

Parameters​

txHashPreimage​

TxHashPreimage

The transaction hash preimage containing output list.

outputIndex​

bigint

The index of the output to extract.

Returns​

ByteString

The byte string of the specified output.


getTxHashFromTxHashPreimage()​

static getTxHashFromTxHashPreimage(txHashPreimage): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txHashPreimageUtils.ts:26

Computes the transaction hash from a given transaction hash preimage. Validates the preimage structure and constructs the hash by concatenating version, input/output counts, input/output lists, and lock time.

Parameters​

txHashPreimage​

TxHashPreimage

The transaction hash preimage containing version, input/output lists, and lock time.

Returns​

ByteString

The computed transaction hash as a ByteString.


loadArtifact()​

static loadArtifact(artifact): typeof SmartContractLib

Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:19

Parameters​

artifact​

Artifact

Returns​

typeof SmartContractLib

Inherited from​

SmartContractLib.loadArtifact