2016-02-23 17:59:26 +02:00
|
|
|
#include "Wallet.h"
|
2016-06-08 13:53:24 +03:00
|
|
|
#include "PendingTransaction.h"
|
|
|
|
#include "TransactionHistory.h"
|
2016-10-02 21:40:40 +03:00
|
|
|
#include "model/TransactionHistoryModel.h"
|
2016-10-07 23:05:51 +03:00
|
|
|
#include "model/TransactionHistorySortFilterModel.h"
|
2016-06-07 16:26:25 +03:00
|
|
|
#include "wallet/wallet2_api.h"
|
|
|
|
|
2016-02-29 16:39:39 +02:00
|
|
|
#include <QFile>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QUrl>
|
2016-06-17 16:35:07 +03:00
|
|
|
#include <QTimer>
|
2016-11-08 17:33:36 +02:00
|
|
|
#include <QtConcurrent/QtConcurrent>
|
2016-02-29 16:39:39 +02:00
|
|
|
|
|
|
|
namespace {
|
2016-11-01 19:14:39 +02:00
|
|
|
static const int DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS = 10;
|
|
|
|
static const int DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS = 60;
|
2016-11-26 17:31:27 +02:00
|
|
|
static const int WALLET_CONNECTION_STATUS_CACHE_TTL_SECONDS = 5;
|
2016-02-29 16:39:39 +02:00
|
|
|
}
|
|
|
|
|
2016-07-13 15:24:40 +03:00
|
|
|
class WalletListenerImpl : public Bitmonero::WalletListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WalletListenerImpl(Wallet * w)
|
|
|
|
: m_wallet(w)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void moneySpent(const std::string &txId, uint64_t amount)
|
|
|
|
{
|
2016-07-14 13:09:39 +03:00
|
|
|
qDebug() << __FUNCTION__;
|
2016-09-23 23:51:24 +03:00
|
|
|
emit m_wallet->moneySpent(QString::fromStdString(txId), amount);
|
2016-07-13 15:24:40 +03:00
|
|
|
}
|
|
|
|
|
2016-09-23 23:51:24 +03:00
|
|
|
|
2016-07-13 15:24:40 +03:00
|
|
|
virtual void moneyReceived(const std::string &txId, uint64_t amount)
|
|
|
|
{
|
2016-09-23 23:51:24 +03:00
|
|
|
qDebug() << __FUNCTION__;
|
|
|
|
emit m_wallet->moneyReceived(QString::fromStdString(txId), amount);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void newBlock(uint64_t height)
|
|
|
|
{
|
2016-09-26 22:55:25 +03:00
|
|
|
// qDebug() << __FUNCTION__;
|
2016-09-23 23:51:24 +03:00
|
|
|
emit m_wallet->newBlock(height);
|
2016-07-13 15:24:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void updated()
|
|
|
|
{
|
2016-07-14 13:09:39 +03:00
|
|
|
qDebug() << __FUNCTION__;
|
2016-07-13 15:24:40 +03:00
|
|
|
emit m_wallet->updated();
|
|
|
|
}
|
|
|
|
|
|
|
|
// called when wallet refreshed by background thread or explicitly
|
|
|
|
virtual void refreshed()
|
|
|
|
{
|
2016-07-14 13:09:39 +03:00
|
|
|
qDebug() << __FUNCTION__;
|
2016-07-13 15:24:40 +03:00
|
|
|
emit m_wallet->refreshed();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Wallet * m_wallet;
|
|
|
|
};
|
|
|
|
|
2016-10-02 21:40:40 +03:00
|
|
|
Wallet::Wallet(QObject * parent)
|
|
|
|
: Wallet(nullptr, parent)
|
|
|
|
{
|
|
|
|
}
|
2016-02-29 16:39:39 +02:00
|
|
|
|
2016-06-07 16:26:25 +03:00
|
|
|
QString Wallet::getSeed() const
|
2016-02-29 16:39:39 +02:00
|
|
|
{
|
2016-06-07 16:26:25 +03:00
|
|
|
return QString::fromStdString(m_walletImpl->seed());
|
2016-02-29 16:39:39 +02:00
|
|
|
}
|
|
|
|
|
2016-06-07 16:26:25 +03:00
|
|
|
QString Wallet::getSeedLanguage() const
|
2016-02-29 16:39:39 +02:00
|
|
|
{
|
2016-06-07 16:26:25 +03:00
|
|
|
return QString::fromStdString(m_walletImpl->getSeedLanguage());
|
2016-02-29 16:39:39 +02:00
|
|
|
}
|
|
|
|
|
2016-06-08 13:53:24 +03:00
|
|
|
void Wallet::setSeedLanguage(const QString &lang)
|
2016-02-24 12:25:20 +02:00
|
|
|
{
|
2016-06-08 13:53:24 +03:00
|
|
|
m_walletImpl->setSeedLanguage(lang.toStdString());
|
|
|
|
}
|
|
|
|
|
|
|
|
Wallet::Status Wallet::status() const
|
|
|
|
{
|
|
|
|
return static_cast<Status>(m_walletImpl->status());
|
2016-02-24 12:25:20 +02:00
|
|
|
}
|
|
|
|
|
2016-11-26 16:34:56 +02:00
|
|
|
Wallet::ConnectionStatus Wallet::connected()
|
2016-07-14 13:09:39 +03:00
|
|
|
{
|
2016-11-26 17:31:27 +02:00
|
|
|
// cache connection status
|
2016-11-26 18:01:59 +02:00
|
|
|
if(!m_initialized || m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl){
|
|
|
|
m_initialized = true;
|
2016-11-26 17:31:27 +02:00
|
|
|
ConnectionStatus newStatus = static_cast<ConnectionStatus>(m_walletImpl->connected());
|
|
|
|
if(newStatus != m_connectionStatus) {
|
|
|
|
m_connectionStatus = newStatus;
|
|
|
|
emit connectionStatusChanged();
|
|
|
|
}
|
|
|
|
m_connectionStatusTime.restart();
|
2016-11-26 16:34:56 +02:00
|
|
|
}
|
2016-11-26 17:31:27 +02:00
|
|
|
|
|
|
|
return m_connectionStatus;
|
2016-07-14 13:09:39 +03:00
|
|
|
}
|
|
|
|
|
2016-10-07 00:47:28 +03:00
|
|
|
bool Wallet::synchronized() const
|
|
|
|
{
|
|
|
|
return m_walletImpl->synchronized();
|
|
|
|
}
|
|
|
|
|
2016-06-07 16:26:25 +03:00
|
|
|
QString Wallet::errorString() const
|
2016-02-24 12:25:20 +02:00
|
|
|
{
|
2016-06-07 16:26:25 +03:00
|
|
|
return QString::fromStdString(m_walletImpl->errorString());
|
2016-02-24 12:25:20 +02:00
|
|
|
}
|
|
|
|
|
2016-02-29 16:39:39 +02:00
|
|
|
bool Wallet::setPassword(const QString &password)
|
2016-02-24 12:25:20 +02:00
|
|
|
{
|
2016-06-07 16:26:25 +03:00
|
|
|
return m_walletImpl->setPassword(password.toStdString());
|
2016-02-23 17:59:26 +02:00
|
|
|
}
|
2016-02-29 16:39:39 +02:00
|
|
|
|
2016-06-07 16:26:25 +03:00
|
|
|
QString Wallet::address() const
|
2016-02-29 16:39:39 +02:00
|
|
|
{
|
2016-06-07 16:26:25 +03:00
|
|
|
return QString::fromStdString(m_walletImpl->address());
|
2016-02-29 16:39:39 +02:00
|
|
|
}
|
|
|
|
|
2016-06-07 16:26:25 +03:00
|
|
|
bool Wallet::store(const QString &path)
|
2016-02-29 16:39:39 +02:00
|
|
|
{
|
2016-06-07 16:26:25 +03:00
|
|
|
return m_walletImpl->store(path.toStdString());
|
2016-02-29 16:39:39 +02:00
|
|
|
}
|
|
|
|
|
2016-10-10 22:36:57 +03:00
|
|
|
bool Wallet::init(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering, quint64 restoreHeight)
|
2016-06-08 13:53:24 +03:00
|
|
|
{
|
|
|
|
return m_walletImpl->init(daemonAddress.toStdString(), upperTransactionLimit);
|
|
|
|
}
|
|
|
|
|
2016-10-10 22:36:57 +03:00
|
|
|
void Wallet::initAsync(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering, quint64 restoreHeight)
|
2016-07-14 13:09:39 +03:00
|
|
|
{
|
2016-10-10 22:36:57 +03:00
|
|
|
if (isRecovering){
|
|
|
|
qDebug() << "RESTORING";
|
|
|
|
m_walletImpl->setRecoveringFromSeed(true);
|
|
|
|
m_walletImpl->setRefreshFromBlockHeight(restoreHeight);
|
|
|
|
}
|
2016-07-14 13:09:39 +03:00
|
|
|
m_walletImpl->initAsync(daemonAddress.toStdString(), upperTransactionLimit);
|
|
|
|
}
|
|
|
|
|
2016-06-08 13:53:24 +03:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2016-09-26 22:55:25 +03:00
|
|
|
quint64 Wallet::blockChainHeight() const
|
|
|
|
{
|
|
|
|
return m_walletImpl->blockChainHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
quint64 Wallet::daemonBlockChainHeight() const
|
|
|
|
{
|
|
|
|
// cache daemon blockchain height for some time (60 seconds by default)
|
|
|
|
|
|
|
|
if (m_daemonBlockChainHeight == 0
|
|
|
|
|| m_daemonBlockChainHeightTime.elapsed() / 1000 > m_daemonBlockChainHeightTtl) {
|
|
|
|
m_daemonBlockChainHeight = m_walletImpl->daemonBlockChainHeight();
|
|
|
|
m_daemonBlockChainHeightTime.restart();
|
|
|
|
}
|
|
|
|
return m_daemonBlockChainHeight;
|
|
|
|
}
|
|
|
|
|
2016-10-04 00:29:30 +03:00
|
|
|
quint64 Wallet::daemonBlockChainTargetHeight() const
|
|
|
|
{
|
2016-11-01 19:14:39 +02:00
|
|
|
|
|
|
|
if (m_daemonBlockChainTargetHeight == 0
|
|
|
|
|| m_daemonBlockChainTargetHeightTime.elapsed() / 1000 > m_daemonBlockChainTargetHeightTtl) {
|
|
|
|
m_daemonBlockChainTargetHeight = m_walletImpl->daemonBlockChainTargetHeight();
|
|
|
|
m_daemonBlockChainTargetHeightTime.restart();
|
|
|
|
}
|
|
|
|
|
2016-10-04 00:29:30 +03:00
|
|
|
return m_daemonBlockChainTargetHeight;
|
|
|
|
}
|
|
|
|
|
2016-06-08 13:53:24 +03:00
|
|
|
bool Wallet::refresh()
|
|
|
|
{
|
2016-06-17 16:35:07 +03:00
|
|
|
bool result = m_walletImpl->refresh();
|
2016-10-04 23:12:58 +03:00
|
|
|
m_history->refresh();
|
2016-06-17 16:35:07 +03:00
|
|
|
if (result)
|
|
|
|
emit updated();
|
|
|
|
return result;
|
2016-06-08 13:53:24 +03:00
|
|
|
}
|
|
|
|
|
2016-07-13 15:24:40 +03:00
|
|
|
void Wallet::refreshAsync()
|
|
|
|
{
|
|
|
|
m_walletImpl->refreshAsync();
|
|
|
|
}
|
|
|
|
|
2016-09-26 22:55:25 +03:00
|
|
|
void Wallet::setAutoRefreshInterval(int seconds)
|
|
|
|
{
|
|
|
|
m_walletImpl->setAutoRefreshInterval(seconds);
|
|
|
|
}
|
|
|
|
|
|
|
|
int Wallet::autoRefreshInterval() const
|
|
|
|
{
|
|
|
|
return m_walletImpl->autoRefreshInterval();
|
|
|
|
}
|
|
|
|
|
2016-06-26 18:04:45 +03:00
|
|
|
PendingTransaction *Wallet::createTransaction(const QString &dst_addr, const QString &payment_id,
|
2016-06-27 15:45:48 +03:00
|
|
|
quint64 amount, quint32 mixin_count,
|
|
|
|
PendingTransaction::Priority priority)
|
2016-06-08 13:53:24 +03:00
|
|
|
{
|
|
|
|
Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createTransaction(
|
2016-06-27 15:45:48 +03:00
|
|
|
dst_addr.toStdString(), payment_id.toStdString(), amount, mixin_count,
|
|
|
|
static_cast<Bitmonero::PendingTransaction::Priority>(priority));
|
2016-11-08 20:48:41 +02:00
|
|
|
PendingTransaction * result = new PendingTransaction(ptImpl,0);
|
2016-06-08 13:53:24 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-11-08 17:33:36 +02:00
|
|
|
void Wallet::createTransactionAsync(const QString &dst_addr, const QString &payment_id,
|
|
|
|
quint64 amount, quint32 mixin_count,
|
|
|
|
PendingTransaction::Priority priority)
|
|
|
|
{
|
|
|
|
QFuture<PendingTransaction*> future = QtConcurrent::run(this, &Wallet::createTransaction,
|
|
|
|
dst_addr, payment_id,amount, mixin_count, priority);
|
|
|
|
QFutureWatcher<PendingTransaction*> * watcher = new QFutureWatcher<PendingTransaction*>();
|
|
|
|
watcher->setFuture(future);
|
|
|
|
connect(watcher, &QFutureWatcher<PendingTransaction*>::finished,
|
2016-11-08 19:02:07 +02:00
|
|
|
this, [this, watcher,dst_addr,payment_id,mixin_count]() {
|
2016-11-08 17:33:36 +02:00
|
|
|
QFuture<PendingTransaction*> future = watcher->future();
|
|
|
|
watcher->deleteLater();
|
2016-11-08 19:02:07 +02:00
|
|
|
emit transactionCreated(future.result(),dst_addr,payment_id,mixin_count);
|
2016-11-08 17:33:36 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-11-09 15:00:43 +02:00
|
|
|
PendingTransaction *Wallet::createTransactionAll(const QString &dst_addr, const QString &payment_id,
|
|
|
|
quint32 mixin_count, PendingTransaction::Priority priority)
|
|
|
|
{
|
|
|
|
Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createTransaction(
|
|
|
|
dst_addr.toStdString(), payment_id.toStdString(), Bitmonero::optional<uint64_t>(), mixin_count,
|
|
|
|
static_cast<Bitmonero::PendingTransaction::Priority>(priority));
|
|
|
|
PendingTransaction * result = new PendingTransaction(ptImpl, this);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-11-11 23:54:17 +02:00
|
|
|
void Wallet::createTransactionAllAsync(const QString &dst_addr, const QString &payment_id,
|
|
|
|
quint32 mixin_count,
|
|
|
|
PendingTransaction::Priority priority)
|
|
|
|
{
|
|
|
|
QFuture<PendingTransaction*> future = QtConcurrent::run(this, &Wallet::createTransactionAll,
|
|
|
|
dst_addr, payment_id, mixin_count, priority);
|
|
|
|
QFutureWatcher<PendingTransaction*> * watcher = new QFutureWatcher<PendingTransaction*>();
|
|
|
|
watcher->setFuture(future);
|
|
|
|
connect(watcher, &QFutureWatcher<PendingTransaction*>::finished,
|
|
|
|
this, [this, watcher,dst_addr,payment_id,mixin_count]() {
|
|
|
|
QFuture<PendingTransaction*> future = watcher->future();
|
|
|
|
watcher->deleteLater();
|
|
|
|
emit transactionCreated(future.result(),dst_addr,payment_id,mixin_count);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-11-08 22:23:50 +02:00
|
|
|
PendingTransaction *Wallet::createSweepUnmixableTransaction()
|
|
|
|
{
|
|
|
|
Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createSweepUnmixableTransaction();
|
|
|
|
PendingTransaction * result = new PendingTransaction(ptImpl, this);
|
|
|
|
return result;
|
|
|
|
}
|
2016-11-08 17:33:36 +02:00
|
|
|
|
2016-11-11 23:54:17 +02:00
|
|
|
void Wallet::createSweepUnmixableTransactionAsync()
|
|
|
|
{
|
|
|
|
QFuture<PendingTransaction*> future = QtConcurrent::run(this, &Wallet::createSweepUnmixableTransaction);
|
|
|
|
QFutureWatcher<PendingTransaction*> * watcher = new QFutureWatcher<PendingTransaction*>();
|
|
|
|
watcher->setFuture(future);
|
|
|
|
connect(watcher, &QFutureWatcher<PendingTransaction*>::finished,
|
|
|
|
this, [this, watcher]() {
|
|
|
|
QFuture<PendingTransaction*> future = watcher->future();
|
|
|
|
watcher->deleteLater();
|
|
|
|
emit transactionCreated(future.result(),"","",0);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-06-08 13:53:24 +03:00
|
|
|
void Wallet::disposeTransaction(PendingTransaction *t)
|
|
|
|
{
|
|
|
|
m_walletImpl->disposeTransaction(t->m_pimpl);
|
|
|
|
delete t;
|
|
|
|
}
|
|
|
|
|
2016-10-07 00:47:28 +03:00
|
|
|
TransactionHistory *Wallet::history() const
|
2016-06-08 13:53:24 +03:00
|
|
|
{
|
|
|
|
return m_history;
|
|
|
|
}
|
|
|
|
|
2016-10-07 23:05:51 +03:00
|
|
|
TransactionHistorySortFilterModel *Wallet::historyModel() const
|
2016-10-02 21:40:40 +03:00
|
|
|
{
|
|
|
|
if (!m_historyModel) {
|
2016-10-07 00:47:28 +03:00
|
|
|
Wallet * w = const_cast<Wallet*>(this);
|
|
|
|
m_historyModel = new TransactionHistoryModel(w);
|
2016-10-02 21:40:40 +03:00
|
|
|
m_historyModel->setTransactionHistory(this->history());
|
2016-10-07 23:05:51 +03:00
|
|
|
m_historySortFilterModel = new TransactionHistorySortFilterModel(w);
|
|
|
|
m_historySortFilterModel->setSourceModel(m_historyModel);
|
2016-10-02 21:40:40 +03:00
|
|
|
}
|
|
|
|
|
2016-10-07 23:05:51 +03:00
|
|
|
return m_historySortFilterModel;
|
2016-10-02 21:40:40 +03:00
|
|
|
}
|
|
|
|
|
2016-02-29 16:39:39 +02:00
|
|
|
|
2016-06-26 18:04:45 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-11-06 01:19:28 +02:00
|
|
|
bool Wallet::setUserNote(const QString &txid, const QString ¬e)
|
|
|
|
{
|
|
|
|
return m_walletImpl->setUserNote(txid.toStdString(), note.toStdString());
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Wallet::getUserNote(const QString &txid) const
|
|
|
|
{
|
|
|
|
return QString::fromStdString(m_walletImpl->getUserNote(txid.toStdString()));
|
|
|
|
}
|
2016-02-29 16:39:39 +02:00
|
|
|
|
2016-11-06 20:27:08 +02:00
|
|
|
QString Wallet::getTxKey(const QString &txid) const
|
|
|
|
{
|
|
|
|
return QString::fromStdString(m_walletImpl->getTxKey(txid.toStdString()));
|
|
|
|
}
|
|
|
|
|
2016-11-08 12:06:34 +02:00
|
|
|
QString Wallet::signMessage(const QString &message, bool filename) const
|
|
|
|
{
|
|
|
|
if (filename) {
|
|
|
|
QFile file(message);
|
|
|
|
uchar *data = NULL;
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (!file.open(QIODevice::ReadOnly))
|
|
|
|
return "";
|
|
|
|
quint64 size = file.size();
|
|
|
|
if (size == 0) {
|
|
|
|
file.close();
|
|
|
|
return QString::fromStdString(m_walletImpl->signMessage(std::string()));
|
|
|
|
}
|
|
|
|
data = file.map(0, size);
|
|
|
|
if (!data) {
|
|
|
|
file.close();
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
std::string signature = m_walletImpl->signMessage(std::string((const char*)data, size));
|
|
|
|
file.unmap(data);
|
|
|
|
file.close();
|
|
|
|
return QString::fromStdString(signature);
|
|
|
|
}
|
|
|
|
catch (const std::exception &e) {
|
|
|
|
if (data)
|
|
|
|
file.unmap(data);
|
|
|
|
file.close();
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return QString::fromStdString(m_walletImpl->signMessage(message.toStdString()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Wallet::verifySignedMessage(const QString &message, const QString &address, const QString &signature, bool filename) const
|
|
|
|
{
|
|
|
|
if (filename) {
|
|
|
|
QFile file(message);
|
|
|
|
uchar *data = NULL;
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (!file.open(QIODevice::ReadOnly))
|
|
|
|
return false;
|
|
|
|
quint64 size = file.size();
|
|
|
|
if (size == 0) {
|
|
|
|
file.close();
|
|
|
|
return m_walletImpl->verifySignedMessage(std::string(), address.toStdString(), signature.toStdString());
|
|
|
|
}
|
|
|
|
data = file.map(0, size);
|
|
|
|
if (!data) {
|
|
|
|
file.close();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool ret = m_walletImpl->verifySignedMessage(std::string((const char*)data, size), address.toStdString(), signature.toStdString());
|
|
|
|
file.unmap(data);
|
|
|
|
file.close();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
catch (const std::exception &e) {
|
|
|
|
if (data)
|
|
|
|
file.unmap(data);
|
|
|
|
file.close();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return m_walletImpl->verifySignedMessage(message.toStdString(), address.toStdString(), signature.toStdString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-07 16:26:25 +03:00
|
|
|
Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent)
|
2016-09-26 22:55:25 +03:00
|
|
|
: QObject(parent)
|
|
|
|
, m_walletImpl(w)
|
|
|
|
, m_history(nullptr)
|
2016-10-02 21:40:40 +03:00
|
|
|
, m_historyModel(nullptr)
|
2016-09-26 22:55:25 +03:00
|
|
|
, m_daemonBlockChainHeight(0)
|
|
|
|
, m_daemonBlockChainHeightTtl(DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS)
|
2016-11-01 19:14:39 +02:00
|
|
|
, m_daemonBlockChainTargetHeight(0)
|
|
|
|
, m_daemonBlockChainTargetHeightTtl(DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS)
|
2016-11-26 17:31:27 +02:00
|
|
|
, m_connectionStatusTtl(WALLET_CONNECTION_STATUS_CACHE_TTL_SECONDS)
|
2016-02-29 16:39:39 +02:00
|
|
|
{
|
2016-10-04 23:12:58 +03:00
|
|
|
m_history = new TransactionHistory(m_walletImpl->history(), this);
|
2016-07-14 13:09:39 +03:00
|
|
|
m_walletImpl->setListener(new WalletListenerImpl(this));
|
2016-11-26 16:34:56 +02:00
|
|
|
m_connectionStatus = Wallet::ConnectionStatus_Disconnected;
|
2016-11-26 17:31:27 +02:00
|
|
|
// start cache timers
|
|
|
|
m_connectionStatusTime.restart();
|
|
|
|
m_daemonBlockChainHeightTime.restart();
|
|
|
|
m_daemonBlockChainTargetHeightTime.restart();
|
2016-11-26 18:01:59 +02:00
|
|
|
m_initialized = false;
|
2016-02-29 16:39:39 +02:00
|
|
|
}
|
|
|
|
|
2016-06-07 16:26:25 +03:00
|
|
|
Wallet::~Wallet()
|
2016-02-29 16:39:39 +02:00
|
|
|
{
|
2016-10-30 19:09:28 +02:00
|
|
|
qDebug("~Wallet: Closing wallet");
|
2016-11-18 23:40:58 +02:00
|
|
|
delete m_history;
|
2016-06-07 16:26:25 +03:00
|
|
|
Bitmonero::WalletManagerFactory::getWalletManager()->closeWallet(m_walletImpl);
|
2016-02-29 16:39:39 +02:00
|
|
|
}
|