proto

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2019 License: MIT Imports: 13 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 AccountsState added in v0.2.0

type AccountsState interface {
	// nil asset means Waves.
	AccountBalance(addr Address, asset []byte) (uint64, error)
}

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) Bytes added in v0.2.0

func (a Address) Bytes() []byte

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) Bytes added in v0.2.0

func (a *Alias) Bytes() []byte

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 NewAttachmentFromBase58 added in v0.1.2

func NewAttachmentFromBase58(s string) (Attachment, error)

NewAttachmentFromBase58 creates an Attachment structure from its base58 string representation.

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) Bytes added in v0.2.0

func (b B58Bytes) Bytes() []byte

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 Block added in v0.2.0

type Block struct {
	BlockHeader
	Transactions []byte `json:"-"`
}

Block is a block of the blockchain

func (*Block) MarshalBinary added in v0.2.0

func (b *Block) MarshalBinary() ([]byte, error)

MarshalBinary encodes Block to binary form

func (*Block) UnmarshalBinary added in v0.2.0

func (b *Block) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes Block from binary form

type BlockHeader added in v0.2.0

type BlockHeader struct {
	Version                uint8
	Timestamp              uint64
	Parent                 crypto.Signature
	ConsensusBlockLength   uint32
	BaseTarget             uint64
	GenSignature           crypto.Digest
	TransactionBlockLength uint32
	TransactionCount       int
	GenPublicKey           crypto.PublicKey
	BlockSignature         crypto.Signature

	Height uint64
}

Block info (except transactions)

func (*BlockHeader) MarshalHeaderToBinary added in v0.2.0

func (b *BlockHeader) MarshalHeaderToBinary() ([]byte, error)

func (*BlockHeader) UnmarshalHeaderFromBinary added in v0.2.0

func (b *BlockHeader) UnmarshalHeaderFromBinary(data []byte) error

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 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"`
	// contains filtered or unexported fields
}

BurnV1 transaction allows to decrease the total supply of the existing asset. Asset must be reissuable.

func NewUnsignedBurnV1

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

NewUnsignedBurnV1 creates new BurnV1 transaction with no signature and ID.

func (BurnV1) GetID added in v0.2.0

func (tx BurnV1) GetID() []byte

func (*BurnV1) MarshalBinary

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

MarshalBinary saves transaction to

func (*BurnV1) Sign

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

Sign calculates and sets signature and ID of the transaction.

func (BurnV1) Transaction added in v0.1.2

func (BurnV1) Transaction()

func (*BurnV1) UnmarshalBinary

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

UnmarshalBinary reads transaction form its binary representation.

func (*BurnV1) Verify

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

Verify checks that the signature of the transaction is valid for the given public key.

type BurnV2 added in v0.1.2

type BurnV2 struct {
	Type    TransactionType `json:"type"`
	Version byte            `json:"version,omitempty"`
	ChainID byte            `json:"-"`
	ID      *crypto.Digest  `json:"id,omitempty"`
	Proofs  *ProofsV1       `json:"proofs,omitempty"`
	// contains filtered or unexported fields
}

BurnV2 same as BurnV1 but version 2 with Proofs.

func NewUnsignedBurnV2 added in v0.1.2

func NewUnsignedBurnV2(chainID byte, senderPK crypto.PublicKey, assetID crypto.Digest, amount, timestamp, fee uint64) (*BurnV2, error)

NewUnsignedBurnV2 creates new BurnV2 transaction without proofs and ID.

func (BurnV2) GetID added in v0.2.0

func (tx BurnV2) GetID() []byte

func (*BurnV2) MarshalBinary added in v0.1.2

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

MarshalBinary writes BurnV2 transaction to its bytes representation.

func (*BurnV2) Sign added in v0.1.2

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

Sign adds signature as a proof at first position.

func (BurnV2) Transaction added in v0.1.2

func (BurnV2) Transaction()

func (*BurnV2) UnmarshalBinary added in v0.1.2

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

UnmarshalBinary reads BurnV2 from its bytes representation.

func (*BurnV2) Verify added in v0.1.2

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

Verify checks that first proof is a valid signature.

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 crypto.Signature
}

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"`
	// contains filtered or unexported fields
}

func NewUnsignedCreateAliasV1

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

func (CreateAliasV1) GetID added in v0.2.0

func (tx CreateAliasV1) GetID() []byte

func (*CreateAliasV1) MarshalBinary

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

func (*CreateAliasV1) Sign

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

func (CreateAliasV1) Transaction added in v0.1.2

func (CreateAliasV1) Transaction()

func (*CreateAliasV1) UnmarshalBinary

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

func (*CreateAliasV1) UnmarshalJSON added in v0.2.0

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

func (*CreateAliasV1) Verify

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

type CreateAliasV2 added in v0.1.2

type CreateAliasV2 struct {
	Type    TransactionType `json:"type"`
	Version byte            `json:"version,omitempty"`
	ID      *crypto.Digest  `json:"id,omitempty"`
	Proofs  *ProofsV1       `json:"proofs,omitempty"`
	// contains filtered or unexported fields
}

func NewUnsignedCreateAliasV2 added in v0.1.2

func NewUnsignedCreateAliasV2(senderPK crypto.PublicKey, alias Alias, fee, timestamp uint64) (*CreateAliasV2, error)

func (CreateAliasV2) GetID added in v0.2.0

func (tx CreateAliasV2) GetID() []byte

func (*CreateAliasV2) MarshalBinary added in v0.1.2

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

MarshalBinary saves the transaction to its binary representation.

func (*CreateAliasV2) Sign added in v0.1.2

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

Sign adds signature as a proof at first position.

func (CreateAliasV2) Transaction added in v0.1.2

func (CreateAliasV2) Transaction()

func (*CreateAliasV2) UnmarshalBinary added in v0.1.2

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

UnmarshalBinary reads the transaction from bytes slice.

func (*CreateAliasV2) UnmarshalJSON added in v0.2.0

func (tx *CreateAliasV2) UnmarshalJSON(data []byte) error

func (*CreateAliasV2) Verify added in v0.1.2

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

Verify checks that first proof is a valid signature.

type DataEntries added in v0.2.0

type DataEntries []DataEntry

DataEntries the slice of various entries of DataTransaction

func (*DataEntries) UnmarshalJSON added in v0.2.0

func (e *DataEntries) UnmarshalJSON(data []byte) error

UnmarshalJSOL special method to unmarshal DataEntries from JSON with detection of real type of each entry.

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 DataEntryType added in v0.2.0

type DataEntryType struct {
	Type string `json:"type"`
}

DataEntryType is the assistive structure used to get the type of DataEntry while unmarshal form JSON.

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   DataEntries      `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) BodyMarshalBinary added in v0.2.0

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

func (DataV1) GetID added in v0.2.0

func (tx DataV1) GetID() []byte

func (*DataV1) MarshalBinary

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

MarshalBinary saves the transaction to bytes.

func (*DataV1) Sign

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

Sign use given secret key to calculate signature of the transaction.

func (DataV1) Transaction added in v0.1.2

func (DataV1) Transaction()

func (*DataV1) UnmarshalBinary

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

UnmarshalBinary reads the transaction from the bytes.

func (*DataV1) Verify

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

Verify chechs that the signature is valid for the given public key.

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       OrderV1           `json:"order1"`
	SellOrder      OrderV1           `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"`
}

ExchangeV1 is a transaction to store settlement on blockchain.

func NewUnsignedExchangeV1

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

func (ExchangeV1) GetID added in v0.2.0

func (tx ExchangeV1) GetID() []byte

func (*ExchangeV1) MarshalBinary

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

MarshalBinary saves the transaction to its binary representation.

func (*ExchangeV1) Sign

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

Sing calculates ID and Signature of the transaction.

func (ExchangeV1) Transaction added in v0.1.2

