types

package
v0.0.0-...-eb85b02 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 14 Imported by: 5

Documentation

Index

Constants

View Source
const Layout = `"2006-01-02T15:04:05"`

Variables

View Source
var (
	ErrInvalidPublicKey             = fmt.Errorf("invalid PublicKey")
	ErrPublicKeyChainPrefixMismatch = fmt.Errorf("PublicKey chain prefix mismatch")
	PrefixChain                     = "BTS"
)

Functions

func Ripemd160

func Ripemd160(in []byte) ([]byte, error)

func Ripemd160Checksum

func Ripemd160Checksum(in []byte) ([]byte, error)

Types

type AssetAmount

type AssetAmount struct {
	Amount  uint64   `json:"amount"`
	AssetID ObjectID `json:"asset_id"`
}

func (AssetAmount) MarshalTransaction

func (aa AssetAmount) MarshalTransaction(encoder *transaction.Encoder) error

func (*AssetAmount) UnmarshalJSON

func (aa *AssetAmount) UnmarshalJSON(b []byte) (err error)

RPC client might return asset amount as uint64 or string, therefore a custom unmarshaller is used

type Buffer

type Buffer []byte

func (Buffer) Bytes

func (p Buffer) Bytes() []byte

func (*Buffer) FromString

func (p *Buffer) FromString(data string) error

func (Buffer) Length

func (p Buffer) Length() int

func (Buffer) MarshalJSON

func (p Buffer) MarshalJSON() ([]byte, error)

func (Buffer) MarshalTransaction

func (p Buffer) MarshalTransaction(enc *transaction.Encoder) error

func (Buffer) String

func (p Buffer) String() string

func (*Buffer) UnmarshalJSON

func (p *Buffer) UnmarshalJSON(data []byte) error

type FillOrderOperation

type FillOrderOperation struct {
	Order   ObjectID
	Account ObjectID
	Pays    AssetAmount
	Recives AssetAmount
	Fee     AssetAmount
	Price   Price
	IsMaker bool
}

FillOrderOpType

func (*FillOrderOperation) Type

func (op *FillOrderOperation) Type() OpType

type LimitOrderCancelOperation

type LimitOrderCancelOperation struct {
	Fee              AssetAmount       `json:"fee"`
	FeePayingAccount ObjectID          `json:"fee_paying_account"`
	Order            ObjectID          `json:"order"`
	Extensions       []json.RawMessage `json:"extensions"`
}

LimitOrderCancelOpType

func (*LimitOrderCancelOperation) MarshalTransaction

func (op *LimitOrderCancelOperation) MarshalTransaction(encoder *transaction.Encoder) error

func (*LimitOrderCancelOperation) Type

func (op *LimitOrderCancelOperation) Type() OpType

type LimitOrderCreateOperation

type LimitOrderCreateOperation struct {
	Fee          AssetAmount       `json:"fee"`
	Seller       ObjectID          `json:"seller"`
	AmountToSell AssetAmount       `json:"amount_to_sell"`
	MinToReceive AssetAmount       `json:"min_to_receive"`
	Expiration   Time              `json:"expiration"`
	FillOrKill   bool              `json:"fill_or_kill"`
	Extensions   []json.RawMessage `json:"extensions"`
}

LimitOrderCreateOperation

func (*LimitOrderCreateOperation) MarshalTransaction

func (op *LimitOrderCreateOperation) MarshalTransaction(encoder *transaction.Encoder) error

func (*LimitOrderCreateOperation) Type

func (op *LimitOrderCreateOperation) Type() OpType

type Memo

type Memo struct {
	From    PublicKey `json:"from"`
	To      PublicKey `json:"to"`
	Nonce   uint64    `json:"nonce"`
	Message Buffer    `json:"message"`
}

func (Memo) MarshalTransaction

func (p Memo) MarshalTransaction(enc *transaction.Encoder) error

type ObjectID

type ObjectID struct {
	Space uint64
	Type  uint64
	ID    uint64
}

On the BitShares blockchains there are no addresses, but objects identified by a unique id, an type and a space in the form: space.type.id

func MustParseObjectID

func MustParseObjectID(str string) ObjectID

func ParseObjectID

func ParseObjectID(str string) (ObjectID, error)

func (*ObjectID) MarshalJSON

func (o *ObjectID) MarshalJSON() ([]byte, error)

func (ObjectID) MarshalTransaction

func (o ObjectID) MarshalTransaction(encoder *transaction.Encoder) error

func (ObjectID) String

