aeternity

package
v4.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2019 License: ISC Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Base58c = ObjectEncoding("b58c")
	Base64c = ObjectEncoding("b64c")
)

Encoding strategies

View Source
const (
	// Prefix separator
	PrefixSeparator = "_"

	// Base58 prefixes
	PrefixAccountPubkey         = HashPrefix("ak_")
	PrefixBlockProofOfFraudHash = HashPrefix("bf_")
	PrefixBlockStateHash        = HashPrefix("bs_")
	PrefixBlockTransactionHash  = HashPrefix("bx_")
	PrefixChannel               = HashPrefix("ch_")
	PrefixCommitment            = HashPrefix("cm_")
	PrefixContractPubkey        = HashPrefix("ct_")
	PrefixKeyBlockHash          = HashPrefix("kh_")
	PrefixMicroBlockHash        = HashPrefix("mh_")
	PrefixName                  = HashPrefix("nm_")
	PrefixOraclePubkey          = HashPrefix("ok_")
	PrefixOracleQueryID         = HashPrefix("oq_")
	PrefixPeerPubkey            = HashPrefix("pp_")
	PrefixSignature             = HashPrefix("sg_")
	PrefixTransactionHash       = HashPrefix("th_")

	// Base 64 encoded transactions
	PrefixContractByteArray = HashPrefix("cb_")
	PrefixOracleResponse    = HashPrefix("or_")
	PrefixOracleQuery       = HashPrefix("ov_")
	PrefixProofOfInclusion  = HashPrefix("pi_")
	PrefixStateTrees        = HashPrefix("ss_")
	PrefixState             = HashPrefix("st_")
	PrefixTransaction       = HashPrefix("tx_")
)

Prefixes

View Source
const (
	IDTagAccount    uint8 = 1
	IDTagName       uint8 = 2
	IDTagCommitment uint8 = 3
	IDTagOracle     uint8 = 4
	IDTagContract   uint8 = 5
	IDTagChannel    uint8 = 6
)

Tag constant for ids (type uint8) see https://github.com/aeternity/protocol/blob/master/serializations.md#the-id-type <<Tag:1/unsigned-integer-unit:8, Hash:32/binary-unit:8>>

View Source
const (
	ObjectTagAccount                             uint = 10
	ObjectTagSignedTransaction                   uint = 11
	ObjectTagSpendTransaction                    uint = 12
	ObjectTagOracle                              uint = 20
	ObjectTagOracleQuery                         uint = 21
	ObjectTagOracleRegisterTransaction           uint = 22
	ObjectTagOracleQueryTransaction              uint = 23
	ObjectTagOracleResponseTransaction           uint = 24
	ObjectTagOracleExtendTransaction             uint = 25
	ObjectTagNameServiceName                     uint = 30
	ObjectTagNameServiceCommitment               uint = 31
	ObjectTagNameServiceClaimTransaction         uint = 32
	ObjectTagNameServicePreclaimTransaction      uint = 33
	ObjectTagNameServiceUpdateTransaction        uint = 34
	ObjectTagNameServiceRevokeTransaction        uint = 35
	ObjectTagNameServiceTransferTransaction      uint = 36
	ObjectTagContract                            uint = 40
	ObjectTagContractCall                        uint = 41
	ObjectTagContractCreateTransaction           uint = 42
	ObjectTagContractCallTransaction             uint = 43
	ObjectTagChannelCreateTransaction            uint = 50
	ObjectTagChannelDepositTransaction           uint = 51
	ObjectTagChannelWithdrawTransaction          uint = 52
	ObjectTagChannelForceProgressTransaction     uint = 521
	ObjectTagChannelCloseMutualTransaction       uint = 53
	ObjectTagChannelCloseSoloTransaction         uint = 54
	ObjectTagChannelSlashTransaction             uint = 55
	ObjectTagChannelSettleTransaction            uint = 56
	ObjectTagChannelOffChainTransaction          uint = 57
	ObjectTagChannelOffChainUpdateTransfer       uint = 570
	ObjectTagChannelOffChainUpdateDeposit        uint = 571
	ObjectTagChannelOffChainUpdateWithdrawal     uint = 572
	ObjectTagChannelOffChainUpdateCreateContract uint = 573
	ObjectTagChannelOffChainUpdateCallContract   uint = 574
	ObjectTagChannel                             uint = 58
	ObjectTagChannelSnapshotTransaction          uint = 59
	ObjectTagPoi                                 uint = 60
	ObjectTagMicroBody                           uint = 101
	ObjectTagLightMicroBlock                     uint = 102
)

Object tags see https://github.com/aeternity/protocol/blob/master/serializations.md#binary-serialization

View Source
const (
	// ConfigFilename default configuration file name
	ConfigFilename = "config"
)

Variables

View Source
var Config = ProfileConfig{
	Name: "Default Config",
	Node: NodeConfig{
		URL:         "https://sdk-mainnet.aepps.com",
		URLInternal: "https://sdk-mainnet.aepps.com",
		URLChannels: "https://sdk-mainnet.aepps.com",
		NetworkID:   "ae_mainnet",
	},
	Client: ClientConfig{
		BaseGas:    *utils.NewIntFromUint64(15000),
		GasPerByte: *utils.NewIntFromUint64(20),
		GasPrice:   *utils.NewIntFromUint64(1000000000),
		TTL:        500,
		Fee:        *utils.RequireIntFromString("200000000000000"),
		Names: AensConfig{
			NameTTL:     500,
			ClientTTL:   500,
			PreClaimFee: *utils.RequireIntFromString("100000000000000"),
			ClaimFee:    *utils.RequireIntFromString("100000000000000"),
			UpdateFee:   *utils.RequireIntFromString("100000000000000"),
		},
		Contracts: ContractConfig{
			Gas:        *utils.NewIntFromUint64(1e9),
			GasPrice:   *utils.NewIntFromUint64(1e9),
			Amount:     *new(big.Int),
			Deposit:    *new(big.Int),
			VMVersion:  3,
			ABIVersion: 1,
		},
		Oracles: OracleConfig{
			QueryFee:         *utils.NewIntFromUint64(0),
			QueryTTLType:     0,
			QueryTTLValue:    300,
			ResponseTTLType:  0,
			ResponseTTLValue: 300,
			VMVersion:        0,
		},
		StateChannels: StateChannelConfig{
			LockPeriod:     0,
			ChannelReserve: 0,
		},
		NativeTransactions: false,
		Offline:            false,
	},
	Tuning: TuningConfig{
		ChainPollInteval:  100,
		ChainTimeout:      5000,
		CryptoKdfMemlimit: 1024 * 32,
		CryptoKdfOpslimit: 3,
		CryptoKdfThreads:  1,
		OutputFormatJSON:  false,
	},
}

Config sytem configuration

Functions

func BaseEncodeTx

func BaseEncodeTx(tx Tx) (string, error)

BaseEncodeTx takes a Tx, runs its RLP() method, and base encodes the result.

func BroadcastTransaction

func BroadcastTransaction(c transactionPoster, txSignedBase64 string) (err error)

BroadcastTransaction differs from Client.PostTransaction() in that the latter just handles the HTTP request via swagger, the former recalculates the txhash and compares it to the node's

response after POSTing the transaction.

func Decode

func Decode(in string) (out []byte, err error)

Decode a string encoded with base58/base64 + checksum to a byte array

func DecodeRLPMessage

func DecodeRLPMessage(rawBytes []byte) []interface{}

DecodeRLPMessage transforms a plain stream of bytes into a structure of bytes that represents the object that was serialized

func Encode

func Encode(prefix HashPrefix, data []byte) string

Encode a byte array into base58/base64 with chacksum and a prefix

func GetNextNonce

func GetNextNonce(c getAccounter, accountID string) (nextNonce uint64, err error)

GetNextNonce retrieves the current accountNonce and adds 1 to it for use in transaction building

func GetTTL

func GetTTL(c getHeighter, offset uint64) (ttl uint64, err error)

GetTTL returns the chain height + offset

func GetTTLNonce

func GetTTLNonce(c getHeightAccounter, accountID string, offset uint64) (height uint64, nonce uint64, err error)

GetTTLNonce combines the commonly used together functions of GetTTL and GetNextNonce

func GetWalletPath

func GetWalletPath(path string) (walletPath string, err error)

GetWalletPath try to locate a wallet

func KeystoreSeal

func KeystoreSeal(account *Account, password string) (j []byte, e error)

KeystoreSeal create an encrypted json keystore with the private key of the account

func Namehash

func Namehash(name string) []byte

Namehash calculate the Namehash of a string TODO: link to the

func Pp

func Pp(data ...interface{})

Pp pretty print

func PpI

func PpI(indentSize int, data ...interface{})

PpI pretty print indent

func PpT

func PpT(indentSize int, title string)

PpT pretty print indent Title

func PrintError

func PrintError(code string, e *models.Error)

PrintError print error

func PrintObject

func PrintObject(title string, i interface{})

PrintObject pretty print an object obtained from the api with a title

func SignEncodeTx

func SignEncodeTx(kp *Account, txRaw []byte, networkID string) (signedEncodedTx, signedEncodedTxHash, signature string, err error)

SignEncodeTx sign and encode a transaction

func SignEncodeTxStr

func SignEncodeTxStr(kp *Account, tx string, networkID string) (signedEncodedTx, signedEncodedTxHash, signature string, err error)

SignEncodeTxStr sign and encode a transaction format as string (ex. tx_xyz)

func StoreAccountToKeyStoreFile

func StoreAccountToKeyStoreFile(account *Account, password, walletName string) (filePath string, err error)

StoreAccountToKeyStoreFile store an account to a json file

func Verify

func Verify(address string, message, signature []byte) (valid bool, err error)

Verify a message with a private key

func VerifySignedTx

func VerifySignedTx(accountID string, txSigned string, networkID string) (valid bool, err error)

VerifySignedTx verifies a tx_ with signature

func WaitForTransactionUntilHeight

func WaitForTransactionUntilHeight(c getTransactionByHashHeighter, txHash string, untilHeight uint64) (blockHeight uint64, blockHash string, err error)

WaitForTransactionUntilHeight waits for a transaction until heightLimit (inclusive) is reached

Types

type Account

type Account struct {
	SigningKey ed25519.PrivateKey
	Address    string
}

Account holds the signing key and the aeternity account address

func AccountFromHexString

func AccountFromHexString(hexPrivateKey string) (account *Account, err error)

AccountFromHexString load an account from hex string

func KeystoreOpen

func KeystoreOpen(data []byte, password string) (account *Account, err error)

KeystoreOpen open and decrypt a keystore

func LoadAccountFromKeyStoreFile

func LoadAccountFromKeyStoreFile(keyFile, password string) (account *Account, err error)

LoadAccountFromKeyStoreFile load file from the keystore

func NewAccount

func NewAccount() (account *Account, err error)

NewAccount genereate a new keypair

func (*Account) Sign

func (account *Account) Sign(message []byte) (signature []byte)

Sign a message with a private key

func (*Account) SigningKeyToHexString

func (account *Account) SigningKeyToHexString() (signingKeyHex string)

SigningKeyToHexString return the SigningKey as an hex string

type AensConfig

type AensConfig struct {
	NameTTL     uint64  `json:"name_ttl" yaml:"name_ttl" mapstructure:"name_ttl"`
	ClientTTL   uint64  `json:"client_ttl" yaml:"client_ttl" mapstructure:"client_ttl"`
	PreClaimFee big.Int `json:"preclaim_fee" yaml:"preclaim_fee" mapstructure:"preclaim_fee"`
	ClaimFee    big.Int `json:"claim_fee" yaml:"claim_fee" mapstructure:"claim_fee"`
	UpdateFee   big.Int `json:"update_fee" yaml:"update_fee" mapstructure:"update_fee"`
}

AensConfig configurations for Aens

type ClientConfig

type ClientConfig struct {
	BaseGas            big.Int
	GasPerByte         big.Int
	GasPrice           big.Int
	TTL                uint64             `json:"ttl" yaml:"ttl" mapstructure:"ttl"`
	Fee                big.Int            `json:"fee" yaml:"fee" mapstructure:"fee"`
	DefaultKey         string             `json:"default_key_name" yaml:"default_key_name" mapstructure:"default_key_name"`
	Names              AensConfig         `json:"names" yaml:"names" mapstructure:"names"`
	Contracts          ContractConfig     `json:"contracts" yaml:"contracts" mapstructure:"contracts"`
	Oracles            OracleConfig       `json:"oracles" yaml:"oracles" mapstructure:"oracles"`
	StateChannels      StateChannelConfig `json:"state_channels" yaml:"state_channels" mapstructure:"state_channels"`
	NativeTransactions bool               `yaml:"native_transactions" json:"native_transactions" mapstructure:"native_transactions"`
	Offline            bool               `yaml:"offline" json:"offline" mapstructure:"offline"`
}

ClientConfig client parameters configuration

type Compiler

type Compiler struct {
	*compiler_client.Compiler
}

Compiler wraps around the swagger-generated Compiler. Unlike the swagger-generated Compiler, this Compiler struct builds the swagger HTTP requests from the Golang native arguments that its methods receive, and uses the swagger-generated Compiler's endpoints to send these requests off. It then parses the swagger response and makes it as native-Go-code-friendly as possible.

func NewCompiler

func NewCompiler(compilerURL string, debug bool) *Compiler

NewCompiler creates a new Compiler instance from a URL

func (*Compiler) APIVersion

func (c *Compiler) APIVersion() (version string, err error)

APIVersion connects to the compiler and returns its version string, e.g. 3.1.0

func (*Compiler) CompileContract

func (c *Compiler) CompileContract(source string) (bytecode string, err error)

CompileContract abstracts away the swagger specifics of posting to /compile

func (*Compiler) DecodeCallResult

func (c *Compiler) DecodeCallResult(callResult string, callValue string, function string, source string) (answer interface{}, err error)

DecodeCallResult abstracts away the swagger specifics of posting to /decode-call-result

func (*Compiler) DecodeCalldataBytecode

func (c *Compiler) DecodeCalldataBytecode(bytecode string, calldata string) (decodedCallData *models.DecodedCalldata, err error)

DecodeCalldataBytecode abstracts away the swagger specifics of posting to /decode-calldata/bytecode

func (*Compiler) DecodeCalldataSource

func (c *Compiler) DecodeCalldataSource(source string, callData string) (decodedCallData *models.DecodedCalldata, err error)

DecodeCalldataSource abstracts away the swagger specifics of posting to /decode-calldata/source

func (*Compiler) DecodeData

func (c *Compiler) DecodeData(data string, sophiaType string) (decodedData *models.SophiaJSONData, err error)

DecodeData abstracts away the swagger specifics of posting to /decode-data

func (*Compiler) EncodeCalldata

func (c *Compiler) EncodeCalldata(source string, function string, args []string) (callData string, err error)

EncodeCalldata abstracts away the swagger specifics of posting to /encode-calldata

func (*Compiler) GenerateACI

func (c *Compiler) GenerateACI(source string) (aci *models.ACI, err error)

GenerateACI abstracts away the swagger specifics of posting to /aci

func (*Compiler) SophiaVersion

func (c *Compiler) SophiaVersion() (version string, err error)

SophiaVersion abstracts away the swagger specifics of getting /version

type Context

type Context struct {
	Client  *Node
	Address string
}

Context stores relevant context (node connection, account address) that one might not want to spell out each time one creates a transaction

func (*Context) ContractCallTx

func (c *Context) ContractCallTx(ContractID, CallData string, AbiVersion uint16, Amount, Gas, GasPrice, Fee big.Int) (tx ContractCallTx, err error)

ContractCallTx returns a transaction for calling a contract on the chain

func (*Context) ContractCreateTx

func (c *Context) ContractCreateTx(Code string, CallData string, VMVersion, AbiVersion uint16, Deposit, Amount, Gas, GasPrice, Fee big.Int) (tx ContractCreateTx, err error)

ContractCreateTx returns a transaction for creating a contract on the chain

func (*Context) NameClaimTx

func (c *Context) NameClaimTx(name string, nameSalt big.Int, fee big.Int) (tx NameClaimTx, err error)

NameClaimTx creates a claim transaction

func (*Context) NamePreclaimTx

func (c *Context) NamePreclaimTx(name string, fee big.Int) (tx NamePreclaimTx, nameSalt *big.Int, err error)

NamePreclaimTx creates a name preclaim transaction and salt (required for claiming) It should return the Tx struct, not the base64 encoded RLP, to ease subsequent inspection.

func (*Context) NameRevokeTx

func (c *Context) NameRevokeTx(name string) (tx NameRevokeTx, err error)

NameRevokeTx revoke a name

func (*Context) NameTransferTx

func (c *Context) NameTransferTx(name string, recipientAddress string) (tx NameTransferTx, err error)

NameTransferTx transfer a name to another owner

func (*Context) NameUpdateTx

func (c *Context) NameUpdateTx(name string, targetAddress string) (tx NameUpdateTx, err error)

NameUpdateTx perform a name update

func (*Context) OracleExtendTx

func (c *Context) OracleExtendTx(oracleID string, ttlType, ttlValue uint64) (tx OracleExtendTx, err error)

OracleExtendTx extend the lifetime of an existing oracle

func (*Context) OracleQueryTx

func (c *Context) OracleQueryTx(OracleID, Query string, QueryFee big.Int, QueryTTLType, QueryTTLValue, ResponseTTLType, ResponseTTLValue uint64) (tx OracleQueryTx, err error)

OracleQueryTx ask something of an oracle

func (*Context) OracleRegisterTx

func (c *Context) OracleRegisterTx(querySpec, responseSpec string, queryFee big.Int, oracleTTLType, oracleTTLValue uint64, abiVersion uint16) (tx OracleRegisterTx, err error)

OracleRegisterTx create a new oracle

func (*Context) OracleRespondTx

func (c *Context) OracleRespondTx(OracleID string, QueryID string, Response string, TTLType uint64, TTLValue uint64) (tx OracleRespondTx, err error)

OracleRespondTx the oracle responds by sending this transaction

type ContractCallTx

type ContractCallTx struct {
	CallerID     string
	AccountNonce uint64
	ContractID   string
	Amount       big.Int
	Gas          big.Int
	GasPrice     big.Int
	AbiVersion   uint16
	CallData     string
	Fee          big.Int
	TTL          uint64
}

ContractCallTx represents calling an existing smart contract VMVersion is not included in RLP serialized representation (implied by contract type already)

func NewContractCallTx

func NewContractCallTx(CallerID string, AccountNonce uint64, ContractID string, Amount, Gas, GasPrice big.Int, AbiVersion uint16, CallData string, Fee big.Int, TTL uint64) ContractCallTx

NewContractCallTx is a constructor for a ContractCallTx struct

func (*ContractCallTx) FeeEstimate

func (tx *ContractCallTx) FeeEstimate() (*big.Int, error)

FeeEstimate estimates the fee needed for the node to accept this transaction, assuming the fee is 8 bytes long when RLP serialized.

func (*ContractCallTx) JSON

func (tx *ContractCallTx) JSON() (string, error)

JSON representation of a Tx is useful for querying the node's debug endpoint

func (*ContractCallTx) RLP

func (tx *ContractCallTx) RLP() (rlpRawMsg []byte, err error)

RLP returns a byte serialized representation

type ContractConfig

type ContractConfig struct {
	Gas        big.Int `json:"gas" yaml:"gas" mapstructure:"gas"`
	GasPrice   big.Int `json:"gas_price" yaml:"gas_price" mapstructure:"gas_price"`
	Amount     big.Int `json:"amount" yaml:"amount" mapstructure:"amount"`
	Deposit    big.Int `json:"deposit" yaml:"deposit" mapstructure:"deposit"`
	VMVersion  uint16  `json:"vm_version" yaml:"vm_version" mapstructure:"vm_version"`
	ABIVersion uint16  `json:"abi_version" yaml:"abi_version" mapstructure:"abi_version"`
}

