sdk

package
v0.0.0-...-f3b97d8 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2019 License: Apache-2.0 Imports: 30 Imported by: 10

Documentation

Overview

Package sdk provides a client library for the Catapult REST API.

Index

Constants

View Source
const NUM_CHECKSUM_BYTES = 4

Variables

View Source
var (
	ErrResourceNotFound              = newRespError("resource is not found")
	ErrArgumentNotValid              = newRespError("argument is not valid")
	ErrInvalidRequest                = newRespError("request is not valid")
	ErrInternalError                 = newRespError("response is nil")
	ErrNotAcceptedResponseStatusCode = newRespError("not accepted response status code")
)

Catapult REST API errors

View Source
var (
	ErrEmptyMosaicIds      = errors.New("list mosaics ids must not by empty")
	ErrNilMosaicId         = errors.New("mosaicId must not be nil")
	ErrNilMosaicAmount     = errors.New("amount must be not nil")
	ErrInvalidMosaicName   = errors.New("mosaic name is invalid")
	ErrNilMosaicProperties = errors.New("mosaic properties must not be nil")
)

Mosaic errors

View Source
var (
	ErrNamespaceTooManyPart = errors.New("too many parts")
	ErrNilNamespaceId       = errors.New("namespaceId is nil or zero")
	ErrEmptyNamespaceIds    = errors.New("list namespace ids must not by empty")
	ErrInvalidNamespaceName = errors.New("namespace name is invalid")
)

Namespace errors

View Source
var (
	ErrNilOrZeroHeight = errors.New("block height should not be nil or zero")
	ErrNilOrZeroLimit  = errors.New("limit should not be nil or zero")
)

Blockchain errors

View Source
var (
	ErrEmptyAddressesIds = errors.New("list of addresses should not be empty")
	ErrNilAddress        = errors.New("address is nil")
	ErrBlankAddress      = errors.New("address is blank")
	ErrNilAccount        = errors.New("account should not be nil")
	ErrInvalidAddress    = errors.New("wrong address")
)
View Source
var TimestampNemesisBlock = time.Unix(1459468800, 0)
View Source
var XemMosaicId, _ = NewMosaicIdFromFullName("nem:xem")

XemMosaicId is mosaic ID on 'nem:xem' address

Functions

func BigIntegerToHex

func BigIntegerToHex(id *big.Int) string

analog JAVA Uint64.bigIntegerToHex

func ExtractVersion

func ExtractVersion(version uint64) (uint64, error)

func FromBigInt

func FromBigInt(int *big.Int) []uint32

func GenerateChecksum

func GenerateChecksum(b []byte) ([]byte, error)

func GenerateNamespacePath

func GenerateNamespacePath(name string) ([]*big.Int, error)

GenerateNamespacePath create list NamespaceId from string

func IntToHex

func IntToHex(u uint32) string

Types

type AbstractTransaction

type AbstractTransaction struct {
	*TransactionInfo
	NetworkType NetworkType
	Deadline    *Deadline
	Type        TransactionType
	Version     uint64
	Fee         *big.Int
	Signature   string
	Signer      *PublicAccount
}

AbstractTransaction

func (*AbstractTransaction) HasMissingSignatures

func (tx *AbstractTransaction) HasMissingSignatures() bool

func (*AbstractTransaction) IsConfirmed

func (tx *AbstractTransaction) IsConfirmed() bool

func (*AbstractTransaction) IsUnannounced

func (tx *AbstractTransaction) IsUnannounced() bool

func (*AbstractTransaction) IsUnconfirmed

func (tx *AbstractTransaction) IsUnconfirmed() bool

func (*AbstractTransaction) String

func (tx *AbstractTransaction) String() string

func (*AbstractTransaction) ToAggregate

func (tx *AbstractTransaction) ToAggregate(signer *PublicAccount)

type Account

type Account struct {
	*PublicAccount
	*crypto.KeyPair
}

func NewAccount

func NewAccount(networkType NetworkType) (*Account, error)

func NewAccountFromPrivateKey

func NewAccountFromPrivateKey(pKey string, networkType NetworkType) (*Account, error)

func (*Account) Sign

func (a *Account) Sign(tx Transaction) (*SignedTransaction, error)

Sign a transaction

func (*Account) SignCosignatureTransaction

func (a *Account) SignCosignatureTransaction(tx *CosignatureTransaction) (*CosignatureSignedTransaction, error)

Sign aggregate signature transaction

func (*Account) SignWithCosignatures

func (a *Account) SignWithCosignatures(tx *AggregateTransaction, cosignatories []*Account) (*SignedTransaction, error)

Sign transaction with cosignatories creating a new SignedTransaction

type AccountInfo

type AccountInfo struct {
	Address          *Address
	AddressHeight    *big.Int
	PublicKey        string
	PublicKeyHeight  *big.Int
	Importance       *big.Int
	ImportanceHeight *big.Int
	Mosaics          []*Mosaic
}

func (*AccountInfo) String

func (a *AccountInfo) String() string

type AccountService

type AccountService service

AccountService provides a set of methods for obtaining information about the Account

func (*AccountService) AggregateBondedTransactions

func (a *AccountService) AggregateBondedTransactions(ctx context.Context, account *PublicAccount, opt *AccountTransactionsOption) ([]*AggregateTransaction, error)

AggregateBondedTransactions return an array of transactions for which an account is the sender or has sign the transaction. A transaction is said to be aggregate bonded with respect to an account if there are missing signatures.

func (*AccountService) GetAccountInfo

func (a *AccountService) GetAccountInfo(ctx context.Context, address *Address) (*AccountInfo, error)

GetAccountInfo return account info from address

func (*AccountService) GetAccountsInfo

func (a *AccountService) GetAccountsInfo(ctx context.Context, addresses []*Address) ([]*AccountInfo, error)

GetAccountsInfo return AccountsInfo for different accounts.

func (*AccountService) GetMultisigAccountGraphInfo

func (a *AccountService) GetMultisigAccountGraphInfo(ctx context.Context, address *Address) (*MultisigAccountGraphInfo, error)

GetMultisigAccountGraphInfo return a MultisigAccountGraphInfo for an account.

func (*AccountService) GetMultisigAccountInfo

func (a *AccountService) GetMultisigAccountInfo(ctx context.Context, address *Address) (*MultisigAccountInfo, error)

GetMultisigAccountInfo return a MultisigAccountInfo for an account.

func (*AccountService) IncomingTransactions

func (a *AccountService) IncomingTransactions(ctx context.Context, account *PublicAccount, opt *AccountTransactionsOption) ([]Transaction, error)

IncomingTransactions return an array of transactions for which an account is the recipient of a transaction. A transaction is said to be incoming with respect to an account if the account is the recipient of a transaction.

func (*AccountService) OutgoingTransactions

func (a *AccountService) OutgoingTransactions(ctx context.Context, account *PublicAccount, opt *AccountTransactionsOption) ([]Transaction, error)

OutgoingTransactions return an array of transactions for which an account is the sender a transaction. A transaction is said to be outgoing with respect to an account if the account is the sender of a transaction.

func (*AccountService) Transactions

func (a *AccountService) Transactions(ctx context.Context, account *PublicAccount, opt *AccountTransactionsOption) ([]Transaction, error)

Transactions return an array of confirmed transactions for which an account is signer or receiver.

func (*AccountService) UnconfirmedTransactions

func (a *AccountService) UnconfirmedTransactions(ctx context.Context, account *PublicAccount, opt *AccountTransactionsOption) ([]Transaction, error)

UnconfirmedTransactions return the array of transactions for which an account is the sender or receiver and which have not yet been included in a block. Unconfirmed transactions are those transactions that have not yet been included in a block. Unconfirmed transactions are not guaranteed to be included in any block.

type AccountTransactionsOption

type AccountTransactionsOption struct {
	PageSize int    `url:"pageSize,omitempty"`
	Id       string `url:"id,omitempty"`
}

type Address

type Address struct {
	Type    NetworkType
	Address string
}

func NewAddress

func NewAddress(address string, networkType NetworkType) *Address

Create an Address from a given raw address

func NewAddressFromEncoded

func NewAddressFromEncoded(encoded string) (*Address, error)

func NewAddressFromPublicKey

func NewAddressFromPublicKey(pKey string, networkType NetworkType) (*Address, error)

Create an Address from a given raw address.

func NewAddressFromRaw

func NewAddressFromRaw(address string) (*Address, error)

func (*Address) Pretty

func (ad *Address) Pretty() string

type AggregateTransaction

type AggregateTransaction struct {
	AbstractTransaction
	InnerTransactions []Transaction
	Cosignatures      []*AggregateTransactionCosignature
}

AggregateTransaction

func NewBondedAggregateTransaction

func NewBondedAggregateTransaction(deadline *Deadline, innerTxs []Transaction, networkType NetworkType) (*AggregateTransaction, error)

func NewCompleteAggregateTransaction

func NewCompleteAggregateTransaction(deadline *Deadline, innerTxs []Transaction, networkType NetworkType) (*AggregateTransaction, error)

Create an aggregate complete transaction

func (*AggregateTransaction) GetAbstractTransaction

func (tx *AggregateTransaction) GetAbstractTransaction() *AbstractTransaction

func (*AggregateTransaction) String

func (tx *AggregateTransaction) String() string

type AggregateTransactionCosignature

type AggregateTransactionCosignature struct {
	Signature string
	Signer    *PublicAccount
}

AggregateTransactionCosignature

func (*AggregateTransactionCosignature) String

type BlockInfo

type BlockInfo struct {
	NetworkType
	Hash                  string
	GenerationHash        string
	TotalFee              *big.Int
	NumTransactions       uint64
	Signature             string
	Signer                *PublicAccount
	Version               uint64
	Type                  uint64
	Height                *big.Int
	Timestamp             *big.Int
	Difficulty            *big.Int
	PreviousBlockHash     string
	BlockTransactionsHash string
}

Models Block

func (*BlockInfo) String

func (b *BlockInfo) String() string

type BlockchainService

type BlockchainService service

func (*BlockchainService) GetBlockByHeight

func (b *BlockchainService) GetBlockByHeight(ctx context.Context, height *big.Int) (*BlockInfo, error)

Get Block Height

func (*BlockchainService) GetBlockTransactions

func (b *BlockchainService) GetBlockTransactions(ctx context.Context, height *big.Int) ([]Transaction, error)

Get Transactions from a block information

func (*BlockchainService) GetBlockchainHeight

func (b *BlockchainService) GetBlockchainHeight(ctx context.Context) (*big.Int, error)

Get the Chain Height

func (*BlockchainService) GetBlockchainScore

func (b *BlockchainService) GetBlockchainScore(ctx context.Context) (*big.Int, error)

Get the Chain Score

func (*BlockchainService) GetBlockchainStorage

func (b *BlockchainService) GetBlockchainStorage(ctx context.Context) (*BlockchainStorageInfo, error)

Get the Storage Information

func (*BlockchainService) GetBlocksByHeightWithLimit

func (b *BlockchainService) GetBlocksByHeightWithLimit(ctx context.Context, height, limit *big.Int) ([]*BlockInfo, error)

GetBlocksByHeightWithLimit Returns blocks information for a given block height and limit

type BlockchainStorageInfo

type BlockchainStorageInfo struct {
	NumBlocks       int `json:"numBlocks"`
	NumTransactions int `json:"numTransactions"`
	NumAccounts     int `json:"numAccounts"`
}

Blockchain Storage

func (*BlockchainStorageInfo) String

func (b *BlockchainStorageInfo) String() string

type Client

type Client struct {

	// Services for communicating to the Catapult REST APIs
	Blockchain  *BlockchainService
	Mosaic      *MosaicService
	Namespace   *NamespaceService
	Network     *NetworkService
	Transaction *TransactionService
	Account     *AccountService
	// contains filtered or unexported fields
}

Client is Catapult API Client configuration

func NewClient

func NewClient(httpClient *http.Client, conf *Config) *Client

NewClient returns a new Catapult API client. If httpClient is nil then it will create http.DefaultClient

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do sends an API Request and returns a parsed response

func (*Client) DoNewRequest

func (c *Client) DoNewRequest(ctx context.Context, method string, path string, body interface{}, v interface{}) (*http.Response, error)

DoNewRequest creates new request, Do it & return result in V

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest prepare & return new request

type ClientWebsocket

type ClientWebsocket struct {
	Uid string

	Subscribe *SubscribeService
	// contains filtered or unexported fields
}

Catapult Websocket Client configuration

func NewConnectWs

func NewConnectWs(host string, timeout time.Duration) (*ClientWebsocket, error)

type Config

type Config struct {
	BaseURL *url.URL
	NetworkType
}

Config provides service configuration

func NewConfig

func NewConfig(baseUrl string, networkType NetworkType) (*Config, error)

NewConfig is Config constructor according to 'baseURL' & 'networkType'

type CosignatureSignedTransaction

type CosignatureSignedTransaction struct {
	ParentHash Hash   `json:"parentHash"`
	Signature  string `json:"signature"`
	Signer     string `json:"signer"`
}

CosignatureSignedTransaction

type CosignatureTransaction

type CosignatureTransaction struct {
	TransactionToCosign *AggregateTransaction
}

func NewCosignatureTransaction

func NewCosignatureTransaction(txToCosign *AggregateTransaction) (*CosignatureTransaction, error)

func (*CosignatureTransaction) String

func (tx *CosignatureTransaction) String() string

type Deadline

type Deadline struct {
	time.Time
}

Deadline

func NewDeadline

func NewDeadline(d time.Duration) *Deadline

Create deadline model

func (*Deadline) GetInstant

func (d *Deadline) GetInstant() int64

type ErrorInfo

type ErrorInfo struct {
	Error error
}

type Hash

type Hash string

func (Hash) String

func (h Hash) String() string

type HashInfo

type HashInfo struct {
	Meta struct {
		Hash `json:"hash"`
	} `json:"meta"`
}

type HashType

type HashType uint8
const SHA3_512 HashType = 0

func (HashType) String

func (ht HashType) String() string

type LockFundsTransaction

type LockFundsTransaction struct {
	AbstractTransaction
	*Mosaic
	Duration *big.Int
	*SignedTransaction
}

LockFundsTransaction

