proto

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2018 License: MIT Imports: 11 Imported by: 38

Documentation

Index

Constants

View Source
const (
	AddressSize = headerSize + bodySize + checksumSize

	MainNetScheme byte = 'W'
	TestNetScheme byte = 'T'
	DevNetScheme  byte = 'D'
)
View Source
const (
	ContentIDGetPeers      = 0x1
	ContentIDPeers         = 0x2
	ContentIDGetSignatures = 0x14
	ContentIDSignatures    = 0x15
	ContentIDGetBlock      = 0x16
	ContentIDBlock         = 0x17
	ContentIDScore         = 0x18
	ContentIDTransaction   = 0x19
	ContentIDCheckpoint    = 0x64
)

Constants for message IDs

View Source
const (
	//WavesAssetName is the default name for basic WAVES asset.
	WavesAssetName = "WAVES"
)

Variables

This section is empty.

Functions

func Bool

func Bool(buf []byte) (bool, error)

func BytesWithUInt16Len

func BytesWithUInt16Len(buf []byte) ([]byte, error)

BytesWithUInt16Len reads from buf an array of bytes of length encoded in first 2 bytes.

func PutBool

func PutBool(buf []byte, b bool)

func PutBytesWithUInt16Len

func PutBytesWithUInt16Len(buf []byte, data []byte)

PutBytesWithUInt16Len prepends given buf with 2 bytes of it's length.

func PutStringWithUInt16Len

func PutStringWithUInt16Len(buf []byte, s string)

func StringWithUInt16Len

func StringWithUInt16Len(buf []byte) (string, error)

Types

type Address

type Address [AddressSize]byte

func NewAddressFromBytes

func NewAddressFromBytes(b []byte) (Address, error)

func NewAddressFromPublicKey

func NewAddressFromPublicKey(scheme byte, publicKey crypto.PublicKey) (Address, error)

func NewAddressFromString

func NewAddressFromString(s string) (Address, error)

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

func (*Address) String

func (a *Address) String() string

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(value []byte) error

func (*Address) Validate

func (a *Address) Validate() (bool, error)

type Alias

type Alias struct {
	Version byte
	Scheme  byte
	Alias   string
}

func NewAlias

func NewAlias(scheme byte, alias string) (*Alias, error)

func NewAliasFromBytes

func NewAliasFromBytes(b []byte) (*Alias, error)

func NewAliasFromString

func NewAliasFromString(s string) (*Alias, error)

func (*Alias) MarshalBinary

func (a *Alias) MarshalBinary() ([]byte, error)

func (Alias) MarshalJSON

func (a Alias) MarshalJSON() ([]byte, error)

func (*Alias) String

func (a *Alias) String() string

func (*Alias) UnmarshalBinary

func (a *Alias) UnmarshalBinary(data []byte) error

func (*Alias) UnmarshalJSON

func (a *Alias) UnmarshalJSON(value []byte) error

type AssetPair

type AssetPair struct {
	AmountAsset OptionalAsset `json:"amountAsset"`
	PriceAsset  OptionalAsset `json:"priceAsset"`
}

AssetPair is a pair of assets in ExchangeTransaction.

type Attachment

type Attachment string

Attachment represents the additional data stored in Transfer and MassTransfer transactions.

func (Attachment) MarshalJSON

func (a Attachment) MarshalJSON() ([]byte, error)

MarshalJSON writes Attachment as a JSON string Value

func (Attachment) String

func (a Attachment) String() string

String returns Attachment's string representation

func (*Attachment) UnmarshalJSON

func (a *Attachment) UnmarshalJSON(value []byte) error

UnmarshalJSON reads Attachment from a JSON string Value

type B58Bytes

type B58Bytes []byte

B58Bytes represents bytes as Base58 string in JSON

func (B58Bytes) MarshalJSON

func (b B58Bytes) MarshalJSON() ([]byte, error)

MarshalJSON writes B58Bytes Value as JSON string

func (B58Bytes) String

func (b B58Bytes) String() string

String represents underlying bytes as Base58 string

func (*B58Bytes) UnmarshalJSON

func (b *B58Bytes) UnmarshalJSON(value []byte) error

UnmarshalJSON reads B58Bytes from JSON string

type BinaryDataEntry

type BinaryDataEntry struct {
	Key   string
	Value []byte
}

BinaryDataEntry represents a key-value data entry that stores binary value.

func (BinaryDataEntry) GetKey

func (e BinaryDataEntry) GetKey() string

GetKey returns the key of data entry.

func (BinaryDataEntry) GetValueType

func (e BinaryDataEntry) GetValueType() ValueType

GetValueType returns the type of value (Binary) stored in an entry.

func (BinaryDataEntry) MarshalBinary

func (e BinaryDataEntry) MarshalBinary() ([]byte, error)

MarshalBinary writes an entry to its byte representation.

func (BinaryDataEntry) MarshalJSON

func (e BinaryDataEntry) MarshalJSON() ([]byte, error)

MarshalJSON converts an entry to its JSON representation. Note that BASE64 is used to represent the binary value.

func (*BinaryDataEntry) UnmarshalBinary

func (e *BinaryDataEntry) UnmarshalBinary(data []byte) error

UnmarshalBinary reads an entry from a binary representation.

func (*BinaryDataEntry) UnmarshalJSON

func (e *BinaryDataEntry) UnmarshalJSON(value []byte) error

UnmarshalJSON converts JSON to a BinaryDataEntry structure. Value should be stored as BASE64 sting in JSON.

type BlockID

type BlockID [64]byte

BlockID represents the ID of a block

type BlockMessage

type BlockMessage struct {
	BlockBytes []byte
}

BlockMessage represents Block message

func (*BlockMessage) MarshalBinary

func (m *BlockMessage) MarshalBinary() ([]byte, error)

MarshalBinary encodes BlockMessage to binary form

func (*BlockMessage) ReadFrom

func (m *BlockMessage) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads BlockMessage from io.Reader

func (*BlockMessage) UnmarshalBinary

func (m *BlockMessage) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes BlockMessage from binary from

func (*BlockMessage) WriteTo

func (m *BlockMessage) WriteTo(w io.Writer) (int64, error)

WriteTo writes BlockMessage to io.Writer

type BlockSignature

type BlockSignature crypto.Signature

BlockSignature is a signature of a formed block

type BooleanDataEntry

type BooleanDataEntry struct {
	Key   string
	Value bool
}

BooleanDataEntry represents a key-value pair that stores a bool value.

func (BooleanDataEntry) GetKey

func (e BooleanDataEntry) GetKey() string

GetKey returns the key of data entry.

func (BooleanDataEntry) GetValueType

func (e BooleanDataEntry) GetValueType() ValueType

GetValueType returns the data type (Boolean) of the entry.

func (BooleanDataEntry) MarshalBinary

func (e BooleanDataEntry) MarshalBinary() ([]byte, error)

MarshalBinary writes a byte representation of the boolean data entry.

func (BooleanDataEntry) MarshalJSON

func (e BooleanDataEntry) MarshalJSON() ([]byte, error)

MarshalJSON writes the data entry to a JSON representation.

func (*BooleanDataEntry) UnmarshalBinary

func (e *BooleanDataEntry) UnmarshalBinary(data []byte) error

UnmarshalBinary reads a byte representation of the data entry.

func (*BooleanDataEntry) UnmarshalJSON

func (e *BooleanDataEntry) UnmarshalJSON(value []byte) error

UnmarshalJSON reads the entry from its JSON representation.

type BurnV1

type BurnV1 struct {
	Type      TransactionType   `json:"type"`
	Version   byte              `json:"version,omitempty"`
	ID        *crypto.Digest    `json:"id,omitempty"`
	Signature *crypto.Signature `json:"signature,omitempty"`
	SenderPK  crypto.PublicKey  `json:"senderPublicKey"`
	AssetID   crypto.Digest     `json:"assetId"`
	Amount    uint64            `json:"amount"`
	Timestamp uint64            `json:"timestamp,omitempty"`
	Fee       uint64            `json:"fee"`
}

func NewUnsignedBurnV1

func NewUnsignedBurnV1(senderPK crypto.PublicKey, assetID crypto.Digest, amount, timestamp, fee uint64) (*BurnV1, error)

func (*BurnV1) MarshalBinary

func (tx *BurnV1) MarshalBinary() ([]byte, error)

func (*BurnV1) Sign

func (tx *BurnV1) Sign(secretKey crypto.SecretKey) error

func (*BurnV1) UnmarshalBinary

func (tx *BurnV1) UnmarshalBinary(data []byte) error

func (*BurnV1) Verify

func (tx *BurnV1) Verify(publicKey crypto.PublicKey) (bool, error)

type CheckPointMessage

type CheckPointMessage struct {
	Checkpoints []CheckpointItem
}

CheckPointMessage represents a CheckPoint message

func (*CheckPointMessage) MarshalBinary

func (m *CheckPointMessage) MarshalBinary() ([]byte, error)

MarshalBinary encodes CheckPointMessage to binary form

func (*CheckPointMessage) ReadFrom

func (m *CheckPointMessage) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads CheckPointMessage from io.Reader

func (*CheckPointMessage) UnmarshalBinary

func (m *CheckPointMessage) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes CheckPointMessage from binary form

func (*CheckPointMessage) WriteTo

func (m *CheckPointMessage) WriteTo(w io.Writer) (int64, error)

WriteTo writes CheckPointMessage to io.Writer

type CheckpointItem

type CheckpointItem struct {
	Height    uint64
	Signature BlockSignature
}

CheckpointItem represents a Checkpoint

type CreateAliasV1

type CreateAliasV1 struct {
	Type      TransactionType   `json:"type"`
	Version   byte              `json:"version,omitempty"`
	ID        *crypto.Digest    `json:"id,omitempty"`
	Signature *crypto.Signature `json:"signature,omitempty"`
	SenderPK  crypto.PublicKey  `json:"senderPublicKey"`
	Alias     Alias             `json:"alias"`
	Fee       uint64            `json:"fee"`
	Timestamp uint64            `json:"timestamp,omitempty"`
}

func NewUnsignedCreateAliasV1

func NewUnsignedCreateAliasV1(senderPK crypto.PublicKey, alias Alias, fee, timestamp uint64) (*CreateAliasV1, error)

func (*CreateAliasV1) MarshalBinary

func (tx *CreateAliasV1) MarshalBinary() ([]byte, error)

func (*CreateAliasV1) Sign

func (tx *CreateAliasV1) Sign(secretKey crypto.SecretKey) error

func (*CreateAliasV1) UnmarshalBinary

func (tx *CreateAliasV1) UnmarshalBinary(data []byte) error

func (*CreateAliasV1) Verify

func (tx *CreateAliasV1) Verify(publicKey crypto.PublicKey) (bool, error)

type DataEntry

type DataEntry interface {
	GetKey() string
	GetValueType() ValueType
	MarshalBinary() ([]byte, error)
	// contains filtered or unexported methods
}

DataEntry is a common interface of all types of data entries. The interface is used to store different types of data entries in one slice.

type DataV1

type DataV1 struct {
	Type      TransactionType  `json:"type"`
	Version   byte             `json:"version,omitempty"`
	ID        *crypto.Digest   `json:"id,omitempty"`
	Proofs    *ProofsV1        `json:"proofs,omitempty"`
	SenderPK  crypto.PublicKey `json:"senderPublicKey"`
	Entries   []DataEntry      `json:"data"`
	Fee       uint64           `json:"fee"`
	Timestamp uint64           `json:"timestamp,omitempty"`
}

DataV1 is first version of the transaction that puts data to the key-value storage of an account.

func NewUnsignedData

func NewUnsignedData(senderPK crypto.PublicKey, fee, timestamp uint64) (*DataV1, error)

NewUnsignedData creates new Data transaction without proofs.

func (*DataV1) AppendEntry

func (tx *DataV1) AppendEntry(entry DataEntry) error

AppendEntry adds the entry to the transaction.

func (*DataV1) MarshalBinary

func (tx *DataV1) MarshalBinary() ([]byte, error)

func (*DataV1) Sign

func (tx *DataV1) Sign(secretKey crypto.SecretKey) error

func (*DataV1) UnmarshalBinary

func (tx *DataV1) UnmarshalBinary(data []byte) error

func (*DataV1) Verify

func (tx *DataV1) Verify(publicKey crypto.PublicKey) (bool, error)

type ExchangeV1

type ExchangeV1 struct {
	Type           TransactionType   `json:"type"`
	Version        byte              `json:"version,omitempty"`
	ID             *crypto.Digest    `json:"id,omitempty"`
	Signature      *crypto.Signature `json:"signature,omitempty"`
	SenderPK       crypto.PublicKey  `json:"senderPublicKey"`
	BuyOrder       Order             `json:"order1"`
	SellOrder      Order             `json:"order2"`
	Price          uint64            `json:"price"`
	Amount         uint64            `json:"amount"`
	BuyMatcherFee  uint64            `json:"buyMatcherFee"`
	SellMatcherFee uint64            `json:"sellMatcherFee"`
	Fee            uint64            `json:"fee"`
	Timestamp      uint64            `json:"timestamp,omitempty"`
}

func NewUnsignedExchangeV1

func NewUnsignedExchangeV1(buy, sell Order, price, amount, buyMatcherFee, sellMatcherFee, fee, timestamp uint64) (*ExchangeV1, error)

func (*ExchangeV1) MarshalBinary

func (tx *ExchangeV1) MarshalBinary() ([]byte, error)

func (*ExchangeV1) Sign

func (tx *ExchangeV1) Sign(secretKey crypto.SecretKey) error

func (*ExchangeV1) UnmarshalBinary

func (tx *ExchangeV1) UnmarshalBinary(data []byte) error

func (*ExchangeV1) Verify

func (tx *ExchangeV1) Verify(publicKey crypto.PublicKey) (bool, error)

type Genesis

type Genesis struct {
	Type      TransactionType   `json:"type"`
	Version   byte              `json:"version,omitempty"`
	ID        *crypto.Signature `json:"id,omitempty"`
	Signature *crypto.Signature `json:"signature,omitempty"`
	Timestamp uint64            `json:"timestamp"`
	Recipient Address           `json:"recipient"`
	Amount    uint64            `json:"amount"`
}

func NewUnsignedGenesis

func NewUnsignedGenesis(recipient Address, amount, timestamp uint64) (*Genesis, error)

func (*Genesis) GenerateSigID

func (tx *Genesis) GenerateSigID() error

func (*Genesis) MarshalBinary

func (tx *Genesis) MarshalBinary() ([]byte, error)

func (*Genesis) UnmarshalBinary

func (tx *Genesis) UnmarshalBinary(data []byte) error

type GetBlockMessage

type GetBlockMessage struct {
	BlockID BlockID
}

GetBlockMessage represents GetBlock message

func (*GetBlockMessage) MarshalBinary

func (m *GetBlockMessage) MarshalBinary() ([]byte, error)

MarshalBinary encodes GetBlockMessage to binary form

func (*GetBlockMessage) ReadFrom

func (m *GetBlockMessage) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads GetBlockMessage from io.Reader

func (*GetBlockMessage) UnmarshalBinary

func (m *GetBlockMessage) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes GetBlockMessage from binary form

func (*GetBlockMessage) WriteTo

func (m *GetBlockMessage) WriteTo(w io.Writer) (int64, error)

WriteTo writes GetBlockMessage to io.Writer

type GetPeersMessage

type GetPeersMessage struct{}

GetPeersMessage implements the GetPeers message from the waves protocol

func (*GetPeersMessage) MarshalBinary

func (m *GetPeersMessage) MarshalBinary() ([]byte, error)

MarshalBinary encodes GetPeersMessage to binary form

func (*GetPeersMessage) ReadFrom

