mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-24 03:25:55 +00:00
88 lines
2.9 KiB
C++
88 lines
2.9 KiB
C++
#ifndef WALLETMANAGER_H
|
|
#define WALLETMANAGER_H
|
|
|
|
#include <QObject>
|
|
|
|
class Wallet;
|
|
namespace Bitmonero {
|
|
class WalletManager;
|
|
}
|
|
|
|
class WalletManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
static WalletManager * instance();
|
|
// wizard: createWallet path;
|
|
Q_INVOKABLE Wallet * createWallet(const QString &path, const QString &password,
|
|
const QString &language, bool testnet = false);
|
|
|
|
/*!
|
|
* \brief openWallet - opens wallet by given path
|
|
* \param path - wallet filename
|
|
* \param password - wallet password. Empty string in wallet isn't password protected
|
|
* \param testnet - determines if we running testnet
|
|
* \return wallet object pointer
|
|
*/
|
|
Q_INVOKABLE Wallet * openWallet(const QString &path, const QString &password, bool testnet = false);
|
|
|
|
/*!
|
|
* \brief openWalletAsync - asynchronous version of "openWallet". Returns immediately. "walletOpened" signal
|
|
* emitted when wallet opened;
|
|
*/
|
|
Q_INVOKABLE void openWalletAsync(const QString &path, const QString &password, bool testnet = false);
|
|
|
|
// wizard: recoveryWallet path; hint: internally it recorvers wallet and set password = ""
|
|
Q_INVOKABLE Wallet * recoveryWallet(const QString &path, const QString &memo,
|
|
bool testnet = false);
|
|
|
|
/*!
|
|
* \brief closeWallet - closes wallet and frees memory
|
|
* \param wallet
|
|
* \return wallet address
|
|
*/
|
|
Q_INVOKABLE QString closeWallet(Wallet * wallet);
|
|
|
|
/*!
|
|
* \brief closeWalletAsync - asynchronous version of "closeWallet"
|
|
* \param wallet - wallet pointer;
|
|
*/
|
|
Q_INVOKABLE void closeWalletAsync(Wallet * wallet);
|
|
|
|
//! checks is given filename is a wallet;
|
|
Q_INVOKABLE bool walletExists(const QString &path) const;
|
|
|
|
//! returns list with wallet's filenames, if found by given path
|
|
Q_INVOKABLE QStringList findWallets(const QString &path);
|
|
|
|
//! returns error description in human language
|
|
Q_INVOKABLE QString errorString() const;
|
|
|
|
|
|
// wizard: both "create" and "recovery" paths.
|
|
// TODO: probably move it to "Wallet" interface
|
|
Q_INVOKABLE bool moveWallet(const QString &src, const QString &dst);
|
|
//! returns libwallet language name for given locale
|
|
Q_INVOKABLE QString walletLanguage(const QString &locale);
|
|
|
|
|
|
//! since we can't call static method from QML, move it to this class
|
|
Q_INVOKABLE QString displayAmount(quint64 amount);
|
|
Q_INVOKABLE quint64 amountFromString(const QString &amount);
|
|
Q_INVOKABLE quint64 amountFromDouble(double amount);
|
|
|
|
signals:
|
|
|
|
void walletOpened(Wallet * wallet);
|
|
void walletClosed(const QString &walletAddress);
|
|
|
|
public slots:
|
|
private:
|
|
|
|
explicit WalletManager(QObject *parent = 0);
|
|
static WalletManager * m_instance;
|
|
Bitmonero::WalletManager * m_pimpl;
|
|
|
|
};
|
|
|
|
#endif // WALLETMANAGER_H
|