ContractConfig configurations for contracts

type ContractCreateTx

type ContractCreateTx struct {
	OwnerID      string
	AccountNonce uint64
	Code         string
	VMVersion    uint16
	AbiVersion   uint16
	Deposit      big.Int
	Amount       big.Int
	Gas          big.Int
	GasPrice     big.Int
	Fee          big.Int
	TTL          uint64
	CallData     string
}

ContractCreateTx represents a transaction that creates a smart contract

func NewContractCreateTx

func NewContractCreateTx(OwnerID string, AccountNonce uint64, Code string, VMVersion, AbiVersion uint16, Deposit, Amount, Gas, GasPrice, Fee big.Int, TTL uint64, CallData string) ContractCreateTx

NewContractCreateTx is a constructor for a ContractCreateTx struct

func (*ContractCreateTx) ContractID

func (tx *ContractCreateTx) ContractID() (string, error)

ContractID returns the ct_ ID that this transaction would produce, which depends on the OwnerID and AccountNonce.

func (*ContractCreateTx) FeeEstimate

func (tx *ContractCreateTx) FeeEstimate() (*big.Int, error)

FeeEstimate estimates the fee needed for the node to accept this transaction, assuming the fee is 8 bytes long when RLP serialized.

func (*ContractCreateTx) JSON

func (tx *ContractCreateTx) JSON() (string, error)

JSON representation of a Tx is useful for querying the node's debug endpoint

func (*ContractCreateTx) RLP

func (tx *ContractCreateTx) RLP() (rlpRawMsg []byte, err error)

RLP returns a byte serialized representation

type HashPrefix

type HashPrefix string

HashPrefix a prefix for an aeternity object hash

func GetHashPrefix

func GetHashPrefix(hash string) (p HashPrefix)

GetHashPrefix get the prefix of an hash, panics if the hash is too short

type NameClaimTx

type NameClaimTx struct {
	AccountID    string
	Name         string
	NameSalt     big.Int
	Fee          big.Int
	TTL          uint64
	AccountNonce uint64
}

NameClaimTx represents a transaction where one claims a previously reserved name on AENS The revealed name is simply sent in plaintext in RLP, while in JSON representation it is base58 encoded.

func NewNameClaimTx

func NewNameClaimTx(accountID, name string, nameSalt big.Int, fee big.Int, ttl, accountNonce uint64) NameClaimTx

NewNameClaimTx is a constructor for a NameClaimTx struct

func (*NameClaimTx) FeeEstimate

func (tx *NameClaimTx) FeeEstimate() (*big.Int, error)

FeeEstimate estimates the fee needed for the node to accept this transaction, assuming the fee is 8 bytes long when RLP serialized.

func (*NameClaimTx) JSON

func (tx *NameClaimTx) JSON() (string, error)

JSON representation of a Tx is useful for querying the node's debug endpoints

func (*NameClaimTx) RLP

func (tx *NameClaimTx) RLP() (rlpRawMsg []byte, err error)

RLP returns a byte serialized representation

type NamePointer

type NamePointer struct {
	*models.NamePointer
}

NamePointer extends the swagger gener ated models.NamePointer to provide RLP serialization

func NewNamePointer

func NewNamePointer(key string, id string) *NamePointer

NewNamePointer is a constructor for a swagger generated NamePointer struct. It returns a pointer because

func (*NamePointer) EncodeRLP

func (np *NamePointer) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder interface.

type NamePreclaimTx

type NamePreclaimTx struct {
	AccountID    string
	CommitmentID string
	Fee          big.Int
	TTL          uint64
	AccountNonce uint64
}

NamePreclaimTx represents a transaction where one reserves a name on AENS without revealing it yet

func NewNamePreclaimTx

func NewNamePreclaimTx(accountID, commitmentID string, fee big.Int, ttl, accountNonce uint64) NamePreclaimTx

NewNamePreclaimTx is a constructor for a NamePreclaimTx struct

func (*NamePreclaimTx) FeeEstimate

func (tx *NamePreclaimTx) FeeEstimate() (*big.Int, error)

FeeEstimate estimates the fee needed for the node to accept this transaction, assuming the fee is 8 bytes long when RLP serialized.

func (*NamePreclaimTx) JSON

func (tx *NamePreclaimTx) JSON() (string, error)

JSON representation of a Tx is useful for querying the node's debug endpoint

func (*NamePreclaimTx) RLP

func (tx *NamePreclaimTx) RLP() (rlpRawMsg []byte, err error)

RLP returns a byte serialized representation

type NameRevokeTx

type NameRevokeTx struct {
	AccountID    string
	NameID       string
	Fee          big.Int
	TTL          uint64
	AccountNonce uint64
}

