aeternity

package
v5.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: ISC Imports: 31 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	// NetworkIDMainnet is the network ID for aeternity mainnet
	NetworkIDMainnet = "ae_mainnet"
	// URLMainnet is the URL to an aeternity Foundation maintained node
	URLMainnet = "https://sdk-mainnet.aepps.com"
	// NetworkIDTestnet is the network ID for aeternity testnet
	NetworkIDTestnet = "ae_uat"
	// URLTestnet is the URL to an aeternity Foundation maintained node
	URLTestnet = "https://sdk-testnet.aepps.com"
	// CompilerBackendFATE indicates that the compiler should use the FATE VM
	// for contract bytecode execution
	CompilerBackendFATE = "fate"
	// CompilerBackendAEVM indicates that the compiler should use the AEVM for
	// contract bytecode execution
	CompilerBackendAEVM = "aevm"
	// OracleTTLTypeDelta indicates that the accompanying TTL value (in blocks)
	// should be interpreted as currentHeight + TTLValue
	OracleTTLTypeDelta = 0
	// OracleTTLTypeAbsolute indicates that the accompanying TTL value (in
	// blocks) should be interpreted as an absolute block height, after which
	// the TTL expires.
	OracleTTLTypeAbsolute = 1
)

Acceptable values for various parameters

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

Base58/Base64 encoding definitions

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

	// Base58 encoded bytearrays
	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_")

	// Base64 encoded bytearrays
	PrefixByteArray         = HashPrefix("ba_")
	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
)

Address-like bytearrays are converted in to an ID (uint8 bytearray) for RLP serialization. ID Tags differentiate between them. https://github.com/aeternity/protocol/blob/master/serializations.md#the-id-type

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
	ObjectTagGeneralizedAccountAttachTransaction uint = 80
	ObjectTagGeneralizedAccountMetaTransaction   uint = 81
	ObjectTagMicroBody                           uint = 101
	ObjectTagLightMicroBlock                     uint = 102
)

Object tags are used to differentiate between different types of bytearrays in RLP serialization. see https://github.com/aeternity/protocol/blob/master/serializations.md#binary-serialization

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",
	},
	Compiler: CompilerConfig{
		URL:     "http://localhost:3080",
		Backend: CompilerBackendAEVM,
	},
	Client: ClientConfig{
		BaseGas:    *utils.NewIntFromUint64(15000),
		GasPerByte: *utils.NewIntFromUint64(20),
		GasPrice:   *utils.NewIntFromUint64(1e9),
		TTL:        500,
		Fee:        *utils.RequireIntFromString("200000000000000"),
		Names: AensConfig{
			NameTTL:   500,
			ClientTTL: 500,
		},
		Contracts: ContractConfig{
			CompilerURL: "http://localhost:3080",
			GasLimit:    *utils.NewIntFromUint64(1e9),
			Amount:      *new(big.Int),
			Deposit:     *new(big.Int),
			VMVersion:   4,
			ABIVersion:  1,
		},
		Oracles: OracleConfig{
			QueryFee:         *utils.NewIntFromUint64(0),
			QueryTTLType:     OracleTTLTypeDelta,
			QueryTTLValue:    300,
			ResponseTTLType:  OracleTTLTypeDelta,
			ResponseTTLValue: 300,
			VMVersion:        0,
		},
		StateChannels: StateChannelConfig{
			LockPeriod:     0,
			ChannelReserve: 0,
		},
	},
	Tuning: TuningConfig{
		ChainPollInterval: 100,
		ChainTimeout:      5000,
		CryptoKdfMemlimit: 1024 * 32,
		CryptoKdfOpslimit: 3,
		CryptoKdfThreads:  1,
		OutputFormatJSON:  false,
	},
}

Config specifies defaults for all configuration parameters

TransactionTypes is a map between the ObjectTags defined above and the corresponding Tx struct

Functions

func Blake2bHash added in v5.1.0

func Blake2bHash(in []byte) (out []byte, err error)

Blake2bHash calculates the blake2b 32bit hash of the input byte array

func Decode

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

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

in aeternity, bytearrays are always base-encoded with a prefix that indicates what the bytearray is. For example, accounts "ak_...." are a plain bytearray that is base58 encoded and prefixed with "ak_" to indicate that it is an account.

Example
b, err := Decode("ak_Egp9yVdpxmvAfQ7vsXGvpnyfNq71msbdUpkMNYGTeTe8kPL3v")
if err != nil {
	return
}
fmt.Println(b)
Output:

[31 19 163 176 139 240 1 64 6 98 166 139 105 216 117 247 128 60 236 76 8 100 127 110 213 216 76 120 151 189 80 163]

func DecodeRLPMessage

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

DecodeRLPMessage takes an RLP serialized bytearray and parses the RLP to return the deserialized, structured data as bytearrays ([]interfaces that should be later coerced into specific types). Only meant for debugging purposes - to parse serialized RLP into a useful type, see DeseralizeTx.

func Encode

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

Encode a byte array into base58/base64 with checksum and a prefix.

in aeternity, bytearrays are always base-encoded with a prefix that indicates what the bytearray is. For example, accounts "ak_...." are a plain bytearray that is base58 encoded and prefixed with "ak_" to indicate that it is an account.

Example
addrB := []byte{31, 19, 163, 176, 139, 240, 1, 64, 6, 98, 166, 139, 105, 216, 117, 247, 128, 60, 236, 76, 8, 100, 127, 110, 213, 216, 76, 120, 151, 189, 80, 163}

addr := Encode("ak_", addrB)
fmt.Println(addr)
Output:

ak_Egp9yVdpxmvAfQ7vsXGvpnyfNq71msbdUpkMNYGTeTe8kPL3v

func GetAccountsByName added in v5.1.0

func GetAccountsByName(n GetAnythingByNameFunc, name string) (addresses []string, err error)

GetAccountsByName returns any account_pubkey entries that it finds in a name's Pointers.

func GetChannelsByName added in v5.1.0

func GetChannelsByName(n GetAnythingByNameFunc, name string) (channels []string, err error)

GetChannelsByName returns any channel entries that it finds in a name's Pointers.

func GetContractsByName added in v5.1.0

func GetContractsByName(n GetAnythingByNameFunc, name string) (contracts []string, err error)

GetContractsByName returns any contract_pubkey entries that it finds in a name's Pointers.

func GetOraclesByName added in v5.1.0

func GetOraclesByName(n GetAnythingByNameFunc, name string) (oracleIDs []string, err error)

GetOraclesByName returns any oracle_pubkey entries that it finds in a name's Pointers.

func GetWalletPath

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

GetWalletPath checks if a file exists at the specified path.

func Hash

func Hash(tx *SignedTx) (txhash string, err error)

Hash calculates the hash of a SignedTx. It is intended to be used after SignedTx.Signatures has been filled out.

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. Names within aeternity are generally referred to only by their namehashes.

The implementation is the same as ENS EIP-137 https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md#namehash-algorithm but using Blake2b.

func NewContextFromURL

func NewContextFromURL(url string, address string, debug bool) (ctx *Context, node *Node)

NewContextFromURL is a convenience function that creates a Context and its TTL/Nonce closures from a URL

func SerializeTx

func SerializeTx(tx rlp.Encoder) (string, error)

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

func Sign

func Sign(kp *Account, tx *SignedTx, networkID string) (signature []byte, err error)

Sign calculates the signature of the SignedTx.Tx. Although it does not use the SignedTx itself, it takes a SignedTx as an argument because if it took a rlp.Encoder as an interface, one might expect the signature to be of the SignedTx itself, which won't work.

func SignBroadcastTransaction added in v5.1.0

func SignBroadcastTransaction(tx rlp.Encoder, signingAccount *Account, n *Node, networkID string) (signedTxStr, hash, signature string, err error)

SignBroadcastTransaction signs a transaction and broadcasts it to a node.

func SignBroadcastWaitTransaction added in v5.1.0

func SignBroadcastWaitTransaction(tx rlp.Encoder, signingAccount *Account, n *Node, networkID string, x uint64) (signedTxStr, hash, signature string, blockHeight uint64, blockHash string, err error)

SignBroadcastWaitTransaction is a convenience function that combines SignBroadcastTransaction and WaitForTransactionForXBlocks.

func StoreAccountToKeyStoreFile

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

StoreAccountToKeyStoreFile saves an encrypted Account to a JSON file

func Verify

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

Verify a message with the signing/private key

func VerifySignedTx

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

VerifySignedTx verifies the signature of a signed transaction, in its RLP serialized, base64 encoded tx_ form.

The network ID is also used when calculating the signature, so the network ID that the transaction was intended for should be provided too.

func WaitForTransactionForXBlocks added in v5.1.0

func WaitForTransactionForXBlocks(c getTransactionByHashHeighter, txHash string, x uint64) (blockHeight uint64, blockHash string, err error)

WaitForTransactionForXBlocks blocks until a transaction has been mined or X blocks have gone by, after which it returns an error. The node polling interval can be configured with Config.Tuning.ChainPollInterval.

Types

type APIVersioner

type APIVersioner interface {
	APIVersion() (version string, err error)
}

APIVersioner guarantees that one can run a APIVersion() method on the mocked/real network connection to the aesophia compiler

type Account

type Account struct {
	SigningKey ed25519.PrivateKey
	Address    string
}

Account holds the signing/private key and the aeternity account address

func AccountFromHexString

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

AccountFromHexString creates an Account from a hexstring

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 loads an encrypted Account from a JSON file

func NewAccount

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

NewAccount generates a new Account

func (*Account) Sign

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

Sign a message with the signing/private key

func (*Account) SigningKeyToHexString

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

SigningKeyToHexString returns the SigningKey as an hex string

type AensConfig

type AensConfig struct {
	// NameTTL is the block height (in this case not an absolute block height,
	// but a delta) after which the name goes into the 'revoked' state.
	NameTTL uint64 `json:"name_ttl" yaml:"name_ttl" mapstructure:"name_ttl"`
	// ClientTTL suggests how long (in seconds) AENS clients should cache an AENS entry.
	ClientTTL uint64 `json:"client_ttl" yaml:"client_ttl" mapstructure:"client_ttl"`
}

AensConfig contains default parameters for AENS

type ClientConfig

type ClientConfig struct {
	// BaseGas is one component of transaction fee calculation.
	BaseGas big.Int `json:"base_gas" yaml:"base_gas" mapstructure:"base_gas"`
	// GasPerByte is multiplied by the RLP serialized transaction's length.
	GasPerByte big.Int `json:"gas_per_byte" yaml:"gas_per_byte" mapstructure:"gas_per_byte"`
	// GasPrice is the conversion factor from gas to AE.
	GasPrice big.Int `json:"gas_price" yaml:"gas_price" mapstructure:"gas_price"`
	// TTL is the default blockheight offset that will be added to the current
	// height to determine a transaction's TTL.
	TTL uint64 `json:"ttl" yaml:"ttl" mapstructure:"ttl"`
	// Fee is a default transaction fee that should be big enough for most transaction types.
	Fee           big.Int            `json:"fee" yaml:"fee" mapstructure:"fee"`
	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"`
}

ClientConfig client parameters configuration

type CompileContracter

type CompileContracter interface {
	CompileContract(source string, backend string) (bytecode string, err error)
}

CompileContracter guarantees that one can run a CompileContract() method on the mocked/real network connection to the aesophia compiler

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, backend 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, backend 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, backend 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, function string, callData string, backend 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, backend 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, backend 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 CompilerConfig added in v5.1.0

type CompilerConfig struct {
	URL     string `json:"url" yaml:"url" mapstructure:"url"`
	Backend string `json:"backend" yaml:"backend" mapstructure:"backend"`
}

CompilerConfig configuration for the compiler

type Context

type Context struct {
	GetTTL      GetTTLFunc
	GetNonce    GetNextNonceFunc
	GetTTLNonce GetTTLNonceFunc
	Address     string
}

Context is a struct that eases transaction creation. Specifically, the role of Context is to automate/hide the tedious details of transaction creation, such as filling in an unused account nonce and an appropriate TTL, so that the transaction creator only has to worry about the details relevant to the task at hand.

