Help us shape the future of Go! Take the 2026 Go Developer Survey

script

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2025 License: MIT Imports: 12 Imported by: 21

Documentation

Index

Constants

View Source
const (
	OP_INSPECTOUTPUTSCRIPTPUBKEY = 0xd1
	OP_INSPECTOUTPUTVALUE        = 0xcf
	OP_PUSHCURRENTINPUTINDEX     = 0xcd
	OP_INSPECTINPUTVALUE         = 0xc9
	OP_SUB64                     = 0xd8
)

Variables

View Source
var ConditionWitnessKey = "condition"
View Source
var ErrNoExitLeaf = fmt.Errorf("no exit leaf")

Functions

func EncodeTaprootSignature added in v0.7.1

func EncodeTaprootSignature(sig []byte, sigHashType txscript.SigHashType) []byte

func EvaluateScriptToBool

func EvaluateScriptToBool(script []byte, witness wire.TxWitness) (bool, error)

EvaluateScriptToBool executes the script with the provided witness as argument and returns a boolean result that can be evaluated by OP_IF / OP_NOIF opcodes.

func FinalizeVtxoScript added in v0.8.0

func FinalizeVtxoScript(ptx *psbt.Packet, inputIndex int) error

FinalizeVtxoScript finalizes the given input as vtxo script IF the witness utxo is a decodable vtxo script closure.

func IsSubDustScript

func IsSubDustScript(script []byte) bool

func P2TRScript

func P2TRScript(taprootKey *btcec.PublicKey) ([]byte, error)

func ParseTaprootSignature added in v0.7.1

func ParseTaprootSignature(rawSig []byte) (*schnorr.Signature, txscript.SigHashType, error)

func SubDustScript

func SubDustScript(taprootKey *btcec.PublicKey) ([]byte, error)

func UnspendableKey

func UnspendableKey() *btcec.PublicKey

Types

type CLTVMultisigClosure

type CLTVMultisigClosure struct {
	MultisigClosure
	Locktime arklib.AbsoluteLocktime
}

CLTVMultisigClosure is a closure that contains a list of public keys and a CHECKLOCKTIMEVERIFY. The witness size is 64 bytes per key, admitting the sighash type is SIGHASH_DEFAULT.

func (*CLTVMultisigClosure) Decode

func (d *CLTVMultisigClosure) Decode(script []byte) (bool, error)

func (*CLTVMultisigClosure) Script

func (d *CLTVMultisigClosure) Script() ([]byte, error)

func (*CLTVMultisigClosure) Witness

func (f *CLTVMultisigClosure) Witness(
	controlBlock []byte, signatures map[string][]byte,
) (wire.TxWitness, error)

type CSVMultisigClosure

type CSVMultisigClosure struct {
	MultisigClosure
	Locktime arklib.RelativeLocktime
}

CSVMultisigClosure is a closure that contains a list of public keys and a CHECKSEQUENCEVERIFY. The witness size is 64 bytes per key, admitting the sighash type is SIGHASH_DEFAULT.

func (*CSVMultisigClosure) Decode

func (d *CSVMultisigClosure) Decode(script []byte) (bool, error)

func (*CSVMultisigClosure) Script

func (d *CSVMultisigClosure) Script() ([]byte, error)

func (*CSVMultisigClosure) Witness

func (f *CSVMultisigClosure) Witness(
	controlBlock []byte, signatures map[string][]byte,
) (wire.TxWitness, error)

type Closure

type Closure interface {
	Script() ([]byte, error)
	Decode(script []byte) (bool, error)
	Witness(controlBlock []byte, opts map[string][]byte) (wire.TxWitness, error)
}

func DecodeClosure

func DecodeClosure(script []byte) (Closure, error)

type ConditionCSVMultisigClosure

type ConditionCSVMultisigClosure struct {
	CSVMultisigClosure
	Condition []byte
}

