2016-02-23 16:59:26 +01:00
|
|
|
#ifndef WALLET_H
|
|
|
|
#define WALLET_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
2016-06-27 14:45:48 +02:00
|
|
|
#include "wallet/wallet2_api.h" // we need to have an access to the Bitmonero::Wallet::Status enum here;
|
|
|
|
#include "PendingTransaction.h" // we need to have an access to the PendingTransaction::Priority enum here;
|
|
|
|
|
2016-06-08 12:53:24 +02:00
|
|
|
|
2016-06-07 15:26:25 +02:00
|
|
|
namespace Bitmonero {
|
|
|
|
class Wallet; // forward declaration
|
|
|
|
}
|
2016-06-08 12:53:24 +02:00
|
|
|
|
2016-06-27 14:45:48 +02:00
|
|
|
|
2016-06-08 12:53:24 +02:00
|
|
|
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)
|
2016-07-14 12:09:39 +02:00
|
|
|
Q_PROPERTY(bool connected READ connected)
|
2016-06-08 12:53:24 +02:00
|
|
|
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-06-26 17:04:45 +02:00
|
|
|
Q_PROPERTY(QString paymentId READ paymentId WRITE setPaymentId)
|
2016-06-08 12:53:24 +02:00
|
|
|
|
2016-07-14 12:09:39 +02:00
|
|
|
|
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
|
|
|
|
2016-07-14 12:09:39 +02:00
|
|
|
//! returns of wallet connected
|
|
|
|
bool connected() 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);
|
|
|
|
|
2016-07-14 12:09:39 +02:00
|
|
|
//! initializes wallet asynchronously
|
|
|
|
Q_INVOKABLE void initAsync(const QString &daemonAddress, quint64 upperTransactionLimit);
|
|
|
|
|
2016-06-08 12:53:24 +02:00
|
|
|
//! 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();
|
|
|
|
|
2016-07-13 14:24:40 +02:00
|
|
|
|
|
|
|
//! refreshes the wallet asynchronously
|
|
|
|
Q_INVOKABLE void refreshAsync();
|
|
|
|
|
2016-06-08 12:53:24 +02:00
|
|
|
//! creates transaction
|
2016-06-26 17:04:45 +02:00
|
|
|
Q_INVOKABLE PendingTransaction * createTransaction(const QString &dst_addr, const QString &payment_id,
|
2016-06-27 14:45:48 +02:00
|
|
|
quint64 amount, quint32 mixin_count,
|
2016-06-28 21:37:14 +02:00
|
|
|
PendingTransaction::Priority priority);
|
2016-06-08 12:53:24 +02:00
|
|
|
//! 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-26 17:04:45 +02:00
|
|
|
//! generate payment id
|
|
|
|
Q_INVOKABLE QString generatePaymentId() const;
|
|
|
|
|
|
|
|
//! integrated address
|
|
|
|
Q_INVOKABLE QString integratedAddress(const QString &paymentId) const;
|
|
|
|
|
|
|
|
|
|
|
|
//! saved payment id
|
|
|
|
QString paymentId() const;
|
|
|
|
|
|
|
|
void setPaymentId(const QString &paymentId);
|
|
|
|
|
2016-06-08 12:53:24 +02:00
|
|
|
// TODO: setListenter() when it implemented in API
|
2016-06-17 15:35:07 +02:00
|
|
|
signals:
|
|
|
|
void updated();
|
|
|
|
|
2016-07-13 14:24:40 +02:00
|
|
|
// emitted when refresh process finished (could take a long time)
|
|
|
|
// signalling only after we
|
|
|
|
void refreshed();
|
|
|
|
|
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-07-13 14:24:40 +02:00
|
|
|
friend class WalletListenerImpl;
|
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-06-26 17:04:45 +02:00
|
|
|
QString m_paymentId;
|
2016-07-14 12:09:39 +02:00
|
|
|
|
2016-02-23 16:59:26 +01:00
|
|
|
};
|
|
|
|
|
2016-02-24 11:25:20 +01:00
|
|
|
#endif // WALLET_H
|