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

simplewallet: handle transfers using a monero: URI #4208

Merged
merged 1 commit into from
Sep 14, 2018

Conversation

moneromooo-monero
Copy link
Collaborator

No description provided.

Copy link
Contributor

@coneiric coneiric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor sticking point, and a couple clarifying questions. Other than that, changes look good to me.

{
std::string extra_nonce;
set_encrypted_payment_id_to_tx_extra_nonce(extra_nonce, payment_id8);
r = add_extra_nonce_to_tx_extra(extra, extra_nonce);
local_args.pop_back();
payment_id_seen = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should r be updated here if parse_short_payment_id fails?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, or it'd make the payment id mandatory.

info.has_payment_id = true;
}
de.amount = amount;
++i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused here: why is the index incremented by one here, or by two below in the else if block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in that branch we found a parameter (a URI), and in the other one we found two (address and amount).

else
{
fail_msg_writer() << tr("Invalid last argument: ") << local_args.back();
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo? Why is true returned on error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To mark the fact the command handler was run, that is what the caller expects.

@coneiric
Copy link
Contributor

Also, something is making the cncrypto tests fail on buildbot. Is this a known bug?

@moneromooo-monero
Copy link
Collaborator Author

Yes

Copy link
Contributor

@stoffu stoffu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the help message needs updating.

@@ -4611,9 +4610,49 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
size_t num_subaddresses = 0;
for (size_t i = 0; i < local_args.size(); i += 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this i += 2 should be dropped.

r = cryptonote::get_account_address_from_str_or_url(info, m_wallet->nettype(), address_uri, oa_prompter);
if (!payment_id_uri.empty())
{
if (!tools::wallet2::parse_short_payment_id(payment_id_uri, info.payment_id))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to wallet2::parse_uri, both short and long payment ID formats seem to be supported. Why limit to short pID only?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because an address cannot contain a long payment id.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Come to think of it, the long payment ID is being deprecated, so this way seems fine to me. I still think the long payment ID is allowed in a URI though, at least that's what I see in the unit test TEST(uri, long_payment_id).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it can. This was extracting from the address, where it can't. But I should check for a long here anyway, and not just at the end, you're right.

@moneromooo-monero moneromooo-monero force-pushed the truri branch 2 times, most recently from bd0a007 to 2710400 Compare August 27, 2018 14:56
}
else
{
fail_msg_writer() << tr("Invalid last argument: ") << local_args.back();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about printing the URI parse error stored in error if not empty?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess. It's wallet2 though, so not translated, but it's better than nothing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, if there's an error, it might not be a URI, and I don't really want to start "guessing" to know whether showing the error is a good idea or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think it's useful to show an error message when the URI parsing fails, because it seems very easy to make incorrectly formatted URIs. How about showing it only when local_args.back() starts with "monero:"?

@@ -2160,14 +2160,14 @@ simple_wallet::simple_wallet()
tr("Show the blockchain height."));
m_cmd_binder.set_handler("transfer_original",
boost::bind(&simple_wallet::transfer, this, _1),
tr("transfer_original [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <amount> [<payment_id>]"),
tr("transfer_original [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] (URI | (<address> <amount>)) [<payment_id>]"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be accurate to also adjust this line as well:

Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)"

@@ -2161,14 +2161,14 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("transfer_original",
boost::bind(&simple_wallet::transfer, this, _1),
tr("transfer_original [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <amount> [<payment_id>]"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, was the change in this line removed by mistake?

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))
set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line never gets executed due to the above logic:

      if (!payment_id_uri.empty())
      {
        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 true;
        }
        ...

Confirmed:

[wallet 9xLMUj]: transfer monero:A1PbM6kDJs7eJnAjwwE7Bk3DH84iQbfKZF6x5i8KuBrhdZBhKgfwuTPCqTEjPZPKJMG32ioosAHR3KkwG97tDfZS5kSJJRN?tx_amount=1.2&tx_payment_id=1234123412341234123412341234123412341234123412341234123412341234
Wallet password: 
Error: failed to parse short payment ID from URI

@stoffu
Copy link
Contributor

stoffu commented Aug 28, 2018

Please address my comment #4208 (comment)

@moneromooo-monero
Copy link
Collaborator Author

Yes, it appears I lost a few fixes in the last merge to the PR branch :( Fixing...

}
else
{
fail_msg_writer() << tr("Invalid last argument: ") << local_args.back();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think it's useful to show an error message when the URI parsing fails, because it seems very easy to make incorrectly formatted URIs. How about showing it only when local_args.back() starts with "monero:"?

set_encrypted_payment_id_to_tx_extra_nonce(extra_nonce, info.payment_id);
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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could add the same warning:

      message_writer() << tr("Unencrypted payment IDs are bad for privacy: ask the recipient to use subaddresses instead");

Copy link
Contributor

@fluffypony fluffypony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed

@fluffypony fluffypony merged commit 2c636e4 into monero-project:master Sep 14, 2018
fluffypony added a commit that referenced this pull request Sep 14, 2018
2c636e4 simplewallet: handle transfers using a monero: URI (moneromooo-monero)
@stoffu stoffu mentioned this pull request Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants