Documentation ¶
Index ¶
- Constants
- Variables
- func Decode(in string) (out []byte, err error)
- func Encode(prefix HashPrefix, data []byte) string
- func GetWalletPath(path string) (walletPath string, err error)
- func KeystoreSeal(account *Account, password string) (j []byte, e error)
- func NameClaimTx(accountID, name string, nameSalt, fee uint64, ttl, nonce uint64) (rlpRawMsg []byte, err error)
- func NamePreclaimTx(accountID, commitmentID string, fee uint64, ttl, nonce uint64) (rlpRawMsg []byte, err error)
- func NameUpdateTx(accountID, nameID string, pointers []string, nameTTL, clientTTL uint64, ...) (rlpRawMsg []byte, err error)
- func OracleExtendTx(oracleID string, accountNonce, ttlType, ttlValue uint64, fee utils.BigInt, ...) (rlpRawMsg []byte, err error)
- func OracleRegisterTx(accountID string, accountNonce uint64, querySpec, responseSpec string, ...) (rlpRawMsg []byte, err error)
- func Pp(data ...interface{})
- func PpI(indentSize int, data ...interface{})
- func PpT(indentSize int, title string)
- func PrintError(code string, e *models.Error)
- func PrintObject(title string, i interface{})
- func SignEncodeTx(kp *Account, txRaw []byte, networkID string) (signedEncodedTx, signedEncodedTxHash, signature string, err error)
- func SignEncodeTxStr(kp *Account, tx string, networkID string) (signedEncodedTx, signedEncodedTxHash, signature string, err error)
- func SpendTx(senderID, recipientID string, amount, fee utils.BigInt, payload string, ...) (rlpRawMsg []byte, err error)
- func SpendTxStr(sender, recipient string, amount, fee utils.BigInt, message string, ...) (base64Tx string, err error)
- func StoreAccountToKeyStoreFile(account *Account, password, walletName string) (filePath string, err error)
- func Verify(address string, message, signature []byte) (valid bool, err error)
- func VerifySignedTx(accountID string, txSigned string, networkID string) (valid bool, err error)
- type Account
- type Ae
- func (ae *Ae) APIGetAccount(accountID string) (account *models.Account, err error)
- func (ae *Ae) APIGetCurrentKeyBlock() (kb *models.KeyBlock, err error)
- func (ae *Ae) APIGetHeight() (height uint64, err error)
- func (ae *Ae) APIGetKeyBlockByHash(keyBlockID string) (txs *models.KeyBlock, err error)
- func (ae *Ae) APIGetMicroBlockHeaderByHash(microBlockID string) (txs *models.MicroBlockHeader, err error)
- func (ae *Ae) APIGetMicroBlockTransactionsByHash(microBlockID string) (txs *models.GenericTxs, err error)
- func (ae *Ae) APIGetNameEntryByName(name string) (nameEntry *models.NameEntry, err error)
- func (ae *Ae) APIGetOracleByPubkey(pubkey string) (oracle *models.RegisteredOracle, err error)
- func (ae *Ae) APIGetStatus() (status *models.Status, err error)
- func (ae *Ae) APIGetTopBlock() (kb *models.KeyBlockOrMicroBlockHeader, err error)
- func (ae *Ae) APIGetTransactionByHash(txHash string) (tx *models.GenericSignedTx, err error)
- func (ae *Ae) APIPostTransaction(signedEncodedTx, signedEncodedTxHash string) (err error)
- func (ae *Ae) BroadcastTransaction(txSignedBase64 string) (err error)
- func (ae *Ae) GetNextNonce(accountID string) (nextNonce uint64, err error)
- func (ae *Ae) GetTTL(offset uint64) (height uint64, err error)
- func (ae *Ae) GetTTLNonce(accountID string, offset uint64) (txTTL, accountNonce uint64, err error)
- func (ae *Ae) PrintGenerationByHeight(height uint64)
- func (ae *Ae) WaitForTransactionUntilHeight(height uint64, txHash string) (blockHeight uint64, blockHash, microBlockHash string, ...)
- func (ae *Ae) WithAccount(account *Account) *Ae
- type Aens
- func (n *Aens) NameClaimTxStr(name string, nameSalt, txTTL, accountNonce uint64) (tx string, err error)
- func (n *Aens) NamePreclaimTxStr(name string, txTTL, accountNonce uint64) (tx string, nameSalt uint64, err error)
- func (n *Aens) NameUpdateTxStr(name string, targetAddress string, txTTL, accountNonce uint64) (tx string, err error)
- type AensConfig
- type ClientConfig
- type Contract
- type ContractConfig
- type HashPrefix
- type NodeConfig
- type ObjectEncoding
- type Oracle
- type OracleConfig
- type ProfileConfig
- type StateChannelConfig
- type TuningConfig
- type Wallet
Constants ¶
const ( Base58c = ObjectEncoding("b58c") Base64c = ObjectEncoding("b64c") )
Encoding strategies
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
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>>
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
const (
// ConfigFilename default configuration file name
ConfigFilename = "config"
)
Variables ¶
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{ TTL: 500, Fee: *utils.RequireBigIntFromString("200000000000000"), Names: AensConfig{ NameTTL: 500, ClientTTL: 500, }, Contracts: ContractConfig{ Gas: 1e9, GasPrice: 1, Deposit: 0, VMVersion: 0, }, Oracles: OracleConfig{ QueryFee: *utils.NewBigIntFromUint64(0), 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 Encode ¶
func Encode(prefix HashPrefix, data []byte) string
Encode a byte array into base58/base64 with chacksum and a prefix
func GetWalletPath ¶
GetWalletPath try to locate a wallet
func KeystoreSeal ¶
KeystoreSeal create an encrypted json keystore with the private key of the account
func NameClaimTx ¶
func NameClaimTx(accountID, name string, nameSalt, fee uint64, ttl, nonce uint64) (rlpRawMsg []byte, err error)
NameClaimTx build a preclaim transaction
func NamePreclaimTx ¶
func NamePreclaimTx(accountID, commitmentID string, fee uint64, ttl, nonce uint64) (rlpRawMsg []byte, err error)
NamePreclaimTx build a preclaim transaction
func NameUpdateTx ¶
func NameUpdateTx(accountID, nameID string, pointers []string, nameTTL, clientTTL uint64, fee uint64, ttl, nonce uint64) (rlpRawMsg []byte, err error)
NameUpdateTx build an update name transaction
func OracleExtendTx ¶
func OracleExtendTx(oracleID string, accountNonce, ttlType, ttlValue uint64, fee utils.BigInt, ttl uint64) (rlpRawMsg []byte, err error)
OracleExtendTx extend an oracle's lifetime
func OracleRegisterTx ¶
func OracleRegisterTx(accountID string, accountNonce uint64, querySpec, responseSpec string, queryFee utils.BigInt, oracleTTLType, oracleTTLValue, abiVersion uint64, txFee utils.BigInt, txTTL uint64) (rlpRawMsg []byte, err error)
OracleRegisterTx register an oracle
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 SpendTx ¶
func SpendTx(senderID, recipientID string, amount, fee utils.BigInt, payload string, ttl, nonce uint64) (rlpRawMsg []byte, err error)
SpendTx create a spend transaction
func SpendTxStr ¶
func SpendTxStr(sender, recipient string, amount, fee utils.BigInt, message string, txTTL, accountNonce uint64) (base64Tx string, err error)
SpendTxStr creates an unsigned SpendTx but returns the base64 representation instead of an RLP bytestring
func StoreAccountToKeyStoreFile ¶
func StoreAccountToKeyStoreFile(account *Account, password, walletName string) (filePath string, err error)
StoreAccountToKeyStoreFile store an account to a json file
Types ¶
type Account ¶
type Account struct { SigningKey ed25519.PrivateKey Address string }
Account holds the signing key and the aeternity account address
func AccountFromHexString ¶
AccountFromHexString load an account from hex string
func KeystoreOpen ¶
KeystoreOpen open and decrypt a keystore
func LoadAccountFromKeyStoreFile ¶
LoadAccountFromKeyStoreFile load file from the keystore
func NewAccount ¶
NewAccount genereate a new keypair
func (*Account) SigningKeyToHexString ¶
SigningKeyToHexString return the SigningKey as an hex string
type Ae ¶
Ae the aeternity client
func (*Ae) APIGetAccount ¶
APIGetAccount return the account
func (*Ae) APIGetCurrentKeyBlock ¶
APIGetCurrentKeyBlock get current key block
func (*Ae) APIGetHeight ¶
APIGetHeight get the height of the chain
func (*Ae) APIGetKeyBlockByHash ¶
APIGetKeyBlockByHash get a key block by its hash
func (*Ae) APIGetMicroBlockHeaderByHash ¶
func (ae *Ae) APIGetMicroBlockHeaderByHash(microBlockID string) (txs *models.MicroBlockHeader, err error)
APIGetMicroBlockHeaderByHash get the header of a micro block
func (*Ae) APIGetMicroBlockTransactionsByHash ¶
func (ae *Ae) APIGetMicroBlockTransactionsByHash(microBlockID string) (txs *models.GenericTxs, err error)
APIGetMicroBlockTransactionsByHash get the transactions of a microblock
func (*Ae) APIGetNameEntryByName ¶
APIGetNameEntryByName return the name entry
func (*Ae) APIGetOracleByPubkey ¶
func (ae *Ae) APIGetOracleByPubkey(pubkey string) (oracle *models.RegisteredOracle, err error)
APIGetOracleByPubkey get an oracle by it's public key
func (*Ae) APIGetStatus ¶
APIGetStatus post transaction
func (*Ae) APIGetTopBlock ¶
func (ae *Ae) APIGetTopBlock() (kb *models.KeyBlockOrMicroBlockHeader, err error)
APIGetTopBlock get the top block of the chain
func (*Ae) APIGetTransactionByHash ¶
func (ae *Ae) APIGetTransactionByHash(txHash string) (tx *models.GenericSignedTx, err error)
APIGetTransactionByHash get a transaction by it's hash
func (*Ae) APIPostTransaction ¶
APIPostTransaction post transaction
func (*Ae) BroadcastTransaction ¶
BroadcastTransaction recalculates the transaction hash and sends the transaction to the node.
func (*Ae) GetNextNonce ¶
GetNextNonce retrieves the current accountNonce for an account + 1
func (*Ae) GetTTLNonce ¶
GetTTLNonce is a convenience function that combines GetTTL() and GetNextNonce()
func (*Ae) PrintGenerationByHeight ¶
PrintGenerationByHeight utility function to print a generation by it's height
func (*Ae) WaitForTransactionUntilHeight ¶
func (ae *Ae) WaitForTransactionUntilHeight(height uint64, txHash string) (blockHeight uint64, blockHash, microBlockHash string, tx *models.GenericSignedTx, err error)
WaitForTransactionUntilHeight waits for a transaction until heightLimit (inclusive) is reached
func (*Ae) WithAccount ¶
WithAccount associate a Account with the client
type Aens ¶
type Aens struct {
// contains filtered or unexported fields
}
Aens abstractions for aens operations
func (*Aens) NameClaimTxStr ¶
func (n *Aens) NameClaimTxStr(name string, nameSalt, txTTL, accountNonce uint64) (tx string, err error)
NameClaimTxStr creates a claim transaction
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 uint64 `json:"preclaim_fee" yaml:"preclaim_fee" mapstructure:"preclaim_fee"` ClaimFee uint64 `json:"claim_fee" yaml:"claim_fee" mapstructure:"claim_fee"` UpdateFee uint64 `json:"update_fee" yaml:"update_fee" mapstructure:"update_fee"` }
AensConfig configurations for Aens
type ClientConfig ¶
type ClientConfig struct { TTL uint64 `json:"ttl" yaml:"ttl" mapstructure:"ttl"` Fee utils.BigInt `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 paramters configuration
type Contract ¶
type Contract struct {
// contains filtered or unexported fields
}
Contract abstractions for contracts
type ContractConfig ¶
type ContractConfig struct { Gas uint64 `json:"gas" yaml:"gas" mapstructure:"gas"` GasPrice uint64 `json:"gas_price" yaml:"gas_price" mapstructure:"gas_price"` Deposit uint64 `json:"deposit" yaml:"deposit" mapstructure:"deposit"` VMVersion uint64 `json:"vm_version" yaml:"vm_version" mapstructure:"vm_version"` }
ContractConfig configurations for contracts
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 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 Oracle ¶
type Oracle struct {
// contains filtered or unexported fields
}
Oracle abstractions for oracles
type OracleConfig ¶
type OracleConfig struct { QueryFee utils.BigInt `json:"query_fee" yaml:"query_fee" mapstructure:"query_fee"` VMVersion uint64 `json:"vm_version" yaml:"vm_version" mapstructure:"vm_version"` }
OracleConfig configurations for contracts
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 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