Class: Opcode

script.Opcode(value, datanullable)

Opcode A simple struct which contains an opcode and pushdata buffer.

Constructor

new Opcode(value, datanullable)

Create an opcode. Note: this should not be called directly.

Parameters:
Name Type Attributes Description
value Number

Opcode.

data Buffer <nullable>

Pushdata buffer.

Properties:
Name Type Description
value Number
data Buffer | null
Source:

Methods

(static) decode(data) → {Opcode}

Instantiate opcode from serialized data.

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
Opcode

(static) fromBool(value) → {Opcode}

Instantiate an opcode from a Number.

Parameters:
Name Type Description
value Boolean
Source:
Returns:
Type
Opcode

(static) fromData(data) → {Opcode}

Instantiate a pushdata opcode from a buffer (will encode minimaldata).

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
Opcode

(static) fromInt(num) → {Opcode}

Instantiate an opcode from a Number.

Parameters:
Name Type Description
num Number
Source:
Returns:
Type
Opcode

(static) fromNum(num) → {Opcode}

Instantiate an opcode from a ScriptNum.

Parameters:
Name Type Description
num ScriptNumber
Source:
Returns:
Type
Opcode

(static) fromOp(op) → {Opcode}

Instantiate an opcode from a number opcode.

Parameters:
Name Type Description
op Number
Source:
Returns:
Type
Opcode

(static) fromPush(data) → {Opcode}

Instantiate a pushdata opcode from a buffer (this differs from fromData in that it will always be a pushdata op).

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
Opcode

(static) fromSmall(num) → {Opcode}

Instantiate an opcode from a small number.

Parameters:
Name Type Description
num Number
Source:
Returns:
Type
Opcode

(static) fromString(str, encopt) → {Opcode}

Instantiate a pushdata opcode from a string.

Parameters:
Name Type Attributes Default Description
str String
enc String <optional>
utf8
Source:
Returns:
Type
Opcode

(static) fromSymbol(name) → {Opcode}

Instantiate a pushdata opcode from symbolic name.

Parameters:
Name Type Description
name String
Source:
Returns:
Type
Opcode
Example
Opcode.fromSymbol('checksequenceverify')

(static) isOpcode(obj) → {Boolean}

Test whether an object an Opcode.

Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Boolean

(static) read(br) → {Opcode}

Instantiate opcode from buffer reader.

Parameters:
Name Type Description
br BufferReader
Source:
Returns:
Type
Opcode

encode() → {Buffer}

Encode the opcode.

Source:
Returns:
Type
Buffer

equals(op) → {Boolean}

Test opcode equality.

Parameters:
Name Type Description
op Opcode
Source:
Returns:
Type
Boolean

getSize() → {Number}

Calculate opcode size.

Source:
Returns:
Type
Number

isBranch() → {Boolean}

Test whether opcode is a branch (if/else/endif).

Source:
Returns:
Type
Boolean

isDisabled() → {Boolean}

Test whether opcode is a disabled opcode.

Source:
Returns:
Type
Boolean

isMinimal() → {Boolean}

Test whether a pushdata abides by minimaldata.

Source:
Returns:
Type
Boolean

toASM(decodenullable) → {String}

Format the opcode as bitcoind asm.

Parameters:
Name Type Attributes Description
decode Boolean <nullable>

Attempt to decode hash types.

Source:
Returns:

Human-readable script.

Type
String

toBool() → {Boolean}

Convert opcode to boolean.

Source:
Returns:
Type
Boolean

toData() → {Buffer|null}

Covert opcode to data push.

Source:
Returns:
Type
Buffer | null

toFormat() → {String}

Convert the opcode to a bitcoind test string.

Source:
Returns:

Human-readable script code.

Type
String

toInt(minimalnullable, limitnullable) → {Number}

Convert opcode to integer.

Parameters:
Name Type Attributes Description
minimal Boolean <nullable>
limit Number <nullable>
Source:
Returns:
Type
Number

toLength() → {Number}

Covert opcode to data length.

Source:
Returns:
Type
Number

toNum(minimalnullable, limitnullable) → {ScriptNum|null}

Convert opcode to script number.

Parameters:
Name Type Attributes Description
minimal Boolean <nullable>
limit Number <nullable>
Source:
Returns:
Type
ScriptNum | null

toOp() → {Number}

Convert Opcode to opcode value.

Source:
Returns:
Type
Number

toPush() → {Buffer|null}

Covert and cast opcode to data push.

Source:
Returns:
Type
Buffer | null

toSmall() → {Number}

Convert opcode to small integer.

Source:
Returns:
Type
Number

toString(encnullable) → {Buffer|null}

Get string for opcode.

Parameters:
Name Type Attributes Description
enc String <nullable>
Source:
Returns:
Type
Buffer | null

toSymbol() → {String}

Convert opcode to its symbolic representation.

Source:
Returns:
Type
String

write(bw)

Encode the opcode to a buffer writer.

Parameters:
Name Type Description
bw BufferWriter
Source: