scryptlib

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: MIT Imports: 29 Imported by: 0

README

go-scryptlib

An sCrypt SDK for the Go language.

You can learn all about writing sCrypt smart contracts in the official docs.

Installation

Compiler

To use the SDK, you need to get a copy of the sCrypt compiler. You can get it either by downloading the sCrypt IDE or executing the following command, if you have an UNIX-like OS:

curl -Ls https://scrypt.io/setup | sh -s --

This will download the latest version of the compiler.

You can also download a specific version of the compiler using the -v flag:

curl -Ls https://scrypt.io/setup | sh -s -- -v 1.3.2
SDK

For installing the SDK itself, run the following command

go get github.com/sCrypt-Inc/go-scryptlib

Usage

Compiling an sCrypt contract

To compile an sCrypt contract, we must first initialize a CompilerWrapper:

compilerBin, _ := FindCompiler()

compilerWrapper := CompilerWrapper {
        CompilerBin: compilerBin,
        OutDir: "./out",
        HexOut: true,
        Debug: true,
        Desc: true,
        Stack: true,
        Optimize: false,
        CmdArgs: "",
        Cwd: "./",
    }

Once that is initialized, we can compile the contract:

compilerResult, _ := compilerWrapper.CompileContractFile("./test/res/demo.scrypt")

This leaves us with a struct of type CompilerResult. This step also outputs results of the compiler, and a contract description file in the "./out" directory, which we passed as a parameter to the CompilerWrapper.

From the compiler results we can derive an in-memory representation of the contract description tree:

desc, _ := compilerResult.ToDescWSourceMap()

This is the basis, that will be used to create a Contract struct, which represents our compiled contract.

contractDemo, _ := NewContractFromDesc(desc)

Then we can set the values for the contracts constructor. This is needed to create a valid locking script for out contract.

x := Int{big.NewInt(7)}
y := Int{big.NewInt(4)}
constructorParams := map[string]ScryptType {
    "x": x,
    "y": y,
}

contractDemo.SetConstructorParams(constructorParams)

fmt.Println(contractDemo.GetLockingScript())

The same is true for our contracts public functions. Because our contract can contain many public functions, we use the functions name for referencing.

sumCorrect := Int{big.NewInt(11)}
addParams := map[string]ScryptType {
    "z": sumCorrect,
}

contractDemo.SetPublicFunctionParams("add", addParams)

fmt.Println(contractDemo.GetUnlockingScript("add"))

We can then localy check, if a public function calls successfully evaluates.

success, err := contractDemo.EvaluatePublicFunction("add")

The above method call will use the parameter values, that we set in the previous steps.

Launch sCrypt IDE debugger

After executing the EvaluatePublicFunction function, you can start the debugger with the launch debugger command by printing the launch debugger url.

// calling genLaunchConfig to generate launch debugger url
url := contractDemo.genLaunchConfig()
fmt.Println(url)

Testing

Run go test -v in the root of this project.

Patch

Some tests with @state decorator fail, you need to patch libsv/go-bt manually.

  1. Copy 0001-fix-parser-sCrypt-state-fail to $GOPATH/pkg/mod/github.com/libsv/go-bt/v2@v2.1.0-beta.4
cp patch/0001-fix-parser-sCrypt-state-fail.patch $GOPATH/pkg/mod/github.com/libsv/go-bt/v2@v2.1.0-beta.4
  1. Modify directory permissions
cd $GOPATH/pkg/mod/github.com/libsv/go-bt/v2@v2.1.0-beta.4 && chmod -R a+w .
  1. Applying Patch
git apply 0001-fix-parser-sCrypt-state-fail.patch

Documentation

Index

Constants

View Source
const (
	STATE_LEN_2BYTES = 2
	STATE_LEN_3BYTES = 3
	STATE_LEN_4BYTES = 4
)

Variables

View Source
var BASIC_SCRYPT_TYPES = map[string]bool{
	"bool":            true,
	"int":             true,
	"bytes":           true,
	"PrivKey":         true,
	"PubKey":          true,
	"Sig":             true,
	"Ripemd160":       true,
	"Sha1":            true,
	"Sha256":          true,
	"SigHashType":     true,
	"SigHashPreimage": true,
	"OpCodeType":      true,
}
View Source
var CURRENT_CONTRACT_DESCRIPTION_VERSION = 8
View Source
var DebugModeTag = map[string]string{
	"FUNC_START": "F0",
	"FUNC_END":   "F1",
	"LOOP_START": "L0",
}
View Source
var SOURCE_REGEXP = regexp.MustCompile(`^(?P<fileIndex>-?\d+):(?P<line>\d+):(?P<col>\d+):(?P<endLine>\d+):(?P<endCol>\d+)(#(?P<tagStr>.+))?`)
View Source
var WARNING_REGEXP = regexp.MustCompile(`Warning:(\s|\n)*(?P<filePath>[^\s]+):(?P<line>\d+):(?P<column>\d+):(?P<line1>\d+):(?P<column1>\d+):*\n(?P<message>[^\n]+)\n`)

Functions

func BigIntToBytes_LE

func BigIntToBytes_LE(value *big.Int) []byte

func BigIntToHex_LE

func BigIntToHex_LE(value *big.Int) string

func CompareScryptTypeSHA256

func CompareScryptTypeSHA256(a ScryptType, b ScryptType) (bool, error)

func CompareScryptVariableTypes

func CompareScryptVariableTypes(a ScryptType, b ScryptType) bool

func ConstructAliasMap

func ConstructAliasMap(aliasesDesc []AliasEntity) map[string]string

Construct a map for resolving alias types from the alias section of the contract description file.

func DeduceActualType

func DeduceActualType(t string, genericTypes map[string]string) string

func DeduceGenericType

func DeduceGenericType(t string, genericTypes []string) (map[string]string, error)

func DropLenPrefix

func DropLenPrefix(val []byte) ([]byte, error)

Drops length prefix of serialized sCrypt type.

func EvenHexStr

func EvenHexStr(hexStr string) string

func FactorizeArrayTypeString

func FactorizeArrayTypeString(typeStr string) (string, []string)

Factor array declaration string to array type and sizes. e.g. 'int[N][N][4]' -> ('int', ['N', 'N', '4'])

func FindCompiler

func FindCompiler() (string, error)

func FlattenSHA256

func FlattenSHA256(val ScryptType) ([32]byte, error)

If data is Struct or a list of ScryptTypes, then hash (SHA256) every element of the flattened structure, concat the resulting hashes and hash again into a single hash. If data is a basic sCrypt type, then hash it's byte value.

func GetNameByType

func GetNameByType(t string) string

func IsArraySameStructure

func IsArraySameStructure(array0 Array, array1 Array) bool

Returns true if the passed Array sCrypt types are of the same structure. Concrete values are not checked! It only recursively goes through Array and Struct types.

func IsArrayType

func IsArrayType(typeStr string) bool

Check if string is of an array type. e.g. "int[2]" or "int[N][3]"

func IsBasicScryptType

func IsBasicScryptType(typeStr string) bool

Check if string is a basic sCrypt type. e.g. "int", "bool", "bytes" ...

func IsGenericType

func IsGenericType(t string) bool

func IsLibrarySameStructure

func IsLibrarySameStructure(lib0 Library, lib1 Library) bool

Returns true if the passed Library sCrypt types are of the same structure. Concrete values are not checked! It only recursively goes through Array , Library, Struct types.

func IsStructsSameStructure

func IsStructsSameStructure(struct0 Struct, struct1 Struct) bool

Returns true if the passed Struct sCrypt types are of the same structure. Concrete values are not checked! It only recursively goes through Array and Struct types.

func NumberFromBuffer

func NumberFromBuffer(s []byte, littleEndian bool) *big.Int

func ParseGenericType

func ParseGenericType(t string) (string, []string)

*

*
* @param type eg. HashedMap<int,int>
* @param eg. ["HashedMap", ["int", "int"]}] An array generic types returned by @getGenericDeclaration
* @returns {"K": "int", "V": "int"}

func ResolveType

func ResolveType(typeStr string, aliases map[string]string) string

func ReverseByteSlice

func ReverseByteSlice(s []byte) []byte

func ToLiteralArrayTypeInt

func ToLiteralArrayTypeInt(typeName string, arraySizes []int) string

Retruns array declaration string for given type name and sizes. Array sizes are passed as a slice of type []int. TODO: Change int types to *big.Int

func ToLiteralArrayTypeStr

func ToLiteralArrayTypeStr(typeName string, arraySizes []string) string

Retruns array declaration string for given type name and sizes. Array sizes are passed as a slice of type []string.

Types

type ABIEntity

type ABIEntity struct {
	Name   string        `json:"name"`
	Type   ABIEntityType `json:"type"`
	Params []ParamEntity `json:"params"`
	Index  int           `json:"index"`
}

type ABIEntityType

type ABIEntityType string
const (
	FUNCTION    ABIEntityType = "function"
	CONSTRUCTOR ABIEntityType = "constructor"
)

type AliasEntity

type AliasEntity struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type Array

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

func NewArray

func NewArray(val []ScryptType) Array

func (Array) Bytes

func (arrayType Array) Bytes() ([]byte, error)

func (Array) Clone

func (array Array) Clone() ScryptType

func (Array) GetTypeString

func (arrayType Array) GetTypeString() string

func (Array) Hex

func (arrayType Array) Hex() (string, error)

func (Array) MarshalJSON

func (arr Array) MarshalJSON() ([]byte, error)

func (Array) StateBytes

func (arrayType Array) StateBytes() ([]byte, error)

func (Array) StateHex

func (arrayType Array) StateHex() (string, error)

type Bool

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

func NewBool

func NewBool(val bool) Bool

func (Bool) Bytes

func (boolType Bool) Bytes() ([]byte, error)

func (Bool) Clone

func (boolType Bool) Clone() ScryptType

func (Bool) GetTypeString

func (boolType Bool) GetTypeString() string

func (Bool) Hex

func (boolType Bool) Hex() (string, error)

func (Bool) MarshalJSON

func (boolType Bool) MarshalJSON() ([]byte, error)

func (Bool) StateBytes

func (boolType Bool) StateBytes() ([]byte, error)

func (Bool) StateHex

func (boolType Bool) StateHex() (string, error)

type BuildType

type BuildType string
const (
	Debug   BuildType = "debug"
	Release BuildType = "release"
)

type Bytes

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

func NewBytes

func NewBytes(val []byte) Bytes

func (Bytes) Bytes

func (bytesType Bytes) Bytes() ([]byte, error)

func (Bytes) Clone

func (bytesType Bytes) Clone() ScryptType

func (Bytes) GetTypeString

func (bytesType Bytes) GetTypeString() string

func (Bytes) Hex

func (bytesType Bytes) Hex() (string, error)

func (Bytes) MarshalJSON

func (bytesType Bytes) MarshalJSON() ([]byte, error)

func (Bytes) StateBytes

func (byteType Bytes) StateBytes() ([]byte, error)

func (Bytes) StateHex

func (byteType Bytes) StateHex() (string, error)

type CompilerResult

type CompilerResult struct {
	Ast             map[string]interface{}   // ASTs from all the compiled source files
	Asm             []map[string]interface{} // ASM data of the compiled contract
	DepAst          map[string]interface{}   // ASTs only of dependencies
	Abi             []ABIEntity              // ABI of the contract
	Warnings        []CompilerWarning        // Warnings returned by the compiler
	CompilerVersion string                   // Version of the compiler binary used to compile the contract
	Contract        string                   // Name of the compiled contract
	StateProps      []StateEntity            // state properties of the compiled contract
	Structs         []StructEntity           // Struct declarations
	Libraries       []LibraryEntity          // Library declarations
	Aliases         []AliasEntity            // Aliases used in the contract

	SourceFile     string                   // URI of the contracts source file
	AutoTypedVars  []map[string]interface{} // Variables with infered type
	SourceMD5      string                   // MD5 hash of the contracts source code
	RawAsm         string                   // Raw locking script in ASM format with parameter placeholders
	RawHex         string                   // Raw locking script in hexadecimal format with parameter placeholders
	CompilerOutAsm map[string]interface{}   // Whole ASM tree, as outputed by the compiler
	// contains filtered or unexported fields
}

func (CompilerResult) ToDesc