func NewLockFundsTransaction

func NewLockFundsTransaction(deadline *Deadline, mosaic *Mosaic, duration *big.Int, signedTx *SignedTransaction, networkType NetworkType) (*LockFundsTransaction, error)

func (*LockFundsTransaction) GetAbstractTransaction

func (tx *LockFundsTransaction) GetAbstractTransaction() *AbstractTransaction

func (*LockFundsTransaction) String

func (tx *LockFundsTransaction) String() string

type Message

type Message struct {
	Type    uint8
	Payload string
}

Message

func NewPlainMessage

func NewPlainMessage(payload string) *Message

The transaction message of 1024 characters.

func (*Message) String

func (m *Message) String() string

type ModifyMultisigAccountTransaction

type ModifyMultisigAccountTransaction struct {
	AbstractTransaction
	MinApprovalDelta int
	MinRemovalDelta  int
	Modifications    []*MultisigCosignatoryModification
}

ModifyMultisigAccountTransaction

func NewModifyMultisigAccountTransaction

func NewModifyMultisigAccountTransaction(deadline *Deadline, minApprovalDelta int, minRemovalDelta int, modifications []*MultisigCosignatoryModification, networkType NetworkType) (*ModifyMultisigAccountTransaction, error)

func (*ModifyMultisigAccountTransaction) GetAbstractTransaction

func (tx *ModifyMultisigAccountTransaction) GetAbstractTransaction() *AbstractTransaction

func (*ModifyMultisigAccountTransaction) String

type Mosaic

type Mosaic struct {
	MosaicId *MosaicId
	Amount   *big.Int
}

Mosaic encapsulates mosaic operations

func NewMosaic

func NewMosaic(mosaicId *MosaicId, amount *big.Int) (*Mosaic, error)

NewMosaic create new Mosaic

func Xem

func Xem(amount int64) *Mosaic

Xem create xem with using xem as unit

func XemRelative

func XemRelative(amount int64) *Mosaic

XemRelative create relative xem with using xem as unit

func (*Mosaic) String

func (m *Mosaic) String() string

type MosaicDefinitionTransaction

type MosaicDefinitionTransaction struct {
	AbstractTransaction
	*MosaicProperties
	*NamespaceId
	*MosaicId
	MosaicName string
}

MosaicDefinitionTransaction

func NewMosaicDefinitionTransaction

func NewMosaicDefinitionTransaction(deadline *Deadline, mosaicName string, namespaceId *NamespaceId, mosaicProps *MosaicProperties, networkType NetworkType) (*MosaicDefinitionTransaction, error)

func (*MosaicDefinitionTransaction) GetAbstractTransaction

func (tx *MosaicDefinitionTransaction) GetAbstractTransaction() *AbstractTransaction

func (*MosaicDefinitionTransaction) String

func (tx *MosaicDefinitionTransaction) String() string

type MosaicId

type MosaicId big.Int

MosaicId encapsulates mosaic ID operations

func NewMosaicId

func NewMosaicId(id *big.Int) (*MosaicId, error)

NewMosaicId return mosaic ID from big.Int

func NewMosaicIdFromFullName

func NewMosaicIdFromFullName(name string) (*MosaicId, error)

NewMosaicIdFromFullName return generate mosaic ID from name

func (*MosaicId) String

func (m *MosaicId) String() string

type MosaicInfo

type MosaicInfo struct {
	MosaicId   *MosaicId
	FullName   string
	Active     bool
	Index      int
	MetaId     string
	Namespace  *NamespaceInfo
	Supply     *big.Int
	Height     *big.Int
	Owner      *PublicAccount
	Properties *MosaicProperties
}

MosaicInfo info structure contains its properties, the owner and the namespace to which it belongs to.

func (*MosaicInfo) ShortName

func (m *MosaicInfo) ShortName() string

ShortName return final part of name Mosaic

func (*MosaicInfo) String

func (m *MosaicInfo) String() string

type MosaicName

type MosaicName struct {
	MosaicId *MosaicId
	Name     string
	ParentId *NamespaceId
}

MosaicName include mosaic ID, name & parent namespace ID

func (*MosaicName) String

func (m *MosaicName) String() string

type MosaicProperties

type MosaicProperties struct {
	SupplyMutable bool
	Transferable  bool
	LevyMutable   bool
	Divisibility  int64
	Duration      *big.Int
}

MosaicProperties structure describes mosaic properties.

func NewMosaicProperties

func NewMosaicProperties(supplyMutable bool, transferable bool, levyMutable bool, divisibility int64, duration *big.Int) *MosaicProperties

NewMosaicProperties return MosaicProperties

func (*MosaicProperties) String

func (mp *MosaicProperties) String() string

type MosaicService

type MosaicService service

MosaicService provides a set of methods for obtaining information about the mosaics

func (*MosaicService) GetMosaic

