StateUtils
bitcoinjs-lib / StateUtils
Class: StateUtils
Defined in: packages/scrypt-ts-btc/src/smart-contract/builtin-libs/stateUtils.ts:17
state utils library
Onchain
Extends
Constructors
new StateUtils()
new StateUtils(...
args
):StateUtils
Defined in: packages/scrypt-ts-btc/src/smart-contract/smartContractLib.ts:29
Parameters
args
...SupportedParamType
[]
Returns
Inherited from
Properties
args
args:
any
[] =[]
Defined in: packages/scrypt-ts-btc/src/smart-contract/smartContractLib.ts:28
Inherited from
artifact
static
artifact:Artifact
Defined in: packages/scrypt-ts-btc/src/smart-contract/smartContractLib.ts:15
Inherited from
stateType?
static
optional
stateType:string
Defined in: packages/scrypt-ts-btc/src/smart-contract/smartContractLib.ts:16
Inherited from
Methods
buildStateHashRootOutput()
static
buildStateHashRootOutput(stateHashes
,t_leadingStateRoots
,t_stateCount
):ByteString
Defined in: packages/scrypt-ts-btc/src/smart-contract/builtin-libs/stateUtils.ts:61
Build state output with leading state roots, and verify the user pass-in stateHashes as well
Parameters
stateHashes
user passed-in stateHashes to verify
t_leadingStateRoots
leading state roots of curTx outputs which should be trustable
t_stateCount
the number of states in curTx which should be trustable
Returns
serialized state output in format ByteString
checkInputStateHash()
static
checkInputStateHash(proof
,stateHash
,t_prevout
):void
Defined in: packages/scrypt-ts-btc/src/smart-contract/builtin-libs/stateUtils.ts:101
Check if state of prev output corresponding to an input
Parameters
proof
input state proof
stateHash
state hash of prev output corresponding to this input
t_prevout
prevout of this input which is trustable
Returns
void
checkStateHash()
static
checkStateHash(stateHashes
,stateHash
,t_hashRoot
,t_outputIndex
):void
Defined in: packages/scrypt-ts-btc/src/smart-contract/builtin-libs/stateUtils.ts:79
Use trustable hashRoot and outputIndex to check passed-in stateHashes and stateHash
Parameters
stateHashes
passed-in stateHashes
stateHash
passed-in stateHash
t_hashRoot
trustable hashRoot
t_outputIndex
trustable outputIndex
Returns
void
checkStateHashRoot()
static
checkStateHashRoot(stateHashes
,t_hashRoot
):void
Defined in: packages/scrypt-ts-btc/src/smart-contract/builtin-libs/stateUtils.ts:24
Check if stateHashes match hashRoot
Parameters
stateHashes
state hash array of tx outputs
t_hashRoot
trustable state hash root
Returns
void
loadArtifact()
static
loadArtifact(artifact
): typeofSmartContractLib
Defined in: packages/scrypt-ts-btc/src/smart-contract/smartContractLib.ts:18
Parameters
artifact
Returns
typeof SmartContractLib
Inherited from
padEmptyStateRoots()
static
padEmptyStateRoots(stateCount
):ByteString
Defined in: packages/scrypt-ts-btc/src/smart-contract/builtin-libs/stateUtils.ts:41
Pad empty state roots to fill the state root array
Parameters
stateCount
the number of states
Returns
padding state roots