func (m *GetPeersMessage) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads GetPeersMessage from io.Reader

func (*GetPeersMessage) UnmarshalBinary

func (m *GetPeersMessage) UnmarshalBinary(b []byte) error

UnmarshalBinary decodes GetPeersMessage from binary form

func (*GetPeersMessage) WriteTo

func (m *GetPeersMessage) WriteTo(w io.Writer) (int64, error)

WriteTo writes GetPeersMessage to io.Writer

type GetSignaturesMessage

type GetSignaturesMessage struct {
	Blocks []BlockID
}

GetSignaturesMessage represents the Get Signatures request

func (*GetSignaturesMessage) MarshalBinary

func (m *GetSignaturesMessage) MarshalBinary() ([]byte, error)

MarshalBinary encodes GetSignaturesMessage to binary form

func (*GetSignaturesMessage) ReadFrom

func (m *GetSignaturesMessage) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads GetSignaturesMessage from io.Reader

func (*GetSignaturesMessage) UnmarshalBinary

func (m *GetSignaturesMessage) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes GetSignaturesMessage from binary form

func (*GetSignaturesMessage) WriteTo

func (m *GetSignaturesMessage) WriteTo(w io.Writer) (int64, error)

WriteTo writes GetSignaturesMessage to io.Writer

type Handshake

type Handshake struct {
	Name              string
	Version           Version
	NodeName          string
	NodeNonce         uint64
	DeclaredAddrBytes []byte
	Timestamp         uint64
}

Handshake is the handshake structure of the waves protocol

func (*Handshake) MarshalBinary

func (h *Handshake) MarshalBinary() ([]byte, error)

MarshalBinary encodes Handshake to binary form

func (*Handshake) ReadFrom

func (h *Handshake) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads Handshake from io.Reader

func (*Handshake) UnmarshalBinary

func (h *Handshake) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes Handshake from binary from

func (*Handshake) WriteTo

func (h *Handshake) WriteTo(w io.Writer) (int64, error)

WriteTo writes Handshake to io.Writer

type IntegerDataEntry

type IntegerDataEntry struct {
	Key   string
	Value int64
}

IntegerDataEntry stores int64 value.

func (IntegerDataEntry) GetKey

func (e IntegerDataEntry) GetKey() string

GetKey returns the key of data entry.

func (IntegerDataEntry) GetValueType

func (e IntegerDataEntry) GetValueType() ValueType

GetValueType returns the value type of the entry.

func (IntegerDataEntry) MarshalBinary

func (e IntegerDataEntry) MarshalBinary() ([]byte, error)

MarshalBinary marshals the integer data entry in its bytes representation.

func (IntegerDataEntry) MarshalJSON

func (e IntegerDataEntry) MarshalJSON() ([]byte, error)

MarshalJSON writes a JSON representation of integer data entry.

func (*IntegerDataEntry) UnmarshalBinary

func (e *IntegerDataEntry) UnmarshalBinary(data []byte) error

UnmarshalBinary reads binary representation of integer data entry to the structure.

func (*IntegerDataEntry) UnmarshalJSON

func (e *IntegerDataEntry) UnmarshalJSON(value []byte) error

UnmarshalJSON reads an integer data entry from its JSON representation.

type IssueV1

type IssueV1 struct {
	Type        TransactionType   `json:"type"`
	Version     byte              `json:"version,omitempty"`
	ID          *crypto.Digest    `json:"id,omitempty"`
	Signature   *crypto.Signature `json:"signature,omitempty"`
	SenderPK    crypto.PublicKey  `json:"senderPublicKey"`
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Quantity    uint64            `json:"quantity"`
	Decimals    byte              `json:"decimals"`
	Reissuable  bool              `json:"reissuable"`
	Timestamp   uint64            `json:"timestamp,omitempty"`
	Fee         uint64            `json:"fee"`
}

func NewUnsignedIssueV1

func NewUnsignedIssueV1(senderPK crypto.PublicKey, name, description string, quantity uint64, decimals byte, reissuable bool, timestamp, fee uint64) (*IssueV1, error)

func (*IssueV1) MarshalBinary

func (tx *IssueV1) MarshalBinary() ([]byte, error)

func (*IssueV1) Sign

func (tx *IssueV1) Sign(secretKey crypto.SecretKey) error

func (*IssueV1) UnmarshalBinary

func (tx *IssueV1) UnmarshalBinary(data []byte) error

func (*IssueV1) Verify

func (tx *IssueV1) Verify(publicKey crypto.PublicKey) (bool, error)

type LeaseCancelV1

type LeaseCancelV1 struct {
	Type      TransactionType   `json:"type"`
	Version   byte              `json:"version,omitempty"`
	ID        *crypto.Digest    `json:"id,omitempty"`
	Signature *crypto.Signature `json:"signature,omitempty"`
	SenderPK  crypto.PublicKey  `json:"senderPublicKey"`
	LeaseID   crypto.Digest     `json:"leaseId"`
	Fee       uint64            `json:"fee"`
	Timestamp uint64            `json:"timestamp,omitempty"`
}

func NewUnsignedLeaseCancelV1

func NewUnsignedLeaseCancelV1(senderPK crypto.PublicKey, leaseID crypto.Digest, fee, timestamp uint64) (*LeaseCancelV1, error)

func (*LeaseCancelV1) MarshalBinary

func (tx *LeaseCancelV1) MarshalBinary() ([]byte, error)

