make initial block download reporting somewhat better by tracking version responses
[novacoin.git] / src / qt / walletmodel.h
1 #ifndef WALLETMODEL_H
2 #define WALLETMODEL_H
3
4 #include <QObject>
5
6 class OptionsModel;
7 class AddressTableModel;
8 class TransactionTableModel;
9 class CWallet;
10
11 struct SendCoinsRecipient
12 {
13     QString address;
14     QString label;
15     qint64 amount;
16 };
17
18 // Interface to a Bitcoin wallet
19 class WalletModel : public QObject
20 {
21     Q_OBJECT
22 public:
23     explicit WalletModel(CWallet *wallet, QObject *parent = 0);
24
25     enum StatusCode
26     {
27         OK,
28         InvalidAmount,
29         InvalidAddress,
30         AmountExceedsBalance,
31         AmountWithFeeExceedsBalance,
32         DuplicateAddress,
33         TransactionCreationFailed,
34         TransactionCommitFailed,
35         Aborted,
36         MiscError
37     };
38
39     OptionsModel *getOptionsModel();
40     AddressTableModel *getAddressTableModel();
41     TransactionTableModel *getTransactionTableModel();
42
43     qint64 getBalance() const;
44     qint64 getUnconfirmedBalance() const;
45     int getNumTransactions() const;
46
47     // Check address for validity
48     bool validateAddress(const QString &address);
49
50     // Return status record for SendCoins
51     // fee is used in case status is "AmountWithFeeExceedsBalance"
52     // hex is filled with the transaction hash if status is "OK"
53     struct SendCoinsReturn
54     {
55         SendCoinsReturn(StatusCode status,
56                          qint64 fee=0,
57                          QString hex=QString()):
58             status(status), fee(fee), hex(hex) {}
59         StatusCode status;
60         qint64 fee;
61         QString hex;
62     };
63
64     // Send coins to list of recipients
65     SendCoinsReturn sendCoins(const QList<SendCoinsRecipient> &recipients);
66 private:
67     CWallet *wallet;
68
69     // Wallet has an options model for wallet-specific options
70     // (transaction fee, for example)
71     OptionsModel *optionsModel;
72
73     AddressTableModel *addressTableModel;
74     TransactionTableModel *transactionTableModel;
75
76     qint64 cachedBalance;
77     qint64 cachedUnconfirmedBalance;
78     qint64 cachedNumTransactions;
79
80 signals:
81     void balanceChanged(qint64 balance, qint64 unconfirmedBalance);
82     void numTransactionsChanged(int count);
83
84     // Asynchronous error notification
85     void error(const QString &title, const QString &message);
86
87 public slots:
88
89 private slots:
90     void update();
91 };
92
93
94 #endif // WALLETMODEL_H