func (ExchangeV1) Transaction()

func (*ExchangeV1) UnmarshalBinary

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

UnmarshalBinary loads the transaction from its binary representation.

func (*ExchangeV1) Verify

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

Verify checks that signature of the transaction is valid.

type ExchangeV2 added in v0.1.2

type ExchangeV2 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"`
	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"`
}

ExchangeV2 is a transaction to store settlement on blockchain.

func NewUnsignedExchangeV2 added in v0.1.2

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

func (ExchangeV2) GetID added in v0.2.0

func (tx ExchangeV2) GetID() []byte

func (*ExchangeV2) MarshalBinary added in v0.1.2

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

MarshalBinary saves the transaction to its binary representation.

func (*ExchangeV2) Sign added in v0.1.2

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

Sign calculates transaction signature using given secret key.

func (ExchangeV2) Transaction added in v0.1.2

func (ExchangeV2) Transaction()

func (*ExchangeV2) UnmarshalBinary added in v0.1.2

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

UnmarshalBinary loads the transaction from its binary representation.

func (*ExchangeV2) UnmarshalJSON added in v0.2.0

func (tx *ExchangeV2) UnmarshalJSON(data []byte) error

func (*ExchangeV2) Verify added in v0.1.2

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

Verify checks that the transaction signature is valid for given public key.

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"`
}

Genesis is a transaction used to initial balances distribution. This transactions allowed only in the first block.

func NewUnsignedGenesis

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

NewUnsignedGenesis returns a new unsigned Genesis transaction. Actually Genesis transaction could not be signed. That is why it doesn't implement Sing method. Instead it has GenerateSigID method, which calculates ID and uses it also as a signature.

func (*Genesis) GenerateSigID

func (tx *Genesis) GenerateSigID() error

GenerateSigID calculates hash of the transaction and use it as an ID. Also doubled hash is used as a signature.

func (Genesis) GetID added in v0.2.0

func (tx Genesis) GetID() []byte

func (*Genesis) MarshalBinary

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

MarshalBinary writes transaction bytes to slice of bytes.

func (Genesis) Transaction added in v0.1.2

func (Genesis) Transaction()

func (*Genesis) UnmarshalBinary

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

UnmarshalBinary reads transaction values from the slice of bytes.

type GetBlockMessage

type GetBlockMessage struct {
	BlockID crypto.Signature
}

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 []crypto.Signature
}

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"`
}

IssueV1 transaction is a transaction to issue new asset.

func NewUnsignedIssueV1

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

NewUnsignedIssueV1 creates new IssueV1 transaction without signature and ID.

func (IssueV1) GetID added in v0.2.0

func (tx IssueV1) GetID() []byte

func (*IssueV1) MarshalBinary

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

MarshalBinary saves transaction's binary representation to slice of bytes.

func (*IssueV1) Sign

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

Sign uses secretKey to sing the transaction.

func (IssueV1) Transaction added in v0.1.2

func (IssueV1) Transaction()

func (*IssueV1) UnmarshalBinary

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

UnmarshalBinary reads transaction from its binary representation.

func (*IssueV1) Verify

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

Verify checks that the signature of transaction is a valid signature for given public key.

type IssueV2 added in v0.1.2

type IssueV2 struct {
	Type        TransactionType  `json:"type"`
	Version     byte             `json:"version"`
	ChainID     byte             `json:"-"`
	ID          *crypto.Digest   `json:"id,omitempty"`
	Proofs      *ProofsV1        `json:"proofs,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"`
	Script      Script           `json:"script"`
	Fee         uint64           `json:"fee"`
	Timestamp   uint64           `json:"timestamp,omitempty"`
}

IssueV2 is a transaction to issue new asset, second version.

func NewUnsignedIssueV2 added in v0.1.2

func NewUnsignedIssueV2(chainID byte, senderPK crypto.PublicKey, name, description string, quantity uint64, decimals byte, reissuable bool, script []byte, timestamp, fee uint64) (*IssueV2, error)