func (*LeaseCancelV1) Sign

func (tx *LeaseCancelV1) Sign(secretKey crypto.SecretKey) error

func (*LeaseCancelV1) UnmarshalBinary

func (tx *LeaseCancelV1) UnmarshalBinary(data []byte) error

func (*LeaseCancelV1) Verify

func (tx *LeaseCancelV1) Verify(publicKey crypto.PublicKey) (bool, error)

type LeaseV1

type LeaseV1 struct {
	Type      TransactionType   `json:"type"`
	Version   byte              `json:"version,omitempty"`
	ID        *crypto.Digest    `json:"id,omitempty"`
	Signature *crypto.Signature `json:"signature,omitempty"`
	SenderPK  crypto.PublicKey  `json:"senderPublicKey"`
	Recipient Address           `json:"recipient"`
	Amount    uint64            `json:"amount"`
	Fee       uint64            `json:"fee"`
	Timestamp uint64            `json:"timestamp,omitempty"`
}

func NewUnsignedLeaseV1

func NewUnsignedLeaseV1(senderPK crypto.PublicKey, recipient Address, amount, fee, timestamp uint64) (*LeaseV1, error)

func (*LeaseV1) MarshalBinary

func (tx *LeaseV1) MarshalBinary() ([]byte, error)

func (*LeaseV1) Sign

func (tx *LeaseV1) Sign(secretKey crypto.SecretKey) error

func (*LeaseV1) UnmarshalBinary

func (tx *LeaseV1) UnmarshalBinary(data []byte) error

func (*LeaseV1) Verify

func (tx *LeaseV1) Verify(publicKey crypto.PublicKey) (bool, error)

type MassTransferEntry

type MassTransferEntry struct {
	Recipient Address `json:"recipient"`
	Amount    uint64  `json:"amount"`
}

func (*MassTransferEntry) MarshalBinary

func (e *MassTransferEntry) MarshalBinary() ([]byte, error)

func (*MassTransferEntry) UnmarshalBinary

func (e *MassTransferEntry) UnmarshalBinary(data []byte) error

type MassTransferV1

type MassTransferV1 struct {
	Type       TransactionType     `json:"type"`
	Version    byte                `json:"version,omitempty"`
	ID         *crypto.Digest      `json:"id,omitempty"`
	Proofs     *ProofsV1           `json:"proofs,omitempty"`
	SenderPK   crypto.PublicKey    `json:"senderPublicKey"`
	Asset      OptionalAsset       `json:"assetId"`
	Transfers  []MassTransferEntry `json:"transfers"`
	Timestamp  uint64              `json:"timestamp,omitempty"`
	Fee        uint64              `json:"fee"`
	Attachment Attachment          `json:"attachment,omitempty"`
}

func NewUnsignedMassTransferV1

func NewUnsignedMassTransferV1(senderPK crypto.PublicKey, asset OptionalAsset, transfers []MassTransferEntry, fee, timestamp uint64, attachment string) (*MassTransferV1, error)

func (*MassTransferV1) MarshalBinary

func (tx *MassTransferV1) MarshalBinary() ([]byte, error)

func (*MassTransferV1) Sign

func (tx *MassTransferV1) Sign(secretKey crypto.SecretKey) error

func (*MassTransferV1) UnmarshalBinary

func (tx *MassTransferV1) UnmarshalBinary(data []byte) error

func (*MassTransferV1) Verify

func (tx *MassTransferV1) Verify(publicKey crypto.PublicKey) (bool, error)

type OptionalAsset

type OptionalAsset struct {
	Present bool
	ID      crypto.Digest
}

OptionalAsset represents an optional asset identification

func NewOptionalAssetFromString

func NewOptionalAssetFromString(s string) (*OptionalAsset, error)

NewOptionalAssetFromString creates an OptionalAsset structure from its string representation.

func (*OptionalAsset) MarshalBinary

func (a *OptionalAsset) MarshalBinary() ([]byte, error)

MarshalBinary marshals the optional asset to its binary representation.

func (OptionalAsset) MarshalJSON

func (a OptionalAsset) MarshalJSON() ([]byte, error)

MarshalJSON writes OptionalAsset as a JSON string Value

func (OptionalAsset) String

func (a OptionalAsset) String() string

String method converts OptionalAsset to its text representation

func (*OptionalAsset) UnmarshalBinary

func (a *OptionalAsset) UnmarshalBinary(data []byte) error

UnmarshalBinary reads the OptionalAsset structure from its binary representation.

func (*OptionalAsset) UnmarshalJSON

func (a *OptionalAsset) UnmarshalJSON(value []byte) error

UnmarshalJSON reads OptionalAsset from a JSON string Value

type OptionalScript

type OptionalScript struct {
	MaybeScript *Script
}

OptionalScript can be used then the script value is optional.

type Order

type Order struct {
	ID         *crypto.Digest    `json:"id,omitempty"`
	Signature  *crypto.Signature `json:"signature,omitempty"`
	SenderPK   crypto.PublicKey  `json:"senderPublicKey"`
	MatcherPK  crypto.PublicKey  `json:"matcherPublicKey"`
	AssetPair  AssetPair         `json:"assetPair"`
	OrderType  OrderType         `json:"orderType"`
	Price      uint64            `json:"price"`
	Amount     uint64            `json:"amount"`
	Timestamp  uint64            `json:"timestamp"`
	Expiration uint64            `json:"expiration"`
	MatcherFee uint64            `json:"matcherFee"`
}

