aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIlya Kitaev <mbg033@gmail.com>2016-02-21 21:18:16 +0300
committerIlya Kitaev <mbg033@gmail.com>2016-03-16 14:27:57 +0300
commitf1f9279d90bd912695307384eac92bf098e092d6 (patch)
tree2cbc0faa18bdeabbd15961586885e317f9a121f8 /src
parenttests for wallet2_api (diff)
downloadmonero-f1f9279d90bd912695307384eac92bf098e092d6.tar.xz
get_seed() included to interface
Diffstat (limited to 'src')
-rw-r--r--src/wallet/wallet2_api.cpp38
-rw-r--r--src/wallet/wallet2_api.h7
2 files changed, 31 insertions, 14 deletions
diff --git a/src/wallet/wallet2_api.cpp b/src/wallet/wallet2_api.cpp
index ffb18c317..f57ccfe69 100644
--- a/src/wallet/wallet2_api.cpp
+++ b/src/wallet/wallet2_api.cpp
@@ -45,6 +45,7 @@ namespace {
}
+Wallet::~Wallet() {}
///////////////////////// Wallet implementation ////////////////////////////////
class WalletImpl : public Wallet
@@ -55,26 +56,26 @@ public:
bool create(const std::string &path, const std::string &password,
const std::string &language);
bool open(const std::string &path, const std::string &password);
-
std::string seed() const;
+ std::string getSeedLanguage() const;
+ void setSeedLanguage(const std::string &arg);
private:
- std::unique_ptr<tools::wallet2> m_wallet;
+ //std::unique_ptr<tools::wallet2> m_wallet;
+ tools::wallet2 * m_wallet;
};
WalletImpl::WalletImpl()
+ :m_wallet(nullptr)
{
}
-
-Wallet::~Wallet() {}
-
WalletImpl::~WalletImpl()
{
- //delete m_wallet;
+ delete m_wallet;
}
bool WalletImpl::create(const std::string &path, const std::string &password, const std::string &language)
@@ -82,6 +83,7 @@ bool WalletImpl::create(const std::string &path, const std::string &password, co
bool keys_file_exists;
bool wallet_file_exists;
tools::wallet2::wallet_exists(path, keys_file_exists, wallet_file_exists);
+ // TODO: figure out how to setup logger;
LOG_PRINT_L3("wallet_path: " << path << "");
LOG_PRINT_L3("keys_file_exists: " << std::boolalpha << keys_file_exists << std::noboolalpha
<< " wallet_file_exists: " << std::boolalpha << wallet_file_exists << std::noboolalpha);
@@ -94,12 +96,12 @@ bool WalletImpl::create(const std::string &path, const std::string &password, co
return false;
}
-
// TODO: validate language
-
-
// TODO: create wallet
- m_wallet.reset(new tools::wallet2());
+ //m_wallet.reset(new tools::wallet2());
+ m_wallet = new tools::wallet2();
+ m_wallet->set_seed_language(language);
+
crypto::secret_key recovery_val, secret_key;
try {
recovery_val = m_wallet->generate(path, password, secret_key, false, false);
@@ -107,14 +109,27 @@ bool WalletImpl::create(const std::string &path, const std::string &password, co
// TODO: log exception
return false;
}
+
return true;
}
std::string WalletImpl::seed() const
{
- return "";
+ std::string seed;
+ if (m_wallet)
+ m_wallet->get_seed(seed);
+ return seed;
+}
+
+std::string WalletImpl::getSeedLanguage() const
+{
+ return m_wallet->get_seed_language();
}
+void WalletImpl::setSeedLanguage(const std::string &arg)
+{
+ m_wallet->set_seed_language(arg);
+}
///////////////////////// WalletManager implementation /////////////////////////
@@ -141,7 +156,6 @@ Wallet *WalletManagerImpl::createWallet(const std::string &path, const std::stri
delete wallet;
wallet = nullptr;
}
-
return wallet;
}
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index e1cd29de1..41b64d276 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -44,8 +44,11 @@ namespace Bitmonero {
struct Wallet
{
// TODO define wallet interface (decide what needed from wallet2)
- virtual ~Wallet() = 0;
- virtual std::string seed() const = 0;
+ virtual ~Wallet() = 0;
+ virtual std::string seed() const = 0;
+ virtual std::string getSeedLanguage() const = 0;
+ virtual void setSeedLanguage(const std::string &arg) = 0;
+
};
/**