txencoder

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NAI_STEEM = "STEEM"
	NAI_SDB   = "SDB"
	NAI_TESTS = "TESTS"
	NAI_VESTS = "VESTS"
	NAI_HDB   = "HDB"
	NAI_TDB   = "TBD"
	NAI_HIVE  = "HIVE"
)

Variables

This section is empty.

Functions

func GetNai

func GetNai(coin string) string

func GetPrecision

func GetPrecision(coin string) uint8

func RemoveFillChar

func RemoveFillChar(nai string) string

Types

type Amount

type Amount struct {
	Amount    []byte // 8 byte
	Precision byte   // 1 byte
	Nai       []byte // 7 byte
}

func (*Amount) Decode

func (a *Amount) Decode(offset int, data []byte) (int, error)

func (*Amount) DecodeRaw

func (a *Amount) DecodeRaw() interface{}

func (*Amount) Encode

func (a *Amount) Encode() *[]byte

type AmountJson

type AmountJson struct {
	From   string `json:"from"`
	To     string `json:"to"`
	Amount string `json:"amount"`
	Memo   string `json:"memo"`
}

type Extension

type Extension struct {
}

func (*Extension) Decode

func (e *Extension) Decode(offset int, data []byte) (int, error)

func (*Extension) Encode

func (e *Extension) Encode() *[]byte

type OpType

type OpType uint8
const (
	Vote OpType = iota
	Comment
	Transfer
)

type Operation

type Operation interface {
	InitData(data *RawOperation) error
}

func NewOperation

func NewOperation(opType OpType) Operation

type RawAmount

type RawAmount struct {
	Amount    uint64 `json:"amount"`
	Precision uint8  `json:"precision"`
	Nai       string `json:"nai"`
}

func CreateAmount

func CreateAmount(amount, nai string) (*RawAmount, error)

func (*RawAmount) ParseToBroadcastJson

func (a *RawAmount) ParseToBroadcastJson() interface{}
{
	"amount": "10",
	"precision": 3,
	"nai": "@@000000021"
}

type RawOperation

type RawOperation interface {
	OpType() OpType
	ParseToBroadcastJson() interface{}
}

func NewRawOperation

func NewRawOperation(opType OpType) RawOperation

type RawTransaction

type RawTransaction struct {
	RefBlockNum    uint16          `json:"ref_block_num"`    // 参考的区块号
	RefBlockPrefix uint32          `json:"ref_block_prefix"` // 参考区块id
	Expiration     time.Time       `json:"expiration"`       // 交易到期时间
	Operations     *[]RawOperation `json:"operations"`       // 交易操作
	Extensions     *[]Extension    `json:"extensions"`       // 交易扩展
	Signatures     *[]string       `json:"signatures"`       // 交易签名
}

func (*RawTransaction) Decoder

func (rt *RawTransaction) Decoder(data []byte) error

func (*RawTransaction) Encode

func (rt *RawTransaction) Encode() (*Transaction, error)

func (*RawTransaction) ParseToBroadcastJson

func (rt *RawTransaction) ParseToBroadcastJson() interface{}

type RawTransferOperation

type RawTransferOperation struct {
	Type   OpType    `json:",omitempty"`
	From   string    `json:",omitempty"`
	To     string    `json:",omitempty"`
	Amount RawAmount `json:",omitempty"`
	Memo   string    `json:",omitempty"`
}

func (*RawTransferOperation) OpType

func (txOp *RawTransferOperation) OpType() OpType

func (*RawTransferOperation) ParseToBroadcastJson

func (txOp *RawTransferOperation) ParseToBroadcastJson() interface{}

[

"transfer",
{
	"from": "hiveio",
	"to": "alice",
	"amount": {
		"amount": "10",
		"precision": 3,
		"nai": "@@000000021"
	},
	"memo": "Thanks for all the fish."
}

]

type Signature

type Signature []byte

type Transaction

type Transaction struct {
	RefBlockNum    []byte       // 2 byte, 当前区块号 & 0xFFFF 获取一个参考的区块
	RefBlockPrefix []byte       // 4 byte, 当前区块id的第四个字节开始取4个字节长度的值进行小端转换作为参考值
	Expiration     []byte       // 4 byte, 时间戳
	Operations     *[]Operation // 交易的操作
	Extensions     *[]Extension // 扩展
	Signatures     *[]Signature // 签名
}

func (*Transaction) Decode

func (tx *Transaction) Decode(offset int, data []byte) (int, error)

func (*Transaction) DecodeRaw

func (tx *Transaction) DecodeRaw() interface{}

func (Transaction) Digest

func (tx Transaction) Digest(chainId string) ([]byte, error)

func (*Transaction) Encode

func (tx *Transaction) Encode() *[]byte

func (*Transaction) EncodeForSign

func (tx *Transaction) EncodeForSign() *[]byte

type TransferJson

type TransferJson struct {
	RefBlockNum    uint16        `json:"ref_block_num"`
	RefBlockPrefix uint32        `json:"ref_block_prefix"`
	Expiration     string        `json:"expiration"`
	Operations     []interface{} `json:"operations"`
	Extensions     []string      `json:"extensions"`
	Signatures     []string      `json:"signatures"`
}

type TransferOperation

type TransferOperation struct {
	Type   byte   // 1 byte
	From   []byte // data len
	To     []byte // data len
	Amount *Amount
	Memo   []byte // data len
}

func (*TransferOperation) Decode

func (txOp *TransferOperation) Decode(offset int, data []byte) (int, error)

func (*TransferOperation) DecodeRaw

func (txOp *TransferOperation) DecodeRaw() interface{}

func (*TransferOperation) Encode

func (txOp *TransferOperation) Encode() *[]byte

func (*TransferOperation) InitData

func (txOp *TransferOperation) InitData(data *RawOperation) error

type TxEncoder

type TxEncoder interface {
	Encode() *[]byte
	Decode(offset int, data []byte) (int, error)
	DecodeRaw() interface{}
}

Jump to

Keyboard shortcuts

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