ConditionCSVMultisigClosure is a closure that contains a condition and a CSV multisig closure. The condition is a boolean script that is executed with the multisig witness.

func (*ConditionCSVMultisigClosure) Decode

func (f *ConditionCSVMultisigClosure) Decode(script []byte) (bool, error)

func (*ConditionCSVMultisigClosure) Script

func (f *ConditionCSVMultisigClosure) Script() ([]byte, error)

func (*ConditionCSVMultisigClosure) Witness

func (f *ConditionCSVMultisigClosure) Witness(
	controlBlock []byte, args map[string][]byte,
) (wire.TxWitness, error)

type ConditionMultisigClosure

type ConditionMultisigClosure struct {
	MultisigClosure
	Condition []byte
}

ConditionMultisigClosure is a closure that contains a condition and a multisig closure. The condition is a boolean script that is executed with the multisig witness.

func (*ConditionMultisigClosure) Decode

func (f *ConditionMultisigClosure) Decode(script []byte) (bool, error)

func (*ConditionMultisigClosure) Script

func (f *ConditionMultisigClosure) Script() ([]byte, error)

func (*ConditionMultisigClosure) Witness

func (f *ConditionMultisigClosure) Witness(
	controlBlock []byte, args map[string][]byte,
) (wire.TxWitness, error)

type MultisigClosure

type MultisigClosure struct {
	PubKeys []*btcec.PublicKey
	Type    MultisigType
}

MultisigClosure is a closure that contains a list of public keys and a CHECKSIG for each key. The witness size is 64 bytes per key, admitting the sighash type is SIGHASH_DEFAULT.

func (*MultisigClosure) Decode

func (f *MultisigClosure) Decode(script []byte) (bool, error)

func (*MultisigClosure) Script

func (f *MultisigClosure) Script() ([]byte, error)

func (*MultisigClosure) Witness

func (f *MultisigClosure) Witness(
	controlBlock []byte, signatures map[string][]byte,
) (wire.TxWitness, error)

type MultisigType

type MultisigType int
const (
	MultisigTypeChecksig MultisigType = iota
	MultisigTypeChecksigAdd
)

type TapscriptsVtxoScript

type TapscriptsVtxoScript struct {
	Closures []Closure
}

func NewDefaultVtxoScript

func NewDefaultVtxoScript(
	owner, signer *btcec.PublicKey, exitDelay arklib.RelativeLocktime,
) *TapscriptsVtxoScript

NewDefaultVtxoScript returns the common VTXO script: A + S | A after T with: - A: the owner of the VTXO. - S: the pubkey of the signer who provided the liquidity for the VTXO. - T: exit delay that must be waited by alice to spend the VTXO once unrolled onchain.

func (*TapscriptsVtxoScript) Decode

func (v *TapscriptsVtxoScript) Decode(scripts []string) error

func (*TapscriptsVtxoScript) Encode

func (v *TapscriptsVtxoScript) Encode() ([]string, error)

func (*TapscriptsVtxoScript) ExitClosures

func (v *TapscriptsVtxoScript) ExitClosures() []Closure

func (*TapscriptsVtxoScript) ForfeitClosures

func (v *TapscriptsVtxoScript) ForfeitClosures() []Closure

func (*TapscriptsVtxoScript) SmallestExitDelay

func (v *TapscriptsVtxoScript) SmallestExitDelay() (*arklib.RelativeLocktime, error)

func (*TapscriptsVtxoScript) TapTree

func (v *TapscriptsVtxoScript) TapTree() (*btcec.PublicKey, taprootTree, error)

func (*TapscriptsVtxoScript) Validate

func (v *TapscriptsVtxoScript) Validate(
	signer *btcec.PublicKey, minLocktime arklib.RelativeLocktime, blockTypeAllowed bool,
) error

type VtxoScript

type VtxoScript arklib.VtxoScript[taprootTree, Closure]

func ParseVtxoScript

func ParseVtxoScript(scripts []string) (VtxoScript, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL