elastosTransaction

package
v1.0.28 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TxTypeTransferAsset   = byte(0x02)
	DefaultPayloadVersion = byte(0x00)
	AddressPrefix         = byte(0x21)
	OP_CHECKSIG           = byte(0xAC)
	AssetID_ELA           = "a3d0eaa466df74983b5d7c543de6904f4c9418ead5ffd6d25814234a96db37b0"
)

Variables

View Source
var (
	BitcoinAlphabet = NewAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
)

Alphabet: copy from https://en.wikipedia.org/wiki/Base58

View Source
var (
	ErrorInvalidBase58String = errors.New("invalid base58 string")
)

Errors

Functions

func Decode

func Decode(input string, alphabet *Alphabet) ([]byte, error)

Decode docode with custom alphabet

func DecodeCheck

func DecodeCheck(address string) ([]byte, []byte, error)

return prefix + hash + error

func Encode

func Encode(input []byte, alphabet *Alphabet) string

Encode encode with custom alphabet

func EncodeCheck

func EncodeCheck(prefix []byte, hash []byte) string

func GetProgramHashFromAddress

func GetProgramHashFromAddress(address string) ([]byte, error)

func SignRawTransaction

func SignRawTransaction(hash string, privateKey []byte) ([]byte, error)

func VerifyAndCombineRawTransaction

func VerifyAndCombineRawTransaction(emptyTrans string, sigPubs []SigPub) (bool, string)

Types

type Alphabet

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

Alphabet The base58 alphabet object.

func NewAlphabet

func NewAlphabet(alphabet string) *Alphabet

NewAlphabet create a custom alphabet from 58-length string. Note: len(rune(alphabet)) must be 58.

func (Alphabet) String

func (alphabet Alphabet) String() string

Alphabet's string representation

type Input

type Input struct {
	TxID     []byte
	Vout     []byte
	Sequence []byte
}

func (Input) ToBytes

func (input Input) ToBytes() []byte

type Output

type Output struct {
	AssetID     []byte
	Amount      []byte
	Lock        []byte
	ProgramHash []byte
}

func (Output) ToBytes

func (output Output) ToBytes() []byte

type SigPub

type SigPub struct {
	PublicKey []byte
	Signature []byte
}

func (SigPub) ToBytes

func (sp SigPub) ToBytes() ([]byte, error)

type Sigpubs

type Sigpubs []SigPub

func (Sigpubs) ToBytes

func (sps Sigpubs) ToBytes() ([]byte, error)

type Transaction

type Transaction struct {
	TxType         byte
	PayloadVersion byte
	Attributes     []*[]byte
	Inputs         []*Input
	Outputs        []*Output
	LockTime       []byte
	Signatures     []*SigPub
}

func NewTransaction

func NewTransaction(vins []Vin, vouts []Vout) (*Transaction, error)

func (Transaction) GetEmptyAndHash

func (tx Transaction) GetEmptyAndHash() ([]byte, []byte)

type TxHash

type TxHash struct {
	Address string
	Hash    string
}

func CreateEmptyRawTransactionAndHash

func CreateEmptyRawTransactionAndHash(vins []Vin, vouts []Vout) (string, []TxHash, error)

type Vin

type Vin struct {
	TxID    string
	Vout    uint16
	Address string
}

func (Vin) NewInput

func (in Vin) NewInput() (*Input, error)

type Vout

type Vout struct {
	AssetID string
	Amount  uint64
	Address string
}

func (Vout) NewOutput

func (out Vout) NewOutput() (*Output, error)

Jump to

Keyboard shortcuts

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