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
staticartifact:Artifact
Defined in: packages/scrypt-ts-btc/src/smart-contract/smartContractLib.ts:15
Inherited from
stateType?
staticoptionalstateType:string
Defined in: packages/scrypt-ts-btc/src/smart-contract/smartContractLib.ts:16
Inherited from
Methods
buildStateHashRootOutput()
staticbuildStateHashRootOutput(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()
staticcheckInputStateHash(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()
staticcheckStateHash(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()
staticcheckStateHashRoot(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()
staticloadArtifact(artifact): typeofSmartContractLib
Defined in: packages/scrypt-ts-btc/src/smart-contract/smartContractLib.ts:18
Parameters
artifact
Returns
typeof SmartContractLib
Inherited from
padEmptyStateRoots()
staticpadEmptyStateRoots(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