2016-02-23 16:59:26 +01:00
|
|
|
#ifndef WALLET_H
|
|
|
|
#define WALLET_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
2016-06-08 12:53:24 +02:00
|
|
|
#include "wallet/wallet2_api.h" // we need to access Status enum here;
|
|
|
|
|
2016-06-07 15:26:25 +02:00
|
|
|
namespace Bitmonero {
|
|
|
|
class Wallet; // forward declaration
|
|
|
|
}
|
2016-06-08 12:53:24 +02:00
|
|
|
|
|
|
|
class PendingTransaction;
|
|
|
|
class TransactionHistory;
|
|
|
|
|
2016-02-23 16:59:26 +01:00
|
|
|
class Wallet : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2016-02-24 11:25:20 +01:00
|
|
|
Q_PROPERTY(QString seed READ getSeed)
|
2016-06-08 12:53:24 +02:00
|
|
|
Q_PROPERTY(QString seedLanguage READ getSeedLanguage)
|
|
|
|
Q_PROPERTY(Status status READ status)
|
|
|
|
Q_PROPERTY(QString errorString READ errorString)
|
|
|
|
Q_PROPERTY(QString address READ address)
|
|
|
|
Q_PROPERTY(quint64 balance READ balance)
|
|
|
|
Q_PROPERTY(quint64 unlockedBalance READ unlockedBalance)
|
|
|
|
Q_PROPERTY(TransactionHistory * history READ history)
|
|
|
|
|
2016-02-23 16:59:26 +01:00
|
|
|
public:
|
2016-06-07 15:26:25 +02:00
|
|
|
enum Status {
|
2016-06-08 12:53:24 +02:00
|
|
|
Status_Ok = Bitmonero::Wallet::Status_Ok,
|
|
|
|
Status_Error = Bitmonero::Wallet::Status_Error
|
2016-06-07 15:26:25 +02:00
|
|
|
};
|
2016-02-24 11:25:20 +01:00
|
|
|
|
2016-06-08 12:53:24 +02:00
|
|
|
Q_ENUM(Status)
|
|
|
|
|
2016-02-29 15:39:39 +01:00
|
|
|
//! returns mnemonic seed
|
2016-06-08 12:53:24 +02:00
|
|
|
QString getSeed() const;
|
2016-02-24 11:25:20 +01:00
|
|
|
|
2016-02-29 15:39:39 +01:00
|
|
|
//! returns seed language
|
2016-06-08 12:53:24 +02:00
|
|
|
QString getSeedLanguage() const;
|
|
|
|
|
|
|
|
//! set seed language
|
|
|
|
Q_INVOKABLE void setSeedLanguage(const QString &lang);
|
2016-02-24 11:25:20 +01:00
|
|
|
|
2016-06-07 15:26:25 +02:00
|
|
|
//! returns last operation's status
|
2016-06-08 12:53:24 +02:00
|
|
|
Status status() const;
|
2016-06-07 15:26:25 +02:00
|
|
|
|
|
|
|
//! returns last operation's error message
|
2016-06-08 12:53:24 +02:00
|
|
|
QString errorString() const;
|
2016-02-24 11:25:20 +01:00
|
|
|
|
2016-02-29 15:39:39 +01:00
|
|
|
//! changes the password using existing parameters (path, seed, seed lang)
|
|
|
|
Q_INVOKABLE bool setPassword(const QString &password);
|
|
|
|
|
2016-06-07 15:26:25 +02:00
|
|
|
//! returns wallet's public address
|
2016-06-08 12:53:24 +02:00
|
|
|
QString address() const;
|
2016-06-07 15:26:25 +02:00
|
|
|
|
|
|
|
//! saves wallet to the file by given path
|
|
|
|
Q_INVOKABLE bool store(const QString &path);
|
2016-02-29 15:39:39 +01:00
|
|
|
|
2016-06-08 12:53:24 +02:00
|
|
|
//! initializes wallet
|
|
|
|
Q_INVOKABLE bool init(const QString &daemonAddress, quint64 upperTransactionLimit);
|
|
|
|
|
|
|
|
//! connects to daemon
|
|
|
|
Q_INVOKABLE bool connectToDaemon();
|
|
|
|
|
|
|
|
//! indicates id daemon is trusted
|
|
|
|
Q_INVOKABLE void setTrustedDaemon(bool arg);
|
|
|
|
|
|
|
|
//! returns balance
|
|
|
|
quint64 balance() const;
|
|
|
|
|
|
|
|
//! returns unlocked balance
|
|
|
|
quint64 unlockedBalance() const;
|
|
|
|
|
|
|
|
//! refreshes the wallet
|
|
|
|
Q_INVOKABLE bool refresh();
|
|
|
|
|
|
|
|
//! creates transaction
|
|
|
|
Q_INVOKABLE PendingTransaction * createTransaction(const QString &dst_addr,
|
|
|
|
quint64 amount);
|
|
|
|
|
|
|
|
//! deletes transaction and frees memory
|
|
|
|
Q_INVOKABLE void disposeTransaction(PendingTransaction * t);
|
|
|
|
|
|
|
|
//! returns transaction history
|
|
|
|
TransactionHistory * history();
|
2016-02-24 11:25:20 +01:00
|
|
|
|
2016-06-08 12:53:24 +02:00
|
|
|
// TODO: setListenter() when it implemented in API
|
2016-02-29 15:39:39 +01:00
|
|
|
|
|
|
|
private:
|
2016-06-07 15:26:25 +02:00
|
|
|
Wallet(Bitmonero::Wallet *w, QObject * parent = 0);
|
|
|
|
~Wallet();
|
2016-02-29 15:39:39 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class WalletManager;
|
2016-06-07 15:26:25 +02:00
|
|
|
//! libwallet's
|
|
|
|
Bitmonero::Wallet * m_walletImpl;
|
2016-06-08 12:53:24 +02:00
|
|
|
// history lifetime managed by wallet;
|
|
|
|
TransactionHistory * m_history;
|
2016-02-23 16:59:26 +01:00
|
|
|
};
|
|
|
|
|
2016-02-24 11:25:20 +01:00
|
|
|
#endif // WALLET_H
|