aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Kitaev <mbg033@gmail.com>2016-03-12 17:52:58 +0300
committerIlya Kitaev <mbg033@gmail.com>2016-03-16 14:29:06 +0300
commit19fcc74912b48791665ea0e81c9ded91180ab6c5 (patch)
tree661894a61e8673d5fd76cb6e9f5a960e021ac186
parentWalletManager::recoveryWallet implemented (diff)
downloadmonero-19fcc74912b48791665ea0e81c9ded91180ab6c5.tar.xz
Wallet::address implemented
-rw-r--r--src/wallet/wallet2_api.cpp6
-rw-r--r--src/wallet/wallet2_api.h1
-rw-r--r--tests/libwallet_api_tests/main.cpp8
3 files changed, 15 insertions, 0 deletions
diff --git a/src/wallet/wallet2_api.cpp b/src/wallet/wallet2_api.cpp
index 645bc9c46..6428e7b32 100644
--- a/src/wallet/wallet2_api.cpp
+++ b/src/wallet/wallet2_api.cpp
@@ -68,6 +68,7 @@ public:
int status() const;
std::string errorString() const;
bool setPassword(const std::string &password);
+ std::string address() const;
private:
void clearStatus();
@@ -233,6 +234,11 @@ bool WalletImpl::setPassword(const std::string &password)
return result;
}
+std::string WalletImpl::address() const
+{
+ return m_wallet->get_account().get_public_address_str(m_wallet->testnet());
+}
+
void WalletImpl::clearStatus()
{
m_status = Status_Ok;
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index d8a0e8419..7a22a88de 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -65,6 +65,7 @@ struct Wallet
//! in case error status, returns error string
virtual std::string errorString() const = 0;
virtual bool setPassword(const std::string &password) = 0;
+ virtual std::string address() const = 0;
};
/**
diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp
index 7357e3a7f..8f4aba6bd 100644
--- a/tests/libwallet_api_tests/main.cpp
+++ b/tests/libwallet_api_tests/main.cpp
@@ -88,7 +88,10 @@ TEST_F(WalletManagerTest, WalletManagerCreatesWallet)
boost::split(words, seed, boost::is_any_of(" "), boost::token_compress_on);
ASSERT_TRUE(words.size() == 25);
std::cout << "** seed: " << wallet->seed() << std::endl;
+ ASSERT_FALSE(wallet->address().empty());
+ std::cout << "** address: " << wallet->address() << std::endl;
ASSERT_TRUE(wmgr->closeWallet(wallet));
+
}
TEST_F(WalletManagerTest, WalletManagerOpensWallet)
@@ -124,15 +127,20 @@ TEST_F(WalletManagerTest, WalletManagerRecoversWallet)
{
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
std::string seed1 = wallet1->seed();
+ std::string address1 = wallet1->address();
+ ASSERT_FALSE(address1.empty());
ASSERT_TRUE(wmgr->closeWallet(wallet1));
deleteWallet(WALLET_NAME);
Bitmonero::Wallet * wallet2 = wmgr->recoveryWallet(WALLET_NAME, seed1);
ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok);
ASSERT_TRUE(wallet2->seed() == seed1);
+ ASSERT_TRUE(wallet2->address() == address1);
ASSERT_TRUE(wmgr->closeWallet(wallet2));
}
+
+
int main(int argc, char** argv)
{
//epee::debug::get_set_enable_assert(true, false);