func (compilerResult CompilerResult) ToDesc() DescriptionFile

func (CompilerResult) ToDescWSourceMap

func (compilerResult CompilerResult) ToDescWSourceMap() (DescriptionFile, error)

type CompilerWarning

type CompilerWarning struct {
	FilePath string
	Line0    int
	Col0     int
	Line1    int
	Col1     int
	Message  string
}

type CompilerWrapper

type CompilerWrapper struct {
	// Path to the scryptc compiler binary file.
	// If left empty the SDK will try to search for it.
	CompilerBin string
	// Location of stored compiler outputs and desc file.
	OutDir   string
	Asm      bool
	HexOut   bool
	Debug    bool
	Optimize bool
	Ast      bool
	// If true, write desc file to OutDir.
	Desc         bool
	CmdArgs      string
	Cwd          string
	ContractPath string
}

func (*CompilerWrapper) CompileContractFile

func (compilerWrapper *CompilerWrapper) CompileContractFile(contractPath string) (CompilerResult, error)

func (*CompilerWrapper) CompileContractString

func (compilerWrapper *CompilerWrapper) CompileContractString(contractCode string) (CompilerResult, error)

func (*CompilerWrapper) GetCompilerVersion

func (compilerWrapper *CompilerWrapper) GetCompilerVersion() (string, error)

type Contract

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

func NewContract

func NewContract(compilerResult CompilerResult) (Contract, error)

Creates a new instance of Contract type.

func NewContractFromDesc

func NewContractFromDesc(desc DescriptionFile) (Contract, error)

Creates a new instance of Contract type from the contracts description tree.

func (*Contract) EvaluatePublicFunction

func (contract *Contract) EvaluatePublicFunction(functionName string) (bool, error)

Evaluate a public function call locally and return whether the evaluation was successfull, meaning the public function call (unlocking script) successfully evaluated against the contract (lockingScript). Constructor parameter values and also the public function parameter values MUST be set.

func (*Contract) GetCodePart

func (contract *Contract) GetCodePart() (string, error)

func (*Contract) GetDataPart

func (contract *Contract) GetDataPart() (string, error)

func (*Contract) GetDataPartInASM

func (contract *Contract) GetDataPartInASM() (string, error)

func (*Contract) GetDataPartInHex

func (contract *Contract) GetDataPartInHex() (string, error)

func (*Contract) GetLibraryTypeTemplate

func (contract *Contract) GetLibraryTypeTemplate(libraryName string) (Library, error)

func (*Contract) GetLockingScript

func (contract *Contract) GetLockingScript() (*bscript.Script, error)

func (*Contract) GetNewLockingScript

func (contract *Contract) GetNewLockingScript(dataPart string) (*bscript.Script, error)

func (*Contract) GetStates

func (contract *Contract) GetStates() (string, error)

func (*Contract) GetStructTypeTemplate

func (contract *Contract) GetStructTypeTemplate(t string) (Struct, error)

Returns template of a specific struct type defined in the contract.

func (*Contract) GetTxContext

func (contract *Contract) GetTxContext() (TxContext, error)

func (*Contract) GetTypeTemplate

func (contract *Contract) GetTypeTemplate(t string) (ScryptType, error)

func (*Contract) GetUnlockingScript

func (contract *Contract) GetUnlockingScript(functionName string) (*bscript.Script, error)

func (*Contract) HasDataPart

func (contract *Contract) HasDataPart() bool

func (*Contract) IsExecutionContextSet

func (contract *Contract) IsExecutionContextSet() bool

Returns if the contracts execution context was already set at least once.

func (*Contract) SetConstructorParams

func (contract *Contract) SetConstructorParams(params map[string]ScryptType) error

Set values for the contracts constructors parameters. The value of "params" must be a map, that maps a public function name (string) to an ScryptType object.

func (*Contract) SetDataPartInASM

func (contract *Contract) SetDataPartInASM(asm string)

func (*Contract) SetDataPartInHex

func (contract *Contract) SetDataPartInHex(hex string)

func (*Contract) SetExecutionContext

func (contract *Contract) SetExecutionContext(ec ExecutionContext)

Set the execution context, that will be used while evaluating a contracts public function. The locking and unlocking scripts, that you wan't to evaluate can be just templates, as they will be substitued localy, while calling the EvaluatePublicFunction method.

func (*Contract) SetPublicFunctionParams

func (contract *Contract) SetPublicFunctionParams(functionName string, params map[string]ScryptType) error

Set values for a specific public function parameters. The value of "params" must be a map, that maps a public function name (string) to an ScryptType object.

func (*Contract) UpdateStateVariable

func (contract *Contract) UpdateStateVariable(variableName string, value ScryptType) error

func (*Contract) UpdateStateVariables

func (contract *Contract) UpdateStateVariables(states map[string]ScryptType) error

type DebugConfiguration

type DebugConfiguration struct {
	Request                string       `json:"request"`
	Type                   string       `json:"type"`
	InternalConsoleOptions string       `json:"internalConsoleOptions"`
	Name                   string       `json:"name"`
	Program                string       `json:"program"`
	ConstructorArgs        []ScryptType `json:"constructorArgs"`
	PubFunc                string       `json:"pubFunc"`
	PubFuncArgs            []ScryptType `json:"pubFuncArgs"`
	TxContext              *TxContext   `json:"txContext"`
}

type DebugLaunch

type DebugLaunch struct {
	Version        string               `json:"version"`
	Configurations []DebugConfiguration `json:"configurations"`
}

type DescriptionFile

type DescriptionFile struct {
	Version         int             `json:"version"`
	CompilerVersion string          `json:"compilerVersion"`
	Contract        string          `json:"contract"`
	Md5             string          `json:"md5"`
	StateProps      []ParamEntity   `json:"stateProps"`
	Structs         []StructEntity  `json:"structs"`
	Libraries       []LibraryEntity `json:"library"`
	Aliases         []AliasEntity   `json:"alias"`
	Abi             []ABIEntity     `json:"abi"`
	BuildType       BuildType       `json:"buildType"`
	File            string          `json:"file"`
	Asm             string          `json:"asm"`
	Hex             string          `json:"hex"`
	Sources         []string        `json:"sources"`
	SourceMap       []string        `json:"sourceMap"`
}

type ExecutionContext

type ExecutionContext struct {
	Tx       *bt.Tx
	InputIdx int
	Flags    scriptflag.Flag
}

type GenericType

type GenericType struct {
	Generic string
	Actual  string
}

type HashedMap

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

func NewHashedMap

func NewHashedMap() HashedMap

func (HashedMap) Bytes

func (hashedMapType HashedMap) Bytes() ([]byte, error)

func (HashedMap) Clone

func (hashedMapType HashedMap) Clone() ScryptType

func (*HashedMap) Delete

func (hashedMapType *HashedMap) Delete(key ScryptType) error

func (HashedMap) GetKeysSorted

func (hashedMapType HashedMap) GetKeysSorted() [][32]byte

func (HashedMap) GetTypeString

func (hashedMapType HashedMap) GetTypeString() string

func (HashedMap) Hex

func (hashedMapType HashedMap) Hex() (string, error)

func (HashedMap) KeyIndex

func (hashedMapType HashedMap) KeyIndex(key ScryptType) (int64, error)

func (HashedMap) MarshalJSON

func (hashedMapType HashedMap) MarshalJSON() ([]byte, error)

func (HashedMap) RawBytes

func (hashedMapType HashedMap) RawBytes() ([]byte, error)

func (HashedMap) RawHex

func (hashedMapType HashedMap) RawHex() (string, error)

func (*HashedMap) Set

func (hashedMapType *HashedMap) Set(key ScryptType, val ScryptType) error

func (HashedMap) StateBytes

func (hashedMapType HashedMap) StateBytes() ([]byte, error)

func (HashedMap) StateHex

func (hashedMapType HashedMap) StateHex() (string, error)

type HashedSet

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

func NewHashedSet

func NewHashedSet() HashedSet

func (*HashedSet) Add

func (hashedSetType *HashedSet) Add(key ScryptType) error

func (HashedSet) Bytes

func (hashedSetType HashedSet) Bytes() ([]byte, error)

func (HashedSet) Clone

func (hashedSetType HashedSet) Clone() ScryptType

