Documentation
¶
Index ¶
Constants ¶
const ( Type42 string = "type42" Sign string = "sign" )
Types for custom instructions
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressResolver ¶
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.
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.