transaction

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2018 License: MIT Imports: 20 Imported by: 12

Documentation

Index

Constants

View Source
const (
	TypeSend                byte = 0x01
	TypeSellCoin            byte = 0x02
	TypeSellAllCoin         byte = 0x03
	TypeBuyCoin             byte = 0x04
	TypeCreateCoin          byte = 0x05
	TypeDeclareCandidacy    byte = 0x06
	TypeDelegate            byte = 0x07
	TypeUnbond              byte = 0x08
	TypeRedeemCheck         byte = 0x09
	TypeSetCandidateOnline  byte = 0x0A
	TypeSetCandidateOffline byte = 0x0B
)

Variables

View Source
var (
	CommissionMultiplier = big.NewInt(10e14)
)
View Source
var (
	ErrInvalidSig = errors.New("invalid transaction v, r, s values")
)

Functions

This section is empty.

Types

type BuyCoinData added in v0.0.6

type BuyCoinData struct {
	CoinToBuy  types.CoinSymbol
	ValueToBuy *big.Int
	CoinToSell types.CoinSymbol
}

func (BuyCoinData) Gas added in v0.0.6

func (data BuyCoinData) Gas() int64

func (BuyCoinData) MarshalJSON added in v0.0.6

func (data BuyCoinData) MarshalJSON() ([]byte, error)

func (BuyCoinData) Run added in v0.0.6

func (data BuyCoinData) Run(sender types.Address, tx *Transaction, context *state.StateDB, isCheck bool, rewardPool *big.Int, currentBlock uint64) Response

func (BuyCoinData) String added in v0.0.6

func (data BuyCoinData) String() string

type CreateCoinData

type CreateCoinData struct {
	Name                 string
	Symbol               types.CoinSymbol
	InitialAmount        *big.Int
	InitialReserve       *big.Int
	ConstantReserveRatio uint
}

func (CreateCoinData) Gas added in v0.0.6

func (data CreateCoinData) Gas() int64

func (CreateCoinData) MarshalJSON

func (data CreateCoinData) MarshalJSON() ([]byte, error)

func (CreateCoinData) Run added in v0.0.6

func (data CreateCoinData) Run(sender types.Address, tx *Transaction, context *state.StateDB, isCheck bool, rewardPool *big.Int, currentBlock uint64) Response

func (CreateCoinData) String added in v0.0.6

func (data CreateCoinData) String() string

type Data

type Data interface {
	MarshalJSON() ([]byte, error)
	String() string
	Gas() int64
	Run(sender types.Address, tx *Transaction, context *state.StateDB, isCheck bool, rewardPool *big.Int, currentBlock uint64) Response
}

type DeclareCandidacyData

type DeclareCandidacyData struct {
	Address    types.Address
	PubKey     []byte
	Commission uint
	Coin       types.CoinSymbol
	Stake      *big.Int
}

func (DeclareCandidacyData) Gas added in v0.0.6

func (data DeclareCandidacyData) Gas() int64

func (DeclareCandidacyData) MarshalJSON

func (data DeclareCandidacyData) MarshalJSON() ([]byte, error)

func (DeclareCandidacyData) Run added in v0.0.6

func (data DeclareCandidacyData) Run(sender types.Address, tx *Transaction, context *state.StateDB, isCheck bool, rewardPool *big.Int, currentBlock uint64) Response

func (DeclareCandidacyData) String added in v0.0.6

func (data DeclareCandidacyData) String() string

type DelegateData

type DelegateData struct {
	PubKey []byte
	Coin   types.CoinSymbol
	Stake  *big.Int
}

func (DelegateData) Gas added in v0.0.6

func (data DelegateData) Gas() int64

func (DelegateData) MarshalJSON

func (data DelegateData) MarshalJSON() ([]byte, error)

func (DelegateData) Run added in v0.0.6

func (data DelegateData) Run(sender types.Address, tx *Transaction, context *state.StateDB, isCheck bool, rewardPool *big.Int, currentBlock uint64) Response

func (DelegateData) String added in v0.0.6

func (data DelegateData) String() string

type RawData

type RawData []byte

type RedeemCheckData

type RedeemCheckData struct {
	RawCheck []byte
	Proof    [65]byte
}

func (RedeemCheckData) Gas added in v0.0.6

func (data RedeemCheckData) Gas() int64

func (RedeemCheckData) MarshalJSON

func (data RedeemCheckData) MarshalJSON() ([]byte, error)

func (RedeemCheckData) Run added in v0.0.6

func (data RedeemCheckData) Run(sender types.Address, tx *Transaction, context *state.StateDB, isCheck bool, rewardPool *big.Int, currentBlock uint64) Response

func (RedeemCheckData) String added in v0.0.6

func (data RedeemCheckData) String() string

type Response

type Response struct {
	Code      uint32          `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	Data      []byte          `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	Log       string          `protobuf:"bytes,3,opt,name=log,proto3" json:"log,omitempty"`
	Info      string          `protobuf:"bytes,4,opt,name=info,proto3" json:"info,omitempty"`
	GasWanted int64           `protobuf:"varint,5,opt,name=gas_wanted,json=gasWanted,proto3" json:"gas_wanted,omitempty"`
	GasUsed   int64           `protobuf:"varint,6,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"`
	Tags      []common.KVPair `protobuf:"bytes,7,rep,name=tags" json:"tags,omitempty"`
	Fee       common.KI64Pair `protobuf:"bytes,8,opt,name=fee" json:"fee"`
}

