Skip to main content

StateUtils

bitcoinjs-lib v0.2.9-beta.16


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​

StateUtils

Inherited from​

SmartContractLib.constructor

Properties​

args​

args: any[] = []

Defined in: packages/scrypt-ts-btc/src/smart-contract/smartContractLib.ts:28

Inherited from​

SmartContractLib.args


artifact​

static artifact: Artifact

Defined in: packages/scrypt-ts-btc/src/smart-contract/smartContractLib.ts:15

Inherited from​

SmartContractLib.artifact


stateType?​

static optional stateType: string

Defined in: packages/scrypt-ts-btc/src/smart-contract/smartContractLib.ts:16

Inherited from​

SmartContractLib.stateType

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​

StateHashes

user passed-in stateHashes to verify

t_leadingStateRoots​

ByteString

leading state roots of curTx outputs which should be trustable

t_stateCount​

Int32

the number of states in curTx which should be trustable

Returns​

ByteString

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​

InputStateProof

input state proof

stateHash​

ByteString

state hash of prev output corresponding to this input

t_prevout​

ByteString

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​

StateHashes

passed-in stateHashes

stateHash​

ByteString

passed-in stateHash

t_hashRoot​

ByteString

trustable hashRoot

t_outputIndex​

Int32

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​

StateHashes

state hash array of tx outputs

t_hashRoot​

ByteString

trustable state hash root

Returns​

void


loadArtifact()​

static loadArtifact(artifact): typeof SmartContractLib

Defined in: packages/scrypt-ts-btc/src/smart-contract/smartContractLib.ts:18

Parameters​

artifact​

Artifact

Returns​

typeof SmartContractLib

Inherited from​

SmartContractLib.loadArtifact


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​

Int32

the number of states

Returns​

ByteString

padding state roots