script

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const (
	WITNESS_V0_SCRIPTHASH_SIZE = 32
	WITNESS_V0_KEYHASH_SIZE    = 20
)
View Source
const (
	// push value
	OP_0         = byte(0x00)
	OP_FALSE     = OP_0
	OP_PUSHDATA1 = byte(0x4c)
	OP_PUSHDATA2 = byte(0x4d)
	OP_PUSHDATA4 = byte(0x4e)
	OP_1NEGATE   = byte(0x4f)
	OP_RESERVED  = byte(0x50)
	OP_1         = byte(0x51)
	OP_TRUE      = OP_1
	OP_2         = byte(0x52)
	OP_3         = byte(0x53)
	OP_4         = byte(0x54)
	OP_5         = byte(0x55)
	OP_6         = byte(0x56)
	OP_7         = byte(0x57)
	OP_8         = byte(0x58)
	OP_9         = byte(0x59)
	OP_10        = byte(0x5a)
	OP_11        = byte(0x5b)
	OP_12        = byte(0x5c)
	OP_13        = byte(0x5d)
	OP_14        = byte(0x5e)
	OP_15        = byte(0x5f)
	OP_16        = byte(0x60)

	// control
	OP_NOP      = byte(0x61)
	OP_VER      = byte(0x62)
	OP_IF       = byte(0x63)
	OP_NOTIF    = byte(0x64)
	OP_VERIF    = byte(0x65)
	OP_VERNOTIF = byte(0x66)
	OP_ELSE     = byte(0x67)
	OP_ENDIF    = byte(0x68)
	OP_VERIFY   = byte(0x69)
	OP_RETURN   = byte(0x6a)

	// stack ops
	OP_TOALTSTACK   = byte(0x6b)
	OP_FROMALTSTACK = byte(0x6c)
	OP_2DROP        = byte(0x6d)
	OP_2DUP         = byte(0x6e)
	OP_3DUP         = byte(0x6f)
	OP_2OVER        = byte(0x70)
	OP_2ROT         = byte(0x71)
	OP_2SWAP        = byte(0x72)
	OP_IFDUP        = byte(0x73)
	OP_DEPTH        = byte(0x74)
	OP_DROP         = byte(0x75)
	OP_DUP          = byte(0x76)
	OP_NIP          = byte(0x77)
	OP_OVER         = byte(0x78)
	OP_PICK         = byte(0x79)
	OP_ROLL         = byte(0x7a)
	OP_ROT          = byte(0x7b)
	OP_SWAP         = byte(0x7c)
	OP_TUCK         = byte(0x7d)

	// splice ops
	OP_CAT    = byte(0x7e)
	OP_SUBSTR = byte(0x7f)
	OP_LEFT   = byte(0x80)
	OP_RIGHT  = byte(0x81)
	OP_SIZE   = byte(0x82)

	// bit logic
	OP_INVERT      = byte(0x83)
	OP_AND         = byte(0x84)
	OP_OR          = byte(0x85)
	OP_XOR         = byte(0x86)
	OP_EQUAL       = byte(0x87)
	OP_EQUALVERIFY = byte(0x88)
	OP_RESERVED1   = byte(0x89)
	OP_RESERVED2   = byte(0x8a)

	// numeric
	OP_1ADD      = byte(0x8b)
	OP_1SUB      = byte(0x8c)
	OP_2MUL      = byte(0x8d)
	OP_2DIV      = byte(0x8e)
	OP_NEGATE    = byte(0x8f)
	OP_ABS       = byte(0x90)
	OP_NOT       = byte(0x91)
	OP_0NOTEQUAL = byte(0x92)

	OP_ADD    = byte(0x93)
	OP_SUB    = byte(0x94)
	OP_MUL    = byte(0x95)
	OP_DIV    = byte(0x96)
	OP_MOD    = byte(0x97)
	OP_LSHIFT = byte(0x98)
	OP_RSHIFT = byte(0x99)

	OP_BOOLAND            = byte(0x9a)
	OP_BOOLOR             = byte(0x9b)
	OP_NUMEQUAL           = byte(0x9c)
	OP_NUMEQUALVERIFY     = byte(0x9d)
	OP_NUMNOTEQUAL        = byte(0x9e)
	OP_LESSTHAN           = byte(0x9f)
	OP_GREATERTHAN        = byte(0xa0)
	OP_LESSTHANOREQUAL    = byte(0xa1)
	OP_GREATERTHANOREQUAL = byte(0xa2)
	OP_MIN                = byte(0xa3)
	OP_MAX                = byte(0xa4)
	OP_WITHIN             = byte(0xa5)

	// crypto
	OP_RIPEMD160           = byte(0xa6)
	OP_SHA1                = byte(0xa7)
	OP_SHA256              = byte(0xa8)
	OP_HASH160             = byte(0xa9)
	OP_HASH256             = byte(0xaa)
	OP_CODESEPARATOR       = byte(0xab)
	OP_CHECKSIG            = byte(0xac)
	OP_CHECKSIGVERIFY      = byte(0xad)
	OP_CHECKMULTISIG       = byte(0xae)
	OP_CHECKMULTISIGVERIFY = byte(0xaf)

	// expansion
	OP_NOP1                = byte(0xb0)
	OP_CHECKLOCKTIMEVERIFY = byte(0xb1)
	OP_NOP2                = OP_CHECKLOCKTIMEVERIFY
	OP_CHECKSEQUENCEVERIFY = byte(0xb2)
	OP_NOP3                = OP_CHECKSEQUENCEVERIFY
	OP_NOP4                = byte(0xb3)
	OP_NOP5                = byte(0xb4)
	OP_NOP6                = byte(0xb5)
	OP_NOP7                = byte(0xb6)
	OP_NOP8                = byte(0xb7)
	OP_NOP9                = byte(0xb8)
	OP_NOP10               = byte(0xb9)

	// template matching params
	OP_SMALLINTEGER = byte(0xfa)
	OP_PUBKEYS      = byte(0xfb)
	OP_PUBKEYHASH   = byte(0xfd)
	OP_PUBKEY       = byte(0xfe)

	OP_INVALIDOPCODE = byte(0xff)
)
View Source
const (
	TX_NONSTANDARD = iota
	// 'standard' transaction types:
	TX_PUBKEY
	TX_PUBKEYHASH
	TX_SCRIPTHASH
	TX_MULTISIG
	TX_NULL_DATA //!< unspendable OP_RETURN script that carries data
	TX_WITNESS_V0_SCRIPTHASH
	TX_WITNESS_V0_KEYHASH
	TX_WITNESS_UNKNOWN //!< Only for Witness versions not already defined above
)

