script

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisassembleString

func DisassembleString(c *cryptos.Crypto, s []byte) (string, error)

DisassembleString disassembles a script into a string

func DisassembleStrings

func DisassembleStrings(c *cryptos.Crypto, s []byte) ([]string, error)

DisassembleStrings disassembles a script into multiple strings

func ParseInt64

func ParseInt64(c *cryptos.Crypto, v []byte) (int64, error)

ParseInt64 parses the int64 for the given crypto

Types

type Disassembler

type Disassembler interface {
	DisassembleString(s []byte) (string, error)
}

Disassembler represents a script disassembler

func NewDisassemblerBCH

func NewDisassemblerBCH() Disassembler

NewDisassemblerBCH returns a new Disassembler for bitcoin-cash

func NewDisassemblerBTC

func NewDisassemblerBTC() Disassembler

NewDisassemblerBTC returns a new Disassembler for bitcoin

func NewDisassemblerDCR

func NewDisassemblerDCR() Disassembler

NewDisassemblerDCR returns a new Disassembler for decred

func NewDisassemblerDOGE

func NewDisassemblerDOGE() Disassembler

NewDisassemblerDOGE returns a new Disassembler for dogecoin

func NewDisassemblerLTC

func NewDisassemblerLTC() Disassembler

NewDisassemblerLTC returns a new Disassembler for litecoin

type Engine

type Engine struct {
	Generator Generator
	// contains filtered or unexported fields
}

Engine represents a scripting engine

func NewEngine

func NewEngine(c *cryptos.Crypto) (*Engine, error)

NewEngine returns a scripting engine for the given crypto

func NewEngineBCH

func NewEngineBCH() *Engine

NewEngineBCH returns a new *Engine for bitcoin-cash

func NewEngineBTC

func NewEngineBTC() *Engine

NewEngineBTC returns a new *Engine for bitcoin

func NewEngineDCR

func NewEngineDCR() *Engine

NewEngineDCR returns a new *Engine for decred

func NewEngineDOGE

func NewEngineDOGE() *Engine

NewEngineDOGE returns a new *Engine for dogecoin

func NewEngineLTC

func NewEngineLTC() *Engine

NewEngineLTC returns a new *Engine for litecoin

func (*Engine) Bytes

func (eng *Engine) Bytes() []byte

Bytes returns the script bytes

func (*Engine) Data

func (eng *Engine) Data(b []byte) *Engine

Data adds b as data the script

func (*Engine) HTLC

func (eng *Engine) HTLC(lockScript, tokenHash, timeLockedScript, hashLockedScript []byte) *Engine

HTLC adds an hash-time-locked contract to the script

func (*Engine) HTLCRecover

func (eng *Engine) HTLCRecover(sig, key, locksScript []byte) *Engine

HTLCRecover recovers an htlc to the script

func (*Engine) HTLCRedeem

func (eng *Engine) HTLCRedeem(sig, key, token, locksScript []byte) *Engine

HTLCRedeem redeems an htlc to the script

func (*Engine) HashLock

func (eng *Engine) HashLock(h []byte, verify bool) *Engine

HashLock adds an hashlock to the script

func (*Engine) If

func (eng *Engine) If(i, e []byte) *Engine

If adds an if-else to the script

func (*Engine) Int64

func (eng *Engine) Int64(n int64) *Engine

Int64 adds n as data to the script

func (*Engine) LockTime

func (eng *Engine) LockTime(lock int64) *Engine

LockTime adds a timelock to the script using a fixed int

func (*Engine) LockTimeTime

func (eng *Engine) LockTimeTime(t time.Time) *Engine

LockTimeTime adds a timelock to the script using an absolute time

func (*Engine) MSTLC

func (eng *Engine) MSTLC(lockScript, timeLockedScript []byte, nRequired int64, pubKeys ...[]byte) *Engine

MSTLC adds a multisig-time-lock contract to the script

func (*Engine) P2MS

func (eng *Engine) P2MS(verify bool, nRequired int64, pubKeys ...[]byte) *Engine

P2MS adds a p2ms contract to the script

func (*Engine) P2PKHHash

func (eng *Engine) P2PKHHash(hash []byte) *Engine

P2PKHHash adds a p2pkh contract to the script using the key hash

func (*Engine) P2PKHPublic

func (eng *Engine) P2PKHPublic(pub []byte) *Engine

P2PKHPublic adds a p2pkh contract to the script using the public key

func (*Engine) P2PKPublic

func (eng *Engine) P2PKPublic(pub []byte) *Engine

P2PKPublic adds a p2pk contract to the script using the public key

func (*Engine) P2SHHash

