Add parse_uri to libwalletqt

This commit is contained in:
MoroccanMalinois 2017-01-11 03:16:21 +00:00
parent 593839a374
commit 6034eaffc8
4 changed files with 26 additions and 0 deletions

View file

@ -450,6 +450,23 @@ bool Wallet::verifySignedMessage(const QString &message, const QString &address,
return m_walletImpl->verifySignedMessage(message.toStdString(), address.toStdString(), signature.toStdString());
}
}
bool Wallet::parse_uri(const QString &uri, QString &address, QString &payment_id, uint64_t &amount, QString &tx_description, QString &recipient_name, QVector<QString> &unknown_parameters, QString &error)
{
std::string s_address, s_payment_id, s_tx_description, s_recipient_name, s_error;
std::vector<std::string> s_unknown_parameters;
bool res= m_walletImpl->parse_uri(uri.toStdString(), s_address, s_payment_id, amount, s_tx_description, s_recipient_name, s_unknown_parameters, s_error);
if(res)
{
address = QString::fromStdString(s_address);
payment_id = QString::fromStdString(s_payment_id);
tx_description = QString::fromStdString(s_tx_description);
recipient_name = QString::fromStdString(s_recipient_name);
for( const auto &p : s_unknown_parameters )
unknown_parameters.append(QString::fromStdString(p));
}
error = QString::fromStdString(s_error);
return res;
}
Wallet::Wallet(Monero::Wallet *w, QObject *parent)
: QObject(parent)

View file

@ -183,6 +183,8 @@ public:
//! verify a signed message
Q_INVOKABLE bool verifySignedMessage(const QString &message, const QString &address, const QString &signature, bool filename = false) const;
//! 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<QString> &unknown_parameters, QString &error);
//! saved payment id
QString paymentId() const;

View file

@ -234,6 +234,12 @@ QString WalletManager::resolveOpenAlias(const QString &address) const
res = std::string(dnssec_valid ? "true" : "false") + "|" + res;
return QString::fromStdString(res);
}
bool WalletManager::parse_uri(const QString &uri, QString &address, QString &payment_id, uint64_t &amount, QString &tx_description, QString &recipient_name, QVector<QString> &unknown_parameters, QString &error)
{
if (m_currentWallet)
return m_currentWallet->parse_uri(uri, address, payment_id, amount, tx_description, recipient_name, unknown_parameters, error);
return false;
}
void WalletManager::setLogLevel(int logLevel)
{

View file

@ -117,6 +117,7 @@ public:
Q_INVOKABLE double getPasswordStrength(const QString &password) const;
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<QString> &unknown_parameters, QString &error);
signals: