Script

object Script

Types

Link copied to clipboard
data class Context(    val tx: Transaction,     val inputIndex: Int,     val amount: Satoshi,     val prevouts: List<TxOut>)

Execution context of a tx script. A script is always executed in the "context" of a transaction that is being verified.

Link copied to clipboard
data class ExecutionData(    val annex: ByteVector?,     val tapleafHash: ByteVector32?,     val validationWeightLeft: Int? = null,     val codeSeparatorPos: Long = 4294967295)
Link copied to clipboard
class Runner(val context: Script.Context, val scriptFlag: Int = ScriptFlags.MANDATORY_SCRIPT_VERIFY_FLAGS)

Functions

Link copied to clipboard
fun checkLockTime(    lockTime: Long,     tx: Transaction,     inputIndex: Int): Boolean
Link copied to clipboard
fun checkSequence(    sequence: Long,     tx: Transaction,     inputIndex: Int): Boolean
Link copied to clipboard
fun cost(op: ScriptElt): Int
Link copied to clipboard
fun createMultiSigMofN(m: Int, pubkeys: List<PublicKey>): List<ScriptElt>

Creates a m-of-n multisig script.

Link copied to clipboard
fun decodeNumber(    input: ByteVector,     checkMinimalEncoding: Boolean,     maximumSize: Int = 4): Long
fun decodeNumber(    input: ByteArray,     checkMinimalEncoding: Boolean,     maximumSize: Int = 4): Long
Link copied to clipboard
fun <T> List<T>.dropCheck(n: Int): List<T>
Link copied to clipboard
fun encodeNumber(value: Int): ByteVector
fun encodeNumber(value: Long): ByteVector
Link copied to clipboard
fun fromSimpleValue(value: Byte): ScriptElt
Link copied to clipboard
fun getWitnessVersion(script: ByteVector): Int?
fun getWitnessVersion(script: List<ScriptElt>): Int?
Link copied to clipboard
fun isDisabled(op: ScriptElt): Boolean
Link copied to clipboard
fun isNativeWitnessScript(script: ByteVector): Boolean
fun isNativeWitnessScript(script: List<ScriptElt>): Boolean
Link copied to clipboard
fun isOpSuccess(opcode: Int): Boolean
Link copied to clipboard
fun isPay2pkh(script: ByteArray): Boolean
fun isPay2pkh(script: List<ScriptElt>): Boolean
Link copied to clipboard
fun isPay2sh(script: ByteArray): Boolean
fun isPay2sh(script: List<ScriptElt>): Boolean
Link copied to clipboard
fun isPay2wpkh(script: ByteArray): Boolean
fun isPay2wpkh(script: List<ScriptElt>): Boolean
Link copied to clipboard
fun isPay2wsh(script: ByteArray): Boolean
fun isPay2wsh(script: List<ScriptElt>): Boolean
Link copied to clipboard
fun isPayToScript(script: ByteArray): Boolean
Link copied to clipboard
fun isPushOnly(script: List<ScriptElt>): Boolean
Link copied to clipboard
fun isSimpleValue(op: ScriptElt): Boolean
Link copied to clipboard
fun isUpgradableNop(op: ScriptElt): Boolean
Link copied to clipboard
fun parse(blob: ByteVector): List<ScriptElt>
fun parse(blob: ByteArray): List<ScriptElt>
fun parse(hex: String): List<ScriptElt>

fun parse(input: Input): List<ScriptElt>

parse a script from a input stream of binary data

Link copied to clipboard
fun pay2pkh(pubKey: PublicKey): List<ScriptElt>
fun pay2pkh(pubKeyHash: ByteArray): List<ScriptElt>
Link copied to clipboard
fun pay2sh(script: ByteArray): List<ScriptElt>
fun pay2sh(script: List<ScriptElt>): List<ScriptElt>
Link copied to clipboard
fun pay2tr(pubkey: XonlyPublicKey): List<ScriptElt>
Link copied to clipboard
fun pay2wpkh(pubKey: PublicKey): List<ScriptElt>
fun pay2wpkh(pubKeyHash: ByteArray): List<ScriptElt>
Link copied to clipboard
fun pay2wsh(script: ByteVector): List<ScriptElt>
fun pay2wsh(script: ByteArray): List<ScriptElt>
fun pay2wsh(script: List<ScriptElt>): List<ScriptElt>
Link copied to clipboard
fun pushSize(op: ScriptElt): Int?
Link copied to clipboard
fun removeSignature(script: List<ScriptElt>, signature: ByteVector): List<ScriptElt>
Link copied to clipboard
fun removeSignatures(script: List<ScriptElt>, sigs: List<ByteVector>): List<ScriptElt>
Link copied to clipboard
fun scriptIterator(input: Input): Iterator<ScriptElt>
fun scriptIterator(script: ByteArray): Iterator<ScriptElt>
Link copied to clipboard
fun sigHashType(sig: ByteVector): Int
fun sigHashType(sig: ByteArray): Int
Link copied to clipboard
fun simpleValue(op: ScriptElt): Byte
Link copied to clipboard
fun <T> List<T>.tail(): List<T>
Link copied to clipboard
fun witnessMultiSigMofN(pubKeys: List<PublicKey>, sigs: List<ByteVector>): ScriptWitness
Link copied to clipboard
fun witnessPay2wpkh(pubKey: PublicKey, sig: ByteVector): ScriptWitness
Link copied to clipboard
fun write(script: List<ScriptElt>): ByteArray
fun write(script: List<ScriptElt>, out: Output)

Properties

Link copied to clipboard
val False: ByteVector
Link copied to clipboard
const val LOCKTIME_THRESHOLD: Long = 500000000
Link copied to clipboard
const val MAX_OPS_PER_SCRIPT: Int = 201
Link copied to clipboard
const val MAX_SCRIPT_ELEMENT_SIZE: Int = 520
Link copied to clipboard
const val MAX_SCRIPT_SIZE: Int = 10000
Link copied to clipboard
const val MAX_STACK_SIZE: Int = 1000
Link copied to clipboard
const val TAPROOT_LEAF_MASK: Int = 254
Link copied to clipboard
const val TAPROOT_LEAF_TAPSCRIPT: Int = 192
Link copied to clipboard
val True: ByteVector
Link copied to clipboard
const val VALIDATION_WEIGHT_OFFSET: Int = 50
Link copied to clipboard
const val VALIDATION_WEIGHT_PER_SIGOP_PASSED: Int = 50
Link copied to clipboard
const val WITNESS_V0_KEYHASH_SIZE: Int = 20
Link copied to clipboard
const val WITNESS_V0_SCRIPTHASH_SIZE: Int = 32
Link copied to clipboard
const val WITNESS_V1_TAPROOT_SIZE: Int = 32