NameRevokeTx represents a transaction that revokes the name, i.e. has the same effect as waiting for the Name's TTL to expire.

func NewNameRevokeTx

func NewNameRevokeTx(accountID, name string, fee big.Int, ttl, accountNonce uint64) NameRevokeTx

NewNameRevokeTx is a constructor for a NameRevokeTx struct

func (*NameRevokeTx) FeeEstimate

func (tx *NameRevokeTx) FeeEstimate() (*big.Int, error)

FeeEstimate estimates the fee needed for the node to accept this transaction, assuming the fee is 8 bytes long when RLP serialized.

func (*NameRevokeTx) JSON

func (tx *NameRevokeTx) JSON() (string, error)

JSON representation of a Tx is useful for querying the node's debug endpoint

func (*NameRevokeTx) RLP

func (tx *NameRevokeTx) RLP() (rlpRawMsg []byte, err error)

RLP returns a byte serialized representation

type NameTransferTx

type NameTransferTx struct {
	AccountID    string
	NameID       string
	RecipientID  string
	Fee          big.Int
	TTL          uint64
	AccountNonce uint64
}

NameTransferTx represents a transaction that transfers ownership of one name to another account.

func NewNameTransferTx

func NewNameTransferTx(AccountID, NameID, RecipientID string, Fee big.Int, TTL, AccountNonce uint64) NameTransferTx

NewNameTransferTx is a constructor for a NameTransferTx struct

func (*NameTransferTx) FeeEstimate

func (tx *NameTransferTx) FeeEstimate() (*big.Int, error)

FeeEstimate estimates the fee needed for the node to accept this transaction, assuming the fee is 8 bytes long when RLP serialized.

func (*NameTransferTx) JSON

func (tx *NameTransferTx) JSON() (string, error)

JSON representation of a Tx is useful for querying the node's debug endpoint

func (*NameTransferTx) RLP

func (tx *NameTransferTx) RLP() (rlpRawMsg []byte, err error)

RLP returns a byte serialized representation

type NameUpdateTx

type NameUpdateTx struct {
	AccountID    string
	NameID       string
	Pointers     []*NamePointer
	NameTTL      uint64
	ClientTTL    uint64
	Fee          big.Int
	TTL          uint64
	AccountNonce uint64
}

NameUpdateTx represents a transaction where one extends the lifetime of a reserved name on AENS

func NewNameUpdateTx

func NewNameUpdateTx(accountID, nameID string, pointers []string, nameTTL, clientTTL uint64, fee big.Int, ttl, accountNonce uint64) NameUpdateTx

NewNameUpdateTx is a constructor for a NameUpdateTx struct

func (*NameUpdateTx) FeeEstimate

func (tx *NameUpdateTx) FeeEstimate() (*big.Int, error)

FeeEstimate estimates the fee needed for the node to accept this transaction, assuming the fee is 8 bytes long when RLP serialized.

func (*NameUpdateTx) JSON

func (tx *NameUpdateTx) JSON() (string, error)

JSON representation of a Tx is useful for querying the node's debug endpoint

func (*NameUpdateTx) RLP

func (tx *NameUpdateTx) RLP() (rlpRawMsg []byte, err error)

RLP returns a byte serialized representation

type Node

type Node struct {
	*apiclient.Node
}

Node is the HTTP connection to the aeternity node

func NewNode

func NewNode(nodeURL string, debug bool) *Node

NewNode obtain a new swagger HTTP client to a aeternity node

func (*Node) GetAccount

func (c *Node) GetAccount(accountID string) (account *models.Account, err error)

GetAccount retrieve an account by its address (public key) it is particularly useful to obtain the nonce for spending transactions

func (*Node) GetContractByID

func (c *Node) GetContractByID(ctID string) (contract *models.ContractObject, err error)

GetContractByID gets a contract by ct_ ID

func (*Node) GetCurrentKeyBlock

func (c *Node) GetCurrentKeyBlock() (kb *models.KeyBlock, err error)

GetCurrentKeyBlock get current key block

func (*Node) GetGenerationByHeight

func (c *Node) GetGenerationByHeight(height uint64) (g *models.Generation, err error)

GetGenerationByHeight gets the keyblock and all its microblocks

func (*Node) GetHeight

func (c *Node) GetHeight() (height uint64, err error)

GetHeight get the height of the chain

func (*Node) GetKeyBlockByHash

func (c *Node) GetKeyBlockByHash(keyBlockID string) (txs *models.KeyBlock, err error)

GetKeyBlockByHash get a key block by its hash

func (*Node) GetMicroBlockHeaderByHash

func (c *Node) GetMicroBlockHeaderByHash(microBlockID string) (txs *models.MicroBlockHeader, err error)

GetMicroBlockHeaderByHash get the header of a micro block

func (*Node) GetMicroBlockTransactionsByHash

func (c *Node) GetMicroBlockTransactionsByHash(microBlockID string) (txs *models.GenericTxs, err error)

GetMicroBlockTransactionsByHash get the transactions of a microblock

func (*Node) GetNameEntryByName