func (ref *MosaicService) GetMosaic(ctx context.Context, mosaicId *MosaicId) (*MosaicInfo, error)

GetMosaic returns @get /mosaic/{mosaicId}

func (*MosaicService) GetMosaicNames

func (ref *MosaicService) GetMosaicNames(ctx context.Context, mscIds []*MosaicId) ([]*MosaicName, error)

GetMosaicNames Get readable names for a set of mosaics post @/mosaic/names

func (*MosaicService) GetMosaics

func (ref *MosaicService) GetMosaics(ctx context.Context, mscIds []*MosaicId) ([]*MosaicInfo, error)

GetMosaics get list mosaics Info post @/mosaic/

func (*MosaicService) GetMosaicsFromNamespace

func (ref *MosaicService) GetMosaicsFromNamespace(ctx context.Context, namespaceId *NamespaceId, pageSize int) (mscInfo []*MosaicInfo, err error)

GetMosaicsFromNamespace Get mosaics information from namespaceId (nsId)

func (*MosaicService) GetMosaicsFromNamespaceUpToMosaic

func (ref *MosaicService) GetMosaicsFromNamespaceUpToMosaic(ctx context.Context, namespaceId *NamespaceId, mosaicId *MosaicId,
	pageSize int) ([]*MosaicInfo, error)

GetMosaicsFromNamespaceUpToMosaic get mosaics information according to namespace ID & mosaic ID

type MosaicSupplyChangeTransaction

type MosaicSupplyChangeTransaction struct {
	AbstractTransaction
	MosaicSupplyType
	*MosaicId
	Delta *big.Int
}

MosaicSupplyChangeTransaction

func NewMosaicSupplyChangeTransaction

func NewMosaicSupplyChangeTransaction(deadline *Deadline, mosaicId *MosaicId, supplyType MosaicSupplyType, delta *big.Int, networkType NetworkType) (*MosaicSupplyChangeTransaction, error)

func (*MosaicSupplyChangeTransaction) GetAbstractTransaction

func (tx *MosaicSupplyChangeTransaction) GetAbstractTransaction() *AbstractTransaction

func (*MosaicSupplyChangeTransaction) String

type MosaicSupplyType

type MosaicSupplyType uint8

MosaicSupplyType mosaic supply type : Decrease the supply - DECREASE. Increase the supply - INCREASE.

const (
	Decrease MosaicSupplyType = iota
	Increase
)

MosaicSupplyType values

func (MosaicSupplyType) String

func (tx MosaicSupplyType) String() string

type MultisigAccountGraphInfo

type MultisigAccountGraphInfo struct {
	MultisigAccounts map[int32][]*MultisigAccountInfo
}

type MultisigAccountInfo

type MultisigAccountInfo struct {
	Account          PublicAccount
	MinApproval      int32
	MinRemoval       int32
	Cosignatories    []*PublicAccount
	MultisigAccounts []*PublicAccount
}

func (*MultisigAccountInfo) String

func (ref *MultisigAccountInfo) String() string

type MultisigCosignatoryModification

type MultisigCosignatoryModification struct {
	Type MultisigCosignatoryModificationType
	*PublicAccount
}

MultisigCosignatoryModification

func (*MultisigCosignatoryModification) String

type MultisigCosignatoryModificationType

type MultisigCosignatoryModificationType uint8
const (
	Add MultisigCosignatoryModificationType = iota
	Remove
)

func (MultisigCosignatoryModificationType) String

type NamespaceId

type NamespaceId big.Int

NamespaceId encapsulates namespace id operations

func NewNamespaceId

func NewNamespaceId(id *big.Int) (*NamespaceId, error)

NewNamespaceId generate new NamespaceId from bigInt

func NewNamespaceIdFromName

func NewNamespaceIdFromName(namespaceName string) (*NamespaceId, error)

NewNamespaceIdFromName generate Id from namespaceName

func (*NamespaceId) String

func (n *NamespaceId) String() string

type NamespaceIds

type NamespaceIds struct {
	List []*NamespaceId
}

NamespaceIds is a list of NamespaceId

func (*NamespaceIds) Decode

func (ref *NamespaceIds) Decode(ptr unsafe.Pointer, iter *jsoniter.Iterator)

Decode get namespace list from JSON stream

func (*NamespaceIds) Encode

func (ref *NamespaceIds) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

Encode serialize NamespaceIds to JSON stream

func (*NamespaceIds) IsEmpty

func (ref *NamespaceIds) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty returns true is list not empty for JSON operation

func (*NamespaceIds) MarshalJSON

func (ref *NamespaceIds) MarshalJSON() (buf []byte, err error)

MarshalJSON serialize namespaceId list

type NamespaceInfo

type NamespaceInfo struct {
	NamespaceId *NamespaceId
	FullName    string
	Active      bool
	Index       int
	MetaId      string
	TypeSpace   NamespaceType
	Depth       int
	Levels      []*NamespaceId
	Parent      *NamespaceInfo
	Owner       *PublicAccount
	StartHeight *big.Int
	EndHeight   *big.Int
}

NamespaceInfo contains the state information of a Namespace.

func (*NamespaceInfo) String

func (ref *NamespaceInfo) String() string

type NamespaceName

type NamespaceName struct {
	NamespaceId *NamespaceId
	Name        string
	ParentId    *NamespaceId /* Optional NamespaceId my be nil */
}

NamespaceName name info structure describes basic information of a namespace and name.

func (*NamespaceName) String

func (n *NamespaceName) String() string

type NamespaceService

type NamespaceService service

NamespaceService provides a set of methods for obtaining information about the namespace

func (*NamespaceService) GetNamespace

func (ref *NamespaceService) GetNamespace(ctx context.Context, nsId *NamespaceId) (*NamespaceInfo, error)

GetNamespace return full info about Namespace according to namespace ID @/namespace/

func (*NamespaceService) GetNamespaceNames

func (ref *NamespaceService) GetNamespaceNames(ctx context.Context, nsIds []*NamespaceId) ([]*NamespaceName, error)

GetNamespaceNames return full info about Namespaces according to slice namespace ID @/namespace/names

func (*NamespaceService) GetNamespacesFromAccount

func (ref *NamespaceService) GetNamespacesFromAccount(ctx context.Context, address *Address, nsId *NamespaceId,
	pageSize int) ([]*NamespaceInfo, error)

GetNamespacesFromAccount get required params addresses, other skipped if value < 0 @/account/%s/namespaces

func (*NamespaceService) GetNamespacesFromAccounts

func (ref *NamespaceService) GetNamespacesFromAccounts(ctx context.Context, addrs []*Address, nsId *NamespaceId,
	pageSize int) ([]*NamespaceInfo, error)

GetNamespacesFromAccounts get required params addresses, other skipped if value is empty @/account/namespaces

type NamespaceType

type NamespaceType uint8

NamespaceType includes constants namespaces types

const (
	Root NamespaceType = iota
	Sub
)

type NetworkService

type NetworkService service

NetworkService provides a set of methods for obtaining information about the Network

func (*NetworkService) GetNetworkType

func (ref *NetworkService) GetNetworkType(ctx context.Context) (NetworkType, error)

GetNetworkType return current network type @get /network

type NetworkType

type NetworkType uint8

NetworkType provides methods for getting network type

const (
	MainNet         NetworkType = 104
	TestNet         NetworkType = 152
	Mijin           NetworkType = 96
	MijinTest       NetworkType = 144
	NotSupportedNet NetworkType = 0
)

NetworkType enums

func ExtractNetworkType

func ExtractNetworkType(version uint64) NetworkType

ExtractNetworkType return networkType from version

func NetworkTypeFromString

func NetworkTypeFromString(networkType string) NetworkType

NetworkTypeFromString return networkType from string representation

func (NetworkType) String

func (nt NetworkType) String() string

type PartialRemovedInfo

type PartialRemovedInfo struct {
	HashInfo
}

structure for Subscribe PartialRemoved

type PublicAccount

type PublicAccount struct {
	Address   *Address
	PublicKey string
}

func NewAccountFromPublicKey

func NewAccountFromPublicKey(pKey string, networkType NetworkType) (*PublicAccount, error)

func (*PublicAccount) String

func (ref *PublicAccount) String() string

type RegisterNamespaceTransaction

type RegisterNamespaceTransaction struct {
	AbstractTransaction
	*NamespaceId
	NamespaceType
	NamspaceName string
	Duration     *big.Int
	ParentId     *NamespaceId
}

RegisterNamespaceTransaction

func NewRegisterRootNamespaceTransaction

func NewRegisterRootNamespaceTransaction(deadline *Deadline, namespaceName string, duration *big.Int, networkType NetworkType) (*RegisterNamespaceTransaction, error)

func NewRegisterSubNamespaceTransaction

func NewRegisterSubNamespaceTransaction(deadline *Deadline, namespaceName string, parentId *NamespaceId, networkType NetworkType) (*RegisterNamespaceTransaction, error)

func (*RegisterNamespaceTransaction) GetAbstractTransaction

func (tx *RegisterNamespaceTransaction) GetAbstractTransaction() *AbstractTransaction

func (*RegisterNamespaceTransaction) String

func (tx *RegisterNamespaceTransaction) String() string

type RespErr

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

func (*RespErr) Error

func (r *RespErr) Error() string

type SecretLockTransaction

type SecretLockTransaction struct {
	AbstractTransaction
	*Mosaic
	HashType
	Duration  *big.Int
	Secret    string
	Recipient *Address
}

SecretLockTransaction

func NewSecretLockTransaction

func NewSecretLockTransaction(deadline *Deadline, mosaic *Mosaic, duration *big.Int, hashType HashType, secret string, recipient *Address, networkType NetworkType) (*SecretLockTransaction, error)

func (*SecretLockTransaction) GetAbstractTransaction

func (tx *SecretLockTransaction) GetAbstractTransaction() *AbstractTransaction

func (*SecretLockTransaction) String

func (tx *SecretLockTransaction) String() string

type SecretProofTransaction

type SecretProofTransaction struct {
	AbstractTransaction
	HashType
	Secret string
	Proof  string
}

SecretProofTransaction

func NewSecretProofTransaction

func NewSecretProofTransaction(deadline *Deadline, hashType HashType, secret string, proof string, networkType NetworkType) (*SecretProofTransaction, error)

func (*SecretProofTransaction) GetAbstractTransaction

func (tx *SecretProofTransaction) GetAbstractTransaction() *AbstractTransaction

func (*SecretProofTransaction) String

func (tx *SecretProofTransaction) String() string

type SignedTransaction

type SignedTransaction struct {
	TransactionType `json:"transactionType"`
	Payload         string `json:"payload"`
	Hash            Hash   `json:"hash"`
}

SignedTransaction

type SignerInfo

type SignerInfo struct {
	Signer     string `json:"signer"`
	Signature  string `json:"signature"`
	ParentHash Hash   `json:"parentHash"`
}

type StatusInfo

type StatusInfo struct {
	Status string `json:"status"`
	Hash   Hash   `json:"hash"`
}

structure for Subscribe status

type SubscribeBlock

type SubscribeBlock struct {
	Ch chan *BlockInfo
	// contains filtered or unexported fields
}
var Block *SubscribeBlock

func (*SubscribeBlock) Unsubscribe

func (s *SubscribeBlock) Unsubscribe() error

type SubscribeError

type SubscribeError struct {
	Ch chan *ErrorInfo
	// contains filtered or unexported fields
}

func (*SubscribeError) Unsubscribe

func (s *SubscribeError) Unsubscribe() error

type SubscribeHash

type SubscribeHash struct {
	Ch chan *UnconfirmedRemoved
	// contains filtered or unexported fields
}

func (*SubscribeHash) Unsubscribe

func (s *SubscribeHash) Unsubscribe() error

type SubscribePartialRemoved

type SubscribePartialRemoved struct {
	Ch chan *PartialRemovedInfo
	// contains filtered or unexported fields
}

func (*SubscribePartialRemoved) Unsubscribe

func (s *SubscribePartialRemoved) Unsubscribe() error

type SubscribeService

type SubscribeService serviceWs

func (*SubscribeService) Block

func (c *SubscribeService) Block() (*SubscribeBlock, error)

Block notifies for every new block. The message contains the BlockInfo struct.

func (*SubscribeService) ConfirmedAdded

func (c *SubscribeService) ConfirmedAdded(add *Address) (*SubscribeTransaction, error)

ConfirmedAdded notifies when a transaction related to an address is included in a block. The message contains the transaction.

func (*SubscribeService) Cosignature

func (c *SubscribeService) Cosignature(add *Address) (*SubscribeSigner, error)

Cosignature notifies when a cosignature signed transaction related to an address is added to an aggregate bonded transaction with partial state. The message contains the cosignature signed transaction.

func (*SubscribeService) Error

func (c *SubscribeService) Error(add *Address) (*SubscribeError, error)

func (*SubscribeService) PartialAdded

func (c *SubscribeService) PartialAdded(add *Address) (*SubscribeTransaction, error)

PartialAdded notifies when an aggregate bonded transaction related to an address is in partial state and waiting to have all required cosigners. The message contains a transaction.

func (*SubscribeService) PartialRemoved

func (c *SubscribeService) PartialRemoved(add *Address) (*SubscribePartialRemoved, error)

PartialRemoved notifies when a transaction related to an address was in partial state but not anymore. The message contains the transaction hash.

func (*SubscribeService) Status

func (c *SubscribeService) Status(add *Address) (*SubscribeStatus, error)

Status notifies when a transaction related to an address rises an error. The message contains the error message and the transaction hash.

func (*SubscribeService) UnconfirmedAdded

func (c *SubscribeService) UnconfirmedAdded(add *Address) (*SubscribeTransaction, error)

UnconfirmedAdded notifies when a transaction related to an address is in unconfirmed state and waiting to be included in a block. The message contains the transaction.

func (*SubscribeService) UnconfirmedRemoved

func (c *SubscribeService) UnconfirmedRemoved(add *Address) (*SubscribeHash, error)

UnconfirmedRemoved notifies when a transaction related to an address was in unconfirmed state but not anymore. The message contains the transaction hash.

type SubscribeSigner

type SubscribeSigner struct {
	Ch chan *SignerInfo
	// contains filtered or unexported fields
}

func (*SubscribeSigner) Unsubscribe

func (s *SubscribeSigner) Unsubscribe() error

type SubscribeStatus

type SubscribeStatus struct {
	Ch chan *StatusInfo
	// contains filtered or unexported fields
}

func (*SubscribeStatus) Unsubscribe

func (s *SubscribeStatus) Unsubscribe() error

type SubscribeTransaction

type SubscribeTransaction struct {
	Ch chan Transaction
	// contains filtered or unexported fields
}

func (*SubscribeTransaction) Unsubscribe

func (s *SubscribeTransaction) Unsubscribe() error

type Transaction

type Transaction interface {
	GetAbstractTransaction() *AbstractTransaction
	String() string
	// contains filtered or unexported methods
}

Models Transaction

func MapTransaction

func MapTransaction(b *bytes.Buffer) (Transaction, error)

func MapTransactions

func MapTransactions(b *bytes.Buffer) ([]Transaction, error)

type TransactionHashesDTO

type TransactionHashesDTO struct {
	Hashes []string `json:"hashes"`
}

TransactionHashes

type TransactionIdsDTO

type TransactionIdsDTO struct {
	Ids []string `json:"transactionIds"`
}

TransactionIds

type TransactionInfo

type TransactionInfo struct {
	Height              *big.Int
	Index               uint32
	Id                  string
	Hash                Hash
	MerkleComponentHash Hash
	AggregateHash       Hash
	AggregateId         string
}

Transaction Info

func (*TransactionInfo) String

func (ti *TransactionInfo) String() string

type TransactionService

type TransactionService service

func (*TransactionService) Announce

func (txs *TransactionService) Announce(ctx context.Context, tx *SignedTransaction) (string, error)

Announce a transaction to the network

func (*TransactionService) AnnounceAggregateBonded

func (txs *TransactionService) AnnounceAggregateBonded(ctx context.Context, tx *SignedTransaction) (string, error)

Announce a partial transaction to the network

func (*TransactionService) AnnounceAggregateBondedCosignature

func (txs *TransactionService) AnnounceAggregateBondedCosignature(ctx context.Context, c *CosignatureSignedTransaction) (string, error)

Announce a cosignature transaction to the network

func (*TransactionService) GetTransaction

func (txs *TransactionService) GetTransaction(ctx context.Context, id string) (Transaction, error)

Returns transaction information for a given transaction id or hash

func (*TransactionService) GetTransactionStatus

func (txs *TransactionService) GetTransactionStatus(ctx context.Context, id string) (*TransactionStatus, error)

Returns transaction status for a given transaction id or hash

func (*TransactionService) GetTransactionStatuses

func (txs *TransactionService) GetTransactionStatuses(ctx context.Context, hashes []string) ([]*TransactionStatus, error)

Returns transaction information for a given set of transaction hash

func (*TransactionService) GetTransactions

func (txs *TransactionService) GetTransactions(ctx context.Context, ids []string) ([]Transaction, error)

Returns transaction information for a given set of transaction id or hash

type TransactionStatus

type TransactionStatus struct {
	Deadline *Deadline
	Group    string
	Status   string
	Hash     Hash
	Height   *big.Int
}

TransactionStatus

func (*TransactionStatus) String

func (ts *TransactionStatus) String() string

type TransactionType

type TransactionType uint16
const (
	AggregateCompleted TransactionType = iota
	AggregateBonded
	MosaicDefinition
	MosaicSupplyChange
	ModifyMultisig
	RegisterNamespace
	Transfer
	Lock
	SecretLock
	SecretProof
)

TransactionType enums

func TransactionTypeFromRaw

func TransactionTypeFromRaw(value uint32) (TransactionType, error)

func (TransactionType) Hex

func (t TransactionType) Hex() uint16

func (TransactionType) Raw

func (t TransactionType) Raw() uint32

func (TransactionType) String

func (t TransactionType) String() string

type TransferTransaction

type TransferTransaction struct {
	AbstractTransaction
	*Message
	Mosaics   []*Mosaic
	Recipient *Address
}

TransferTransaction

func NewTransferTransaction

func NewTransferTransaction(deadline *Deadline, recipient *Address, mosaics []*Mosaic, message *Message, networkType NetworkType) (*TransferTransaction, error)

Create a transfer transaction

func (*TransferTransaction) GetAbstractTransaction

func (tx *TransferTransaction) GetAbstractTransaction() *AbstractTransaction

func (*TransferTransaction) String

func (tx *TransferTransaction) String() string

type UnconfirmedRemoved

type UnconfirmedRemoved struct {
	HashInfo
}

structure for Subscribe UnconfirmedRemoved

type VarSize

type VarSize uint32
const (
	ByteSize  VarSize = 1
	ShortSize VarSize = 2
	IntSize   VarSize = 4
)

Jump to

Keyboard shortcuts

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