func (*HashedSet) Delete

func (hashedSetType *HashedSet) Delete(key ScryptType) error

func (HashedSet) GetKeysSorted

func (hashedSetType HashedSet) GetKeysSorted() [][32]byte

func (HashedSet) GetTypeString

func (hashedSetType HashedSet) GetTypeString() string

func (HashedSet) Hex

func (hashedSetType HashedSet) Hex() (string, error)

func (HashedSet) KeyIndex

func (hashedSetType HashedSet) KeyIndex(key ScryptType) (int64, error)

func (HashedSet) MarshalJSON

func (hashedSetType HashedSet) MarshalJSON() ([]byte, error)

func (HashedSet) RawBytes

func (hashedSetType HashedSet) RawBytes() ([]byte, error)

func (HashedSet) RawHex

func (hashedSetType HashedSet) RawHex() (string, error)

func (HashedSet) StateBytes

func (hashedSetType HashedSet) StateBytes() ([]byte, error)

func (HashedSet) StateHex

func (hashedSetType HashedSet) StateHex() (string, error)

type Int

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

func NewInt

func NewInt(val int64) Int

func (Int) Bytes

func (intType Int) Bytes() ([]byte, error)

func (Int) Clone

func (intType Int) Clone() ScryptType

func (Int) GetTypeString

func (intType Int) GetTypeString() string

func (Int) Hex

func (intType Int) Hex() (string, error)

func (Int) MarshalJSON

func (intType Int) MarshalJSON() ([]byte, error)

func (Int) StateBytes

func (intType Int) StateBytes() ([]byte, error)

func (Int) StateHex

func (intType Int) StateHex() (string, error)

type Library

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

func (Library) Bytes

func (libraryType Library) Bytes() ([]byte, error)

func (Library) Clone

func (l Library) Clone() ScryptType

func (Library) GetTypeString

func (libraryType Library) GetTypeString() string

func (Library) Hex

func (libraryType Library) Hex() (string, error)

func (Library) MarshalJSON

func (libraryType Library) MarshalJSON() ([]byte, error)

func (Library) StateBytes

func (libraryType Library) StateBytes() ([]byte, error)

func (Library) StateHex

func (libraryType Library) StateHex() (string, error)

func (*Library) UpdatePropertyValue

func (libraryType *Library) UpdatePropertyValue(propertyName string, newVal ScryptType)

func (*Library) UpdateValue

func (libraryType *Library) UpdateValue(paramName string, newVal ScryptType)

type LibraryEntity

type LibraryEntity struct {
	Name         string        `json:"name"`
	Params       []ParamEntity `json:"params"`
	Properties   []ParamEntity `json:"properties"`
	GenericTypes []string      `json:"genericTypes"`
}

type OpCodeType

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

func NewOpCodeType

func NewOpCodeType(val []byte) OpCodeType

func (OpCodeType) Bytes

func (opCodeType OpCodeType) Bytes() ([]byte, error)

func (OpCodeType) Clone

func (opCodeType OpCodeType) Clone() ScryptType

func (OpCodeType) GetTypeString

func (opCodeType OpCodeType) GetTypeString() string

func (OpCodeType) Hex

func (opCodeType OpCodeType) Hex() (string, error)

func (OpCodeType) MarshalJSON

func (opCodeType OpCodeType) MarshalJSON() ([]byte, error)

func (OpCodeType) StateBytes

func (opCodeType OpCodeType) StateBytes() ([]byte, error)

func (OpCodeType) StateHex

func (opCodeType OpCodeType) StateHex() (string, error)

type ParamEntity

type ParamEntity struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type PrivKey

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

func NewPrivKey

func NewPrivKey(val *bec.PrivateKey) PrivKey

func (PrivKey) Bytes

func (privKeyType PrivKey) Bytes() ([]byte, error)

func (PrivKey) Clone

func (privKeyType PrivKey) Clone() ScryptType

func (PrivKey) GetTypeString

func (privKeyType PrivKey) GetTypeString() string

func (PrivKey) Hex

func (privKeyType PrivKey) Hex() (string, error)

func (PrivKey) MarshalJSON

