Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple-URI support in parse_uri and make_uri #9756

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7469d69
Multiple url functionality.
U65535F Jan 28, 2025
d1f69b9
Remove commented line.
U65535F Jan 28, 2025
1b1e930
Fix error by removing repeated code block.
U65535F Jan 28, 2025
168668a
fix no member named errors
U65535F Jan 28, 2025
ab0c39e
Add function overloads for make_uri to make it compatible with older …
U65535F Jan 28, 2025
25b3ef2
Fix tests
U65535F Jan 29, 2025
a55f1f1
Fix function overloads
U65535F Jan 29, 2025
246926a
Fix errors of parse_uri saying that m_wallet was not found.
U65535F Jan 29, 2025
bfa2c35
Add semi-colon
U65535F Jan 29, 2025
cd922c6
Update parse_uri to support single tx
U65535F Jan 29, 2025
0fe95f9
fix parse_uri
U65535F Jan 29, 2025
a5750c5
fix errors
U65535F Jan 29, 2025
4a83b22
fix make_uri
U65535F Jan 30, 2025
6ca8ace
Slight imporvements and fix always failing test code.
U65535F Jan 30, 2025
dab6fe2
Fix tests that were using atomic units in URL. Add parameter consiste…
U65535F Jan 30, 2025
20e6095
Fix failing python functional tests
U65535F Jan 31, 2025
546fb29
fix improper size calc
U65535F Jan 31, 2025
993ebfc
Move overloads to wallet2.cpp. Introduce backwards compatibility in w…
U65535F Feb 1, 2025
577b7ee
Fix function declarations
U65535F Feb 1, 2025
faf7306
fix uri_data not found by replacing it with tools::wallet2::uri_data …
U65535F Feb 1, 2025
48fe7eb
remove override keyword from wallet.h: make_uri and parse_uri
U65535F Feb 1, 2025
9383f36
fix override issue
U65535F Feb 1, 2025
ca7b72e
add semi-colon.
U65535F Feb 2, 2025
a7fbf60
warning fix: loop variable 'entry' creates a copy.
U65535F Feb 2, 2025
df0021e
Merge branch 'master' of https://github.com/U65535F/monero
U65535F Feb 2, 2025
400d812
add const keyword
U65535F Feb 2, 2025
d678eee
allow standalone payment ids (yet not recommended; fallback)
U65535F Feb 2, 2025
bd357c5
Exclude core_tests
U65535F Feb 2, 2025
f0de5c8
fix failing uri.py by properly calling make_uri and parse_uri. restor…
U65535F Feb 2, 2025
c489d7d
introduce a custom convert to url func instead of modifying existing …
U65535F Feb 2, 2025
5911114
fix conver_to_url_format not declared by changing call to epee::net_u…
U65535F Feb 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 56 additions & 11 deletions src/simplewallet/simplewallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6532,25 +6532,70 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
bool r = true;