func RunTx

func RunTx(context *state.StateDB, isCheck bool, rawTx []byte, rewardPool *big.Int, currentBlock uint64) Response

type SellAllCoinData added in v0.1.2

type SellAllCoinData struct {
	CoinToSell types.CoinSymbol
	CoinToBuy  types.CoinSymbol
}

func (SellAllCoinData) Gas added in v0.1.2

func (data SellAllCoinData) Gas() int64

func (SellAllCoinData) MarshalJSON added in v0.1.2

func (data SellAllCoinData) MarshalJSON() ([]byte, error)

func (SellAllCoinData) Run added in v0.1.2

func (data SellAllCoinData) Run(sender types.Address, tx *Transaction, context *state.StateDB, isCheck bool, rewardPool *big.Int, currentBlock uint64) Response

func (SellAllCoinData) String added in v0.1.2

func (data SellAllCoinData) String() string

type SellCoinData added in v0.0.6

type SellCoinData struct {
	CoinToSell  types.CoinSymbol
	ValueToSell *big.Int
	CoinToBuy   types.CoinSymbol
}

func (SellCoinData) Gas added in v0.0.6

func (data SellCoinData) Gas() int64

func (SellCoinData) MarshalJSON added in v0.0.6

func (data SellCoinData) MarshalJSON() ([]byte, error)

func (SellCoinData) Run added in v0.0.6

func (data SellCoinData) Run(sender types.Address, tx *Transaction, context *state.StateDB, isCheck bool, rewardPool *big.Int, currentBlock uint64) Response

func (SellCoinData) String added in v0.0.6

func (data SellCoinData) String() string

type SendData

type SendData struct {
	Coin  types.CoinSymbol
	To    types.Address
	Value *big.Int
}

func (SendData) Gas added in v0.0.6

func (data SendData) Gas() int64

func (SendData) MarshalJSON

func (data SendData) MarshalJSON() ([]byte, error)

func (SendData) Run added in v0.0.6

func (data SendData) Run(sender types.Address, tx *Transaction, context *state.StateDB, isCheck bool, rewardPool *big.Int, currentBlock uint64) Response

func (SendData) String added in v0.0.6

func (data SendData) String() string

type SetCandidateOffData

type SetCandidateOffData struct {
	PubKey []byte
}

func (SetCandidateOffData) Gas added in v0.0.6

func (data SetCandidateOffData) Gas() int64

func (SetCandidateOffData) MarshalJSON

func (data SetCandidateOffData) MarshalJSON() ([]byte, error)

func (SetCandidateOffData) Run added in v0.0.6

func (data SetCandidateOffData) Run(sender types.Address, tx *Transaction, context *state.StateDB, isCheck bool, rewardPool *big.Int, currentBlock uint64) Response

func (SetCandidateOffData) String added in v0.0.6

func (data SetCandidateOffData) String() string

type SetCandidateOnData

type SetCandidateOnData struct {
	PubKey []byte
}

func (SetCandidateOnData) Gas added in v0.0.6

func (data SetCandidateOnData) Gas() int64

func (SetCandidateOnData) MarshalJSON

func (data SetCandidateOnData) MarshalJSON() ([]byte, error)

func (SetCandidateOnData) Run added in v0.0.6

func (data SetCandidateOnData) Run(sender types.Address, tx *Transaction, context *state.StateDB, isCheck bool, rewardPool *big.Int, currentBlock uint64) Response

func (SetCandidateOnData) String added in v0.0.6

func (data SetCandidateOnData) String() string

type Transaction

type Transaction struct {
	Nonce       uint64
	GasPrice    *big.Int
	GasCoin     types.CoinSymbol
	Type        byte
	Data        RawData
	Payload     []byte
	ServiceData []byte
	V           *big.Int
	R           *big.Int
	S           *big.Int
	// contains filtered or unexported fields
}

func DecodeFromBytes

func DecodeFromBytes(buf []byte) (*Transaction, error)

func (*Transaction) Gas

func (tx *Transaction) Gas() int64

func (*Transaction) GetDecodedData

func (tx *Transaction) GetDecodedData() Data

func (*Transaction) Hash

func (tx *Transaction) Hash() types.Hash

func (*Transaction) Sender

func (tx *Transaction) Sender() (types.Address, error)

func (*Transaction) Serialize

func (tx *Transaction) Serialize() ([]byte, error)

func (*Transaction) SetDecodedData

func (tx *Transaction) SetDecodedData(data Data)

func (*Transaction) SetSignature

func (tx *Transaction) SetSignature(sig []byte)

func (*Transaction) Sign

func (tx *Transaction) Sign(prv *ecdsa.PrivateKey) error

func (*Transaction) String

func (tx *Transaction) String() string

type UnbondData

type UnbondData struct {
	PubKey []byte
	Coin   types.CoinSymbol
	Value  *big.Int
}

func (UnbondData) Gas added in v0.0.6

func (data UnbondData) Gas() int64

func (UnbondData) MarshalJSON

func (data UnbondData) MarshalJSON() ([]byte, error)

func (UnbondData) Run added in v0.0.6

func (data UnbondData) Run(sender types.Address, tx *Transaction, context *state.StateDB, isCheck bool, rewardPool *big.Int, currentBlock uint64) Response

func (UnbondData) String added in v0.0.6

func (data UnbondData) String() string

Jump to

Keyboard shortcuts

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