func (c *Node) GetNameEntryByName(name string) (nameEntry *models.NameEntry, err error)

GetNameEntryByName return the name entry

func (*Node) GetOracleByPubkey

func (c *Node) GetOracleByPubkey(pubkey string) (oracle *models.RegisteredOracle, err error)

GetOracleByPubkey get an oracle by it's public key

func (*Node) GetOracleQueriesByPubkey

func (c *Node) GetOracleQueriesByPubkey(pubkey string) (oracleQueries *models.OracleQueries, err error)

GetOracleQueriesByPubkey get a list of queries made to a particular oracle

func (*Node) GetStatus

func (c *Node) GetStatus() (status *models.Status, err error)

GetStatus post transaction

func (*Node) GetTopBlock

func (c *Node) GetTopBlock() (kb *models.KeyBlockOrMicroBlockHeader, err error)

GetTopBlock get the top block of the chain

func (*Node) GetTransactionByHash

func (c *Node) GetTransactionByHash(txHash string) (tx *models.GenericSignedTx, err error)

GetTransactionByHash get a transaction by it's hash

func (*Node) PostTransaction

func (c *Node) PostTransaction(signedEncodedTx, signedEncodedTxHash string) (err error)

PostTransaction post transaction

func (*Node) PrintGenerationByHeight

func (c *Node) PrintGenerationByHeight(height uint64)

PrintGenerationByHeight utility function to print a generation by it's height TODO this belongs in cmd and needs to be tested with error cases

type NodeConfig

type NodeConfig struct {
	URL         string `yaml:"url" json:"url" mapstructure:"url"`
	URLInternal string `yaml:"url_internal" json:"url_internal" mapstructure:"url_internal"`
	URLChannels string `yaml:"url_channels" json:"url_channels" mapstructure:"url_channels"`
	NetworkID   string `yaml:"network_id" json:"network_id" mapstructure:"network_id"`
}

NodeConfig configuration for the node node

type ObjectEncoding

type ObjectEncoding string

ObjectEncoding the encoding of an object

type OracleConfig

type OracleConfig struct {
	QueryFee         big.Int `json:"query_fee" yaml:"query_fee" mapstructure:"query_fee"`
	QueryTTLType     uint64  `json:"query_ttl_type" yaml:"query_ttl_type" mapstructure:"query_ttl_type"`
	QueryTTLValue    uint64  `json:"query_ttl_value" yaml:"query_ttl_value" mapstructure:"query_ttl_value"`
	ResponseTTLType  uint64  `json:"response_ttl_type" yaml:"response_ttl_type" mapstructure:"response_ttl_type"`
	ResponseTTLValue uint64  `json:"response_ttl_value" yaml:"response_ttl_value" mapstructure:"response_ttl_value"`
	VMVersion        uint64  `json:"vm_version" yaml:"vm_version" mapstructure:"vm_version"`
}

OracleConfig configurations for contracts

type OracleExtendTx

type OracleExtendTx struct {
	OracleID       string
	AccountNonce   uint64
	OracleTTLType  uint64
	OracleTTLValue uint64
	Fee            big.Int
	TTL            uint64
}

OracleExtendTx represents a transaction that extends the lifetime of an oracle

func NewOracleExtendTx

func NewOracleExtendTx(oracleID string, accountNonce, oracleTTLType, oracleTTLValue uint64, Fee big.Int, TTL uint64) OracleExtendTx

NewOracleExtendTx is a constructor for a OracleExtendTx struct

func (*OracleExtendTx) JSON

func (tx *OracleExtendTx) JSON() (string, error)

JSON representation of a Tx is useful for querying the node's debug endpoint

func (*OracleExtendTx) RLP

func (tx *OracleExtendTx) RLP() (rlpRawMsg []byte, err error)

RLP returns a byte serialized representation

type OracleQueryTx

type OracleQueryTx struct {
	SenderID         string
	AccountNonce     uint64
	OracleID         string
	Query            string
	QueryFee         big.Int
	QueryTTLType     uint64
	QueryTTLValue    uint64
	ResponseTTLType  uint64
	ResponseTTLValue uint64
	Fee              big.Int
	TTL              uint64
}

OracleQueryTx represents a transaction that a program sends to query an oracle

func NewOracleQueryTx

func NewOracleQueryTx(SenderID string, AccountNonce uint64, OracleID, Query string, QueryFee big.Int, QueryTTLType, QueryTTLValue, ResponseTTLType, ResponseTTLValue uint64, Fee big.Int, TTL uint64) OracleQueryTx

NewOracleQueryTx is a constructor for a OracleQueryTx struct

func (*OracleQueryTx) JSON

func (tx *OracleQueryTx) JSON() (string, error)

JSON representation of a Tx is useful for querying the node's debug endpoint

func (*OracleQueryTx) RLP

func (tx *OracleQueryTx) RLP() (rlpRawMsg []byte, err error)

RLP returns a byte serialized representation

type OracleRegisterTx