func (privKeyType PrivKey) MarshalJSON() ([]byte, error)

func (PrivKey) StateBytes

func (privKeyType PrivKey) StateBytes() ([]byte, error)

func (PrivKey) StateHex

func (privKeyType PrivKey) StateHex() (string, error)

type PubKey

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

func NewPubKey

func NewPubKey(val *bec.PublicKey) PubKey

func (PubKey) Bytes

func (pubKeyType PubKey) Bytes() ([]byte, error)

func (PubKey) Clone

func (pubKeyType PubKey) Clone() ScryptType

func (PubKey) GetTypeString

func (pubKeyType PubKey) GetTypeString() string

func (PubKey) Hex

func (pubKeyType PubKey) Hex() (string, error)

func (PubKey) MarshalJSON

func (pubKeyType PubKey) MarshalJSON() ([]byte, error)

func (PubKey) StateBytes

func (pubKeyType PubKey) StateBytes() ([]byte, error)

func (PubKey) StateHex

func (pubKeyType PubKey) StateHex() (string, error)

type ResultsAsm

type ResultsAsm struct {
	Asm           []map[string]interface{}
	AsmTree       map[string]interface{}
	AutoTypedVars []map[string]interface{}
	AsmRaw        string
	HexRaw        string
}

type ResultsAst

type ResultsAst struct {
	Ast              map[string]interface{}
	DepAst           map[string]interface{}
	Aliases          []AliasEntity
	Abi              []ABIEntity
	Structs          []StructEntity
	Libraries        []LibraryEntity
	StateProps       []StateEntity
	MainContractName string
}

type Ripemd160

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

func NewPubKeyHash

func NewPubKeyHash(value string) (Ripemd160, error)

func NewRipemd160FromBase58

func NewRipemd160FromBase58(value string) (Ripemd160, error)

func (Ripemd160) Bytes

func (ripemd160Type Ripemd160) Bytes() ([]byte, error)

func (Ripemd160) Clone

func (ripemd160Type Ripemd160) Clone() ScryptType

func (Ripemd160) GetTypeString

func (ripemd160Type Ripemd160) GetTypeString() string

func (Ripemd160) Hex

func (ripemd160Type Ripemd160) Hex() (string, error)

func (Ripemd160) MarshalJSON

func (ripemd160Type Ripemd160) MarshalJSON() ([]byte, error)

func (Ripemd160) StateBytes

func (ripemd160Type Ripemd160) StateBytes() ([]byte, error)

func (Ripemd160) StateHex

func (ripemd160Type Ripemd160) StateHex() (string, error)

type ScryptType

type ScryptType interface {
	Hex() (string, error)
	Bytes() ([]byte, error)
	GetTypeString() string
	StateHex() (string, error)
	StateBytes() ([]byte, error)
	Clone() ScryptType
}

func FlattenArray

func FlattenArray(arr Array) []ScryptType

func FlattenData

func FlattenData(val ScryptType) []ScryptType

Turns hierarchical sCrypt type into a single dimensional slice of ScryptType values.

type Sha1

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

func NewSha1

func NewSha1(val []byte) Sha1

func (Sha1) Bytes

func (sha1Type Sha1) Bytes() ([]byte, error)

func (Sha1) Clone

func (sha1Type Sha1) Clone() ScryptType

func (Sha1) GetTypeString

func (sha1 Sha1) GetTypeString() string

func (Sha1) Hex

func (sha1Type Sha1) Hex() (string, error)

func (Sha1) MarshalJSON

func (sha1Type Sha1) MarshalJSON() ([]byte, error)

func (Sha1) StateBytes

func (sha1Type Sha1) StateBytes() ([]byte, error)

func (Sha1) StateHex

func (sha1Type Sha1) StateHex() (string, error)

type Sha256

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

func NewSha256

func NewSha256(val []byte) Sha256

func (Sha256) Bytes

func (sha256Type Sha256) Bytes() ([]byte, error)

func (Sha256) Clone

func (sha256Type Sha256) Clone() ScryptType

func (Sha256) GetTypeString

func (sha256 Sha256) GetTypeString() string

func (Sha256) Hex

func (sha256Type Sha256) Hex() (string, error)

func (Sha256) MarshalJSON

