Rename wallet api namespace Monero:: -> Wallet::

This commit is contained in:
Jason Rhinelander 2020-10-22 18:37:54 -03:00
parent 862df3b5fe
commit 63de78d1d0
22 changed files with 178 additions and 226 deletions

View File

@ -111,12 +111,12 @@ int main(int argc, char* argv[])
SL(wallet::unsigned_tx_set);
SL(wallet::signed_tx_set);
SL(Monero::WalletImpl);
SL(Monero::AddressBookRow);
SL(Monero::TransactionInfoImpl);
SL(Monero::TransactionHistoryImpl);
SL(Monero::PendingTransactionImpl);
SL(Monero::UnsignedTransactionImpl);
SL(Wallet::WalletImpl);
SL(Wallet::AddressBookRow);
SL(Wallet::TransactionInfoImpl);
SL(Wallet::TransactionHistoryImpl);
SL(Wallet::PendingTransactionImpl);
SL(Wallet::UnsignedTransactionImpl);
return 0;
}

View File

@ -37,7 +37,7 @@
#include <vector>
namespace Monero {
namespace Wallet {
AddressBook::~AddressBook() {}
@ -147,5 +147,3 @@ AddressBookImpl::~AddressBookImpl()
}
} // namespace
namespace Bitmonero = Monero;

View File

@ -31,7 +31,7 @@
#include "wallet/api/wallet2_api.h"
#include "wallet/wallet2.h"
namespace Monero {
namespace Wallet {
class WalletImpl;
@ -65,6 +65,3 @@ private:
};
}
namespace Bitmonero = Monero;

View File

