4#include "connection/connection.h"
5#include "encoder/encoder.h"
6#include "IoTeXConstants.h"
7#include "protobuf/pb_api.h"
8#include "random/random.h"
9#include "signer/signer.h"
29 Account(uint8_t privateKey[IOTEX_PRIVATE_KEY_SIZE]);
61 void getPublicKey(uint8_t buffer[IOTEX_PUBLIC_KEY_SIZE]);
95 void signMessage(
const uint8_t* message,
size_t size, uint8_t signature[IOTEX_SIGNATURE_SIZE]);
104 uint8_t signature[IOTEX_SIGNATURE_SIZE]);
114 uint8_t signature[IOTEX_SIGNATURE_SIZE],
115 uint8_t hash[IOTEX_HASH_SIZE] =
nullptr);
134 template<
typename TAPI>
136 const char* gasPrice,
const char* amount,
137 const char* recipient, uint8_t hash[IOTEX_HASH_SIZE])
141 core.gasLimit = gasLimit;
143 strcpy(core.gasPrice, gasPrice);
145 strcpy(core.transfer.amount, amount);
146 core.transfer.payload =
"";
147 strcpy(core.transfer.recipient, recipient);
150 uint8_t signature[IOTEX_SIGNATURE_SIZE];
153 return conn.api.wallets.sendTokenTransfer(_publicKey, signature, core, hash);
170 template<
typename TAPI>
172 const char* gasPrice,
const char* amount,
173 const char contract[IOTEX_ADDRESS_C_STRING_SIZE],
174 IotexString data, uint8_t hash[IOTEX_HASH_SIZE])
178 core.gasLimit = gasLimit;
180 strcpy(core.gasPrice, gasPrice);
181 strcpy(core.execution.amount, amount);
182 strcpy(core.execution.contract, contract);
183 core.execution.data = data;
186 uint8_t signature[IOTEX_SIGNATURE_SIZE];
189 return conn.api.wallets.sendExecution(_publicKey, signature, core, hash);
193 IotexString _iotexAddr;
194 IotexString _ethAddr;
195 uint8_t _publicKey[IOTEX_PUBLIC_KEY_SIZE];
196 uint8_t _privateKey[IOTEX_PRIVATE_KEY_SIZE];
201 Random* _pRandomGenerator;
209 void GenerateAddressesFromPrivateKey();
210 void generateIotexAddress();
211 void generateEthAddress();
212 void setDepsFromGlobals();
220 uint8_t privateKey[IOTEX_PRIVATE_KEY_SIZE] =
nullptr);
void signTokenTransferAction(iotex::ResponseTypes::ActionCore_Transfer &transfer, uint8_t signature[IOTEX_SIGNATURE_SIZE])
Signs a token transfer action.
Definition: account.cpp:99
void getIotexAddress(char buffer[IOTEX_ADDRESS_C_STRING_SIZE])
Get the IoTeX address as a null terminated string.
Definition: account.cpp:54
void getPublicKeyString(char buffer[IOTEX_PUBLIC_KEY_C_STRING_SIZE])
Get the public key as a null terminated string.
Definition: account.cpp:74
Account()
Construct a new Account object with a new randomly generated address.
Definition: account.cpp:16
ResultCode sendTokenTransferAction(Connection< TAPI > &conn, uint64_t nonce, uint64_t gasLimit, const char *gasPrice, const char *amount, const char *recipient, uint8_t hash[IOTEX_HASH_SIZE])
Sends a token transfer action to the blockchain.
Definition: account.h:135
void getEthereumAddress(char buffer[ETH_ADDRESS_C_STRING_SIZE])
Get the Ethereum address as a null terminated string.
Definition: account.cpp:59
void getPrivateKey(uint8_t buffer[IOTEX_PRIVATE_KEY_SIZE])
Get the private key as a byte array.
Definition: account.cpp:79
ResultCode sendExecutionAction(Connection< TAPI > &conn, uint64_t nonce, uint64_t gasLimit, const char *gasPrice, const char *amount, const char contract[IOTEX_ADDRESS_C_STRING_SIZE], IotexString data, uint8_t hash[IOTEX_HASH_SIZE])
Sends an execution action to the blockchain.
Definition: account.h:171
void getPublicKey(uint8_t buffer[IOTEX_PUBLIC_KEY_SIZE])
Get the public key as a byte array.
Definition: account.cpp:69
void signExecutionAction(iotex::ResponseTypes::ActionCore_Execution &execution, uint8_t signature[IOTEX_SIGNATURE_SIZE], uint8_t hash[IOTEX_HASH_SIZE]=nullptr)
Signs an execution action.
Definition: account.cpp:111
void getPrivateKeyString(char buffer[IOTEX_PRIVATE_KEY_C_STRING_SIZE])
Get the private key as a null terminated string.
Definition: account.cpp:84
void signMessage(const uint8_t *message, size_t size, uint8_t signature[IOTEX_SIGNATURE_SIZE])
Singns a message.
Definition: account.cpp:93
void getEthereumAddressBytes(uint8_t buffer[ETH_ADDRESS_SIZE])
Get the Ethereum address as a byte array.
Definition: account.cpp:64
Definition: connection.h:13