script

package
v0.0.0-...-32c8a8c Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScriptVersion = 0
)

Variables

This section is empty.

Functions

func DecodeInt64

func DecodeInt64(opcode byte, script []byte) (int64, []byte, error)

DecodeInt64 decodes a Bitcoin script integer from the provided script. It handles OP_0, OP_1NEGATE, OP_1-OP_16, and minimally encoded integers.

func DecodeMultiSigScript

func DecodeMultiSigScript(script []byte) ([][]byte, error)

func DecodeTimelockScript

func DecodeTimelockScript(timelockScript []byte) (int64, []byte, error)

func DecodeTransferScript

func DecodeTransferScript(script []byte, params *chaincfg.Params) (btcutil.Address, error)

func EncodeMultiSigScript

func EncodeMultiSigScript(network types.Network, pubKeys [][]byte, nRequired int) ([]byte, error)

func EncodeTimeLockScript

func EncodeTimeLockScript(lockTime int64, redeemScript []byte) ([]byte, error)

func EncodeTransferScript

func EncodeTransferScript(address btcutil.Address) ([]byte, error)

func OpReturnScript

func OpReturnScript(data []byte) ([]byte, error)

Types

type AfterNode

type AfterNode struct {
	Time int64
}

AfterNod represents a locktime argument if Time is less than 500000000, it is a block height otherwise, it is a unix timestamp

func (*AfterNode) FromScript

func (a *AfterNode) FromScript(script []byte) error

func (*AfterNode) ToScript

func (a *AfterNode) ToScript(builder *txscript.ScriptBuilder)

func (*AfterNode) Validate

func (a *AfterNode) Validate() error

type CompositeNode

type CompositeNode struct {
	Children []Node
}

CompositeNode represents a logical combination ( and, or ) of child nodes

func (*CompositeNode) ToScript

func (a *CompositeNode) ToScript(builder *txscript.ScriptBuilder)

func (*CompositeNode) Validate

func (a *CompositeNode) Validate() error

type LeafArgs

type LeafArgs struct {
	Script  string                        // Script for this leaf node
	Version txscript.TapscriptLeafVersion // Leaf version (default: 0xc0 for Taproot v1)
}

LeafArgs represents a Taproot leaf node

func (*LeafArgs) FromScript

func (a *LeafArgs) FromScript(script []byte) error

func (*LeafArgs) ToScript

func (a *LeafArgs) ToScript(builder *txscript.ScriptBuilder)

func (*LeafArgs) Validate

func (a *LeafArgs) Validate() error

type MultiNode

type MultiNode struct {
	Required int
	Keys     []string
}

MultiNode represents a multisig argument

func (*MultiNode) ToScript

func (a *MultiNode) ToScript(builder *txscript.ScriptBuilder)

func (*MultiNode) Validate

func (a *MultiNode) Validate() error

type Node

type Node interface {
	Validate() error
	ToScript(*txscript.ScriptBuilder)
}

type NodeType

type NodeType string
const (
	Pk           NodeType = "pk"
	Pkh          NodeType = "pkh"
	Older        NodeType = "older"
	After        NodeType = "after"
	Thresh       NodeType = "thresh"
	And          NodeType = "and_b"
	Or           NodeType = "or_b"
	Multi        NodeType = "multi"
	CheckSig     NodeType = "checksig"
	CheckSigHash NodeType = "checksighash"
	Tr           NodeType = "taproot"
	Leaf         NodeType = "leaf"
)

type OlderNode

type OlderNode struct {
	Time int64
}

OlderNode represents a relative locktime argument

func (*OlderNode) FromScript

func (a *OlderNode) FromScript(script []byte) error

func (*OlderNode) SetBlock

func (a *OlderNode) SetBlock(height int64) error

func (*OlderNode) SetTime

func (a *OlderNode) SetTime(seconds int64) error

func (*OlderNode) ToScript

func (a *OlderNode) ToScript(builder *txscript.ScriptBuilder)

func (*OlderNode) Validate

func (a *OlderNode) Validate() error

type PkNode

type PkNode struct {
	PubKey []byte
}

PkNode represents a public key argument

func (*PkNode) FromScript

func (a *PkNode) FromScript(script []byte) error

func (*PkNode) ToScript

func (a *PkNode) ToScript(builder *txscript.ScriptBuilder)

func (*PkNode) Validate

func (a *PkNode) Validate() error

type PkhNode

type PkhNode struct {
	Hash []byte
}

PkhNode represents a public key hash argument

func (*PkhNode) FromScript

func (a *PkhNode) FromScript(script []byte) error

func (*PkhNode) ToScript

func (a *PkhNode) ToScript(builder *txscript.ScriptBuilder)

func (*PkhNode) Validate

func (a *PkhNode) Validate() error

type ThreshNode

type ThreshNode struct {
	Threshold int
	Children  []Node
}

ThreshNode represents a threshold condition

func (*ThreshNode) ToScript

func (a *ThreshNode) ToScript(builder *txscript.ScriptBuilder)

func (*ThreshNode) Validate

func (a *ThreshNode) Validate() error

type TrArgs

type TrArgs struct {
	InternalKey string
	MerkleRoot  string
}

TrArgs represents a Taproot script

func (*TrArgs) ToScript

func (a *TrArgs) ToScript(builder *txscript.ScriptBuilder)

func (*TrArgs) Validate

func (a *TrArgs) Validate() error

Jump to

Keyboard shortcuts

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