NewUnsignedIssueV2 creates a new IssueV2 transaction with empty Proofs.

func (IssueV2) GetID added in v0.2.0

func (tx IssueV2) GetID() []byte

func (*IssueV2) MarshalBinary added in v0.1.2

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

MarshalBinary converts transaction to its binary representation.

func (*IssueV2) NonEmptyScript added in v0.1.2

func (tx *IssueV2) NonEmptyScript() bool

NonEmptyScript returns true if the script of the transaction is not empty, otherwise false.

func (*IssueV2) Sign added in v0.1.2

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

Sign calculates transaction signature using given secret key.

func (IssueV2) Transaction added in v0.1.2

func (IssueV2) Transaction()

func (*IssueV2) UnmarshalBinary added in v0.1.2

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

UnmarshalBinary reads transaction from its binary representation.

func (*IssueV2) Verify added in v0.1.2

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

Verify checks that the transaction signature is valid for given public key.

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"`
	// contains filtered or unexported fields
}

LeaseCancelV1 transaction can be used to cancel previously created leasing.

func NewUnsignedLeaseCancelV1

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

NewUnsignedLeaseCancelV1 creates new LeaseCancelV1 transaction structure without a signature and an ID.

func (LeaseCancelV1) GetID added in v0.2.0

func (tx LeaseCancelV1) GetID() []byte

func (*LeaseCancelV1) MarshalBinary

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

MarshalBinary saves transaction to its binary representation.

func (*LeaseCancelV1) Sign

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

func (LeaseCancelV1) Transaction added in v0.1.2

func (LeaseCancelV1) Transaction()

func (*LeaseCancelV1) UnmarshalBinary

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

func (*LeaseCancelV1) Verify

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

Verify checks that signature of the transaction is valid for the given public key.

type LeaseCancelV2 added in v0.1.2

type LeaseCancelV2 struct {
	Type    TransactionType `json:"type"`
	Version byte            `json:"version,omitempty"`
	ChainID byte            `json:"-"`
	ID      *crypto.Digest  `json:"id,omitempty"`
	Proofs  *ProofsV1       `json:"proofs,omitempty"`
	// contains filtered or unexported fields
}

LeaseCancelV2 same as LeaseCancelV1 but with proofs.

func NewUnsignedLeaseCancelV2 added in v0.1.2

func NewUnsignedLeaseCancelV2(chainID byte, senderPK crypto.PublicKey, leaseID crypto.Digest, fee, timestamp uint64) (*LeaseCancelV2, error)

NewUnsignedLeaseCancelV2 creates new LeaseCancelV2 transaction structure without a signature and an ID.

func (LeaseCancelV2) GetID added in v0.2.0

func (tx LeaseCancelV2) GetID() []byte

func (*LeaseCancelV2) MarshalBinary added in v0.1.2

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

MarshalBinary saves the transaction to its binary representation.

func (*LeaseCancelV2) Sign added in v0.1.2

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

Sign adds signature as a proof at first position.

func (LeaseCancelV2) Transaction added in v0.1.2

func (LeaseCancelV2) Transaction()

func (*LeaseCancelV2) UnmarshalBinary added in v0.1.2

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

UnmarshalBinary reads the transaction from bytes slice.

func (*LeaseCancelV2) Verify added in v0.1.2

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

Verify checks that first proof is a valid signature.

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"`
	// contains filtered or unexported fields
}

LeaseV1 is a transaction that allows to lease Waves to other account.

func NewUnsignedLeaseV1

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

NewUnsignedLeaseV1 creates new LeaseV1 transaction without signature and ID set.

func (LeaseV1) GetID added in v0.2.0

func (tx LeaseV1) GetID() []byte

func (*LeaseV1) MarshalBinary

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

MarshalBinary saves the transaction to its binary representation.

func (*LeaseV1) Sign

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

Sign calculates ID and Signature of the transaction.

func (LeaseV1) Transaction added in v0.1.2

func (LeaseV1) Transaction()

func (*LeaseV1) UnmarshalBinary

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

UnmarshalBinary reads the transaction from bytes slice.

func (*LeaseV1) Verify

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

Verify checks that the signature of the transaction is valid for the given public key.

type LeaseV2 added in v0.1.2

type LeaseV2 struct {
	Type    TransactionType `json:"type"`
	Version byte            `json:"version,omitempty"`
	ID      *crypto.Digest  `json:"id,omitempty"`
	Proofs  *ProofsV1       `json:"proofs,omitempty"`
	// contains filtered or unexported fields
}

LeaseV2 is a second version of the LeaseV1 transaction.

func NewUnsignedLeaseV2 added in v0.1.2

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

NewUnsignedLeaseV2 creates new LeaseV1 transaction without signature and ID set.

func (LeaseV2) GetID added in v0.2.0

func (tx LeaseV2) GetID() []byte

func (*LeaseV2) MarshalBinary added in v0.1.2

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

MarshalBinary saves the transaction to its binary representation.

func (*LeaseV2) Sign added in v0.1.2

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

Sign adds signature as a proof at first position.

func (LeaseV2) Transaction added in v0.1.2

func (LeaseV2) Transaction()

func (*LeaseV2) UnmarshalBinary added in v0.1.2

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

UnmarshalBinary reads the transaction from bytes slice.

func (*LeaseV2) Verify added in v0.1.2

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

Verify checks that first proof is a valid signature.

type MassTransferEntry

type MassTransferEntry struct {
	Recipient Recipient `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"`
}

MassTransferV1 is a transaction that performs multiple transfers of one asset to the accounts at once.

func NewUnsignedMassTransferV1

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

NewUnsignedMassTransferV1 creates new MassTransferV1 transaction structure without signature and ID.

func (MassTransferV1) GetID added in v0.2.0

func (tx MassTransferV1) GetID() []byte

func (*MassTransferV1) MarshalBinary

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

MarshalBinary saves the transaction to its binary representation.

func (*MassTransferV1) Sign

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

Sign calculates signature and ID of the transaction.

func (MassTransferV1) Transaction added in v0.1.2

func (MassTransferV1) Transaction()

func (*MassTransferV1) UnmarshalBinary

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

UnmarshalBinary loads transaction from its binary representation.

func (*MassTransferV1) Verify

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

Verify checks that the signature is valid for the given public key.

type OptionalAsset

type OptionalAsset struct {
	Present bool
	ID      crypto.Digest
}

OptionalAsset represents an optional asset identification

func NewOptionalAssetFromBytes added in v0.2.0

func NewOptionalAssetFromBytes(b []byte) (*OptionalAsset, error)

func NewOptionalAssetFromDigest added in v0.2.0

func NewOptionalAssetFromDigest(d crypto.Digest) (*OptionalAsset, error)

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) ToID added in v0.2.0

func (a *OptionalAsset) ToID() []byte

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 Order

type Order interface {
	GetVersion() byte
	GetOrderType() OrderType
	GetMatcherPK() crypto.PublicKey
}

type OrderType

type OrderType byte

