mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-22 15:32:24 +00:00
Wallet::address implemented
This commit is contained in:
parent
180ac6e438
commit
19fcc74912
3 changed files with 15 additions and 0 deletions
|
@ -68,6 +68,7 @@ public:
|
||||||
int status() const;
|
int status() const;
|
||||||
std::string errorString() const;
|
std::string errorString() const;
|
||||||
bool setPassword(const std::string &password);
|
bool setPassword(const std::string &password);
|
||||||
|
std::string address() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clearStatus();
|
void clearStatus();
|
||||||
|
@ -233,6 +234,11 @@ bool WalletImpl::setPassword(const std::string &password)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string WalletImpl::address() const
|
||||||
|
{
|
||||||
|
return m_wallet->get_account().get_public_address_str(m_wallet->testnet());
|
||||||
|
}
|
||||||
|
|
||||||
void WalletImpl::clearStatus()
|
void WalletImpl::clearStatus()
|
||||||
{
|
{
|
||||||
m_status = Status_Ok;
|
m_status = Status_Ok;
|
||||||
|
|
|
@ -65,6 +65,7 @@ struct Wallet
|
||||||
//! in case error status, returns error string
|
//! in case error status, returns error string
|
||||||
virtual std::string errorString() const = 0;
|
virtual std::string errorString() const = 0;
|
||||||
virtual bool setPassword(const std::string &password) = 0;
|
virtual bool setPassword(const std::string &password) = 0;
|
||||||
|
virtual std::string address() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -88,7 +88,10 @@ TEST_F(WalletManagerTest, WalletManagerCreatesWallet)
|
||||||
boost::split(words, seed, boost::is_any_of(" "), boost::token_compress_on);
|
boost::split(words, seed, boost::is_any_of(" "), boost::token_compress_on);
|
||||||
ASSERT_TRUE(words.size() == 25);
|
ASSERT_TRUE(words.size() == 25);
|
||||||
std::cout << "** seed: " << wallet->seed() << std::endl;
|
std::cout << "** seed: " << wallet->seed() << std::endl;
|
||||||
|
ASSERT_FALSE(wallet->address().empty());
|
||||||
|
std::cout << "** address: " << wallet->address() << std::endl;
|
||||||
ASSERT_TRUE(wmgr->closeWallet(wallet));
|
ASSERT_TRUE(wmgr->closeWallet(wallet));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WalletManagerTest, WalletManagerOpensWallet)
|
TEST_F(WalletManagerTest, WalletManagerOpensWallet)
|
||||||
|
@ -124,15 +127,20 @@ TEST_F(WalletManagerTest, WalletManagerRecoversWallet)
|
||||||
{
|
{
|
||||||
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
|
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
|
||||||
std::string seed1 = wallet1->seed();
|
std::string seed1 = wallet1->seed();
|
||||||
|
std::string address1 = wallet1->address();
|
||||||
|
ASSERT_FALSE(address1.empty());
|
||||||
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
||||||
deleteWallet(WALLET_NAME);
|
deleteWallet(WALLET_NAME);
|
||||||
Bitmonero::Wallet * wallet2 = wmgr->recoveryWallet(WALLET_NAME, seed1);
|
Bitmonero::Wallet * wallet2 = wmgr->recoveryWallet(WALLET_NAME, seed1);
|
||||||
ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok);
|
ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok);
|
||||||
ASSERT_TRUE(wallet2->seed() == seed1);
|
ASSERT_TRUE(wallet2->seed() == seed1);
|
||||||
|
ASSERT_TRUE(wallet2->address() == address1);
|
||||||
ASSERT_TRUE(wmgr->closeWallet(wallet2));
|
ASSERT_TRUE(wmgr->closeWallet(wallet2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
//epee::debug::get_set_enable_assert(true, false);
|
//epee::debug::get_set_enable_assert(true, false);
|
||||||
|
|
Loading…
Reference in a new issue