TxUtils
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
static
artifact:Artifact
Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:16
Inherited from
stateType?
static
optional
stateType:string
Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:17
Inherited from
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
change output to build
Returns
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
satoshis
serialized satoshis of the output
dataHash
Returns
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
the data payload
Returns
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
the data payload
Returns
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
satoshis
serialized satoshis of the output
Returns
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
the satoshi amount
addr
the recipient's public key hash
Returns
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
Returns
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
the satoshi amount
Returns
a UInt64
loadArtifact()
static
loadArtifact(artifact
): typeofSmartContractLib
Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:19
Parameters
artifact
Returns
typeof SmartContractLib
Inherited from
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
tx input, must be a segwit input
Returns
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
the satoshi amount
Returns
a ByteString