OrderType an alias for byte that encodes the type of OrderV1 (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 OrderV1 added in v0.1.2

type OrderV1 struct {
	ID        *crypto.Digest    `json:"id,omitempty"`
	Signature *crypto.Signature `json:"signature,omitempty"`
	// contains filtered or unexported fields
}

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

func NewUnsignedOrderV1 added in v0.1.2

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

NewUnsignedOrderV1 creates the new unsigned order.

func (OrderV1) GetMatcherPK added in v0.1.2

func (o OrderV1) GetMatcherPK() crypto.PublicKey

func (OrderV1) GetOrderType added in v0.1.2

func (o OrderV1) GetOrderType() OrderType

func (OrderV1) GetVersion added in v0.1.2

func (o OrderV1) GetVersion() byte

func (*OrderV1) MarshalBinary added in v0.1.2

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

MarshalBinary writes order to its bytes representation.

func (*OrderV1) Sign added in v0.1.2

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

Sign adds a signature to the order.

func (*OrderV1) UnmarshalBinary added in v0.1.2

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

UnmarshalBinary reads an order from its binary representation.

func (*OrderV1) Verify added in v0.1.2

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

Verify checks that the order's signature is valid.

type OrderV2 added in v0.1.2

type OrderV2 struct {
	Version byte           `json:"version"`
	ID      *crypto.Digest `json:"id,omitempty"`
	Proofs  *ProofsV1      `json:"proofs,omitempty"`
	// contains filtered or unexported fields
}

OrderV2 is an order created and signed by user. Two matched orders builds up an Exchange transaction. Version 2 with proofs.

func NewUnsignedOrderV2 added in v0.1.2

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

NewUnsignedOrderV2 creates the new unsigned order.

func (OrderV2) GetMatcherPK added in v0.1.2

func (o OrderV2) GetMatcherPK() crypto.PublicKey

func (OrderV2) GetOrderType added in v0.1.2

func (o OrderV2) GetOrderType() OrderType

func (OrderV2) GetVersion added in v0.1.2

func (o OrderV2) GetVersion() byte

func (*OrderV2) MarshalBinary added in v0.1.2

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

MarshalBinary writes order to its bytes representation.

func (*OrderV2) Sign added in v0.1.2

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

Sign adds a signature to the order.

func (*OrderV2) UnmarshalBinary added in v0.1.2

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

UnmarshalBinary reads an order from its binary representation.

func (*OrderV2) Verify added in v0.1.2

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

Verify checks that the order's signature is valid.

type OrderVersion added in v0.2.0

type OrderVersion struct {
	Version byte `json:"version"`
}

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"`
}

Payment transaction is deprecated and can be used only for validation of blockchain.

func NewUnsignedPayment

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

NewUnsignedPayment creates new Payment transaction with empty Signature and ID fields.

func (Payment) GetID added in v0.2.0

func (tx Payment) GetID() []byte

func (*Payment) MarshalBinary

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

MarshalBinary returns a bytes representation of Payment transaction.

func (*Payment) Sign

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

Sign calculates transaction signature and set it as an ID.

func (Payment) Transaction added in v0.1.2

func (Payment) Transaction()

func (*Payment) UnmarshalBinary

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

UnmarshalBinary reads Payment transaction from its binary representation.

func (*Payment) Verify

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

Verify checks that the Signature is valid for given public key.

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) String added in v0.2.0

func (m PeerInfo) String() string

String() implements Stringer interface for PeerInfo

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 Recipient added in v0.2.0

type Recipient struct {
	Address *Address
	Alias   *Alias
	// contains filtered or unexported fields
}

func NewRecipientFromAddress added in v0.2.0

func NewRecipientFromAddress(a Address) Recipient

func NewRecipientFromAlias added in v0.2.0

func NewRecipientFromAlias(a Alias) Recipient

func (*Recipient) MarshalBinary added in v0.2.0

func (r *Recipient) MarshalBinary() ([]byte, error)

func (Recipient) MarshalJSON added in v0.2.0

func (r Recipient) MarshalJSON() ([]byte, error)

func (*Recipient) String added in v0.2.0

func (r *Recipient) String() string

func (*Recipient) UnmarshalBinary added in v0.2.0

func (r *Recipient) UnmarshalBinary(data []byte) error

func (*Recipient) UnmarshalJSON added in v0.2.0

func (r *Recipient) UnmarshalJSON(value []byte) error

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"`
	// contains filtered or unexported fields
}

ReissueV1 is a transaction that allows to issue new amount of existing token, if it was issued as reissuable.

func NewUnsignedReissueV1

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

NewUnsignedReissueV1 creates new ReissueV1 transaction without signature and ID.

func (ReissueV1) GetID added in v0.2.0

func (tx ReissueV1) GetID() []byte