type OracleRegisterTx struct {
	AccountID      string
	AccountNonce   uint64
	QuerySpec      string
	ResponseSpec   string
	QueryFee       big.Int
	OracleTTLType  uint64
	OracleTTLValue uint64
	AbiVersion     uint16
	Fee            big.Int
	TTL            uint64
}

OracleRegisterTx represents a transaction that registers an oracle on the blockchain's state

func NewOracleRegisterTx

func NewOracleRegisterTx(accountID string, accountNonce uint64, querySpec, responseSpec string, queryFee big.Int, oracleTTLType, oracleTTLValue uint64, abiVersion uint16, txFee big.Int, txTTL uint64) OracleRegisterTx

NewOracleRegisterTx is a constructor for a OracleRegisterTx struct

func (*OracleRegisterTx) JSON

func (tx *OracleRegisterTx) JSON() (string, error)

JSON representation of a Tx is useful for querying the node's debug endpoint BUG: Account Nonce won'tx be represented in JSON output if nonce is 0, thanks to swagger.json

func (*OracleRegisterTx) RLP

func (tx *OracleRegisterTx) RLP() (rlpRawMsg []byte, err error)

RLP returns a byte serialized representation

type OracleRespondTx

type OracleRespondTx struct {
	OracleID         string
	AccountNonce     uint64
	QueryID          string
	Response         string
	ResponseTTLType  uint64
	ResponseTTLValue uint64
	Fee              big.Int
	TTL              uint64
}

OracleRespondTx represents a transaction that an oracle sends to respond to an incoming query

func NewOracleRespondTx

func NewOracleRespondTx(OracleID string, AccountNonce uint64, QueryID string, Response string, TTLType uint64, TTLValue uint64, Fee big.Int, TTL uint64) OracleRespondTx

NewOracleRespondTx is a constructor for a OracleRespondTx struct

func (*OracleRespondTx) JSON

func (tx *OracleRespondTx) JSON() (string, error)

JSON representation of a Tx is useful for querying the node's debug endpoint

func (*OracleRespondTx) RLP

func (tx *OracleRespondTx) RLP() (rlpRawMsg []byte, err error)

RLP returns a byte serialized representation

type ProfileConfig

type ProfileConfig struct {
	Name   string       `json:"name" yaml:"name" mapstructure:"name"`
	Node   NodeConfig   `json:"node" yaml:"node" mapstructure:"node"`
	Client ClientConfig `json:"client" yaml:"client" mapstructure:"client"`
	Tuning TuningConfig `json:"tuning" yaml:"tuning" mapstructure:"tuning"`
}

ProfileConfig a configuration profile

type SpendTx

type SpendTx struct {
	SenderID    string
	RecipientID string
	Amount      big.Int
	Fee         big.Int
	Payload     string
	TTL         uint64
	Nonce       uint64
}

SpendTx represents a simple transaction where one party sends another AE

func NewSpendTx

func NewSpendTx(senderID, recipientID string, amount, fee big.Int, payload string, ttl, nonce uint64) SpendTx

NewSpendTx is a constructor for a SpendTx struct

func (*SpendTx) FeeEstimate

func (tx *SpendTx) FeeEstimate() (*big.Int, error)

FeeEstimate estimates the fee needed for the node to accept this transaction, assuming the fee is 8 bytes long when RLP serialized.

func (*SpendTx) JSON

func (tx *SpendTx) JSON() (string, error)

JSON representation of a Tx is useful for querying the node's debug endpoint

func (*SpendTx) RLP

func (tx *SpendTx) RLP() (rlpRawMsg []byte, err error)

RLP returns a byte serialized representation

type StateChannelConfig

type StateChannelConfig struct {
	LockPeriod     uint64 `json:"lock_period" yaml:"lock_period" mapstructure:"lock_period"`
	ChannelReserve uint64 `json:"channel_reserve" yaml:"channel_reserve" mapstructure:"channel_reserve"`
}

StateChannelConfig configurations for contracts TODO: not complete

type TuningConfig

type TuningConfig struct {
	ChainPollInteval  int64  `json:"chain_poll_interval" yaml:"chain_poll_interval" mapstructure:"chain_poll_interval"`
	ChainTimeout      int64  `json:"chain_timeout" yaml:"chain_timeout" mapstructure:"chain_timeout"`
	CryptoKdfMemlimit uint32 `json:"crypto_kdf_memlimit" yaml:"crypto_kdf_memlimit" mapstructure:"crypto_kdf_memlimit"`
	CryptoKdfOpslimit uint32 `json:"crypto_kdf_opslimit" yaml:"crypto_kdf_opslimit" mapstructure:"crypto_kdf_opslimit"`
	CryptoKdfThreads  uint8  `json:"crypto_kdf_threads" yaml:"crypto_kdf_threads" mapstructure:"crypto_kdf_threads"`
	OutputFormatJSON  bool   `json:"-" yaml:"-" mapstructure:"-"`
}

TuningConfig fine tuning of parameters of the client

type Tx

type Tx interface {
	RLP() ([]byte, error)
}

Tx interface guarantees that code using Tx can rely on these functions being present

Jump to

Keyboard shortcuts

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