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
Inherited from
Properties
args
args:
any[] =[]
Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:31
Inherited from
artifact
staticartifact:Artifact
Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:16
Inherited from
stateType?
staticoptionalstateType:string
Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:17
Inherited from
Methods
getInputByteString()
staticgetInputByteString(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
The transaction hash preimage containing input data.
inputIndex
bigint
The index of the input to extract.
Returns
The byte string representing the specified input.
getOutputByteString()
staticgetOutputByteString(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
The transaction hash preimage containing output list.
outputIndex
bigint
The index of the output to extract.
Returns
The byte string of the specified output.
getTxHashFromTxHashPreimage()
staticgetTxHashFromTxHashPreimage(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
The transaction hash preimage containing version, input/output lists, and lock time.
Returns
The computed transaction hash as a ByteString.
loadArtifact()
staticloadArtifact(artifact): typeofSmartContractLib
Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:19
Parameters
artifact
Returns
typeof SmartContractLib