Variables

This section is empty.

Functions

func DecodeOPN

func DecodeOPN(opCode byte) int

func ExtractDestination

func ExtractDestination(scriptPubKey Script) (bool, int, []string)

func GetScriptTypeStr

func GetScriptTypeStr(scriptType int) string

func IsMultiAddress

func IsMultiAddress(scriptType int) bool

func IsNoneAddress

func IsNoneAddress(scriptType int) bool

func IsSingleAddress

func IsSingleAddress(scriptType int) bool

func Solver

func Solver(scriptPubKey Script) (bool, int, [][]byte)

Types

type Script

type Script struct {
	// contains filtered or unexported fields
}

func (Script) GetScriptBytes

func (s Script) GetScriptBytes() []byte

func (Script) GetScriptLength

func (s Script) GetScriptLength() int

func (Script) IsMultiSig

func (s Script) IsMultiSig() bool

func (Script) IsPayToPubKey

func (s Script) IsPayToPubKey() bool

func (Script) IsPayToPubKeyHash

func (s Script) IsPayToPubKeyHash() bool

func (Script) IsPayToScriptHash

func (s Script) IsPayToScriptHash() bool

func (Script) IsPayToWitnessScriptHash

func (s Script) IsPayToWitnessScriptHash() bool

func (Script) IsWitnessProgram

func (s Script) IsWitnessProgram() (bool, int, []byte)

func (Script) Pack

func (s Script) Pack(writer io.Writer) error

func (Script) PackToHex

func (s Script) PackToHex() (string, error)

func (*Script) SetScriptBytes

func (s *Script) SetScriptBytes(scriptBytes []byte)

func (*Script) UnPack

func (s *Script) UnPack(reader io.Reader) error

func (*Script) UnPackFromHex

func (s *Script) UnPackFromHex(hexStr string) error

type ScriptWitness

type ScriptWitness struct {
	// contains filtered or unexported fields
}

func (ScriptWitness) GetScriptWitnessBytes

func (s ScriptWitness) GetScriptWitnessBytes() [][]byte

func (ScriptWitness) Pack

func (s ScriptWitness) Pack(writer io.Writer) error

func (ScriptWitness) PackToHex

func (s ScriptWitness) PackToHex() (string, error)

func (*ScriptWitness) SetScriptWitnessBytes

func (s *ScriptWitness) SetScriptWitnessBytes(witnessBytes [][]byte)

func (*ScriptWitness) UnPack

func (s *ScriptWitness) UnPack(reader io.Reader) error

func (*ScriptWitness) UnPackFromHex

func (s *ScriptWitness) UnPackFromHex(hexStr string) error

Jump to

Keyboard shortcuts

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