func (eng *Engine) P2SHHash(h []byte) *Engine

P2SHHash adds a p2sh contract to the script using the script hash

func (*Engine) P2SHScript

func (eng *Engine) P2SHScript(s []byte) *Engine

P2SHScript adds a p2sh contract to the script using the script s

func (*Engine) Sequence

func (eng *Engine) Sequence(lock int64) *Engine

Sequence adds a sequence check to the script

func (*Engine) SetBytes

func (eng *Engine) SetBytes(b []byte)

SetBytes sets the script bytes

type Generator

type Generator interface {
	// If else statement. If e is nil an else branch will not be present
	If(i, e []byte) []byte
	// Data returns the bytes as data
	Data(b []byte) []byte
	// Int64 returns n as data
	Int64(n int64) []byte
	// P2PKHHash returns a p2pkh contract using the hash
	P2PKHHash(hash []byte) []byte
	// P2PKHPublic returns a p2pkh contract using the public key
	P2PKHPublic(pub []byte) []byte
	// P2PKPublic returns a p2pk contract using the public key
	P2PKPublic(pub []byte) []byte
	// P2SHHash returns a p2sh contract using the hash
	P2SHHash(h []byte) []byte
	// P2SHScript returns a p2sh contract using the script
	P2SHScript(s []byte) []byte
	// P2SHRedeem returns a script to redeem a p2sh contract
	P2SHRedeem(s []byte, pref ...[]byte) []byte
	// P2MS returns a p2ms contract
	P2MS(verify bool, nRequired int64, pubKeys ...[]byte) []byte
	// LockTime returns an absolute timelock using an int
	LockTime(lock int64) []byte
	// LockTimeTime returns an absolute timelock using an time.Time
	LockTimeTime(t time.Time) []byte
	// Sequence returns a relative timelock using an int
	Sequence(lock int64) []byte
	// HashLock returns an hashlock
	HashLock(h []byte, verify bool) []byte
	// HTLC returns returns an hash time locked contract
	HTLC(lockScript, tokenHash, timeLockedScript, hashLockedScript []byte) []byte
	// HTLCRedeem returns the script to redeem an htlc
	HTLCRedeem(sig, key, token, locksScript []byte) []byte
	// HTLCRecover returns the script to recover an htlc
	HTLCRecover(sig, key, locksScript []byte) []byte
	// MSTLC returns a multi-sig time locked contract
	MSTLC(lockScript, timeLockedScript []byte, nRequired int64, pubKeys ...[]byte) []byte
}

Generator represents a script generator

func NewGenerator

func NewGenerator(c *cryptos.Crypto) (Generator, error)

NewGenerator returns a generator for the given crypto

func NewGeneratorBCH

func NewGeneratorBCH() Generator

NewGeneratorBCH returns a new bitcoin-cash generator

func NewGeneratorBTC

func NewGeneratorBTC() Generator

NewGeneratorBTC returns a new bitcoin generator

func NewGeneratorDCR

func NewGeneratorDCR() Generator

NewGeneratorDCR returns a new decred generator

func NewGeneratorDOGE

func NewGeneratorDOGE() Generator

NewGeneratorDOGE returns a new dogecoin generator

func NewGeneratorLTC

func NewGeneratorLTC() Generator

NewGeneratorLTC returns a new litecoin generator

type IntParser

type IntParser interface{ ParseInt64(v []byte) (int64, error) }

IntParser represent and int64 parser

func NewIntParserBCH

func NewIntParserBCH() IntParser

NewIntParserBCH returns a new int64 parser for bitcoin-cash

func NewIntParserBTC

func NewIntParserBTC() IntParser

NewIntParserBTC returns a new int64 parser for bitcoin

func NewIntParserDCR

func NewIntParserDCR() IntParser

NewIntParserDCR returns a new int64 parser for decred

func NewIntParserDOGE

func NewIntParserDOGE() IntParser

NewIntParserDOGE returns a new int64 parser for dogecoin

func NewIntParserLTC

func NewIntParserLTC() IntParser

NewIntParserLTC returns a new int64 parser for litecoin

type SequenceNumberBTC

type SequenceNumberBTC int64

SequenceNumberBTC represents the nSequence field in bitcoin

func (SequenceNumberBTC) Disable

Disable the lock

func (SequenceNumberBTC) IsSeconds

func (s SequenceNumberBTC) IsSeconds() SequenceNumberBTC

IsSeconds sets the seconds bit (use blocks otherwise)

func (SequenceNumberBTC) Set

Set the sequence value from an int32

func (SequenceNumberBTC) SetDuration

Set the sequence value from a time.Duration

Jump to

Keyboard shortcuts

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