1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#include "WalletManager.h"
#include "Wallet.h"
#include "wallet/wallet2_api.h"
#include <QFile>
#include <QFileInfo>
#include <QDir>
#include <QDebug>
#include <QUrl>
WalletManager * WalletManager::m_instance = nullptr;
WalletManager *WalletManager::instance()
{
if (!m_instance) {
m_instance = new WalletManager;
}
return m_instance;
}
Wallet *WalletManager::createWallet(const QString &path, const QString &password,
const QString &language, bool testnet)
{
Bitmonero::Wallet * w = m_pimpl->createWallet(path.toStdString(), password.toStdString(),
language.toStdString(), testnet);
Wallet * wallet = new Wallet(w);
return wallet;
}
Wallet *WalletManager::openWallet(const QString &path, const QString &password, bool testnet)
{
// TODO: call the libwallet api here;
Bitmonero::Wallet * w = m_pimpl->openWallet(path.toStdString(), password.toStdString(), testnet);
Wallet * wallet = new Wallet(w);
return wallet;
}
Wallet *WalletManager::recoveryWallet(const QString &path, const QString &memo, bool testnet)
{
Bitmonero::Wallet * w = m_pimpl->recoveryWallet(path.toStdString(), memo.toStdString(), testnet);
Wallet * wallet = new Wallet(w);
return wallet;
}
void WalletManager::closeWallet(Wallet *wallet)
{
delete wallet;
}
bool WalletManager::walletExists(const QString &path) const
{
return m_pimpl->walletExists(path.toStdString());
}
QStringList WalletManager::findWallets(const QString &path)
{
std::vector<std::string> found_wallets = m_pimpl->findWallets(path.toStdString());
QStringList result;
for (const auto &w : found_wallets) {
result.append(QString::fromStdString(w));
}
return result;
}
QString WalletManager::errorString() const
{
return tr("Unknown error");
}
bool WalletManager::moveWallet(const QString &src, const QString &dst)
{
return true;
}
QString WalletManager::walletLanguage(const QString &locale)
{
return "English";
}
QString WalletManager::displayAmount(quint64 amount)
{
return QString::fromStdString(Bitmonero::Wallet::displayAmount(amount));
}
WalletManager::WalletManager(QObject *parent) : QObject(parent)
{
m_pimpl = Bitmonero::WalletManagerFactory::getWalletManager();
}
|