func (sha256Type Sha256) MarshalJSON() ([]byte, error)

func (Sha256) StateBytes

func (sha256Type Sha256) StateBytes() ([]byte, error)

func (Sha256) StateHex

func (sha256Type Sha256) StateHex() (string, error)

type Sig

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

func NewSigFromDECBytes

func NewSigFromDECBytes(sigBytes []byte, shf sighash.Flag) (Sig, error)

func (Sig) Bytes

func (sigType Sig) Bytes() ([]byte, error)

func (Sig) Clone

func (sigType Sig) Clone() ScryptType

func (Sig) GetTypeString

func (sigType Sig) GetTypeString() string

func (Sig) Hex

func (sigType Sig) Hex() (string, error)

func (Sig) MarshalJSON

func (sigType Sig) MarshalJSON() ([]byte, error)

func (Sig) StateBytes

func (sigType Sig) StateBytes() ([]byte, error)

func (Sig) StateHex

func (sigType Sig) StateHex() (string, error)

type SigHashPreimage

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

func NewSigHashPreimage

func NewSigHashPreimage(val []byte) SigHashPreimage

func (SigHashPreimage) Bytes

func (sigHashPreimageType SigHashPreimage) Bytes() ([]byte, error)

func (SigHashPreimage) Clone

func (sigHashPreimageType SigHashPreimage) Clone() ScryptType

func (SigHashPreimage) GetTypeString

func (sigHashPreimage SigHashPreimage) GetTypeString() string

func (SigHashPreimage) Hex

func (sigHashPreimageType SigHashPreimage) Hex() (string, error)

func (SigHashPreimage) MarshalJSON

func (sigHashPreimage SigHashPreimage) MarshalJSON() ([]byte, error)

func (SigHashPreimage) StateBytes

func (sigHashPreimageType SigHashPreimage) StateBytes() ([]byte, error)

func (SigHashPreimage) StateHex

func (sigHashPreimageType SigHashPreimage) StateHex() (string, error)

type SigHashType

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

func NewSighHashType

func NewSighHashType(val []byte) SigHashType

func (SigHashType) Bytes

func (sigHashType SigHashType) Bytes() ([]byte, error)

func (SigHashType) Clone

func (sigHashType SigHashType) Clone() ScryptType

func (SigHashType) GetTypeString

func (sigHashType SigHashType) GetTypeString() string

func (SigHashType) Hex

func (sigHashType SigHashType) Hex() (string, error)

func (SigHashType) MarshalJSON

func (sigHashType SigHashType) MarshalJSON() ([]byte, error)

func (SigHashType) StateBytes

func (sigHashType SigHashType) StateBytes() ([]byte, error)

func (SigHashType) StateHex

func (sigHashType SigHashType) StateHex() (string, error)

type StateEntity

type StateEntity = ParamEntity

type StateProp

type StateProp struct {
	Name       string
	TypeString string
	Value      ScryptType
}

type Struct

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

func (Struct) Bytes

func (structType Struct) Bytes() ([]byte, error)

func (Struct) Clone

func (st Struct) Clone() ScryptType

func (Struct) GetTypeString

func (structType Struct) GetTypeString() string

func (Struct) Hex

func (structType Struct) Hex() (string, error)

func (Struct) MarshalJSON

func (structType Struct) MarshalJSON() ([]byte, error)

func (Struct) StateBytes

func (structType Struct) StateBytes() ([]byte, error)

func (Struct) StateHex

func (structType Struct) StateHex() (string, error)

func (*Struct) UpdateValue

func (structType *Struct) UpdateValue(fieldName string, newVal ScryptType) error

type StructEntity

type StructEntity struct {
	Name         string        `json:"name"`
	Params       []ParamEntity `json:"params"`
	GenericTypes []string      `json:"genericTypes"`
}

type TxContext

type TxContext struct {
	Hex           string `json:"hex"`
	InputIndex    int    `json:"inputIndex"`
	InputSatoshis int    `json:"inputSatoshis"`
	OpReturn      string `json:"opReturn"`
	OpReturnHex   string `json:"opReturnHex"`
}

func (TxContext) MarshalJSON

func (txContext TxContext) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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