parent
da1b74a707
commit
5c10be3251
@ -0,0 +1,37 @@
|
||||
#include "PendingTransaction.h"
|
||||
|
||||
PendingTransaction::Status PendingTransaction::status() const
|
||||
{
|
||||
return static_cast<Status>(m_pimpl->status());
|
||||
}
|
||||
|
||||
QString PendingTransaction::errorString() const
|
||||
{
|
||||
return QString::fromStdString(m_pimpl->errorString());
|
||||
}
|
||||
|
||||
bool PendingTransaction::commit()
|
||||
{
|
||||
return m_pimpl->commit();
|
||||
}
|
||||
|
||||
quint64 PendingTransaction::amount() const
|
||||
{
|
||||
return m_pimpl->amount();
|
||||
}
|
||||
|
||||
quint64 PendingTransaction::dust() const
|
||||
{
|
||||
return m_pimpl->dust();
|
||||
}
|
||||
|
||||
quint64 PendingTransaction::fee() const
|
||||
{
|
||||
return m_pimpl->fee();
|
||||
}
|
||||
|
||||
PendingTransaction::PendingTransaction(Bitmonero::PendingTransaction *pt, QObject *parent)
|
||||
: QObject(parent), m_pimpl(pt)
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
#ifndef PENDINGTRANSACTION_H
|
||||
#define PENDINGTRANSACTION_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <wallet/wallet2_api.h>
|
||||
|
||||
//namespace Bitmonero {
|
||||
//class PendingTransaction;
|
||||
//}
|
||||
|
||||
class PendingTransaction : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Status status READ status)
|
||||
Q_PROPERTY(QString errorString READ errorString)
|
||||
Q_PROPERTY(quint64 amount READ amount)
|
||||
Q_PROPERTY(quint64 dust READ dust)
|
||||
Q_PROPERTY(quint64 fee READ fee)
|
||||
|
||||
public:
|
||||
enum Status {
|
||||
Status_Ok = Bitmonero::PendingTransaction::Status_Ok,
|
||||
Status_Error = Bitmonero::PendingTransaction::Status_Error
|
||||
};
|
||||
|
||||
Status status() const;
|
||||
QString errorString() const;
|
||||
Q_INVOKABLE bool commit();
|
||||
quint64 amount() const;
|
||||
quint64 dust() const;
|
||||
quint64 fee() const;
|
||||
private:
|
||||
explicit PendingTransaction(Bitmonero::PendingTransaction * pt, QObject *parent = 0);
|
||||
|
||||
private:
|
||||
friend class Wallet;
|
||||
Bitmonero::PendingTransaction * m_pimpl;
|
||||
};
|
||||
|
||||
#endif // PENDINGTRANSACTION_H
|
@ -0,0 +1,50 @@
|
||||
#include "TransactionHistory.h"
|
||||
#include "TransactionInfo.h"
|
||||
#include <wallet/wallet2_api.h>
|
||||
|
||||
|
||||
int TransactionHistory::count() const
|
||||
{
|
||||
return m_pimpl->count();
|
||||
}
|
||||
|
||||
TransactionInfo *TransactionHistory::transaction(int index)
|
||||
{
|
||||
// box up Bitmonero::TransactionInfo
|
||||
Bitmonero::TransactionInfo * impl = m_pimpl->transaction(index);
|
||||
TransactionInfo * result = new TransactionInfo(impl, this);
|
||||
return result;
|
||||
}
|
||||
|
||||
TransactionInfo *TransactionHistory::transaction(const QString &id)
|
||||
{
|
||||
// box up Bitmonero::TransactionInfo
|
||||
Bitmonero::TransactionInfo * impl = m_pimpl->transaction(id.toStdString());
|
||||
TransactionInfo * result = new TransactionInfo(impl, this);
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<TransactionInfo *> TransactionHistory::getAll() const
|
||||
{
|
||||
qDeleteAll(m_tinfo);
|
||||
m_tinfo.clear();
|
||||
TransactionHistory * parent = const_cast<TransactionHistory*>(this);
|
||||
for (const auto i : m_pimpl->getAll()) {
|
||||
TransactionInfo * ti = new TransactionInfo(i, parent);
|
||||
m_tinfo.append(ti);
|
||||
}
|
||||
return m_tinfo;
|
||||
}
|
||||
|
||||
void TransactionHistory::refresh()
|
||||
{
|
||||
// XXX this invalidates previously saved history that might be used by clients
|
||||
m_pimpl->refresh();
|
||||
emit invalidated();
|
||||
}
|
||||
|
||||
TransactionHistory::TransactionHistory(Bitmonero::TransactionHistory *pimpl, QObject *parent)
|
||||
: QObject(parent), m_pimpl(pimpl)
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
#ifndef TRANSACTIONHISTORY_H
|
||||
#define TRANSACTIONHISTORY_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
|
||||
namespace Bitmonero {
|
||||
class TransactionHistory;
|
||||
}
|
||||
|
||||
class TransactionInfo;
|
||||
|
||||
class TransactionHistory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int count READ count)
|
||||
|
||||
public:
|
||||
int count() const;
|
||||
Q_INVOKABLE TransactionInfo *transaction(int index);
|
||||
Q_INVOKABLE TransactionInfo * transaction(const QString &id);
|
||||
Q_INVOKABLE QList<TransactionInfo*> getAll() const;
|
||||
Q_INVOKABLE void refresh();
|
||||
|
||||
signals:
|
||||
void invalidated();
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
private:
|
||||
explicit TransactionHistory(Bitmonero::TransactionHistory * pimpl, QObject *parent = 0);
|
||||
|
||||
private:
|
||||
friend class Wallet;
|
||||
|
||||
Bitmonero::TransactionHistory * m_pimpl;
|
||||
mutable QList<TransactionInfo*> m_tinfo;
|
||||
|
||||
};
|
||||
|
||||
#endif // TRANSACTIONHISTORY_H
|
@ -0,0 +1,55 @@
|
||||
#include "TransactionInfo.h"
|
||||
#include <QDateTime>
|
||||
|
||||
TransactionInfo::Direction TransactionInfo::direction() const
|
||||
{
|
||||
return static_cast<Direction>(m_pimpl->direction());
|
||||
}
|
||||
|
||||
bool TransactionInfo::isPending() const
|
||||
{
|
||||
return m_pimpl->isPending();
|
||||
}
|
||||
|
||||
bool TransactionInfo::isFailed() const
|
||||
{
|
||||
return m_pimpl->isFailed();
|
||||
}
|
||||
|
||||
quint64 TransactionInfo::amount() const
|
||||
{
|
||||
return m_pimpl->amount();
|
||||
}
|
||||
|
||||
quint64 TransactionInfo::fee() const
|
||||
{
|
||||
return m_pimpl->fee();
|
||||
|
||||
}
|
||||
|
||||
quint64 TransactionInfo::blockHeight() const
|
||||
{
|
||||
return m_pimpl->blockHeight();
|
||||
}
|
||||
|
||||
QString TransactionInfo::hash() const
|
||||
{
|
||||
return QString::fromStdString(m_pimpl->hash());
|
||||
}
|
||||
|
||||
QString TransactionInfo::timestamp()
|
||||
{
|
||||
QString result = QDateTime::fromTime_t(m_pimpl->timestamp()).toString(Qt::ISODate);
|
||||
return result;
|
||||
}
|
||||
|
||||
QString TransactionInfo::paymentId()
|
||||
{
|
||||
return QString::fromStdString(m_pimpl->paymentId());
|
||||
}
|
||||
|
||||
TransactionInfo::TransactionInfo(Bitmonero::TransactionInfo *pimpl, QObject *parent)
|
||||
: QObject(parent), m_pimpl(pimpl)
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
#ifndef TRANSACTIONINFO_H
|
||||
#define TRANSACTIONINFO_H
|
||||
|
||||
#include <QObject>
|
||||
#include <wallet/wallet2_api.h>
|
||||
|
||||
class TransactionInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Direction direction READ direction)
|
||||
Q_PROPERTY(bool isPending READ isPending)
|
||||
Q_PROPERTY(bool isFailed READ isFailed)
|
||||
Q_PROPERTY(quint64 amount READ amount)
|
||||
Q_PROPERTY(quint64 fee READ fee)
|
||||
Q_PROPERTY(quint64 blockHeight READ blockHeight)
|
||||
Q_PROPERTY(QString hash READ hash)
|
||||
Q_PROPERTY(QString timestamp READ timestamp)
|
||||
Q_PROPERTY(QString paymentId READ paymentId)
|
||||
|
||||
public:
|
||||
enum Direction {
|
||||
Direction_In = Bitmonero::TransactionInfo::Direction_In,
|
||||
Direction_Out = Bitmonero::TransactionInfo::Direction_Out
|
||||
};
|
||||
|
||||
// TODO: implement as separate class;
|
||||
|
||||
// struct Transfer {
|
||||
// Transfer(uint64_t _amount, const std::string &address);
|
||||
// const uint64_t amount;
|
||||
// const std::string address;
|
||||
// };
|
||||
Direction direction() const;
|
||||
bool isPending() const;
|
||||
bool isFailed() const;
|
||||
quint64 amount() const;
|
||||
quint64 fee() const;
|
||||
quint64 blockHeight() const;
|
||||
//! transaction_id
|
||||
QString hash() const;
|
||||
QString timestamp();
|
||||
QString paymentId();
|
||||
|
||||
// TODO: implement it
|
||||
//! only applicable for output transactions
|
||||
// virtual const std::vector<Transfer> & transfers() const = 0;
|
||||
private:
|
||||
explicit TransactionInfo(Bitmonero::TransactionInfo * pimpl, QObject *parent = 0);
|
||||
private:
|
||||
friend class TransactionHistory;
|
||||
Bitmonero::TransactionInfo * m_pimpl;
|
||||
};
|
||||
|
||||
#endif // TRANSACTIONINFO_H
|
Reference in new issue