Order is an order created and signed by user. Two matched orders builds up an Exchange transaction.

func NewUnsignedOrder

func NewUnsignedOrder(senderPK, matcherPK crypto.PublicKey, amountAsset, priceAsset OptionalAsset, orderType OrderType, price, amount, timestamp, expiration, matcherFee uint64) (*Order, error)

NewUnsignedOrder creates the new unsigned order.

func (*Order) MarshalBinary

func (o *Order) MarshalBinary() ([]byte, error)

MarshalBinary writes order to its bytes representation.

func (*Order) Sign

func (o *Order) Sign(secretKey crypto.SecretKey) error

Sign adds a signature to the order.

func (*Order) UnmarshalBinary

func (o *Order) UnmarshalBinary(data []byte) error

UnmarshalBinary reads an order from its binary representation.

func (*Order) Verify

func (o *Order) Verify(publicKey crypto.PublicKey) (bool, error)

Verify checks that the order's signature is valid.

type OrderType

type OrderType byte

OrderType an alias for byte that encodes the type of Order (BUY|SELL).

const (
	Buy OrderType = iota
	Sell
)

iota: reset

func (OrderType) MarshalJSON

func (o OrderType) MarshalJSON() ([]byte, error)

MarshalJSON writes value of OrderType to JSON representation.

func (OrderType) String

func (o OrderType) String() string

func (*OrderType) UnmarshalJSON

func (o *OrderType) UnmarshalJSON(value []byte) error

UnmarshalJSON reads the OrderType value from JSON value.

type Payment

type Payment struct {
	Type      TransactionType   `json:"type"`
	Version   byte              `json:"version"`
	ID        *crypto.Signature `json:"id,omitempty"`
	Signature *crypto.Signature `json:"signature,omitempty"`
	SenderPK  crypto.PublicKey  `json:"senderPublicKey"`
	Recipient Address           `json:"recipient"`
	Amount    uint64            `json:"amount"`
	Fee       uint64            `json:"fee"`
	Timestamp uint64            `json:"timestamp"`
}

func NewUnsignedPayment

func NewUnsignedPayment(senderPK crypto.PublicKey, recipient Address, amount, fee, timestamp uint64) (*Payment, error)

func (*Payment) MarshalBinary

func (tx *Payment) MarshalBinary() ([]byte, error)

func (*Payment) Sign

func (tx *Payment) Sign(secretKey crypto.SecretKey) error

func (*Payment) UnmarshalBinary

func (tx *Payment) UnmarshalBinary(data []byte) error

func (*Payment) Verify

func (tx *Payment) Verify(publicKey crypto.PublicKey) (bool, error)

type PeerInfo

type PeerInfo struct {
	Addr net.IP
	Port uint16
}

PeerInfo represents the address of a single peer

func (*PeerInfo) MarshalBinary

func (m *PeerInfo) MarshalBinary() ([]byte, error)

MarshalBinary encodes PeerInfo message to binary form

func (PeerInfo) MarshalJSON

func (m PeerInfo) MarshalJSON() ([]byte, error)

MarshalJSON writes PeerInfo Value as JSON string

func (*PeerInfo) UnmarshalBinary

func (m *PeerInfo) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes PeerInfo message from binary form

func (*PeerInfo) UnmarshalJSON

func (m *PeerInfo) UnmarshalJSON(value []byte) error

UnmarshalJSON reads PeerInfo from JSON string

type PeersMessage

type PeersMessage struct {
	Peers []PeerInfo
}

PeersMessage represents the peers message

func (*PeersMessage) MarshalBinary

func (m *PeersMessage) MarshalBinary() ([]byte, error)

MarshalBinary encodes PeersMessage message to binary form

func (*PeersMessage) ReadFrom

func (m *PeersMessage) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads PeersMessage from io.Reader

func (*PeersMessage) UnmarshalBinary

func (m *PeersMessage) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes PeersMessage from binary form

func (*PeersMessage) WriteTo

func (m *PeersMessage) WriteTo(w io.Writer) (int64, error)

WriteTo writes PeersMessage to io.Writer

type ProofsV1

type ProofsV1 struct {
	Version byte
	Proofs  []B58Bytes
}

ProofsV1 is a collection of proofs.

func (*ProofsV1) MarshalBinary

func (p *ProofsV1) MarshalBinary() ([]byte, error)

MarshalBinary writes the proofs to its binary form.

func (ProofsV1) MarshalJSON

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

MarshalJSON writes the proofs to JSON.

func (*ProofsV1) Sign

func (p *ProofsV1) Sign(pos int, key crypto.SecretKey, data []byte) error

Sign creates a signature and stores it as a proof at given position.

func (ProofsV1) String

func (p ProofsV1) String() string

String gives a string representation of the proofs collection.

func (*ProofsV1) UnmarshalBinary

func (p *ProofsV1) UnmarshalBinary(data []byte) error

UnmarshalBinary reads the proofs from its binary representation.

func (*ProofsV1) UnmarshalJSON

func (p *ProofsV1) UnmarshalJSON(value []byte) error

UnmarshalJSON reads the proofs from JSON.

func (*ProofsV1) Verify

func (p *ProofsV1) Verify(pos int, key crypto.PublicKey, data []byte) (bool, error)

