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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
#include "Wallet.h"
#include "PendingTransaction.h"
#include "TransactionHistory.h"
#include "wallet/wallet2_api.h"
#include <QFile>
#include <QDir>
#include <QDebug>
#include <QUrl>
#include <QTimer>
namespace {
}
class WalletListenerImpl : public Bitmonero::WalletListener
{
public:
WalletListenerImpl(Wallet * w)
: m_wallet(w)
{
}
virtual void moneySpent(const std::string &txId, uint64_t amount)
{
// TODO
Q_UNUSED(txId)
Q_UNUSED(amount)
}
virtual void moneyReceived(const std::string &txId, uint64_t amount)
{
// TODO
Q_UNUSED(txId)
Q_UNUSED(amount)
}
virtual void updated()
{
emit m_wallet->updated();
}
// called when wallet refreshed by background thread or explicitly
virtual void refreshed()
{
emit m_wallet->refreshed();
}
private:
Wallet * m_wallet;
};
QString Wallet::getSeed() const
{
return QString::fromStdString(m_walletImpl->seed());
}
QString Wallet::getSeedLanguage() const
{
return QString::fromStdString(m_walletImpl->getSeedLanguage());
}
void Wallet::setSeedLanguage(const QString &lang)
{
m_walletImpl->setSeedLanguage(lang.toStdString());
}
Wallet::Status Wallet::status() const
{
return static_cast<Status>(m_walletImpl->status());
}
QString Wallet::errorString() const
{
return QString::fromStdString(m_walletImpl->errorString());
}
bool Wallet::setPassword(const QString &password)
{
return m_walletImpl->setPassword(password.toStdString());
}
QString Wallet::address() const
{
return QString::fromStdString(m_walletImpl->address());
}
bool Wallet::store(const QString &path)
{
return m_walletImpl->store(path.toStdString());
}
bool Wallet::init(const QString &daemonAddress, quint64 upperTransactionLimit)
{
return m_walletImpl->init(daemonAddress.toStdString(), upperTransactionLimit);
}
bool Wallet::connectToDaemon()
{
return m_walletImpl->connectToDaemon();
}
void Wallet::setTrustedDaemon(bool arg)
{
m_walletImpl->setTrustedDaemon(arg);
}
quint64 Wallet::balance() const
{
return m_walletImpl->balance();
}
quint64 Wallet::unlockedBalance() const
{
return m_walletImpl->unlockedBalance();
}
bool Wallet::refresh()
{
bool result = m_walletImpl->refresh();
if (result)
emit updated();
return result;
}
void Wallet::refreshAsync()
{
m_walletImpl->refreshAsync();
}
PendingTransaction *Wallet::createTransaction(const QString &dst_addr, const QString &payment_id,
quint64 amount, quint32 mixin_count,
PendingTransaction::Priority priority)
{
Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createTransaction(
dst_addr.toStdString(), payment_id.toStdString(), amount, mixin_count,
static_cast<Bitmonero::PendingTransaction::Priority>(priority));
PendingTransaction * result = new PendingTransaction(ptImpl, this);
return result;
}
void Wallet::disposeTransaction(PendingTransaction *t)
{
m_walletImpl->disposeTransaction(t->m_pimpl);
delete t;
}
TransactionHistory *Wallet::history()
{
if (!m_history) {
Bitmonero::TransactionHistory * impl = m_walletImpl->history();
m_history = new TransactionHistory(impl, this);
}
return m_history;
}
QString Wallet::generatePaymentId() const
{
return QString::fromStdString(Bitmonero::Wallet::genPaymentId());
}
QString Wallet::integratedAddress(const QString &paymentId) const
{
return QString::fromStdString(m_walletImpl->integratedAddress(paymentId.toStdString()));
}
QString Wallet::paymentId() const
{
return m_paymentId;
}
void Wallet::setPaymentId(const QString &paymentId)
{
m_paymentId = paymentId;
}
Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent)
: QObject(parent), m_walletImpl(w), m_history(nullptr)
{
}
Wallet::~Wallet()
{
Bitmonero::WalletManagerFactory::getWalletManager()->closeWallet(m_walletImpl);
}
|