@ -43,7 +43,7 @@
using namespace std;
namespace Monero {
namespace Wallet {
PendingTransaction::~PendingTransaction() {}
@ -261,6 +261,3 @@ std::vector<std::string> PendingTransactionImpl::signersKeys() const {
}
}
namespace Bitmonero = Monero;

View File

@ -28,14 +28,14 @@
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#include "wallet/api/wallet2_api.h"
#include "wallet/wallet2.h"
#include "wallet2_api.h"
#include "../wallet2.h"
#include <string>
#include <vector>
namespace Monero {
namespace Wallet {
class WalletImpl;
class PendingTransactionImpl : public PendingTransaction
@ -71,7 +71,4 @@ private:
std::vector<crypto::key_image> m_key_images;
};
}
namespace Bitmonero = Monero;

View File

@ -34,7 +34,7 @@
#include <vector>
namespace Monero {
namespace Wallet {
Subaddress::~Subaddress() {}

View File

@ -29,7 +29,7 @@
#include "wallet/api/wallet2_api.h"
#include "wallet/wallet2.h"
namespace Monero {
namespace Wallet {
class WalletImpl;

View File

@ -34,7 +34,7 @@
#include <vector>
namespace Monero {
namespace Wallet {
SubaddressAccount::~SubaddressAccount() {}

View File

@ -29,7 +29,7 @@
#include "wallet/api/wallet2_api.h"
#include "wallet/wallet2.h"
namespace Monero {
namespace Wallet {
class WalletImpl;

View File

@ -40,7 +40,7 @@
#include <string>
#include <list>
namespace Monero {
namespace Wallet {
TransactionHistory::~TransactionHistory() {}
@ -251,5 +251,3 @@ void TransactionHistoryImpl::refresh()
}
} // namespace
namespace Bitmonero = Monero;

View File

@ -31,7 +31,7 @@
#include "wallet/api/wallet2_api.h"
#include <shared_mutex>
namespace Monero {
namespace Wallet {
class WalletImpl;
@ -55,6 +55,3 @@ private:
};
}
namespace Bitmonero = Monero;

View File

@ -31,7 +31,7 @@
#include "transaction_info.h"
namespace Monero {
namespace Wallet {
TransactionInfo::~TransactionInfo() {}
@ -147,5 +147,3 @@ uint64_t TransactionInfoImpl::unlockTime() const
}
} // namespace
namespace Bitmonero = Monero;

View File

@ -32,7 +32,7 @@
#include <string>
#include <ctime>
namespace Monero {
namespace Wallet {
enum class reward_type {
unspecified,
@ -90,5 +90,3 @@ private:
};
} // namespace
namespace Bitmonero = Monero;

View File

@ -42,7 +42,7 @@
using namespace std;
namespace Monero {
namespace Wallet {
UnsignedTransaction::~UnsignedTransaction() {}
@ -316,6 +316,3 @@ uint64_t UnsignedTransactionImpl::minMixinCount() const
}
} // namespace
namespace Bitmonero = Monero;

View File

@ -35,7 +35,7 @@
#include <vector>
namespace Monero {
namespace Wallet {
class WalletImpl;
class UnsignedTransactionImpl : public UnsignedTransaction
@ -71,5 +71,3 @@ private:
}
namespace Bitmonero = Monero;

View File

@ -28,14 +28,12 @@
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#include "include_base_utils.h" // LOG_PRINT_x
#include "misc_log_ex.h"
#include "common/util.h"
using namespace std;
namespace Monero {
namespace Wallet {
namespace Utils {
bool isAddressLocal(const std::string &address)
@ -58,7 +56,4 @@ void onStartup()
}
} // namespace
namespace Bitmonero = Monero;

View File

@ -57,7 +57,7 @@ using namespace cryptonote;
#undef LOKI_DEFAULT_LOG_CATEGORY
#define LOKI_DEFAULT_LOG_CATEGORY "WalletAPI"
namespace Monero {
namespace Wallet {
namespace {
static const int DEFAULT_REFRESH_INTERVAL_MILLIS = 1000 * 10;
@ -2542,14 +2542,10 @@ void WalletImpl::deviceShowAddress(uint32_t accountIndex, uint32_t addressIndex,
crypto::hash8 payment_id;
bool res = tools::wallet2::parse_short_payment_id(paymentId, payment_id);
if (!res)
{
throw runtime_error("Invalid payment ID");
}
throw std::runtime_error("Invalid payment ID");
payment_id_param = payment_id;
}
m_wallet->device_show_address(accountIndex, addressIndex, payment_id_param);
}
} // namespace
namespace Bitmonero = Monero;

View File

@ -28,8 +28,7 @@
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#ifndef WALLET_IMPL_H
#define WALLET_IMPL_H
#pragma once
#include "wallet/api/wallet2_api.h"
#include "wallet/wallet2.h"
@ -40,7 +39,7 @@
#include <thread>
namespace Monero {
namespace Wallet {
class TransactionHistoryImpl;
class PendingTransactionImpl;
class UnsignedTransactionImpl;
@ -273,8 +272,3 @@ private:
} // namespace
namespace Bitmonero = Monero;
#endif

View File

@ -42,7 +42,7 @@
#include "common/fs.h"
// Public interface for libwallet library
namespace Monero {
namespace Wallet {
enum NetworkType : uint8_t {
MAINNET = 0,
@ -1296,13 +1296,9 @@ struct WalletManagerFactory
LogLevel_Max = LogLevel_4
};
static WalletManagerBase * getWalletManager();
static WalletManagerBase* getWalletManager();
static void setLogLevel(int level);
static void setLogCategories(const std::string &categories);
};
}
namespace Bitmonero = Monero;
} // namespace Wallet

View File

@ -43,7 +43,7 @@
#undef LOKI_DEFAULT_LOG_CATEGORY
#define LOKI_DEFAULT_LOG_CATEGORY "WalletAPI"
namespace Monero {
namespace Wallet {
Wallet* WalletManagerImpl::createWallet(const fs::path& path, const std::string &password,
const std::string &language, NetworkType nettype, uint64_t kdf_rounds)
@ -340,5 +340,3 @@ void WalletManagerFactory::setLogCategories(const std::string &categories)
}
namespace Bitmonero = Monero;

View File

@ -33,7 +33,7 @@
#include "rpc/http_client.h"
#include <string>
namespace Monero {
namespace Wallet {
class WalletManagerImpl : public WalletManagerBase
{
@ -101,5 +101,3 @@ private:
};
} // namespace
namespace Bitmonero = Monero;

View File

@ -125,8 +125,8 @@ struct Utils
static std::string get_wallet_address(const std::string &filename, const std::string &password)
{
Monero::WalletManager *wmgr = Monero::WalletManagerFactory::getWalletManager();
Monero::Wallet * w = wmgr->openWallet(filename, password, Monero::NetworkType::TESTNET);
Wallet::WalletManager *wmgr = Wallet::WalletManagerFactory::getWalletManager();
Wallet::Wallet * w = wmgr->openWallet(filename, password, Wallet::NetworkType::TESTNET);
std::string result = w->mainAddress();
wmgr->closeWallet(w);
return result;
@ -136,14 +136,14 @@ struct Utils
struct WalletManagerTest : public testing::Test
{
Monero::WalletManager * wmgr;
Wallet::WalletManager * wmgr;
WalletManagerTest()
{
std::cout << __FUNCTION__ << std::endl;
wmgr = Monero::WalletManagerFactory::getWalletManager();
// Monero::WalletManagerFactory::setLogLevel(Monero::WalletManagerFactory::LogLevel_4);
wmgr = Wallet::WalletManagerFactory::getWalletManager();
// Wallet::WalletManagerFactory::setLogLevel(Wallet::WalletManagerFactory::LogLevel_4);
Utils::deleteWallet(WALLET_NAME);
Utils::deleteDir(fs::path(WALLET_NAME_WITH_DIR).parent_path().string());
}
@ -159,13 +159,13 @@ struct WalletManagerTest : public testing::Test
struct WalletManagerMainnetTest : public testing::Test
{
Monero::WalletManager * wmgr;
Wallet::WalletManager * wmgr;
WalletManagerMainnetTest()
{
std::cout << __FUNCTION__ << std::endl;
wmgr = Monero::WalletManagerFactory::getWalletManager();
wmgr = Wallet::WalletManagerFactory::getWalletManager();
Utils::deleteWallet(WALLET_NAME_MAINNET);
}
@ -179,11 +179,11 @@ struct WalletManagerMainnetTest : public testing::Test
struct WalletTest1 : public testing::Test
{
Monero::WalletManager * wmgr;
Wallet::WalletManager * wmgr;
WalletTest1()
{
wmgr = Monero::WalletManagerFactory::getWalletManager();
wmgr = Wallet::WalletManagerFactory::getWalletManager();
}
@ -192,11 +192,11 @@ struct WalletTest1 : public testing::Test
struct WalletTest2 : public testing::Test
{
Monero::WalletManager * wmgr;
Wallet::WalletManager * wmgr;
WalletTest2()
{
wmgr = Monero::WalletManagerFactory::getWalletManager();
wmgr = Wallet::WalletManagerFactory::getWalletManager();
}
};
@ -204,8 +204,8 @@ struct WalletTest2 : public testing::Test
TEST_F(WalletManagerTest, WalletManagerCreatesWallet)
{
Monero::Wallet * wallet = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Monero::NetworkType::MAINNET);
ASSERT_TRUE(wallet->status() == Monero::Wallet::Status_Ok);
Wallet::Wallet * wallet = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Wallet::NetworkType::MAINNET);
ASSERT_TRUE(wallet->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(!wallet->seed().empty());
std::vector<std::string> words;
std::string seed = wallet->seed();
@ -221,11 +221,11 @@ TEST_F(WalletManagerTest, WalletManagerCreatesWallet)
TEST_F(WalletManagerTest, WalletManagerOpensWallet)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Wallet::NetworkType::MAINNET);
std::string seed1 = wallet1->seed();
ASSERT_TRUE(wmgr->closeWallet(wallet1));
Monero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, Monero::NetworkType::MAINNET);
ASSERT_TRUE(wallet2->status() == Monero::Wallet::Status_Ok);
Wallet::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, Wallet::NetworkType::MAINNET);
ASSERT_TRUE(wallet2->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wallet2->seed() == seed1);
std::cout << "** seed: " << wallet2->seed() << std::endl;
}
@ -233,31 +233,31 @@ TEST_F(WalletManagerTest, WalletManagerOpensWallet)
TEST_F(WalletManagerTest, WalletMaxAmountAsString)
{
LOG_PRINT_L3("max amount: " << Monero::Wallet::displayAmount(
Monero::Wallet::maximumAllowedAmount()));
LOG_PRINT_L3("max amount: " << Wallet::Wallet::displayAmount(
Wallet::Wallet::maximumAllowedAmount()));
}
TEST_F(WalletManagerTest, WalletAmountFromString)
{
uint64_t amount = Monero::Wallet::amountFromString("18446740");
uint64_t amount = Wallet::Wallet::amountFromString("18446740");
ASSERT_TRUE(amount > 0);
amount = Monero::Wallet::amountFromString("11000000000000");
amount = Wallet::Wallet::amountFromString("11000000000000");
ASSERT_FALSE(amount > 0);
amount = Monero::Wallet::amountFromString("0.0");
amount = Wallet::Wallet::amountFromString("0.0");
ASSERT_FALSE(amount > 0);
amount = Monero::Wallet::amountFromString("10.1");
amount = Wallet::Wallet::amountFromString("10.1");
ASSERT_TRUE(amount > 0);
}
void open_wallet_helper(Monero::WalletManager *wmgr, Monero::Wallet **wallet, const std::string &pass, std::mutex *mutex)
void open_wallet_helper(Wallet::WalletManager *wmgr, Wallet::Wallet **wallet, const std::string &pass, std::mutex *mutex)
{
if (mutex)
mutex->lock();
LOG_PRINT_L3("opening wallet in thread: " << boost::this_thread::get_id());
*wallet = wmgr->openWallet(WALLET_NAME, pass, Monero::NetworkType::TESTNET);
*wallet = wmgr->openWallet(WALLET_NAME, pass, Wallet::NetworkType::TESTNET);
LOG_PRINT_L3("wallet address: " << (*wallet)->mainAddress());
LOG_PRINT_L3("wallet status: " << (*wallet)->status());
LOG_PRINT_L3("closing wallet in thread: " << boost::this_thread::get_id());
@ -273,23 +273,23 @@ void open_wallet_helper(Monero::WalletManager *wmgr, Monero::Wallet **wallet, co
// // create password protected wallet
// std::string wallet_pass = "password";
// std::string wrong_wallet_pass = "1111";
// Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, wallet_pass, WALLET_LANG, Monero::NetworkType::TESTNET);
// Wallet::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, wallet_pass, WALLET_LANG, Wallet::NetworkType::TESTNET);
// std::string seed1 = wallet1->seed();
// ASSERT_TRUE(wmgr->closeWallet(wallet1));
// Monero::Wallet *wallet2 = nullptr;
// Monero::Wallet *wallet3 = nullptr;
// Wallet::Wallet *wallet2 = nullptr;
// Wallet::Wallet *wallet3 = nullptr;
// std::mutex mutex;
// std::thread thread1(open_wallet, wmgr, &wallet2, wrong_wallet_pass, &mutex);
// thread1.join();
// ASSERT_TRUE(wallet2->status() != Monero::Wallet::Status_Ok);
// ASSERT_TRUE(wallet2->status() != Wallet::Wallet::Status_Ok);
// ASSERT_TRUE(wmgr->closeWallet(wallet2));
// std::thread thread2(open_wallet, wmgr, &wallet3, wallet_pass, &mutex);
// thread2.join();
// ASSERT_TRUE(wallet3->status() == Monero::Wallet::Status_Ok);
// ASSERT_TRUE(wallet3->status() == Wallet::Wallet::Status_Ok);
// ASSERT_TRUE(wmgr->closeWallet(wallet3));
//}
@ -299,22 +299,22 @@ TEST_F(WalletManagerTest, WalletManagerOpensWalletWithPasswordAndReopen)
// create password protected wallet
std::string wallet_pass = "password";
std::string wrong_wallet_pass = "1111";
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, wallet_pass, WALLET_LANG, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, wallet_pass, WALLET_LANG, Wallet::NetworkType::TESTNET);
std::string seed1 = wallet1->seed();
ASSERT_TRUE(wmgr->closeWallet(wallet1));
Monero::Wallet *wallet2 = nullptr;
Monero::Wallet *wallet3 = nullptr;
Wallet::Wallet *wallet2 = nullptr;
Wallet::Wallet *wallet3 = nullptr;
std::mutex mutex;
open_wallet_helper(wmgr, &wallet2, wrong_wallet_pass, nullptr);
ASSERT_TRUE(wallet2 != nullptr);
ASSERT_TRUE(wallet2->status() != Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet2->status() != Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wmgr->closeWallet(wallet2));
open_wallet_helper(wmgr, &wallet3, wallet_pass, nullptr);
ASSERT_TRUE(wallet3 != nullptr);
ASSERT_TRUE(wallet3->status() == Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet3->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wmgr->closeWallet(wallet3));
}
@ -322,12 +322,12 @@ TEST_F(WalletManagerTest, WalletManagerOpensWalletWithPasswordAndReopen)
TEST_F(WalletManagerTest, WalletManagerStoresWallet)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Wallet::NetworkType::MAINNET);
std::string seed1 = wallet1->seed();
wallet1->store("");
ASSERT_TRUE(wmgr->closeWallet(wallet1));
Monero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, Monero::NetworkType::MAINNET);
ASSERT_TRUE(wallet2->status() == Monero::Wallet::Status_Ok);
Wallet::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, Wallet::NetworkType::MAINNET);
ASSERT_TRUE(wallet2->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wallet2->seed() == seed1);
}
@ -335,45 +335,45 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet)
TEST_F(WalletManagerTest, WalletManagerMovesWallet)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Wallet::NetworkType::MAINNET);
std::string WALLET_NAME_MOVED = std::string("/tmp/") + WALLET_NAME + ".moved";
std::string seed1 = wallet1->seed();
ASSERT_TRUE(wallet1->store(WALLET_NAME_MOVED));
Monero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME_MOVED, WALLET_PASS, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME_MOVED, WALLET_PASS, Wallet::NetworkType::MAINNET);
ASSERT_TRUE(wallet2->filename() == WALLET_NAME_MOVED);
ASSERT_TRUE(wallet2->keysFilename() == WALLET_NAME_MOVED + ".keys");
ASSERT_TRUE(wallet2->status() == Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet2->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wallet2->seed() == seed1);
}
TEST_F(WalletManagerTest, WalletManagerChangesPassword)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Wallet::NetworkType::MAINNET);
std::string seed1 = wallet1->seed();
ASSERT_TRUE(wallet1->setPassword(WALLET_PASS2));
ASSERT_TRUE(wmgr->closeWallet(wallet1));
Monero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS2, Monero::NetworkType::MAINNET);
ASSERT_TRUE(wallet2->status() == Monero::Wallet::Status_Ok);
Wallet::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS2, Wallet::NetworkType::MAINNET);
ASSERT_TRUE(wallet2->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wallet2->seed() == seed1);
ASSERT_TRUE(wmgr->closeWallet(wallet2));
Monero::Wallet * wallet3 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, Monero::NetworkType::MAINNET);
ASSERT_FALSE(wallet3->status() == Monero::Wallet::Status_Ok);
Wallet::Wallet * wallet3 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, Wallet::NetworkType::MAINNET);
ASSERT_FALSE(wallet3->status() == Wallet::Wallet::Status_Ok);
}
TEST_F(WalletManagerTest, WalletManagerRecoversWallet)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Wallet::NetworkType::MAINNET);
std::string seed1 = wallet1->seed();
std::string address1 = wallet1->mainAddress();
ASSERT_FALSE(address1.empty());
ASSERT_TRUE(wmgr->closeWallet(wallet1));
Utils::deleteWallet(WALLET_NAME);
Monero::Wallet * wallet2 = wmgr->recoveryWallet(WALLET_NAME, seed1, Monero::NetworkType::MAINNET);
ASSERT_TRUE(wallet2->status() == Monero::Wallet::Status_Ok);
Wallet::Wallet * wallet2 = wmgr->recoveryWallet(WALLET_NAME, seed1, Wallet::NetworkType::MAINNET);
ASSERT_TRUE(wallet2->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wallet2->seed() == seed1);
ASSERT_TRUE(wallet2->mainAddress() == address1);
ASSERT_TRUE(wmgr->closeWallet(wallet2));
@ -382,15 +382,15 @@ TEST_F(WalletManagerTest, WalletManagerRecoversWallet)
TEST_F(WalletManagerTest, WalletManagerStoresWallet1)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Wallet::NetworkType::MAINNET);
std::string seed1 = wallet1->seed();
std::string address1 = wallet1->mainAddress();
ASSERT_TRUE(wallet1->store(""));
ASSERT_TRUE(wallet1->store(WALLET_NAME_COPY));
ASSERT_TRUE(wmgr->closeWallet(wallet1));
Monero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME_COPY, WALLET_PASS, Monero::NetworkType::MAINNET);
ASSERT_TRUE(wallet2->status() == Monero::Wallet::Status_Ok);
Wallet::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME_COPY, WALLET_PASS, Wallet::NetworkType::MAINNET);
ASSERT_TRUE(wallet2->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wallet2->seed() == seed1);
ASSERT_TRUE(wallet2->mainAddress() == address1);
ASSERT_TRUE(wmgr->closeWallet(wallet2));
@ -399,15 +399,15 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet1)
TEST_F(WalletManagerTest, WalletManagerStoresWallet2)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Wallet::NetworkType::MAINNET);
std::string seed1 = wallet1->seed();
std::string address1 = wallet1->mainAddress();
ASSERT_TRUE(wallet1->store(WALLET_NAME_WITH_DIR));
ASSERT_TRUE(wmgr->closeWallet(wallet1));
wallet1 = wmgr->openWallet(WALLET_NAME_WITH_DIR, WALLET_PASS, Monero::NetworkType::MAINNET);
ASSERT_TRUE(wallet1->status() == Monero::Wallet::Status_Ok);
wallet1 = wmgr->openWallet(WALLET_NAME_WITH_DIR, WALLET_PASS, Wallet::NetworkType::MAINNET);
ASSERT_TRUE(wallet1->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wallet1->seed() == seed1);
ASSERT_TRUE(wallet1->mainAddress() == address1);
ASSERT_TRUE(wmgr->closeWallet(wallet1));
@ -416,21 +416,21 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet2)
TEST_F(WalletManagerTest, WalletManagerStoresWallet3)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Wallet::NetworkType::MAINNET);
std::string seed1 = wallet1->seed();
std::string address1 = wallet1->mainAddress();
ASSERT_FALSE(wallet1->store(WALLET_NAME_WITH_DIR_NON_WRITABLE));
ASSERT_TRUE(wmgr->closeWallet(wallet1));
wallet1 = wmgr->openWallet(WALLET_NAME_WITH_DIR_NON_WRITABLE, WALLET_PASS, Monero::NetworkType::MAINNET);
ASSERT_FALSE(wallet1->status() == Monero::Wallet::Status_Ok);
wallet1 = wmgr->openWallet(WALLET_NAME_WITH_DIR_NON_WRITABLE, WALLET_PASS, Wallet::NetworkType::MAINNET);
ASSERT_FALSE(wallet1->status() == Wallet::Wallet::Status_Ok);
// "close" always returns true;
ASSERT_TRUE(wmgr->closeWallet(wallet1));
wallet1 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, Monero::NetworkType::MAINNET);
ASSERT_TRUE(wallet1->status() == Monero::Wallet::Status_Ok);
wallet1 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, Wallet::NetworkType::MAINNET);
ASSERT_TRUE(wallet1->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wallet1->seed() == seed1);
ASSERT_TRUE(wallet1->mainAddress() == address1);
ASSERT_TRUE(wmgr->closeWallet(wallet1));
@ -440,20 +440,20 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet3)
TEST_F(WalletManagerTest, WalletManagerStoresWallet4)
{
Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, Wallet::NetworkType::MAINNET);
std::string seed1 = wallet1->seed();
std::string address1 = wallet1->mainAddress();
ASSERT_TRUE(wallet1->store(""));
ASSERT_TRUE(wallet1->status() == Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet1->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wallet1->store(""));
ASSERT_TRUE(wallet1->status() == Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet1->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wmgr->closeWallet(wallet1));
wallet1 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, Monero::NetworkType::MAINNET);
ASSERT_TRUE(wallet1->status() == Monero::Wallet::Status_Ok);
wallet1 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, Wallet::NetworkType::MAINNET);
ASSERT_TRUE(wallet1->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wallet1->seed() == seed1);
ASSERT_TRUE(wallet1->mainAddress() == address1);
ASSERT_TRUE(wmgr->closeWallet(wallet1));
@ -475,16 +475,16 @@ TEST_F(WalletManagerTest, WalletManagerFindsWallet)
TEST_F(WalletTest1, WalletGeneratesPaymentId)
{
std::string payment_id = Monero::Wallet::genPaymentId();
std::string payment_id = Wallet::Wallet::genPaymentId();
ASSERT_TRUE(payment_id.length() == 16);
}
TEST_F(WalletTest1, WalletGeneratesIntegratedAddress)
{
std::string payment_id = Monero::Wallet::genPaymentId();
std::string payment_id = Wallet::Wallet::genPaymentId();
Monero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
std::string integrated_address = wallet1->integratedAddress(payment_id);
ASSERT_TRUE(integrated_address.length() == 106);
}
@ -492,14 +492,14 @@ TEST_F(WalletTest1, WalletGeneratesIntegratedAddress)
TEST_F(WalletTest1, WalletShowsBalance)
{
Monero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
ASSERT_TRUE(wallet1->balance(0) > 0);
ASSERT_TRUE(wallet1->unlockedBalance(0) > 0);
uint64_t balance1 = wallet1->balance(0);
uint64_t unlockedBalance1 = wallet1->unlockedBalance(0);
ASSERT_TRUE(wmgr->closeWallet(wallet1));
Monero::Wallet * wallet2 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet2 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
ASSERT_TRUE(balance1 == wallet2->balance(0));
std::cout << "wallet balance: " << wallet2->balance(0) << std::endl;
@ -510,7 +510,7 @@ TEST_F(WalletTest1, WalletShowsBalance)
TEST_F(WalletTest1, WalletReturnsCurrentBlockHeight)
{
Monero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
ASSERT_TRUE(wallet1->blockChainHeight() > 0);
wmgr->closeWallet(wallet1);
}
@ -518,14 +518,14 @@ TEST_F(WalletTest1, WalletReturnsCurrentBlockHeight)
TEST_F(WalletTest1, WalletReturnsDaemonBlockHeight)
{
Monero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
// wallet not connected to daemon
ASSERT_TRUE(wallet1->daemonBlockChainHeight() == 0);
ASSERT_TRUE(wallet1->status() != Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet1->status() != Wallet::Wallet::Status_Ok);
ASSERT_FALSE(wallet1->errorString().empty());
wmgr->closeWallet(wallet1);
wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
// wallet connected to daemon
wallet1->init(TESTNET_DAEMON_ADDRESS, 0);
ASSERT_TRUE(wallet1->daemonBlockChainHeight() > 0);
@ -538,7 +538,7 @@ TEST_F(WalletTest1, WalletRefresh)
{
std::cout << "Opening wallet: " << CURRENT_SRC_WALLET << std::endl;
Monero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
// make sure testnet daemon is running
std::cout << "connecting to daemon: " << TESTNET_DAEMON_ADDRESS << std::endl;
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
@ -548,12 +548,12 @@ TEST_F(WalletTest1, WalletRefresh)
TEST_F(WalletTest1, WalletConvertsToString)
{
std::string strAmount = Monero::Wallet::displayAmount(AMOUNT_5XMR);
ASSERT_TRUE(AMOUNT_5XMR == Monero::Wallet::amountFromString(strAmount));
std::string strAmount = Wallet::Wallet::displayAmount(AMOUNT_5XMR);
ASSERT_TRUE(AMOUNT_5XMR == Wallet::Wallet::amountFromString(strAmount));
ASSERT_TRUE(AMOUNT_5XMR == Monero::Wallet::amountFromDouble(5.0));
ASSERT_TRUE(AMOUNT_10XMR == Monero::Wallet::amountFromDouble(10.0));
ASSERT_TRUE(AMOUNT_1XMR == Monero::Wallet::amountFromDouble(1.0));
ASSERT_TRUE(AMOUNT_5XMR == Wallet::Wallet::amountFromDouble(5.0));
ASSERT_TRUE(AMOUNT_10XMR == Wallet::Wallet::amountFromDouble(10.0));
ASSERT_TRUE(AMOUNT_1XMR == Wallet::Wallet::amountFromDouble(1.0));
}
@ -562,25 +562,25 @@ TEST_F(WalletTest1, WalletConvertsToString)
TEST_F(WalletTest1, WalletTransaction)
{
Monero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
// make sure testnet daemon is running
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet1->refresh());
uint64_t balance = wallet1->balance(0);
ASSERT_TRUE(wallet1->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(wallet1->status() == Wallet::PendingTransaction::Status_Ok);
std::string recepient_address = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
const int MIXIN_COUNT = 4;
Monero::PendingTransaction * transaction = wallet1->createTransaction(recepient_address,
Wallet::PendingTransaction * transaction = wallet1->createTransaction(recepient_address,
PAYMENT_ID_EMPTY,
AMOUNT_10XMR,
MIXIN_COUNT,
Monero::PendingTransaction::Priority_Medium,
Wallet::PendingTransaction::Priority_Medium,
0,
std::set<uint32_t>{});
ASSERT_TRUE(transaction->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(transaction->status() == Wallet::PendingTransaction::Status_Ok);
wallet1->refresh();
ASSERT_TRUE(wallet1->balance(0) == balance);
@ -604,26 +604,26 @@ TEST_F(WalletTest1, WalletTransactionWithMixin)
std::string payment_id = "";
Monero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
// make sure testnet daemon is running
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet1->refresh());
uint64_t balance = wallet1->balance(0);
ASSERT_TRUE(wallet1->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(wallet1->status() == Wallet::PendingTransaction::Status_Ok);
std::string recepient_address = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
for (auto mixin : mixins) {
std::cerr << "Transaction mixin count: " << mixin << std::endl;
Monero::PendingTransaction * transaction = wallet1->createTransaction(
recepient_address, payment_id, AMOUNT_5XMR, mixin, Monero::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
Wallet::PendingTransaction * transaction = wallet1->createTransaction(
recepient_address, payment_id, AMOUNT_5XMR, mixin, Wallet::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
std::cerr << "Transaction status: " << transaction->status() << std::endl;
std::cerr << "Transaction fee: " << Monero::Wallet::displayAmount(transaction->fee()) << std::endl;
std::cerr << "Transaction fee: " << Wallet::Wallet::displayAmount(transaction->fee()) << std::endl;
std::cerr << "Transaction error: " << transaction->errorString() << std::endl;
ASSERT_TRUE(transaction->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(transaction->status() == Wallet::PendingTransaction::Status_Ok);
wallet1->disposeTransaction(transaction);
}
@ -638,34 +638,34 @@ TEST_F(WalletTest1, WalletTransactionWithPriority)
std::string payment_id = "";
Monero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
// make sure testnet daemon is running
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet1->refresh());
uint64_t balance = wallet1->balance(0);
ASSERT_TRUE(wallet1->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(wallet1->status() == Wallet::PendingTransaction::Status_Ok);
std::string recepient_address = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
uint32_t mixin = 2;
uint64_t fee = 0;
std::vector<Monero::PendingTransaction::Priority> priorities = {
Monero::PendingTransaction::Priority_Low,
Monero::PendingTransaction::Priority_Medium,
Monero::PendingTransaction::Priority_High
std::vector<Wallet::PendingTransaction::Priority> priorities = {
Wallet::PendingTransaction::Priority_Low,
Wallet::PendingTransaction::Priority_Medium,
Wallet::PendingTransaction::Priority_High
};
for (auto it = priorities.begin(); it != priorities.end(); ++it) {
std::cerr << "Transaction priority: " << *it << std::endl;
Monero::PendingTransaction * transaction = wallet1->createTransaction(
Wallet::PendingTransaction * transaction = wallet1->createTransaction(
recepient_address, payment_id, AMOUNT_5XMR, mixin, *it, 0, std::set<uint32_t>{});
std::cerr << "Transaction status: " << transaction->status() << std::endl;
std::cerr << "Transaction fee: " << Monero::Wallet::displayAmount(transaction->fee()) << std::endl;
std::cerr << "Transaction fee: " << Wallet::Wallet::displayAmount(transaction->fee()) << std::endl;
std::cerr << "Transaction error: " << transaction->errorString() << std::endl;
ASSERT_TRUE(transaction->fee() > fee);
ASSERT_TRUE(transaction->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(transaction->status() == Wallet::PendingTransaction::Status_Ok);
fee = transaction->fee();
wallet1->disposeTransaction(transaction);
}
@ -678,11 +678,11 @@ TEST_F(WalletTest1, WalletTransactionWithPriority)
TEST_F(WalletTest1, WalletHistory)
{
Monero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
// make sure testnet daemon is running
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet1->refresh());
Monero::TransactionHistory * history = wallet1->history();
Wallet::TransactionHistory * history = wallet1->history();
history->refresh();
ASSERT_TRUE(history->count() > 0);
@ -696,11 +696,11 @@ TEST_F(WalletTest1, WalletHistory)
TEST_F(WalletTest1, WalletTransactionAndHistory)
{
return;
Monero::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
// make sure testnet daemon is running
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet_src->refresh());
Monero::TransactionHistory * history = wallet_src->history();
Wallet::TransactionHistory * history = wallet_src->history();
history->refresh();
ASSERT_TRUE(history->count() > 0);
size_t count1 = history->count();
@ -714,11 +714,11 @@ TEST_F(WalletTest1, WalletTransactionAndHistory)
std::string wallet4_addr = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr,
Wallet::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr,
PAYMENT_ID_EMPTY,
AMOUNT_10XMR * 5, 1, Monero::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
AMOUNT_10XMR * 5, 1, Wallet::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
ASSERT_TRUE(tx->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->status() == Wallet::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->commit());
history = wallet_src->history();
history->refresh();
@ -735,11 +735,11 @@ TEST_F(WalletTest1, WalletTransactionAndHistory)
TEST_F(WalletTest1, WalletTransactionWithPaymentId)
{
Monero::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
// make sure testnet daemon is running
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet_src->refresh());
Monero::TransactionHistory * history = wallet_src->history();
Wallet::TransactionHistory * history = wallet_src->history();
history->refresh();
ASSERT_TRUE(history->count() > 0);
size_t count1 = history->count();
@ -752,15 +752,15 @@ TEST_F(WalletTest1, WalletTransactionWithPaymentId)
std::string wallet4_addr = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
std::string payment_id = Monero::Wallet::genPaymentId();
std::string payment_id = Wallet::Wallet::genPaymentId();
ASSERT_TRUE(payment_id.length() == 16);
Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr,
Wallet::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr,
payment_id,
AMOUNT_1XMR, 1, Monero::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
AMOUNT_1XMR, 1, Wallet::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
ASSERT_TRUE(tx->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->status() == Wallet::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->commit());
history = wallet_src->history();
history->refresh();
@ -781,10 +781,10 @@ TEST_F(WalletTest1, WalletTransactionWithPaymentId)
}
struct MyWalletListener : public Monero::WalletListener
struct MyWalletListener : public Wallet::WalletListener
{
Monero::Wallet * wallet;
Wallet::Wallet * wallet;
uint64_t total_tx;
uint64_t total_rx;
std::mutex mutex;
@ -801,7 +801,7 @@ struct MyWalletListener : public Monero::WalletListener
MyWalletListener(Monero::Wallet * wallet)
MyWalletListener(Wallet::Wallet * wallet)
: total_tx(0), total_rx(0)
{
reset();
@ -877,7 +877,7 @@ struct MyWalletListener : public Monero::WalletListener
TEST_F(WalletTest2, WalletCallBackRefreshedSync)
{
Monero::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
MyWalletListener * wallet_src_listener = new MyWalletListener(wallet_src);
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet_src_listener->refresh_triggered);
@ -893,7 +893,7 @@ TEST_F(WalletTest2, WalletCallBackRefreshedSync)
TEST_F(WalletTest2, WalletCallBackRefreshedAsync)
{
Monero::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
MyWalletListener * wallet_src_listener = new MyWalletListener(wallet_src);
std::unique_lock lock{wallet_src_listener->mutex};
@ -914,26 +914,26 @@ TEST_F(WalletTest2, WalletCallBackRefreshedAsync)
TEST_F(WalletTest2, WalletCallbackSent)
{
Monero::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
// make sure testnet daemon is running
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet_src->refresh());
MyWalletListener * wallet_src_listener = new MyWalletListener(wallet_src);
uint64_t balance = wallet_src->balance(0);
std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance(0)) << std::endl;
Monero::Wallet * wallet_dst = wmgr->openWallet(CURRENT_DST_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet_dst = wmgr->openWallet(CURRENT_DST_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
uint64_t amount = AMOUNT_1XMR * 5;
std::cout << "** Sending " << Monero::Wallet::displayAmount(amount) << " to " << wallet_dst->mainAddress();
std::cout << "** Sending " << Wallet::Wallet::displayAmount(amount) << " to " << wallet_dst->mainAddress();
Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->mainAddress(),
Wallet::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->mainAddress(),
PAYMENT_ID_EMPTY,
amount, 1, Monero::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
std::cout << "** Committing transaction: " << Monero::Wallet::displayAmount(tx->amount())
<< " with fee: " << Monero::Wallet::displayAmount(tx->fee());
amount, 1, Wallet::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
std::cout << "** Committing transaction: " << Wallet::Wallet::displayAmount(tx->amount())
<< " with fee: " << Wallet::Wallet::displayAmount(tx->fee());
ASSERT_TRUE(tx->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->status() == Wallet::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->commit());
std::unique_lock lock{wallet_src_listener->mutex};
@ -952,13 +952,13 @@ TEST_F(WalletTest2, WalletCallbackSent)
TEST_F(WalletTest2, WalletCallbackReceived)
{
Monero::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
// make sure testnet daemon is running
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet_src->refresh());
std::cout << "** Balance src1: " << wallet_src->displayAmount(wallet_src->balance(0)) << std::endl;
Monero::Wallet * wallet_dst = wmgr->openWallet(CURRENT_DST_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet_dst = wmgr->openWallet(CURRENT_DST_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
ASSERT_TRUE(wallet_dst->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet_dst->refresh());
uint64_t balance = wallet_dst->balance(0);
@ -966,15 +966,15 @@ TEST_F(WalletTest2, WalletCallbackReceived)
std::unique_ptr<MyWalletListener> wallet_dst_listener (new MyWalletListener(wallet_dst));
uint64_t amount = AMOUNT_1XMR * 5;
std::cout << "** Sending " << Monero::Wallet::displayAmount(amount) << " to " << wallet_dst->mainAddress();
Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->mainAddress(),
std::cout << "** Sending " << Wallet::Wallet::displayAmount(amount) << " to " << wallet_dst->mainAddress();
Wallet::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->mainAddress(),
PAYMENT_ID_EMPTY,
amount, 1, Monero::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
amount, 1, Wallet::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
std::cout << "** Committing transaction: " << Monero::Wallet::displayAmount(tx->amount())
<< " with fee: " << Monero::Wallet::displayAmount(tx->fee());
std::cout << "** Committing transaction: " << Wallet::Wallet::displayAmount(tx->amount())
<< " with fee: " << Wallet::Wallet::displayAmount(tx->fee());
ASSERT_TRUE(tx->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->status() == Wallet::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->commit());
std::unique_lock lock{wallet_dst_listener->mutex};
@ -998,7 +998,7 @@ TEST_F(WalletTest2, WalletCallbackReceived)
TEST_F(WalletTest2, WalletCallbackNewBlock)
{
Monero::Wallet * wallet_src = wmgr->openWallet(TESTNET_WALLET5_NAME, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
Wallet::Wallet * wallet_src = wmgr->openWallet(TESTNET_WALLET5_NAME, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET);
// make sure testnet daemon is running
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet_src->refresh());
@ -1024,7 +1024,7 @@ TEST_F(WalletTest2, WalletCallbackNewBlock)
TEST_F(WalletManagerMainnetTest, CreateOpenAndRefreshWalletMainNetSync)
{
Monero::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG, Wallet::NetworkType::MAINNET);
std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
wallet->init(MAINNET_DAEMON_ADDRESS, 0);
std::cerr << "TEST: waiting on refresh lock...\n";
@ -1043,7 +1043,7 @@ TEST_F(WalletManagerMainnetTest, CreateAndRefreshWalletMainNetAsync)
// supposing 2 minutes should be enough for fast refresh
constexpr auto wait_for = 2min;
Monero::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG, Wallet::NetworkType::MAINNET);
std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
std::unique_lock lock{wallet_listener->mutex};
@ -1052,7 +1052,7 @@ TEST_F(WalletManagerMainnetTest, CreateAndRefreshWalletMainNetAsync)
std::cerr << "TEST: waiting on refresh lock...\n";
wallet_listener->cv_refresh.wait_for(lock, wait_for);
std::cerr << "TEST: refresh lock acquired...\n";
ASSERT_TRUE(wallet->status() == Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wallet_listener->refresh_triggered);
ASSERT_TRUE(wallet->connected());
ASSERT_TRUE(wallet->blockChainHeight() == wallet->daemonBlockChainHeight());
@ -1066,9 +1066,9 @@ TEST_F(WalletManagerMainnetTest, OpenAndRefreshWalletMainNetAsync)
// supposing 2 minutes should be enough for fast refresh
constexpr auto wait_for = 2min;
Monero::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG, Wallet::NetworkType::MAINNET);
wmgr->closeWallet(wallet);
wallet = wmgr->openWallet(WALLET_NAME_MAINNET, "", Monero::NetworkType::MAINNET);
wallet = wmgr->openWallet(WALLET_NAME_MAINNET, "", Wallet::NetworkType::MAINNET);
std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
@ -1078,7 +1078,7 @@ TEST_F(WalletManagerMainnetTest, OpenAndRefreshWalletMainNetAsync)
std::cerr << "TEST: waiting on refresh lock...\n";
wallet_listener->cv_refresh.wait_for(lock, wait_for);
std::cerr << "TEST: refresh lock acquired...\n";
ASSERT_TRUE(wallet->status() == Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wallet_listener->refresh_triggered);
ASSERT_TRUE(wallet->connected());
ASSERT_TRUE(wallet->blockChainHeight() == wallet->daemonBlockChainHeight());
@ -1092,7 +1092,7 @@ TEST_F(WalletManagerMainnetTest, RecoverAndRefreshWalletMainNetAsync)
// supposing 2 minutes should be enough for fast refresh
constexpr auto wait_for = 2min;
Monero::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG, Monero::NetworkType::MAINNET);
Wallet::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG, Wallet::NetworkType::MAINNET);
std::string seed = wallet->seed();
std::string address = wallet->mainAddress();
wmgr->closeWallet(wallet);
@ -1101,8 +1101,8 @@ TEST_F(WalletManagerMainnetTest, RecoverAndRefreshWalletMainNetAsync)
Utils::deleteWallet(WALLET_NAME_MAINNET);
// ..and recovering wallet from seed
wallet = wmgr->recoveryWallet(WALLET_NAME_MAINNET, seed, Monero::NetworkType::MAINNET);
ASSERT_TRUE(wallet->status() == Monero::Wallet::Status_Ok);
wallet = wmgr->recoveryWallet(WALLET_NAME_MAINNET, seed, Wallet::NetworkType::MAINNET);
ASSERT_TRUE(wallet->status() == Wallet::Wallet::Status_Ok);
ASSERT_TRUE(wallet->mainAddress() == address);
std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
std::unique_lock lock{wallet_listener->mutex};
@ -1114,7 +1114,7 @@ TEST_F(WalletManagerMainnetTest, RecoverAndRefreshWalletMainNetAsync)
// as it needs much more than 120 seconds for mainnet
wallet_listener->cv_refresh.wait_for(lock, wait_for);
ASSERT_TRUE(wallet->status() == Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet->status() == Wallet::Wallet::Status_Ok);
ASSERT_FALSE(wallet_listener->refresh_triggered);
ASSERT_TRUE(wallet->connected());
ASSERT_FALSE(wallet->blockChainHeight() == wallet->daemonBlockChainHeight());
@ -1162,7 +1162,7 @@ int main(int argc, char** argv)
CURRENT_DST_WALLET = TESTNET_WALLET1_NAME;
::testing::InitGoogleTest(&argc, argv);
Monero::WalletManagerFactory::setLogLevel(Monero::WalletManagerFactory::LogLevel_Max);
Wallet::WalletManagerFactory::setLogLevel(Wallet::WalletManagerFactory::LogLevel_Max);
return RUN_ALL_TESTS();
CATCH_ENTRY_L0("main", 1);
}