Verify checks that the proof at given position is a valid signature.

type ReissueV1

type ReissueV1 struct {
	Type       TransactionType   `json:"type"`
	Version    byte              `json:"version,omitempty"`
	ID         *crypto.Digest    `json:"id,omitempty"`
	Signature  *crypto.Signature `json:"signature,omitempty"`
	SenderPK   crypto.PublicKey  `json:"senderPublicKey"`
	AssetID    crypto.Digest     `json:"assetId"`
	Quantity   uint64            `json:"quantity"`
	Reissuable bool              `json:"reissuable"`
	Timestamp  uint64            `json:"timestamp,omitempty"`
	Fee        uint64            `json:"fee"`
}

func NewUnsignedReissueV1

func NewUnsignedReissueV1(senderPK crypto.PublicKey, assetID crypto.Digest, quantity uint64, reissuable bool, timestamp, fee uint64) (*ReissueV1, error)

func (*ReissueV1) MarshalBinary

func (tx *ReissueV1) MarshalBinary() ([]byte, error)

func (*ReissueV1) Sign

func (tx *ReissueV1) Sign(secretKey crypto.SecretKey) error

func (*ReissueV1) UnmarshalBinary

func (tx *ReissueV1) UnmarshalBinary(data []byte) error

func (*ReissueV1) Verify

func (tx *ReissueV1) Verify(publicKey crypto.PublicKey) (bool, error)

type ScoreMessage

type ScoreMessage struct {
	Score []byte
}

ScoreMessage represents Score message

func (*ScoreMessage) MarshalBinary

func (m *ScoreMessage) MarshalBinary() ([]byte, error)

MarshalBinary encodes ScoreMessage to binary form

func (*ScoreMessage) ReadFrom

func (m *ScoreMessage) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads ScoreMessage from io.Reader

func (*ScoreMessage) UnmarshalBinary

func (m *ScoreMessage) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes ScoreMessage from binary form

func (*ScoreMessage) WriteTo

func (m *ScoreMessage) WriteTo(w io.Writer) (int64, error)

WriteTo writes ScoreMessage to io.Writer

type Script

type Script struct {
	Version byte
	Body    []byte
}

Script the type to srote executable script in SetScriptTransaction.

type SetScriptV1

type SetScriptV1 struct {
	Type      TransactionType  `json:"type"`
	Version   byte             `json:"version,omitempty"`
	ID        *crypto.Digest   `json:"id,omitempty"`
	Proofs    *ProofsV1        `json:"proofs,omitempty"`
	ChainID   byte             `json:"-"`
	SenderPK  crypto.PublicKey `json:"senderPublicKey"`
	Script    []byte           `json:"script"`
	Fee       uint64           `json:"fee"`
	Timestamp uint64           `json:"timestamp,omitempty"`
}

SetScriptV1 is a transaction to set smart script on an account.

func NewUnsignedSetScriptV1

func NewUnsignedSetScriptV1(chain byte, senderPK crypto.PublicKey, script []byte, fee, timestamp uint64) (*SetScriptV1, error)

NewUnsignedSetScriptV1 creates new unsigned SetScriptV1 transaction.

func (*SetScriptV1) MarshalBinary

func (tx *SetScriptV1) MarshalBinary() ([]byte, error)

MarshalBinary writes SetScriptV1 transaction to its bytes representation.

func (*SetScriptV1) NonEmptyScript

func (tx *SetScriptV1) NonEmptyScript() bool

NonEmptyScript returns true if transaction contains non-empty script.

func (*SetScriptV1) Sign

func (tx *SetScriptV1) Sign(secretKey crypto.SecretKey) error

Sign adds signature as a proof at first position.

func (*SetScriptV1) UnmarshalBinary

func (tx *SetScriptV1) UnmarshalBinary(data []byte) error

UnmarshalBinary reads SetScriptV1 transaction from its binary representation.

func (*SetScriptV1) Verify

func (tx *SetScriptV1) Verify(publicKey crypto.PublicKey) (bool, error)

Verify checks that first proof is a valid signature.

type SignaturesMessage

type SignaturesMessage struct {
	Signatures []BlockSignature
}

SignaturesMessage represents Signatures message

func (*SignaturesMessage) MarshalBinary

func (m *SignaturesMessage) MarshalBinary() ([]byte, error)

MarshalBinary encodes SignaturesMessage to binary form

func (*SignaturesMessage) ReadFrom

func (m *SignaturesMessage) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads SignaturesMessage from binary form

func (*SignaturesMessage) UnmarshalBinary

func (m *SignaturesMessage) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes SignaturesMessage from binary form

func (*SignaturesMessage) WriteTo

func (m *SignaturesMessage) WriteTo(w io.Writer) (int64, error)

WriteTo writes SignaturesMessage to binary form

type SponsorshipV1

type SponsorshipV1 struct {
	Type        TransactionType  `json:"type"`
	Version     byte             `json:"version,omitempty"`
	ID          *crypto.Digest   `json:"id,omitempty"`
	Proofs      *ProofsV1        `json:"proofs,omitempty"`
	SenderPK    crypto.PublicKey `json:"senderPublicKey"`
	AssetID     crypto.Digest    `json:"assetId"`
	MinAssetFee uint64           `json:"minSponsoredAssetFee"`
	Fee         uint64           `json:"fee"`
	Timestamp   uint64           `json:"timestamp,omitempty"`
}

