implement some functions to perform testing

This commit is contained in:
Czarek Nakamoto
2023-12-27 23:05:56 +01:00
parent fb76ef5ddd
commit 07f56276b0
2 changed files with 725 additions and 31 deletions
+98 -28
View File
@@ -25,32 +25,9 @@ extern "C"
{
#endif
// void* MONERO_WalletManager_createWallet(const char* path, const char* password, const char* language, int networkType)
void* MONERO_WalletManager_createWallet(const char* path, const char* password, const char* language, int networkType) {
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
std::cout << "WE GOT OUT\n";
std::string _path(path);
std::string _password(password);
std::string _language(language);
std::cout << "_path = " << _path << "\n";
std::cout << "_password = " << _password << "\n";
std::cout << "_language = " << _language << "\n";
Monero::Wallet *wallet =
Monero::WalletManagerFactory::getWalletManager()->createWallet(
_path,
_password,
_language,
_networkType);
return reinterpret_cast<void*>(wallet);
}
// virtual Wallet * recoveryWallet(const std::string &path, const std::string &mnemonic, NetworkType nettype, uint64_t restoreHeight = 0) = 0;
const char* MONERO_Wallet_errorString(void* wallet_ptr) {
const char* MONERO_Wallet_seed(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->errorString().c_str();
return wallet->seed().c_str();
}
int MONERO_Wallet_status(void* wallet_ptr) {
@@ -58,9 +35,102 @@ int MONERO_Wallet_status(void* wallet_ptr) {
return wallet->status();
}
int MONERO_DEBUG_sleep(int time) {
sleep(time);
return time-1;
const char* MONERO_Wallet_errorString(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->errorString().c_str();
}
const char* MONERO_Wallet_address(void* wallet_ptr, uint64_t accountIndex, uint64_t addressIndex) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->address(accountIndex, addressIndex).c_str();
}
const char* MONERO_Wallet_secretViewKey(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->secretViewKey().c_str();
}
const char* MONERO_Wallet_publicViewKey(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->publicViewKey().c_str();
}
const char* MONERO_Wallet_secretSpendKey(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->secretSpendKey().c_str();
}
const char* MONERO_Wallet_publicSpendKey(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->publicSpendKey().c_str();
}
void MONERO_Wallet_stop(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
wallet->stop();
}
void MONERO_Wallet_store(void* wallet_ptr, const char* path) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
wallet->store(std::string(path));
}
uint64_t MONERO_Wallet_balance(void* wallet_ptr, uint32_t accountIndex) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->balance(accountIndex);
}
uint64_t MONERO_Wallet_unlockedBalance(void* wallet_ptr, uint32_t accountIndex) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->unlockedBalance(accountIndex);
}
void* MONERO_WalletManager_createWallet(const char* path, const char* password, const char* language, int networkType) {
Monero::Wallet *wallet =
Monero::WalletManagerFactory::getWalletManager()->createWallet(
std::string(path),
std::string(password),
std::string(language),
static_cast<Monero::NetworkType>(networkType));
return reinterpret_cast<void*>(wallet);
}
void* MONERO_WalletManager_openWallet(const char* path, const char* password, int networkType) {
Monero::Wallet *wallet =
Monero::WalletManagerFactory::getWalletManager()->openWallet(
std::string(path),
std::string(password),
static_cast<Monero::NetworkType>(networkType));
return reinterpret_cast<void*>(wallet);
}
void* MONERO_WalletManager_recoveryWallet(const char* path, const char* password, const char* mnemonic, int networkType, uint64_t restoreHeight, uint64_t kdfRounds, const char* seedOffset) {
// (const std::string &path, const std::string &password, const std::string &mnemonic,
// NetworkType nettype = MAINNET, uint64_t restoreHeight = 0, uint64_t kdf_rounds = 1,
// const std::string &seed_offset = {})
Monero::Wallet *wallet =
Monero::WalletManagerFactory::getWalletManager()->recoveryWallet(
std::string(path),
std::string(password),
std::string(mnemonic),
static_cast<Monero::NetworkType>(networkType),
restoreHeight,
kdfRounds,
std::string(seedOffset));
return reinterpret_cast<void*>(wallet);
}
bool MONERO_WalletManager_closeWallet(void* wallet_ptr, bool store) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return Monero::WalletManagerFactory::getWalletManager()->closeWallet(
wallet,
store);
}
// DEBUG functions
// the Answer to the Ultimate Question of Life, the Universe, and Everything.
int MONERO_DEBUG_theAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything(int x) {
return x*42;
}
#ifdef __cplusplus