-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Conversation
There was a problem hiding this 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; | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
src/simplewallet/simplewallet.cpp
Outdated
else | ||
{ | ||
fail_msg_writer() << tr("Invalid last argument: ") << local_args.back(); | ||
return true; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Also, something is making the |
Yes |
There was a problem hiding this 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.
src/simplewallet/simplewallet.cpp
Outdated
@@ -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) |
There was a problem hiding this comment.
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.
src/simplewallet/simplewallet.cpp
Outdated
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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
.
There was a problem hiding this comment.
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.
bd0a007
to
2710400
Compare
src/simplewallet/simplewallet.cpp
Outdated
} | ||
else | ||
{ | ||
fail_msg_writer() << tr("Invalid last argument: ") << local_args.back(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:"?
src/simplewallet/simplewallet.cpp
Outdated
@@ -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>]"), |
There was a problem hiding this comment.
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)"
2710400
to
433f5b0
Compare
src/simplewallet/simplewallet.cpp
Outdated
@@ -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>]"), |
There was a problem hiding this comment.
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?
src/simplewallet/simplewallet.cpp
Outdated
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); |
There was a problem hiding this comment.
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
Please address my comment #4208 (comment) |
Yes, it appears I lost a few fixes in the last merge to the PR branch :( Fixing... |
433f5b0
to
a01809a
Compare
src/simplewallet/simplewallet.cpp
Outdated
} | ||
else | ||
{ | ||
fail_msg_writer() << tr("Invalid last argument: ") << local_args.back(); |
There was a problem hiding this comment.
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:"?
src/simplewallet/simplewallet.cpp
Outdated
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)) |
There was a problem hiding this comment.
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");
a01809a
to
2c636e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed
2c636e4 simplewallet: handle transfers using a monero: URI (moneromooo-monero)
No description provided.