Skip to main content

SigHash

scrypt-ts / SigHash

Class: SigHash

A library to access various fields in the [preimage][https://github.com/bitcoin-sv/bitcoin-sv/blob/master/doc/abc/replay-protected-sighash.md](https://github.com/bitcoin-sv/bitcoin-sv/blob/master/doc/abc/replay-protected-sighash.md). For example, we usually use SigHash.scriptCode(preimage: SigHashPreimage) to access the scriptCode of the preimage, and use SigHash.value(preimage: SigHashPreimage) to access the value field of the preimage, which is the value of the number of bitcoins spent in this contract.

Table of contents​

Constructors​

Properties​

Methods​

Constructors​

constructor​

• new SigHash()

Properties​

ALL​

▪ Static Readonly ALL: SigHashType

Defined in​

dist/smart-contract/builtins/functions.d.ts:985


ANYONECANPAY_ALL​

▪ Static Readonly ANYONECANPAY_ALL: SigHashType

Defined in​

dist/smart-contract/builtins/functions.d.ts:988


ANYONECANPAY_NONE​

▪ Static Readonly ANYONECANPAY_NONE: SigHashType

Defined in​

dist/smart-contract/builtins/functions.d.ts:989


ANYONECANPAY_SINGLE​

▪ Static Readonly ANYONECANPAY_SINGLE: SigHashType

Defined in​

dist/smart-contract/builtins/functions.d.ts:990


NONE​

▪ Static Readonly NONE: SigHashType

Defined in​

dist/smart-contract/builtins/functions.d.ts:986


SINGLE​

▪ Static Readonly SINGLE: SigHashType

Defined in​

dist/smart-contract/builtins/functions.d.ts:987

Methods​

hashOutputs​

▸ Static hashOutputs(preimage): ByteString

get hashOutputs of the transaction from the preimage

Parameters​

NameTypeDescription
preimageSigHashPreimagethe preimage

Returns​

ByteString

return hashOutputs ByteString in 32-byte hash

Defined in​

dist/smart-contract/builtins/functions.d.ts:1050


hashPrevouts​

▸ Static hashPrevouts(preimage): ByteString

get hashPrevouts of the transaction from the preimage

Parameters​

NameTypeDescription
preimageSigHashPreimagethe preimage

Returns​

ByteString

return hashPrevouts ByteString in 32-byte little endian

Defined in​

dist/smart-contract/builtins/functions.d.ts:1002


hashSequence​

▸ Static hashSequence(preimage): ByteString

get hashSequence of the transaction from the preimage

Parameters​

NameTypeDescription
preimageSigHashPreimagethe preimage

Returns​

ByteString

return hashSequence ByteString in 32-byte little endian

Defined in​

dist/smart-contract/builtins/functions.d.ts:1008


nLocktime​

▸ Static nLocktime(preimage): bigint

get nLocktime of the transaction from the preimage

Parameters​

NameTypeDescription
preimageSigHashPreimagethe preimage

Returns​

bigint

return nLocktime

Defined in​

dist/smart-contract/builtins/functions.d.ts:1062


nLocktimeRaw​

▸ Static nLocktimeRaw(preimage): ByteString

get nLocktime of the transaction from the preimage

Parameters​

NameTypeDescription
preimageSigHashPreimagethe preimage

Returns​

ByteString

return nLocktime ByteString in 4-byte little endian

Defined in​

dist/smart-contract/builtins/functions.d.ts:1056


nSequence​

▸ Static nSequence(preimage): bigint

nSequence of the input from the preimage

Parameters​

NameTypeDescription
preimageSigHashPreimagethe preimage

Returns​

bigint

return nSequence

Defined in​

dist/smart-contract/builtins/functions.d.ts:1044


nSequenceRaw​

▸ Static nSequenceRaw(preimage): ByteString

nSequence of the input from the preimage

Parameters​

NameTypeDescription
preimageSigHashPreimagethe preimage

Returns​

ByteString

return nSequence ByteString in 4-byte little endian

Defined in​

dist/smart-contract/builtins/functions.d.ts:1038


nVersion​

▸ Static nVersion(preimage): ByteString

get version of the transaction from the preimage

Parameters​

NameTypeDescription
preimageSigHashPreimagethe preimage

Returns​

ByteString

return version ByteString in 4-byte little endian

Defined in​

dist/smart-contract/builtins/functions.d.ts:996


outpoint​

▸ Static outpoint(preimage): ByteString

get outpoint of the transaction from the preimage

Parameters​

NameTypeDescription
preimageSigHashPreimagethe preimage

Returns​

ByteString

return outpoint ByteString in 32-byte hash + 4-byte little endian

Defined in​

dist/smart-contract/builtins/functions.d.ts:1014


scriptCode​

▸ Static scriptCode(preimage): ByteString

get scriptCode of the transaction from the preimage. scriptCode is just scriptPubKey if there is no CODESEPARATOR in the latter

Parameters​

NameTypeDescription
preimageSigHashPreimagethe preimage

Returns​

ByteString

return scriptCode ByteString

Defined in​

dist/smart-contract/builtins/functions.d.ts:1020


sigHashType​

▸ Static sigHashType(preimage): SigHashType

sighash type of the signature from the preimage

Parameters​

NameTypeDescription
preimageSigHashPreimagethe preimage

Returns​

SigHashType

return sighash type

Defined in​

dist/smart-contract/builtins/functions.d.ts:1068


value​

▸ Static value(preimage): bigint

get value of the output spent by this input from the preimage

Parameters​

NameTypeDescription
preimageSigHashPreimagethe preimage

Returns​

bigint

return value

Defined in​

dist/smart-contract/builtins/functions.d.ts:1032


valueRaw​

▸ Static valueRaw(preimage): ByteString

get value of the output spent by this input from the preimage

Parameters​

NameTypeDescription
preimageSigHashPreimagethe preimage

Returns​

ByteString

return value ByteString in 8-byte little endian

Defined in​

dist/smart-contract/builtins/functions.d.ts:1026