1
mirror of https://github.com/monero-project/monero-gui synced 2024-12-25 01:53:43 +01:00
monero-gui/src/libwalletqt/Wallet.h

121 lines
3.3 KiB
C
Raw Normal View History

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
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
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)
Q_PROPERTY(QString paymentId READ paymentId WRITE setPaymentId)
2016-06-08 12:53:24 +02:00
2016-02-23 16:59:26 +01:00
public:
enum Status {
2016-06-08 12:53:24 +02:00
Status_Ok = Bitmonero::Wallet::Status_Ok,
Status_Error = Bitmonero::Wallet::Status_Error
};
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-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);
//! returns last operation's status
2016-06-08 12:53:24 +02:00
Status status() const;
//! returns last operation's error message
2016-06-08 12:53:24 +02:00
QString errorString() const;
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);
//! returns wallet's public address
2016-06-08 12:53:24 +02:00
QString address() const;
//! 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, const QString &payment_id,
2016-06-27 14:45:48 +02:00
quint64 amount, quint32 mixin_count,
PendingTransaction::Priority priority = PendingTransaction::Priority_Low);
2016-06-08 12:53:24 +02:00
//! deletes transaction and frees memory
Q_INVOKABLE void disposeTransaction(PendingTransaction * t);
//! returns transaction history
TransactionHistory * history();
//! 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-02-29 15:39:39 +01:00
private:
Wallet(Bitmonero::Wallet *w, QObject * parent = 0);
~Wallet();
2016-02-29 15:39:39 +01:00
private:
friend class WalletManager;
//! libwallet's
Bitmonero::Wallet * m_walletImpl;
2016-06-08 12:53:24 +02:00
// history lifetime managed by wallet;
TransactionHistory * m_history;
QString m_paymentId;
2016-02-23 16:59:26 +01:00
};
#endif // WALLET_H