aboutsummaryrefslogtreecommitdiff
path: root/src/libwalletqt/TransactionInfo.h
blob: 7e9396a1c1104b4d4c7681df69e125f48d9ead79 (plain)
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
#ifndef TRANSACTIONINFO_H
#define TRANSACTIONINFO_H

#include <wallet/wallet2_api.h>
#include <QObject>
#include <QDateTime>

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(double amount READ amount)
    Q_PROPERTY(quint64 atomicAmount READ atomicAmount)
    Q_PROPERTY(QString displayAmount READ displayAmount)
    Q_PROPERTY(QString fee READ fee)
    Q_PROPERTY(quint64 blockHeight READ blockHeight)
    Q_PROPERTY(QString hash READ hash)
    Q_PROPERTY(QDateTime timestamp READ timestamp)
    Q_PROPERTY(QString date READ date)
    Q_PROPERTY(QString time READ time)
    Q_PROPERTY(QString paymentId READ paymentId)

public:
    enum Direction {
        Direction_In  =  Bitmonero::TransactionInfo::Direction_In,
        Direction_Out =  Bitmonero::TransactionInfo::Direction_Out,
        Direction_Both // invalid direction value, used for filtering
    };

    Q_ENUM(Direction)

//   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;
    double amount() const;
    quint64 atomicAmount() const;
    QString displayAmount() const;
    QString fee() const;
    quint64 blockHeight() const;
    //! transaction_id
    QString hash() const;
    QDateTime timestamp() const;
    QString date() const;
    QString time() const;
    QString paymentId() const;


    // 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;
};

// in order to wrap it to QVariant
Q_DECLARE_METATYPE(TransactionInfo*)


#endif // TRANSACTIONINFO_H