From a55f1f190a6ddbb8d0c1ad6d4078628626a4eca1 Mon Sep 17 00:00:00 2001 From: U65535F <132809543+U65535F@users.noreply.github.com> Date: Wed, 29 Jan 2025 07:46:01 +0530 Subject: [PATCH] Fix function overloads --- src/wallet/api/wallet.cpp | 16 +++++++++++++--- src/wallet/wallet2.cpp | 21 ++++++++++++++++++--- src/wallet/wallet2.h | 1 + 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index b3c47714eb1..ca279b5802e 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -2551,11 +2551,13 @@ bool WalletImpl::checkBackgroundSync(const std::string &message) const bool WalletImpl::parse_uri(const std::string &uri, std::string &address, std::string &payment_id, uint64_t &amount, std::string &tx_description, std::string &recipient_name, std::vector &unknown_parameters, std::string &error) { std::vector data; - if (!m_wallet->parse_uri(uri, data, payment_id, tx_description, unknown_parameters, error)) { + if (!m_wallet->parse_uri(uri, data, payment_id, tx_description, unknown_parameters, error)) + { setStatusError(tr("Failed to parse uri")); return false; } - if (data.size() > 1) { + if (data.size() > 1) + { setStatusError(tr("Multi-recipient URIs currently unsupported")); return false; } @@ -2567,7 +2569,15 @@ bool WalletImpl::parse_uri(const std::string &uri, std::string &address, std::st std::string WalletImpl::make_uri(const std::string &address, const std::string &payment_id, uint64_t amount, const std::string &tx_description, const std::string &recipient_name, std::string &error) const { - return m_wallet->make_uri(address, payment_id, amount, tx_description, recipient_name, error); + tools::wallet2::uri_data entry; + entry.address = address; + entry.amount = amount; + entry.recipient_name = recipient_name; + + std::vector data; + data.push_back(entry); + + return make_uri(data, payment_id, tx_description, error); } std::string WalletImpl::getDefaultDataDir() const diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 1fc313dea56..2c100c364f6 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -15143,9 +15143,24 @@ bool wallet2::parse_uri(const std::string &uri, std::vector &data, std return true; } -} -bool wallet2::parse_uri(const std::string& uri, std::string& address, std::string& payment_id, uint64_t& amount, std::string& description, std::string& recipient_name, std::unordered_map& unknown_parameters, std::string& error) { - return parse_uri(uri, address, payment_id, amount, description, error); + +bool wallet2::parse_uri(const std::string& uri, std::string& address, std::string& payment_id, uint64_t& amount, std::string& description, std::string& recipient_name, std::unordered_map& unknown_parameters, std::string& error) +{ + std::vector data; + if (!m_wallet->parse_uri(uri, data, payment_id, tx_description, unknown_parameters, error)) + { + setStatusError(tr("Failed to parse uri")); + return false; + } + if (data.size() > 1) + { + setStatusError(tr("Multi-recipient URIs currently unsupported")); + return false; + } + address = data[0].address; + amount = data[0].amount; + recipient_name = data[0].recipient_name; + return true; } //---------------------------------------------------------------------------------------------------- uint64_t wallet2::get_blockchain_height_by_date(uint16_t year, uint8_t month, uint8_t day) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index a851cb02ca7..ed52d77dd57 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -1650,6 +1650,7 @@ namespace tools std::string make_uri(std::vector data, const std::string &payment_id, const std::string &tx_description, std::string &error) const; bool parse_uri(const std::string &uri, std::vector &data, std::string &payment_id, std::string &tx_description, std::vector &unknown_parameters, std::string &error); + bool parse_uri(const std::string& uri, std::string& address, std::string& payment_id, uint64_t& amount, std::string& description, std::string& recipient_name, std::unordered_map& unknown_parameters, std::string& error); uint64_t get_blockchain_height_by_date(uint16_t year, uint8_t month, uint8_t day); // 1<=month<=12, 1<=day<=31