tx

package
v0.0.0-...-bfbcaa6 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GasAssert = "0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7"
	NEOAssert = "0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b"
)

Asserts .

View Source
const (
	MinerTransaction      byte = 0x00
	IssueTransaction      byte = 0x01
	ClaimTransaction      byte = 0x02
	EnrollmentTransaction byte = 0x20
	RegisterTransaction   byte = 0x40
	ContractTransaction   byte = 0x80
	PublishTransaction    byte = 0xd0
	InvocationTransaction byte = 0xd1
)

Transaction types

View Source
const (
	ContractHash   = byte(0x00)
	ECDH02         = byte(0x02)
	ECDH03         = byte(0x03)
	Script         = byte(0x20)
	Vote           = byte(0x30)
	CertURL        = byte(0x80)
	DescriptionURL = byte(0x81)
	Description    = byte(90)
	Hash1          = byte(0xa1)
	Hash2          = byte(0xa2)
	Hash3          = byte(0xa3)
	Hash4          = byte(0xa4)
	Hash5          = byte(0xa5)
	Hash6          = byte(0xa6)
	Hash7          = byte(0xa7)
	Hash8          = byte(0xa8)
	Hash9          = byte(0xa9)
	Hash10         = byte(0xaa)
	Hash11         = byte(0xab)
	Hash12         = byte(0xac)
	Hash13         = byte(0xad)
	Hash14         = byte(0xae)
	Hash15         = byte(0xaf)
	Remark         = byte(0xf0)
	Remark1        = byte(0xf1)
	Remark2        = byte(0xf2)
	Remark3        = byte(0xf3)
	Remark4        = byte(0xf4)
	Remark5        = byte(0xf5)
	Remark6        = byte(0xf6)
	Remark7        = byte(0xf7)
	Remark8        = byte(0xf8)
	Remark9        = byte(0xf9)
	Remark10       = byte(0xfa)
	Remark11       = byte(0xfb)
	Remark12       = byte(0xfc)
	Remark13       = byte(0xfd)
	Remark14       = byte(0xfe)
	Remark15       = byte(0xff)
)

Attr Usage

Variables

View Source
var (
	ErrNoUTXO = errors.New("no enough utxo")
)

Err

Functions

func DecodeAddress

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

DecodeAddress .

func EncodeAddress

func EncodeAddress(address []byte) string

EncodeAddress .

func ToInvocationAddress

func ToInvocationAddress(address string) string

ToInvocationAddress neo wallet address to invocation address

Types

type Attribute

type Attribute struct {
	Usage byte
	Data  []byte
}

Attribute .

func (*Attribute) JSON

func (attr *Attribute) JSON() string

JSON .

func (*Attribute) Read

func (attr *Attribute) Read(reader io.Reader) error

func (*Attribute) Write

func (attr *Attribute) Write(writer io.Writer) error

Write .

type ClaimTx

type ClaimTx Transaction

ClaimTx .

func NewClaimTx

func NewClaimTx() *ClaimTx

NewClaimTx .

func (*ClaimTx) Claim

func (tx *ClaimTx) Claim(amount float64, to string, claims []*rpc.UTXO) error

Claim .

func (*ClaimTx) JSON

func (tx *ClaimTx) JSON() string

JSON .

func (*ClaimTx) Tx

func (tx *ClaimTx) Tx() *Transaction

Tx get basic transaction object

type ContractTx

type ContractTx Transaction

ContractTx contract transaction

func NewContractTx

func NewContractTx() *ContractTx

NewContractTx create new contract transaction

func (*ContractTx) CalcInputs

func (tx *ContractTx) CalcInputs(outputs []*Vout, unspent []*rpc.UTXO) error

CalcInputs .

func (*ContractTx) Tx

func (tx *ContractTx) Tx() *Transaction

Tx .

type Fixed8

type Fixed8 int64

Fixed8 fixed point number

func MakeFixed8

func MakeFixed8(val float64) Fixed8

MakeFixed8 .

func (*Fixed8) Float64

func (fixed8 *Fixed8) Float64() float64

Float64 convert fixe8 to float64

func (*Fixed8) Int

func (fixed8 *Fixed8) Int() *big.Int

Int convert to big.Int object

func (*Fixed8) Read

func (fixed8 *Fixed8) Read(reader io.Reader) error

func (*Fixed8) String

func (fixed8 *Fixed8) String() string

func (*Fixed8) Write

func (fixed8 *Fixed8) Write(writer io.Writer) error

type InvocationTx

type InvocationTx Transaction

InvocationTx .

func NewInvocationTx

func NewInvocationTx(script []byte, gas float64, fromScriptHash []byte, nonce []byte) *InvocationTx

NewInvocationTx .

func (*InvocationTx) CalcInputs

func (tx *InvocationTx) CalcInputs(outputs []*Vout, unspent []*rpc.UTXO) error

CalcInputs .

func (*InvocationTx) Tx

func (tx *InvocationTx) Tx() *Transaction

Tx .

type Scripts

type Scripts struct {
	StackScript  []byte
	RedeemScript []byte
}

Scripts .

func (*Scripts) JSON

func (scripts *Scripts) JSON() string

JSON .

func (*Scripts) Read

func (scripts *Scripts) Read(reader io.Reader) error

func (*Scripts) Write

func (scripts *Scripts) Write(writer io.Writer) error

WriteBytes .

type Serializable

type Serializable interface {
	Read(reader io.Reader) error
	Write(writer io.Writer) error
}

Serializable .

type ToJSON

type ToJSON interface {
	JSON() string
}

ToJSON .

type Transaction

type Transaction struct {
	Type       byte         // transaction type
	Version    byte         // tx version
	Extend     Serializable // special transaction data type
	Attributes []*Attribute // transaction extra attributes
	Inputs     []*Vin       // transaction input utxos
	Outputs    []*Vout      // transaction change utxos
	Scripts    []*Scripts   // tx scripts
	SignData   []byte       // sign source data
	SignResult []byte       // sign result
	TxID       string       // transaction id
	RawData    []byte       // raw transaction
}

Transaction neo transaction object

func (*Transaction) CalcInputs

func (tx *Transaction) CalcInputs(outputs []*Vout, unspent []*rpc.UTXO) ([]*Vin, []*rpc.UTXO, error)

CalcInputs calculate tx Inputs

func (*Transaction) Read

func (tx *Transaction) Read(reader io.Reader) error

func (*Transaction) Sign

func (tx *Transaction) Sign(ecdsaPrivateKey *ecdsa.PrivateKey) ([]byte, string, error)

Sign sign transaction

func (*Transaction) String

func (tx *Transaction) String() string

func (*Transaction) Write

func (tx *Transaction) Write(writer io.Writer) error

type Varint

type Varint uint64

Varint .

func (*Varint) Read

func (varint *Varint) Read(reader io.Reader) error

func (*Varint) Write

func (varint *Varint) Write(writer io.Writer) error

type Vin

type Vin struct {
	Tx string `json:"tx"`
	N  uint16 `json:"n"`
}

Vin .

func (*Vin) Read

func (vin *Vin) Read(reader io.Reader) error

func (*Vin) Write

func (vin *Vin) Write(writer io.Writer) error

type Vout

type Vout struct {
	Asset   string `json:"asset"`
	Value   Fixed8 `json:"value"`
	Address string `json:"address"`
}

Vout .

func (*Vout) Read

func (vout *Vout) Read(reader io.Reader) error

func (*Vout) Write

func (vout *Vout) Write(writer io.Writer) error

Jump to

Keyboard shortcuts

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