return result;
}
-QString WalletManager::errorString() const
-{
- return tr("Unknown error");
-}
-
quint64 WalletManager::maximumAllowedAmount() const
{
return Monero::Wallet::maximumAllowedAmount();
}
-QString WalletManager::maximumAllowedAmountAsString() const
-{
- return WalletManager::displayAmount(WalletManager::maximumAllowedAmount());
-}
-
QString WalletManager::displayAmount(quint64 amount, bool trailing_zeroes, int decimals)
{
auto amountStr = QString::fromStdString(Monero::Wallet::displayAmount(amount));
return QString::fromStdString(Monero::Wallet::paymentIdFromAddress(address.toStdString(), static_cast<Monero::NetworkType>(nettype)));
}
-void WalletManager::setDaemonAddressAsync(const QString &address)
-{
- m_scheduler.run([this, address] {
- m_pimpl->setDaemonAddress(address.toStdString());
- });
-}
-
-bool WalletManager::connected() const
-{
- return m_pimpl->connected();
-}
-
-quint64 WalletManager::networkDifficulty() const
-{
- return m_pimpl->networkDifficulty();
-}
-
-quint64 WalletManager::blockchainHeight() const
-{
- return m_pimpl->blockchainHeight();
-}
-
-quint64 WalletManager::blockchainTargetHeight() const
-{
- return m_pimpl->blockchainTargetHeight();
-}
-
-bool WalletManager::localDaemonSynced() const
-{
- return blockchainHeight() > 1 && blockchainHeight() >= blockchainTargetHeight();
-}
-
bool WalletManager::isDaemonLocal(const QString &daemon_address) const
{
return daemon_address.isEmpty() ? false : Monero::Utils::isAddressLocal(daemon_address.toStdString());
Monero::WalletManagerFactory::setLogCategories(categories.toStdString());
}
-QString WalletManager::urlToLocalPath(const QUrl &url) const
-{
- return QDir::toNativeSeparators(url.toLocalFile());
-}
-
-QUrl WalletManager::localPathToUrl(const QString &path) const
-{
- return QUrl::fromLocalFile(path);
-}
-
bool WalletManager::clearWalletCache(const QString &wallet_path)
{
QString fileName = wallet_path;
m_passphraseReceiver->onPassphraseEntered(passphrase, enter_on_device, entry_abort);
}
}
-
-QString WalletManager::proxyAddress() const
-{
- QMutexLocker locker(&m_proxyMutex);
- return m_proxyAddress;
-}
-
-void WalletManager::setProxyAddress(QString address)
-{
- m_scheduler.run([this, address] {
- {
- QMutexLocker locker(&m_proxyMutex);
-
- if (!m_pimpl->setProxy(address.toStdString()))
- {
- qCritical() << "Failed to set proxy address" << address;
- }
-
- m_proxyAddress = std::move(address);
- }
- emit proxyAddressChanged();
- });
-}
\ No newline at end of file
class Wallet;
namespace Monero {
-struct WalletManager;
+ struct WalletManager;
}
class WalletManager : public QObject, public PassprasePrompter
{
Q_OBJECT
- Q_PROPERTY(bool connected READ connected)
public:
enum LogLevel {
static WalletManager * instance();
// wizard: createWallet path;
- Q_INVOKABLE Wallet * createWallet(const QString &path, const QString &password,
+ Wallet * createWallet(const QString &path, const QString &password,
const QString &language, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1);
/*!
* \param nettype - type of network the wallet is running on
* \return wallet object pointer
*/
- Q_INVOKABLE Wallet * openWallet(const QString &path, const QString &password, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1);
+ Wallet * openWallet(const QString &path, const QString &password, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1);
/*!
* \brief openWalletAsync - asynchronous version of "openWallet". Returns immediately. "walletOpened" signal
* emitted when wallet opened;
*/
- Q_INVOKABLE void openWalletAsync(const QString &path, const QString &password, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1);
+ void openWalletAsync(const QString &path, const QString &password, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1);
// wizard: recoveryWallet path; hint: internally it recorvers wallet and set password = ""
- Q_INVOKABLE Wallet * recoveryWallet(const QString &path, const QString &password, const QString &seed, const QString &seed_offset,
+ Wallet * recoveryWallet(const QString &path, const QString &password, const QString &seed, const QString &seed_offset,
NetworkType::Type nettype = NetworkType::MAINNET, quint64 restoreHeight = 0, quint64 kdfRounds = 1);
- Q_INVOKABLE Wallet * createWalletFromKeys(const QString &path,
+ Wallet * createWalletFromKeys(const QString &path,
const QString &password,
const QString &language,
NetworkType::Type nettype,
quint64 restoreHeight = 0,
quint64 kdfRounds = 1);
- Q_INVOKABLE Wallet * createDeterministicWalletFromSpendKey(const QString &path,
+ Wallet * createDeterministicWalletFromSpendKey(const QString &path,
const QString &password,
const QString &language,
NetworkType::Type nettype,
quint64 kdfRounds,
const QString &offset_passphrase = "");
- Q_INVOKABLE Wallet * createWalletFromDevice(const QString &path,
+ Wallet * createWalletFromDevice(const QString &path,
const QString &password,
NetworkType::Type nettype,
const QString &deviceName,
quint64 restoreHeight = 0,
const QString &subaddressLookahead = "");
- Q_INVOKABLE void createWalletFromDeviceAsync(const QString &path,
+ void createWalletFromDeviceAsync(const QString &path,
const QString &password,
NetworkType::Type nettype,
const QString &deviceName,
//! checks is given filename is a wallet;
- Q_INVOKABLE bool walletExists(const QString &path) const;
+ bool walletExists(const QString &path) const;
//! verify wallet password
- Q_INVOKABLE bool verifyWalletPassword(const QString &keys_file_name, const QString &password, bool no_spend_key, uint64_t kdf_rounds = 1) const;
+ bool verifyWalletPassword(const QString &keys_file_name, const QString &password, bool no_spend_key, uint64_t kdf_rounds = 1) 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;
+ QStringList findWallets(const QString &path);
//! since we can't call static method from QML, move it to this class
- Q_INVOKABLE static QString displayAmount(quint64 amount, bool trailing_zeroes = true, int decimals = 12);
- Q_INVOKABLE static quint64 amountFromString(const QString &amount);
- Q_INVOKABLE static quint64 amountFromDouble(double amount);
- Q_INVOKABLE quint64 maximumAllowedAmount() const;
-
- // QML JS engine doesn't support unsigned integers
- Q_INVOKABLE QString maximumAllowedAmountAsString() const;
-
- Q_INVOKABLE bool paymentIdValid(const QString &payment_id) const;
- Q_INVOKABLE static bool addressValid(const QString &address, NetworkType::Type nettype);
- Q_INVOKABLE static bool keyValid(const QString &key, const QString &address, bool isViewKey, NetworkType::Type nettype);
+ static QString displayAmount(quint64 amount, bool trailing_zeroes = true, int decimals = 12);
+ static quint64 amountFromString(const QString &amount);
+ static quint64 amountFromDouble(double amount);
+ quint64 maximumAllowedAmount() const;
- Q_INVOKABLE QString paymentIdFromAddress(const QString &address, NetworkType::Type nettype) const;
+ bool paymentIdValid(const QString &payment_id) const;
+ static bool addressValid(const QString &address, NetworkType::Type nettype);
+ static bool keyValid(const QString &key, const QString &address, bool isViewKey, NetworkType::Type nettype);
- Q_INVOKABLE void setDaemonAddressAsync(const QString &address);
- Q_INVOKABLE bool connected() const;
- Q_INVOKABLE quint64 networkDifficulty() const;
- Q_INVOKABLE quint64 blockchainHeight() const;
- Q_INVOKABLE quint64 blockchainTargetHeight() const;
- Q_INVOKABLE bool localDaemonSynced() const;
- Q_INVOKABLE bool isDaemonLocal(const QString &daemon_address) const;
+ QString paymentIdFromAddress(const QString &address, NetworkType::Type nettype) const;
- // QML missing such functionality, implementing these helpers here
- Q_INVOKABLE QString urlToLocalPath(const QUrl &url) const;
- Q_INVOKABLE QUrl localPathToUrl(const QString &path) const;
+ bool isDaemonLocal(const QString &daemon_address) const;
- Q_INVOKABLE void setLogLevel(int logLevel);
- Q_INVOKABLE void setLogCategories(const QString &categories);
-
- Q_INVOKABLE quint64 add(quint64 x, quint64 y) const { return x + y; }
- Q_INVOKABLE quint64 sub(quint64 x, quint64 y) const { return x - y; }
- Q_INVOKABLE qint64 addi(qint64 x, qint64 y) const { return x + y; }
- Q_INVOKABLE qint64 subi(qint64 x, qint64 y) const { return x - y; }
+ void setLogLevel(int logLevel);
+ void setLogCategories(const QString &categories);
QString resolveOpenAlias(const QString &address, bool &dnssecValid) const;
void resolveOpenAliasAsync(const QString &address);
// clear/rename wallet cache
- Q_INVOKABLE static bool clearWalletCache(const QString &fileName);
+ static bool clearWalletCache(const QString &fileName);
- Q_INVOKABLE void onPassphraseEntered(const QString &passphrase, bool enter_on_device, bool entry_abort=false);
+ void onPassphraseEntered(const QString &passphrase, bool enter_on_device, bool entry_abort=false);
virtual void onWalletPassphraseNeeded(bool on_device) override;
- QString proxyAddress() const;
- void setProxyAddress(QString address);
-
signals:
void walletOpened(Wallet * wallet);
void walletCreated(Wallet * wallet);
void deviceButtonRequest(quint64 buttonCode);
void deviceButtonPressed();
void deviceError(const QString &message);
- void miningStatus(bool isMining) const;
- void proxyAddressChanged() const;
void openAliasResolved(const QString &alias, const QString &address, bool dnssecValid);
-public slots:
private:
friend class WalletPassphraseListenerImpl;
mutable QMutex m_mutex;
PassphraseReceiver *m_passphraseReceiver;
QMutex m_mutex_passphraseReceiver;
- QString m_proxyAddress;
- mutable QMutex m_proxyMutex;
FutureScheduler m_scheduler;
};