From dcc16a44bee19c5e99cc967268e6a1428decf27a Mon Sep 17 00:00:00 2001 From: selsta Date: Sun, 5 Sep 2021 05:48:32 +0200 Subject: [PATCH] libwalletqt: add make_uri function --- src/libwalletqt/Wallet.cpp | 6 ++++++ src/libwalletqt/Wallet.h | 2 ++ src/libwalletqt/WalletManager.cpp | 8 ++++++++ src/libwalletqt/WalletManager.h | 1 + 4 files changed, 17 insertions(+) diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index f7cc1965..5099ad16 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -925,6 +925,12 @@ bool Wallet::parse_uri(const QString &uri, QString &address, QString &payment_id return res; } +QString Wallet::make_uri(const QString &address, const quint64 &amount, const QString &tx_description, const QString &recipient_name) const +{ + std::string error; + return QString::fromStdString(m_walletImpl->make_uri(address.toStdString(), "", amount, tx_description.toStdString(), recipient_name.toStdString(), error)); +} + bool Wallet::rescanSpent() { QMutexLocker locker(&m_asyncMutex); diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index e0157ee3..07f370e8 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -296,6 +296,8 @@ public: //! Parse URI Q_INVOKABLE bool parse_uri(const QString &uri, QString &address, QString &payment_id, uint64_t &amount, QString &tx_description, QString &recipient_name, QVector &unknown_parameters, QString &error); + //! Make URI + Q_INVOKABLE QString make_uri(const QString &address, const quint64 &amount = 0, const QString &tx_description = "", const QString &recipient_name = "") const; //! Namespace your cacheAttribute keys to avoid collisions Q_INVOKABLE bool setCacheAttribute(const QString &key, const QString &val); diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp index 338c2f0c..65d108e8 100644 --- a/src/libwalletqt/WalletManager.cpp +++ b/src/libwalletqt/WalletManager.cpp @@ -441,6 +441,14 @@ QVariantMap WalletManager::parse_uri_to_object(const QString &uri) const return result; } +QString WalletManager::make_uri(const QString &address, const quint64 &amount, const QString &tx_description, const QString &recipient_name) const +{ + QMutexLocker locker(&m_mutex); + if (m_currentWallet) + return m_currentWallet->make_uri(address, amount, tx_description, recipient_name); + return ""; +} + void WalletManager::setLogLevel(int logLevel) { Monero::WalletManagerFactory::setLogLevel(logLevel); diff --git a/src/libwalletqt/WalletManager.h b/src/libwalletqt/WalletManager.h index 2b424b73..84835a9c 100644 --- a/src/libwalletqt/WalletManager.h +++ b/src/libwalletqt/WalletManager.h @@ -179,6 +179,7 @@ public: Q_INVOKABLE QString resolveOpenAlias(const QString &address) const; Q_INVOKABLE bool parse_uri(const QString &uri, QString &address, QString &payment_id, uint64_t &amount, QString &tx_description, QString &recipient_name, QVector &unknown_parameters, QString &error) const; Q_INVOKABLE QVariantMap parse_uri_to_object(const QString &uri) const; + Q_INVOKABLE QString make_uri(const QString &address, const quint64 &amount = 0, const QString &tx_description = "", const QString &recipient_name = "") const; Q_INVOKABLE bool saveQrCode(const QString &, const QString &) const; Q_INVOKABLE void saveQrCodeToClipboard(const QString &) const; Q_INVOKABLE void checkUpdatesAsync(