// check for a URI
std::string address_uri, payment_id_uri, tx_description, recipient_name, error;
std::string payment_id_uri, tx_description, error;
std::vector<std::string> unknown_parameters;
uint64_t amount = 0;
bool has_uri = m_wallet->parse_uri(local_args[i], address_uri, payment_id_uri, amount, tx_description, recipient_name, unknown_parameters, error);
std::vector<tools::wallet2::uri_data> uri_data;
bool has_uri = m_wallet->parse_uri(local_args[i], uri_data, payment_id_uri, tx_description, unknown_parameters, error);
if (has_uri)
{
r = cryptonote::get_account_address_from_str_or_url(info, m_wallet->nettype(), address_uri, oa_prompter);
if (payment_id_uri.size() == 16)

for (size_t j = 0; j < uri_data.size(); j++)
{
if (!tools::wallet2::parse_short_payment_id(payment_id_uri, info.payment_id))
r = cryptonote::get_account_address_from_str_or_url(info, m_wallet->nettype(), uri_data[j].address, oa_prompter);
if (payment_id_uri.size() == 16)
{
fail_msg_writer() << tr("failed to parse short payment ID from URI");
if (!tools::wallet2::parse_short_payment_id(payment_id_uri, info.payment_id))
{
fail_msg_writer() << tr("failed to parse short payment ID from URI");
return false;
}
info.has_payment_id = true;
}
de.amount = uri_data[j].amount;
de.original = uri_data[j].address;
if (!r)
{
fail_msg_writer() << tr("failed to parse address");
return false;
}
info.has_payment_id = true;
de.addr = info.address;
de.is_subaddress = info.is_subaddress;
de.is_integrated = info.has_payment_id;

if (info.has_payment_id || !payment_id_uri.empty())
{
if (payment_id_seen)
{
fail_msg_writer() << tr("a single transaction cannot use more than one payment id");
return false;
}
crypto::hash payment_id;
std::string extra_nonce;
if (info.has_payment_id)
{
set_encrypted_payment_id_to_tx_extra_nonce(extra_nonce, info.payment_id);
}
else if (tools::wallet2::parse_payment_id(payment_id_uri, payment_id))
{
LONG_PAYMENT_ID_SUPPORT_CHECK();
}
else
{
fail_msg_writer() << tr("failed to parse payment id, though it was detected");
return false;
}
bool r = add_extra_nonce_to_tx_extra(extra, extra_nonce);
if(!r)
{
fail_msg_writer() << tr("failed to set up payment id, though it was decoded correctly");
return false;
}
payment_id_seen = true;
}
dsts.push_back(de);
}
de.amount = amount;
de.original = local_args[i];
++i;
i++;
break;
}
else if (i + 1 < local_args.size())
{
Expand Down
12 changes: 11 additions & 1 deletion src/wallet/api/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2548,7 +2548,12 @@ bool WalletImpl::checkBackgroundSync(const std::string &message) const
return false;
}

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<std::string> &unknown_parameters, std::string &error)
bool WalletImpl::parse_uri(const std::string &uri, std::vector<tools::wallet2::uri_data> &data, std::string &payment_id, std::string &tx_description, std::vector<std::string> &unknown_parameters, std::string &error)
{
return m_wallet->parse_uri(uri, data, payment_id, tx_description, unknown_parameters, error);
}

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<std::string>& unknown_parameters, std::string& error)
{
return m_wallet->parse_uri(uri, address, payment_id, amount, tx_description, recipient_name, unknown_parameters, error);
}
Expand All @@ -2558,6 +2563,11 @@ std::string WalletImpl::make_uri(const std::string &address, const std::string &
return m_wallet->make_uri(address, payment_id, amount, tx_description, recipient_name, error);
}

std::string WalletImpl::make_uri(std::vector<tools::wallet2::uri_data> data, const std::string &payment_id, const std::string &tx_description, std::string &error) const
{
return m_wallet->make_uri(data, payment_id, tx_description, error);
}

std::string WalletImpl::getDefaultDataDir() const
{
return tools::get_default_data_dir();
Expand Down
3 changes: 3 additions & 0 deletions src/wallet/api/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ class WalletImpl : public Wallet
virtual void startRefresh() override;
virtual void pauseRefresh() override;
virtual bool 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<std::string> &unknown_parameters, std::string &error) override;
virtual bool parse_uri(const std::string &uri, std::vector<tools::wallet2::uri_data> &data, std::string &payment_id, std::string &tx_description, std::vector<std::string> &unknown_parameters, std::string &error);
virtual std::string 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 override;
virtual std::string make_uri(std::vector<tools::wallet2::uri_data> data, const std::string &payment_id, const std::string &tx_description, std::string &error) const;

virtual std::string getDefaultDataDir() const override;
virtual bool blackballOutputs(const std::vector<std::string> &outputs, bool add) override;
virtual bool blackballOutput(const std::string &amount, const std::string &offset) override;
Expand Down
2 changes: 2 additions & 0 deletions src/wallet/api/wallet2_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1066,8 +1066,10 @@ struct Wallet
virtual bool verifyMessageWithPublicKey(const std::string &message, const std::string &publicKey, const std::string &signature) const = 0;

virtual bool 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<std::string> &unknown_parameters, std::string &error) = 0;

virtual std::string 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 = 0;


virtual std::string getDefaultDataDir() const = 0;

/*
Expand Down
Loading
Loading