ScriptBuilder provides a facility for building custom scripts. It allows you to push opcodes, ints, and data while respecting canonical encoding. In general it does not ensure the script will execute correctly, however any data pushes which would exceed the maximum allowed script engine limits and are therefore guaranteed not to execute will not be pushed and will result in the Script function returning an error.

Constructors

Methods

  • AddData pushes the passed data to the end of the script. It automatically chooses canonical opcodes depending on the length of the data.

    A zero length buffer will lead to a push of empty data onto the stack (Op0 = OpFalse) and any push of data greater than MAX_SCRIPT_ELEMENT_SIZE will not modify the script since that is not allowed by the script engine.

    Also, the script will not be modified if pushing the data would cause the script to exceed the maximum allowed script engine size MAX_SCRIPTS_SIZE.

    Parameters

    • data: string | Uint8Array

    Returns ScriptBuilder

  • Pushes the passed opcode to the end of the script. The script will not be modified if pushing the opcode would cause the script to exceed the maximum allowed script engine size.

    Parameters

    • op: number

    Returns ScriptBuilder

  • Adds the passed opcodes to the end of the script. Supplied opcodes can be represented as an Uint8Array or a HexString.

    Parameters

    • opcodes: string | Uint8Array

    Returns ScriptBuilder

  • Drains (empties) the script builder, returning the script bytes represented by a hex string.

    Returns string

  • Generates a signature script that fits a pay-to-script-hash script.

    Parameters

    • signature: string | Uint8Array

    Returns string

  • Returns void

  • Parameters

    Returns string

    • Return copy of self without private attributes.

    Returns Object

  • Return stringified version of self.

    Returns string

  • Get script bytes represented by a hex string.

    Returns string

  • Parameters

    • data: string | Uint8Array

    Returns number

  • Creates a new ScriptBuilder over an existing script. Supplied script can be represented as an Uint8Array or a HexString.

    Parameters

    • script: string | Uint8Array

    Returns ScriptBuilder

Generated using TypeDoc