func NewContextFromNode added in v5.1.0

func NewContextFromNode(node *Node, address string) (ctx *Context)

NewContextFromNode is a convenience function that creates a Context and its TTL/Nonce closures from a Node instance

func (*Context) ContractCallTx

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

ContractCallTx creates a contract call transaction,, filling in the account nonce and transaction TTL automatically.

func (*Context) ContractCreateTx

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

ContractCreateTx creates a contract create transaction, filling in the account nonce and transaction TTL automatically.

func (*Context) NameClaimTx

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

NameClaimTx creates a claim transaction, filling in the account nonce and transaction TTL automatically.

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, filling in the account nonce and transaction TTL automatically. It also generates a commitment ID and salt, later used to claim the name.

func (*Context) NameRevokeTx

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

NameRevokeTx creates a name revoke transaction, filling in the account nonce and transaction TTL automatically.

func (*Context) NameTransferTx

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

NameTransferTx creates a name transfer transaction, filling in the account nonce and transaction TTL automatically.

func (*Context) NameUpdateTx

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

NameUpdateTx creates a name update transaction, filling in the account nonce and transaction TTL automatically.

func (*Context) OracleExtendTx

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

OracleExtendTx creates an oracle extend transaction, filling in the account nonce and transaction TTL automatically.

func (*Context) OracleQueryTx

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

OracleQueryTx creates an oracle query transaction, filling in the account nonce and transaction TTL automatically.

func (*Context) OracleRegisterTx

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

OracleRegisterTx creates an oracle register transaction, filling in the account nonce and transaction TTL automatically.

func (*Context) OracleRespondTx

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

OracleRespondTx creates an oracle response transaction, filling in the account nonce and transaction TTL automatically.

func (*Context) SpendTx

func (c *Context) SpendTx(senderID string, recipientID string, amount, fee big.Int, payload []byte) (tx *SpendTx, err error)

SpendTx creates a spend transaction, filling in the account nonce and transaction TTL automatically.

type Contract

type Contract struct {
	Tag             byte
	RLPVersion      byte
	SourceCodeHash  []byte
	TypeInfo        []ContractFunction
	Bytecode        []byte
	CompilerVersion string
	Payable         bool
}

Contract represents the internals of the compiled cb_ bytecode that the compiler returns and exposes those internals as fields.

func NewContractFromString

func NewContractFromString(cb string) (c Contract, err error)

NewContractFromString takes a cb_ compiled bytecode string and returns a Contract struct

type ContractCallTx

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

ContractCallTx represents calling an existing smart contract

func NewContractCallTx

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

NewContractCallTx is a constructor for a ContractCallTx struct

func (*ContractCallTx) DecodeRLP