func (*ReissueV1) MarshalBinary

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

MarshalBinary saves the transaction to its binary representation.

func (*ReissueV1) Sign

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

Sign use given private key to calculate signature of the transaction. This function also calculates digest of transaction data and assigns it to ID field.

func (ReissueV1) Transaction added in v0.1.2

func (ReissueV1) Transaction()

func (*ReissueV1) UnmarshalBinary

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

UnmarshalBinary reads transaction from its binary representation.

func (*ReissueV1) Verify

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

Verify checks that the signature of the transaction is valid for given public key.

type ReissueV2 added in v0.1.2

type ReissueV2 struct {
	Type    TransactionType `json:"type"`
	Version byte            `json:"version,omitempty"`
	ChainID byte            `json:"-"`
	ID      *crypto.Digest  `json:"id,omitempty"`
	Proofs  *ProofsV1       `json:"proofs,omitempty"`
	// contains filtered or unexported fields
}

ReissueV2 same as ReissueV1 but version 2 with Proofs.

func NewUnsignedReissueV2 added in v0.1.2

func NewUnsignedReissueV2(chainID byte, senderPK crypto.PublicKey, assetID crypto.Digest, quantity uint64, reissuable bool, timestamp, fee uint64) (*ReissueV2, error)

NewUnsignedReissueV2 creates new ReissueV2 transaction without signature and ID.

func (ReissueV2) GetID added in v0.2.0

func (tx ReissueV2) GetID() []byte

func (*ReissueV2) MarshalBinary added in v0.1.2

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

MarshalBinary writes ReissueV2 transaction to its bytes representation.

func (*ReissueV2) Sign added in v0.1.2

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

Sign adds signature as a proof at first position.

func (ReissueV2) Transaction added in v0.1.2

func (ReissueV2) Transaction()

func (*ReissueV2) UnmarshalBinary added in v0.1.2

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

UnmarshalBinary reads ReissueV2 from its bytes representation.

func (*ReissueV2) Verify added in v0.1.2

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

Verify checks that first proof is a valid signature.

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 []byte

func (Script) MarshalJSON added in v0.2.0

func (s Script) MarshalJSON() ([]byte, error)

MarshalJSON writes Script as JSON

func (Script) String added in v0.2.0

func (s Script) String() string

String gives a string representation of Script bytes, script bytes encoded as BASE64 with prefix

func (*Script) UnmarshalJSON added in v0.2.0

func (s *Script) UnmarshalJSON(value []byte) error

UnmarshalJSON reads Script from it's JSON representation

type SetAssetScriptV1 added in v0.2.0

type SetAssetScriptV1 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"`
	AssetID   crypto.Digest    `json:"assetId"`
	Script    Script           `json:"script"`
	Fee       uint64           `json:"fee"`
	Timestamp uint64           `json:"timestamp,omitempty"`
}

SetAssetScriptV1 is a transaction to set smart script on an asset.

func NewUnsignedSetAssetScriptV1 added in v0.2.0

func NewUnsignedSetAssetScriptV1(chain byte, senderPK crypto.PublicKey, assetID crypto.Digest, script []byte, fee, timestamp uint64) (*SetAssetScriptV1, error)

NewUnsignedSetAssetScriptV1 creates new unsigned SetAssetScriptV1 transaction.

func (SetAssetScriptV1) GetID added in v0.2.0

func (tx SetAssetScriptV1) GetID() []byte

func (*SetAssetScriptV1) MarshalBinary added in v0.2.0

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

MarshalBinary writes SetAssetScriptV1 transaction to its bytes representation.

func (*SetAssetScriptV1) NonEmptyScript added in v0.2.0

func (tx *SetAssetScriptV1) NonEmptyScript() bool

NonEmptyScript returns true if transaction contains non-empty script.

func (*SetAssetScriptV1) Sign added in v0.2.0

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

Sign adds signature as a proof at first position.

func (SetAssetScriptV1) Transaction added in v0.2.0

