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
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
ZERO_SATS
readonlystaticZERO_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()
staticbuildChangeOutput(change):ByteString
Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:66
Build serialized change output
Parameters
change
change output to build
Returns
serialized change output in format ByteString
buildDataOutput()
staticbuildDataOutput(scriptHash,satoshis,dataHash):ByteString
Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:50
Build serialized tx output
Parameters
scriptHash
satoshis
serialized satoshis of the output
dataHash
Returns
serialized tx output in format ByteString
buildOpReturnOutput()
staticbuildOpReturnOutput(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
the data payload
Returns
a ByteString contains the data payload
buildOpreturnScript()
staticbuildOpreturnScript(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
the data payload
Returns
a ByteString contains the data payload
buildOutput()
staticbuildOutput(scriptHash,satoshis):ByteString
Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:38
Build serialized tx output
Parameters
scriptHash
satoshis
serialized satoshis of the output
Returns
serialized tx output in format ByteString
buildP2PKHOutput()
staticbuildP2PKHOutput(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
the satoshi amount
addr
the recipient's public key hash
Returns
a ByteString representing the P2PKH output
buildP2PKHScript()
staticbuildP2PKHScript(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
Returns
a ByteString representing the P2PKH script
byteStringToSatoshis()
staticbyteStringToSatoshis(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
the satoshi amount
Returns
a UInt64
loadArtifact()
staticloadArtifact(artifact): typeofSmartContractLib
Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:19
Parameters
artifact
Returns
typeof SmartContractLib
Inherited from
mergeInput()
staticmergeInput(txInput):ByteString
Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/txUtils.ts:78
Merge tx input into a ByteString
Parameters
txInput
tx input, must be a segwit input
Returns
serialized tx input
satoshisToByteString()
staticsatoshisToByteString(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
the satoshi amount
Returns
a ByteString