func (tx *ContractCallTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder

func (*ContractCallTx) EncodeRLP

func (tx *ContractCallTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

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

type ContractConfig

type ContractConfig struct {
	CompilerURL string `json:"compiler" yaml:"compiler" mapstructure:"compiler"`
	// GasLimit is a default value for the maximum amount of gas that a contract
	// execution should consume. see
	// https://github.com/aeternity/protocol/blob/master/consensus/consensus.md
	//
	// In order to control the size and the number of transactions in a micro
	// block, each transaction has a gas. The sum of gas of all the transactions
	// cannot exceed the gas limit per micro block, which is 6 000 000.
	// The gas of a transaction is the sum of:
	// * the base gas;
	// * other gas components, such as gas proportional to the byte size of the
	//   transaction or relative TTL, gas needed for contract execution.
	GasLimit big.Int `json:"gas" yaml:"gas" mapstructure:"gas"`
	// Amount is an optional amount to transfer to the contract account.
	Amount big.Int `json:"amount" yaml:"amount" mapstructure:"amount"`
	// Deposit will be "held by the contract" until it is deactivated.
	Deposit big.Int `json:"deposit" yaml:"deposit" mapstructure:"deposit"`
	// VMVersion indicates which virtual machine should be used for bytecode execution.
	VMVersion uint16 `json:"vm_version" yaml:"vm_version" mapstructure:"vm_version"`
	// ABIVersion indicates the binary interface/calling convention used by the contract.
	ABIVersion uint16 `json:"abi_version" yaml:"abi_version" mapstructure:"abi_version"`
}

ContractConfig contains default parameters for contracts

type ContractCreateTx

type ContractCreateTx struct {
	OwnerID      string
	AccountNonce uint64
	Code         string
	VMVersion    uint16
	AbiVersion   uint16
	Deposit      big.Int
	Amount       big.Int
	GasLimit     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, GasLimit, 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) DecodeRLP

func (tx *ContractCreateTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder

func (*ContractCreateTx) EncodeRLP

func (tx *ContractCreateTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

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

type ContractFunction

type ContractFunction struct {
	FuncHash []byte
	FuncName string
	Payable  bool
	ArgType  []byte
	OutType  []byte
}

ContractFunction struct represents the type information for a single function in a Sophia smart contract. FuncHash is the Blake2b hash of the function name and function types. All data is provided by the compiler in the cb_ compiled bytecode.

type DecodeCallResulter

type DecodeCallResulter interface {
	DecodeCallResult(callResult string, callValue string, function string, source string, backend string) (answer interface{}, err error)
}

DecodeCallResulter guarantees that one can run a DecodeCallResult() method on the mocked/real network connection to the aesophia compiler

type DecodeCalldataBytecoder

type DecodeCalldataBytecoder interface {
	DecodeCalldataBytecode(bytecode string, calldata string, backend string) (decodedCallData *models.DecodedCalldata, err error)
}

DecodeCalldataBytecoder guarantees that one can run a DecodeCalldataBytecode() method on the mocked/real network connection to the aesophia compiler

type DecodeCalldataSourcer

type DecodeCalldataSourcer interface {
	DecodeCalldataSource(source string, function string, callData string, backend string) (decodedCallData *models.DecodedCalldata, err error)
}

DecodeCalldataSourcer guarantees that one can run a DecodeCalldataSource() method on the mocked/real network connection to the aesophia compiler

type DecodeDataer

type DecodeDataer interface {
	DecodeData(data string, sophiaType string) (decodedData *models.SophiaJSONData, err error)
}

DecodeDataer guarantees that one can run a DecodeData() method on the mocked/real network connection to the aesophia compiler

type EncodeCalldataer

type EncodeCalldataer interface {
	EncodeCalldata(source string, function string, args []string, backend string) (callData string, err error)
}

EncodeCalldataer guarantees that one can run a EncodeCalldata() method on the mocked/real network connection to the aesophia compiler

type GAAttachTx

type GAAttachTx struct {
	OwnerID      string
	AccountNonce uint64
	Code         string
	AuthFunc     []byte
	VMVersion    uint16
	AbiVersion   uint16
	GasLimit     big.Int
	GasPrice     big.Int
	Fee          big.Int
	TTL          uint64
	CallData     string
}

GAAttachTx is a transaction that converts a plain old account (POA) into a Generalized Account. The function in the contract that should be used for authenticating transactions from that account is denoted by the parameter AuthFunc.

func NewGAAttachTx

func NewGAAttachTx(OwnerID string, AccountNonce uint64, Code string, AuthFunc []byte, VMVersion uint16, AbiVersion uint16, GasLimit big.Int, GasPrice big.Int, Fee big.Int, TTL uint64, CallData string) *GAAttachTx

NewGAAttachTx creates a GAAttachTx

func (*GAAttachTx) DecodeRLP

func (tx *GAAttachTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder

func (*GAAttachTx) EncodeRLP

func (tx *GAAttachTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

type GAMetaTx

type GAMetaTx struct {
	AccountID  string
	AuthData   string
	AbiVersion uint16
	GasLimit   big.Int
	GasPrice   big.Int
	Fee        big.Int
	TTL        uint64
	Tx         *SignedTx
}

GAMetaTx wraps a normal Tx (that is not a GAAttachTx) that will only be executed if the contract located at GaID returns true

func NewGAMetaTx

func NewGAMetaTx(AccountID string, AuthData string, AbiVersion uint16, GasLimit big.Int, GasPrice big.Int, Fee big.Int, TTL uint64, Tx rlp.Encoder) *GAMetaTx

NewGAMetaTx creates a GAMetaTx

func (*GAMetaTx) DecodeRLP

func (tx *GAMetaTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder

func (*GAMetaTx) EncodeRLP

func (tx *GAMetaTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

type GenerateACIer

type GenerateACIer interface {
	GenerateACI(source string, backend string) (aci *models.ACI, err error)
}

GenerateACIer guarantees that one can run a GenerateACI() method on the mocked/real network connection to the aesophia compiler

type GetAccounter

type GetAccounter interface {
	GetAccount(accountID string) (*models.Account, error)
}

GetAccounter guarantees that one can run a GetAccount() method on the mocked/real network connection

type GetAnythingByNameFunc added in v5.1.0

type GetAnythingByNameFunc func(name, key string) (results []string, err error)

GetAnythingByNameFunc describes a function that returns lookup results for a AENS name

func GenerateGetAnythingByName added in v5.1.0

func GenerateGetAnythingByName(n GetNameEntryByNamer) GetAnythingByNameFunc

GenerateGetAnythingByName is the underlying implementation of Get*ByName

type GetGenerationByHeighter

type GetGenerationByHeighter interface {
	GetGenerationByHeight(height uint64) (*models.Generation, error)
}

GetGenerationByHeighter guarantees that one can run a GetGenerationByHeight() method on the mocked/real network connection

type GetHeighter

type GetHeighter interface {
	GetHeight() (uint64, error)
}

GetHeighter guarantees that one can run a GetHeight() method on the mocked/real network connection

type GetKeyBlockByHasher

type GetKeyBlockByHasher interface {
	GetKeyBlockByHash(string) (*models.KeyBlock, error)
}

GetKeyBlockByHasher guarantees that one can run a GetKeyBlockByHash() method on the mocked/real network connection

type GetMicroBlockHeaderByHasher

type GetMicroBlockHeaderByHasher interface {
	GetMicroBlockHeaderByHash(string) (*models.MicroBlockHeader, error)
}

GetMicroBlockHeaderByHasher guarantees that one can run a GetMicroBlockHeaderByHash() method on the mocked/real network connection

type GetMicroBlockTransactionsByHasher

type GetMicroBlockTransactionsByHasher interface {
	GetMicroBlockTransactionsByHash(string) (*models.GenericTxs, error)
}

GetMicroBlockTransactionsByHasher guarantees that one can run a GetMicroBlockTransactionsByHash() method on the mocked/real network connection

type GetNameEntryByNamer

type GetNameEntryByNamer interface {
	GetNameEntryByName(string) (*models.NameEntry, error)
}

GetNameEntryByNamer guarantees that one can run a GetNameEntryByName() method on the mocked/real network connection

type GetNextNonceFunc added in v5.1.0

type GetNextNonceFunc func(accountID string) (nonce uint64, err error)

GetNextNonceFunc defines a function that will return an unused account nonce for making a transaction.

func GenerateGetNextNonce added in v5.1.0

func GenerateGetNextNonce(n GetAccounter) GetNextNonceFunc

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

type GetOracleByPubkeyer

type GetOracleByPubkeyer interface {
	GetOracleByPubkey(string) (*models.RegisteredOracle, error)
}

GetOracleByPubkeyer guarantees that one can run a GetOracleByPubkey() method on the mocked/real network connection

type GetStatuser

type GetStatuser interface {
	GetStatus() (*models.Status, error)
}

GetStatuser guarantees that one can run a GetStatus() method on the mocked/real network connection

type GetTTLFunc added in v5.1.0

type GetTTLFunc func(offset uint64) (ttl uint64, err error)

GetTTLFunc defines a function that will return an appropriate TTL for a transaction.

func GenerateGetTTL added in v5.1.0

func GenerateGetTTL(n GetHeighter) GetTTLFunc

GenerateGetTTL returns the chain height + offset

type GetTTLNonceFunc added in v5.1.0

type GetTTLNonceFunc func(address string, offset uint64) (ttl, nonce uint64, err error)

GetTTLNonceFunc describes a function that combines the roles of GetTTLFunc and GetNextNonceFunc

func GenerateGetTTLNonce added in v5.1.0

func GenerateGetTTLNonce(ttlFunc GetTTLFunc, nonceFunc GetNextNonceFunc) GetTTLNonceFunc

GenerateGetTTLNonce combines the commonly used together functions of GetTTL and GetNextNonce

type GetTopBlocker

type GetTopBlocker interface {
	GetTopBlock() (*models.KeyBlockOrMicroBlockHeader, error)
}

GetTopBlocker guarantees that one can run a GetTopBlock() method on the mocked/real network connection

type GetTransactionByHasher

type GetTransactionByHasher interface {
	GetTransactionByHash(string) (*models.GenericSignedTx, error)
}

GetTransactionByHasher guarantees that one can run a GetTransactionByHash() method on the mocked/real network connection

type HashPrefix

type HashPrefix string

HashPrefix describes a prefix that is attached to every base-encoded bytearray used in aeternity to describe its function.

For example, the "ak_" HashPrefix describes an account address and "ct_" HashPrefix describes a contract address.

func GetHashPrefix

func GetHashPrefix(hash string) (p HashPrefix)

GetHashPrefix returns a HashPrefix of a string. It panics if the hash contains only the prefix (length 3).

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) DecodeRLP

func (tx *NameClaimTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder

func (*NameClaimTx) EncodeRLP

func (tx *NameClaimTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

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

type NamePointer

type NamePointer struct {
	Key string
	ID  string
}

NamePointer is a go-native representation of swagger generated models.NamePointer.

func NewNamePointer

func NewNamePointer(key string, id string) *NamePointer

NewNamePointer is a constructor for NamePointer struct.

func (*NamePointer) DecodeRLP

func (np *NamePointer) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder interface.

func (*NamePointer) EncodeRLP

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

EncodeRLP implements rlp.Encoder interface.

func (*NamePointer) Swagger

func (np *NamePointer) Swagger() *models.NamePointer

Swagger generates the go-swagger representation of this model

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) DecodeRLP

func (tx *NamePreclaimTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder

func (*NamePreclaimTx) EncodeRLP

func (tx *NamePreclaimTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

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

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) DecodeRLP

func (tx *NameRevokeTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder interface.

func (*NameRevokeTx) EncodeRLP

func (tx *NameRevokeTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

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

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) DecodeRLP

func (tx *NameTransferTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder interface.

func (*NameTransferTx) EncodeRLP

func (tx *NameTransferTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

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

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) DecodeRLP

func (tx *NameUpdateTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder

func (*NameUpdateTx) EncodeRLP

func (tx *NameUpdateTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

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

type Node

type Node struct {
	*apiclient.Node
}

Node represents a HTTP connection to an aeternity node

func NewNode

func NewNode(nodeURL string, debug bool) *Node

NewNode instantiates a new swagger HTTP client to an aeternity node. No network connection is actually performed, this only sets up the HTTP client code.

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 returns a node's Status.

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

type NodeConfig

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

NodeConfig configuration for the node

type NodeInterface

NodeInterface collects together all the interfaces defined in this file to describe the capabilities of a generic connection to an aeternity (or mock) node

type ObjectEncoding

type ObjectEncoding string

ObjectEncoding is an enum string that describes whether a bytearray is base58 or base64 encoded

type OracleConfig

type OracleConfig struct {
	// QueryFee is locked up until the oracle answers (and gets the fee) or the
	// transaction TTL expires (and the sender is refunded). In other words, it
	// is a bounty.
	QueryFee big.Int `json:"query_fee" yaml:"query_fee" mapstructure:"query_fee"`
	// QueryTTLType indicates whether the TTLValue should be interpreted as an absolute or delta blockheight.
	QueryTTLType uint64 `json:"query_ttl_type" yaml:"query_ttl_type" mapstructure:"query_ttl_type"`
	// QueryTTLValue indicates how long the query is open for response from the oracle.
	QueryTTLValue uint64 `json:"query_ttl_value" yaml:"query_ttl_value" mapstructure:"query_ttl_value"`
	// ResponseTTLType indicates whether the TTLValue should be interpreted as an absolute or delta blockheight.
	ResponseTTLType uint64 `json:"response_ttl_type" yaml:"response_ttl_type" mapstructure:"response_ttl_type"`
	// ResponseTTLValue indicates how long the response is available when given from the oracle.
	ResponseTTLValue uint64 `json:"response_ttl_value" yaml:"response_ttl_value" mapstructure:"response_ttl_value"`
	VMVersion        uint16 `json:"vm_version" yaml:"vm_version" mapstructure:"vm_version"`
}

OracleConfig contains default parameters for oracles

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) DecodeRLP

func (tx *OracleExtendTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder

func (*OracleExtendTx) EncodeRLP

func (tx *OracleExtendTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

func (*OracleExtendTx) JSON

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

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

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) DecodeRLP

func (tx *OracleQueryTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder

func (*OracleQueryTx) EncodeRLP

func (tx *OracleQueryTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

func (*OracleQueryTx) JSON

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

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

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) DecodeRLP

func (tx *OracleRegisterTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder

func (*OracleRegisterTx) EncodeRLP

func (tx *OracleRegisterTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

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

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) DecodeRLP

func (tx *OracleRespondTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder

func (*OracleRespondTx) EncodeRLP

func (tx *OracleRespondTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

func (*OracleRespondTx) JSON

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

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

type PostTransactioner

type PostTransactioner interface {
	PostTransaction(string, string) error
}

PostTransactioner guarantees that one can run a PostTransaction() method on the mocked/real network connection

type ProfileConfig

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

ProfileConfig a configuration profile

type SignedTx

type SignedTx struct {
	Signatures [][]byte
	Tx         rlp.Encoder
}

SignedTx wraps around other Tx structs to hold the signature.

func NewSignedTx

func NewSignedTx(Signatures [][]byte, tx rlp.Encoder) (s *SignedTx)

NewSignedTx ensures that all fields of SignedTx are filled out.

func SignHashTx

func SignHashTx(kp *Account, tx Transaction, networkID string) (signedTx *SignedTx, txhash, signature string, err error)

SignHashTx wraps a *Tx struct in a SignedTx, then returns its signature and hash.

func (*SignedTx) DecodeRLP

func (tx *SignedTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder

func (*SignedTx) EncodeRLP

func (tx *SignedTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

type SophiaVersioner

type SophiaVersioner interface {
	SophiaVersion() (version string, err error)
}

SophiaVersioner guarantees that one can run a SophiaVersion() method on the mocked/real network connection to the aesophia compiler

type SpendTx

type SpendTx struct {
	SenderID    string
	RecipientID string
	Amount      big.Int
	Fee         big.Int
	Payload     []byte
	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 []byte, ttl, nonce uint64) *SpendTx

NewSpendTx is a constructor for a SpendTx struct

func (*SpendTx) DecodeRLP

func (tx *SpendTx) DecodeRLP(s *rlp.Stream) (err error)

DecodeRLP implements rlp.Decoder

func (*SpendTx) EncodeRLP

func (tx *SpendTx) EncodeRLP(w io.Writer) (err error)

EncodeRLP implements rlp.Encoder

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

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 Transaction

type Transaction interface {
	rlp.Encoder
}

Transaction is used to indicate a transaction of any type.

func DeserializeTx

func DeserializeTx(rawRLP []byte) (Transaction, error)

DeserializeTx takes a RLP serialized transaction as a bytearray and returns the corresponding Tx struct

func DeserializeTxStr

func DeserializeTxStr(txRLP string) (Transaction, error)

DeserializeTxStr takes a tx_ string and returns the corresponding Tx struct

func GetTransactionType

func GetTransactionType(rawRLP []byte) (tx Transaction, err error)

GetTransactionType reads the RLP input and returns a blank Tx struct of the correct type

type TuningConfig

type TuningConfig struct {
	ChainPollInterval 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

Jump to

Keyboard shortcuts

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