func (o ObjectID) String() string

func (*ObjectID) UnmarshalJSON

func (o *ObjectID) UnmarshalJSON(s []byte) error

type OpType

type OpType uint16
const (
	TransferOpType OpType = iota
	LimitOrderCreateOpType
	LimitOrderCancelOpType
	CallOrderUpdateOpType
	FillOrderOpType
)

type Operation

type Operation interface {
	Type() OpType
}

type Operations

type Operations []Operation

func (Operations) MarshalJSON

func (ops Operations) MarshalJSON() ([]byte, error)

func (*Operations) UnmarshalJSON

func (ops *Operations) UnmarshalJSON(b []byte) (err error)

type Price

type Price struct {
	Base  AssetAmount `json:"base"`
	Quote AssetAmount `json:"quote"`
}

type PublicKey

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

func NewPublicKeyFromString

func NewPublicKeyFromString(key string) (*PublicKey, error)

func NewPublicKeyWithPrefixFromString

func NewPublicKeyWithPrefixFromString(key, prefixChain string) (*PublicKey, error)

NewPublicKey creates a new PublicKey from string

func (PublicKey) Bytes

func (p PublicKey) Bytes() []byte

func (PublicKey) Equal

func (p PublicKey) Equal(pub *PublicKey) bool

func (PublicKey) MarshalJSON

func (p PublicKey) MarshalJSON() ([]byte, error)

func (PublicKey) MarshalTransaction

func (p PublicKey) MarshalTransaction(enc *transaction.Encoder) error

func (PublicKey) MaxSharedKeyLength

func (p PublicKey) MaxSharedKeyLength() int

MaxSharedKeyLength returns the maximum length of the shared key the public key can produce.

func (PublicKey) String

func (p PublicKey) String() string

func (PublicKey) ToECDSA

func (p PublicKey) ToECDSA() *ecdsa.PublicKey

func (*PublicKey) UnmarshalJSON

func (p *PublicKey) UnmarshalJSON(data []byte) error

type Suint32

type Suint32 uint32

Suint32 uint32 with redeclared JSON unmarshal; Can be parsed from uint32 either string

func (*Suint32) UnmarshalJSON

func (su *Suint32) UnmarshalJSON(b []byte) (err error)

type Suint64

type Suint64 uint64

Suint64 uint64 with redeclared JSON unmarshal; Can be parsed from uint64 either string

func (*Suint64) UnmarshalJSON

func (su *Suint64) UnmarshalJSON(b []byte) (err error)

type Time

type Time struct {
	*time.Time
}

func NewTime

func NewTime(t time.Time) Time

func (*Time) MarshalJSON

func (t *Time) MarshalJSON() ([]byte, error)

func (Time) MarshalTransaction

func (t Time) MarshalTransaction(encoder *transaction.Encoder) error

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

type Transaction

type Transaction struct {
	RefBlockNum    uint16     `json:"ref_block_num"`
	RefBlockPrefix uint32     `json:"ref_block_prefix"`
	Expiration     Time       `json:"expiration"`
	Operations     Operations `json:"operations"`
	Signatures     []string   `json:"signatures"`
}

func (*Transaction) MarshalTransaction

func (tx *Transaction) MarshalTransaction(encoder *transaction.Encoder) error

MarshalTransaction implements transaction.Marshaller interface.

func (*Transaction) PushOperation

func (tx *Transaction) PushOperation(op Operation)

PushOperation can be used to add an operation into the transaction.

type TransferOperation

type TransferOperation struct {
	From       ObjectID          `json:"from"`
	To         ObjectID          `json:"to"`
	Amount     AssetAmount       `json:"amount"`
	Fee        AssetAmount       `json:"fee"`
	Memo       *Memo             `json:"memo,omitempty"`
	Extensions []json.RawMessage `json:"extensions"`
}

TransferOperation

func NewTransferOperation

func NewTransferOperation(from, to ObjectID, amount, fee AssetAmount) *TransferOperation

NewTransferOperation returns a new instance of TransferOperation

func (*TransferOperation) MarshalTransaction

func (op *TransferOperation) MarshalTransaction(encoder *transaction.Encoder) error

func (*TransferOperation) Type

func (op *TransferOperation) Type() OpType

type UnknownOperation

type UnknownOperation struct {
	Data json.RawMessage
	// contains filtered or unexported fields
}

UnknownOperation

func (*UnknownOperation) Type

func (op *UnknownOperation) Type() OpType

Jump to

Keyboard shortcuts

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