Skip to main content

TxUtils

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


@opcat-labs/scrypt-ts-opcat / TxUtils

Class: TxUtils

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

Library for parsing and constructing transactions

Onchain​

Extends​

Constructors​

new TxUtils()​

new TxUtils(...args): TxUtils

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

Parameters​

args​

...SupportedParamType[]

Returns​

TxUtils

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


ZERO_SATS​

readonly static ZERO_SATS: UInt64 = 0n

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:29

if a output satoshi value is zero

Methods​

buildChangeOutput()​

static buildChangeOutput(change): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:66

Build serialized change output

Parameters​

change​

TxOut

change output to build

Returns​

ByteString

serialized change output in format ByteString


buildDataOutput()​

static buildDataOutput(scriptHash, satoshis, dataHash): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:50

Build serialized tx output

Parameters​

scriptHash​

ByteString

satoshis​

UInt64

serialized satoshis of the output

dataHash​

ByteString

Returns​

ByteString

serialized tx output in format ByteString


buildOpReturnOutput()​

static buildOpReturnOutput(data): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:95

build OP_RETURN script from data payload

Parameters​

data​

ByteString

the data payload

Returns​

ByteString

a ByteString contains the data payload


buildOpreturnScript()​

static buildOpreturnScript(data): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:134

build OP_FALSE OP_RETURN script from data payload

Parameters​

data​

ByteString

the data payload

Returns​

ByteString

a ByteString contains the data payload


buildOutput()​

static buildOutput(scriptHash, satoshis): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:38

Build serialized tx output

Parameters​

scriptHash​

ByteString

satoshis​

UInt64

serialized satoshis of the output

Returns​

ByteString

serialized tx output in format ByteString


buildP2PKHOutput()​

static buildP2PKHOutput(amount, addr): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:124

constructs a P2PKH output from a given PubKeyHash and satoshi amount

Parameters​

amount​

UInt64

the satoshi amount

addr​

Ripemd160

the recipient's public key hash

Returns​

ByteString

a ByteString representing the P2PKH output


buildP2PKHScript()​

static buildP2PKHScript(addr): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:106

constructs a P2PKH script from a given PubKeyHash

Parameters​

addr​

Ripemd160

Returns​

ByteString

a ByteString representing the P2PKH script


byteStringToSatoshis()​

static byteStringToSatoshis(bs): UInt64

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:154

convert a ByteString to a UInt64 number

Parameters​

bs​

ByteString

the satoshi amount

Returns​

UInt64

a UInt64


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


mergeInput()​

static mergeInput(txInput): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:78

Merge tx input into a ByteString

Parameters​

txInput​

TxIn

tx input, must be a segwit input

Returns​

ByteString

serialized tx input


satoshisToByteString()​

static satoshisToByteString(n): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:144

convert a UInt64 number to 8 bytes in little-end order.

Parameters​

n​

UInt64

the satoshi amount

Returns​

ByteString

a ByteString