SponsorshipV1 is a transaction to setup fee sponsorship for an asset.

func NewUnsignedSponsorshipV1

func NewUnsignedSponsorshipV1(senderPK crypto.PublicKey, assetID crypto.Digest, minAssetFee, fee, timestamp uint64) (*SponsorshipV1, error)

NewUnsignedSponsorshipV1 creates new unsigned SponsorshipV1 transaction

func (*SponsorshipV1) MarshalBinary

func (tx *SponsorshipV1) MarshalBinary() ([]byte, error)

MarshalBinary writes SponsorshipV1 transaction to its bytes representation.

func (*SponsorshipV1) Sign

func (tx *SponsorshipV1) Sign(secretKey crypto.SecretKey) error

Sign adds signature as a proof at first position.

func (*SponsorshipV1) UnmarshalBinary

func (tx *SponsorshipV1) UnmarshalBinary(data []byte) error

UnmarshalBinary reads SponsorshipV1 from its bytes representation.

func (*SponsorshipV1) Verify

func (tx *SponsorshipV1) Verify(publicKey crypto.PublicKey) (bool, error)

Verify checks that first proof is a valid signature.

type StringDataEntry

type StringDataEntry struct {
	Key   string
	Value string
}

StringDataEntry structure is a key-value pair to store a string value.

func (StringDataEntry) GetKey

func (e StringDataEntry) GetKey() string

GetKey returns the key of key-value pair.

func (StringDataEntry) GetValueType

func (e StringDataEntry) GetValueType() ValueType

GetValueType returns the type of value in key-value entry.

func (StringDataEntry) MarshalBinary

func (e StringDataEntry) MarshalBinary() ([]byte, error)

MarshalBinary converts the data entry to its byte representation.

func (StringDataEntry) MarshalJSON

func (e StringDataEntry) MarshalJSON() ([]byte, error)

MarshalJSON writes the entry to its JSON representation.

func (*StringDataEntry) UnmarshalBinary

func (e *StringDataEntry) UnmarshalBinary(data []byte) error

UnmarshalBinary reads an StringDataEntry structure from bytes.

func (*StringDataEntry) UnmarshalJSON

func (e *StringDataEntry) UnmarshalJSON(value []byte) error

UnmarshalJSON reads the entry from JSON.

type TransactionMessage

type TransactionMessage struct {
	Transaction []byte
}

TransactionMessage represents Transaction message

func (*TransactionMessage) MarshalBinary

func (m *TransactionMessage) MarshalBinary() ([]byte, error)

MarshalBinary encodes TransactionMessage to binary form

func (*TransactionMessage) ReadFrom

func (m *TransactionMessage) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads TransactionMessage from io.Reader

func (*TransactionMessage) UnmarshalBinary

func (m *TransactionMessage) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes TransactionMessage from binary form

func (*TransactionMessage) WriteTo

func (m *TransactionMessage) WriteTo(w io.Writer) (int64, error)

WriteTo writes TransactionMessage to io.Writer

type TransactionType

type TransactionType byte
const (
	GenesisTransaction TransactionType = iota + 1
	PaymentTransaction
	IssueTransaction
	TransferTransaction
	ReissueTransaction
	BurnTransaction
	ExchangeTransaction
	LeaseTransaction
	LeaseCancelTransaction
	CreateAliasTransaction
	MassTransferTransaction
	DataTransaction
	SetScriptTransaction
	SponsorshipTransaction
)

type TransferV1

type TransferV1 struct {
	Type        TransactionType   `json:"type"`
	Version     byte              `json:"version,omitempty"`
	ID          *crypto.Digest    `json:"id,omitempty"`
	Signature   *crypto.Signature `json:"signature,omitempty"`
	SenderPK    crypto.PublicKey  `json:"senderPublicKey"`
	AmountAsset OptionalAsset     `json:"assetId"`
	FeeAsset    OptionalAsset     `json:"feeAssetId"`
	Timestamp   uint64            `json:"timestamp,omitempty"`
	Amount      uint64            `json:"amount"`
	Fee         uint64            `json:"fee"`
	Recipient   Address           `json:"recipient"`
	Attachment  Attachment        `json:"attachment,omitempty"`
}

func NewUnsignedTransferV1

func NewUnsignedTransferV1(senderPK crypto.PublicKey, amountAsset, feeAsset OptionalAsset, timestamp, amount, fee uint64, recipient Address, attachment string) (*TransferV1, error)

func (*TransferV1) MarshalBinary

func (tx *TransferV1) MarshalBinary() ([]byte, error)

func (*TransferV1) Sign

func (tx *TransferV1) Sign(secretKey crypto.SecretKey) error

func (*TransferV1) UnmarshalBinary

func (tx *TransferV1) UnmarshalBinary(data []byte) error

func (*TransferV1) Verify

func (tx *TransferV1) Verify(publicKey crypto.PublicKey) (bool, error)

type ValueType

type ValueType byte

ValueType is an alias for byte that encodes the value type.

const (
	Integer ValueType = iota
	Boolean
	Binary
	String
)

Supported value types.

func (ValueType) String

func (vt ValueType) String() string

String translates ValueType value to human readable name.

type Version

type Version struct {
	Major, Minor, Patch uint32
}

Version represents the version of the protocol

Jump to

Keyboard shortcuts

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