custominstructions

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Type42 string = "type42"
	Sign   string = "sign"
)

Types for custom instructions

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressResolver

type AddressResolver struct {
	Address *script.Address
	// contains filtered or unexported fields
}

AddressResolver implements resolver for custom instructions that resolve a public key to an address.

func (*AddressResolver) Finalize

func (ar *AddressResolver) Finalize() error

Finalize ensures that the address is resolved.

func (*AddressResolver) Initialize

func (ar *AddressResolver) Initialize(key *primitives.PublicKey) error

Initialize initializes the address resolver with a public key.

func (*AddressResolver) Sign

func (ar *AddressResolver) Sign(_ string) (bool, error)

Sign derives an address from the current public key.

func (*AddressResolver) Type42

func (ar *AddressResolver) Type42(instruction string) (bool, error)

Type42 derives a new public key from the current public key using a type42 method.

type InputKeys

type InputKeys interface {
	primitives.PublicKey | primitives.PrivateKey
}

InputKeys is a union type that can be either a public or private key. It is used to define the type of the key that is being used as input for the interpreter.

type Interpreter

type Interpreter[R Resolver[TKey], TKey InputKeys] struct {
	// contains filtered or unexported fields
}

Interpreter is a struct that is used to interpret custom instructions.

func NewAddressInterpreter

func NewAddressInterpreter() *Interpreter[*AddressResolver, primitives.PublicKey]

NewAddressInterpreter creates a new custom instructions interpreter that resolves a public key to an address.

func NewInterpreter

func NewInterpreter[R Resolver[TKey], TKey InputKeys](resolver R) *Interpreter[R, TKey]

NewInterpreter creates a new interpreter for custom instructions with a given resolver.

func NewLockingScriptInterpreter

func NewLockingScriptInterpreter() *Interpreter[*LockingScriptResolver, primitives.PublicKey]

NewLockingScriptInterpreter creates a new custom instructions interpreter that resolves a public key to a locking script (and address).

func (*Interpreter[I, TKey]) Process

func (p *Interpreter[I, TKey]) Process(key *TKey, instructions bsv.CustomInstructions) (I, error)

Process processes custom instructions for a given key.

type LockingScriptResolver

type LockingScriptResolver struct {
	AddressResolver

	LockingScript *script.Script
}

LockingScriptResolver implements resolver for custom instructions that resolve a public key to a locking script (and address). Uses the AddressResolver because a locking script is easily derived from an address.

func (*LockingScriptResolver) Finalize

func (lr *LockingScriptResolver) Finalize() error

Finalize ensures that the address is resolved and derives the locking script from the address.

type Resolver

type Resolver[TKey InputKeys] interface {
	Type42(instruction string) (proceed bool, err error)
	Sign(instruction string) (proceed bool, err error)

	Initialize(key *TKey) error
	Finalize() error
}

Resolver is an interface that is used to resolve custom instructions. It is used by the interpreter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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