func (SetAssetScriptV1) Transaction()

func (*SetAssetScriptV1) UnmarshalBinary added in v0.2.0

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

UnmarshalBinary reads SetAssetScriptV1 transaction from its binary representation.

func (*SetAssetScriptV1) Verify added in v0.2.0

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

Verify checks that first proof is a valid signature.

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    Script           `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) GetID added in v0.2.0

func (tx SetScriptV1) GetID() []byte

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) Transaction added in v0.1.2

func (SetScriptV1) Transaction()

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 []crypto.Signature
}

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) GetID added in v0.2.0

func (tx SponsorshipV1) GetID() []byte

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) Transaction added in v0.1.2

func (SponsorshipV1) Transaction()

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 Transaction added in v0.1.2

type Transaction interface {
	Transaction()
	GetID() []byte
	MarshalBinary() ([]byte, error)
	UnmarshalBinary([]byte) error
}

func BytesToTransaction added in v0.2.0

func BytesToTransaction(tx []byte) (Transaction, error)

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

TransactionType

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

All transaction types supported.

type TransactionValidator added in v0.2.0

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

func NewTransactionValidator added in v0.2.0

func NewTransactionValidator(genesis crypto.Signature, state AccountsState) (*TransactionValidator, error)

func (*TransactionValidator) IsSupported added in v0.2.0

func (tv *TransactionValidator) IsSupported(tx Transaction) bool

func (*TransactionValidator) ValidateTransaction added in v0.2.0

func (tv *TransactionValidator) ValidateTransaction(blockID crypto.Signature, tx Transaction, initialisation bool) error

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"`
	// contains filtered or unexported fields
}

TransferV1 transaction to transfer any token from one account to another. Version 1.

func NewUnsignedTransferV1

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

NewUnsignedTransferV1 creates new TransferV1 transaction without signature and ID.

func (TransferV1) GetID added in v0.2.0

func (tx TransferV1) GetID() []byte

func (*TransferV1) MarshalBinary

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

MarshalBinary saves transaction to its binary representation.

func (*TransferV1) Sign

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

Sign calculates a signature and a digest as an ID of the transaction.

func (TransferV1) Transaction added in v0.1.2

func (TransferV1) Transaction()

func (*TransferV1) UnmarshalBinary

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

UnmarshalBinary reads transaction from its binary representation.

func (*TransferV1) Verify

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

Verify use given public key to verify that the signature is valid.

type TransferV2 added in v0.1.2

type TransferV2 struct {
	Type    TransactionType `json:"type"`
	Version byte            `json:"version,omitempty"`
	ID      *crypto.Digest  `json:"id,omitempty"`
	Proofs  *ProofsV1       `json:"proofs,omitempty"`
	// contains filtered or unexported fields
}

TransferV2 transaction to transfer any token from one account to another. Version 2.

func NewUnsignedTransferV2 added in v0.1.2

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

NewUnsignedTransferV2 creates new TransferV2 transaction without proofs and ID.

func (*TransferV2) BodyMarshalBinary added in v0.2.0

func (tx *TransferV2) BodyMarshalBinary() ([]byte, error)

func (*TransferV2) BodyUnmarshalBinary added in v0.2.0

func (tx *TransferV2) BodyUnmarshalBinary(data []byte) error

func (TransferV2) GetID added in v0.2.0

func (tx TransferV2) GetID() []byte

func (*TransferV2) MarshalBinary added in v0.1.2

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

MarshalBinary writes TransferV2 transaction to its bytes representation.

func (*TransferV2) Sign added in v0.1.2

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

Sign adds signature as a proof at first position.

func (TransferV2) Transaction added in v0.1.2

func (TransferV2) Transaction()

func (*TransferV2) UnmarshalBinary added in v0.1.2

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

UnmarshalBinary reads TransferV2 from its bytes representation.

func (*TransferV2) Verify added in v0.1.2

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

Verify checks that first proof is a valid signature.

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