73
73
#include " multisig/multisig.h"
74
74
#include " wallet/wallet_args.h"
75
75
#include " wallet/fee_priority.h"
76
+ #include " wallet/uri.hpp"
76
77
#include " version.h"
77
78
#include < stdexcept>
78
79
#include " wallet/message_store.h"
@@ -6479,15 +6480,18 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6479
6480
{
6480
6481
std::string payment_id_str = local_args.back ();
6481
6482
crypto::hash payment_id;
6482
- bool r = true ;
6483
6483
if (tools::wallet2::parse_long_payment_id (payment_id_str, payment_id))
6484
6484
{
6485
6485
LONG_PAYMENT_ID_SUPPORT_CHECK ();
6486
- }
6487
- if (!r)
6488
- {
6489
- fail_msg_writer () << tr (" payment id failed to encode" );
6490
- return false ;
6486
+ std::string extra_nonce;
6487
+ set_payment_id_to_tx_extra_nonce (extra_nonce, payment_id);
6488
+ if (!add_extra_nonce_to_tx_extra (extra, extra_nonce))
6489
+ {
6490
+ fail_msg_writer () << tr (" failed to set up payment id" );
6491
+ return false ;
6492
+ }
6493
+ payment_id_seen = true ;
6494
+ local_args.pop_back ();
6491
6495
}
6492
6496
}
6493
6497
@@ -6514,6 +6518,7 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6514
6518
6515
6519
vector<cryptonote::address_parse_info> dsts_info;
6516
6520
vector<cryptonote::tx_destination_entry> dsts;
6521
+ std::string tx_description;
6517
6522
for (size_t i = 0 ; i < local_args.size (); )
6518
6523
{
6519
6524
dsts_info.emplace_back ();
@@ -6522,25 +6527,66 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6522
6527
bool r = true ;
6523
6528
6524
6529
// check for a URI
6525
- std::string address_uri, payment_id_uri, tx_description, recipient_name, error;
6526
- std::vector<std::string> unknown_parameters;
6527
- uint64_t amount = 0 ;
6528
- bool has_uri = m_wallet-> parse_uri (local_args[i], address_uri, payment_id_uri, amount , tx_description, recipient_name , unknown_parameters, error);
6530
+ std::string error;
6531
+ std::vector<std::string> unknown_parameters, addresses, recipient_names ;
6532
+ std::vector< uint64_t > amounts ;
6533
+ bool has_uri = parse_uri (local_args[i], addresses, amounts, recipient_names , tx_description, unknown_parameters, error);
6529
6534
if (has_uri)
6530
6535
{
6531
- r = cryptonote::get_account_address_from_str_or_url (info, m_wallet-> nettype (), address_uri, oa_prompter) ;
6532
- if (payment_id_uri. size () == 16 )
6536
+ std::string payment_id_uri ;
6537
+ for ( auto &unknown_parameter : unknown_parameters)
6533
6538
{
6534
- if (! tools::wallet2::parse_short_payment_id (payment_id_uri, info. payment_id ))
6539
+ if (boost::starts_with (unknown_parameter, " tx_payment_id= " ))
6535
6540
{
6536
- fail_msg_writer () << tr (" failed to parse short payment ID from URI" );
6541
+ payment_id_uri = unknown_parameter.substr (sizeof (" tx_payment_id=" )-1 );
6542
+ }
6543
+ }
6544
+ bool payment_id_used = false ;
6545
+ for (size_t j = 0 ; j < addresses.size (); ++j)
6546
+ {
6547
+ r = cryptonote::get_account_address_from_str_or_url (info, m_wallet->nettype (), addresses[j], oa_prompter);
6548
+ if (!r)
6549
+ {
6550
+ fail_msg_writer () << tr (" failed to parse address" );
6537
6551
return false ;
6538
6552
}
6539
- info.has_payment_id = true ;
6553
+
6554
+ if (!payment_id_uri.empty () && !payment_id_used)
6555
+ {
6556
+ if (payment_id_seen)
6557
+ {
6558
+ fail_msg_writer () << tr (" a single transaction cannot use more than one payment id" );
6559
+ return false ;
6560
+ }
6561
+ if (payment_id_uri.size () == 16 )
6562
+ {
6563
+ if (!tools::wallet2::parse_short_payment_id (payment_id_uri, info.payment_id ))
6564
+ {
6565
+ fail_msg_writer () << tr (" failed to parse short payment ID from URI" );
6566
+ return false ;
6567
+ }
6568
+ info.has_payment_id = true ;
6569
+ std::string extra_nonce;
6570
+ set_encrypted_payment_id_to_tx_extra_nonce (extra_nonce, info.payment_id );
6571
+ if (!add_extra_nonce_to_tx_extra (extra, extra_nonce))
6572
+ {
6573
+ fail_msg_writer () << tr (" failed to set up payment id" );
6574
+ return false ;
6575
+ }
6576
+ }
6577
+ payment_id_seen = true ;
6578
+ }
6579
+ payment_id_used = true ;
6580
+
6581
+ de.amount = amounts[j];
6582
+ de.original = addresses[j];
6583
+ de.addr = info.address ;
6584
+ de.is_subaddress = info.is_subaddress ;
6585
+ de.is_integrated = info.has_payment_id ;
6586
+ dsts.push_back (de);
6540
6587
}
6541
- de.amount = amount;
6542
- de.original = local_args[i];
6543
6588
++i;
6589
+ continue ;
6544
6590
}
6545
6591
else if (i + 1 < local_args.size ())
6546
6592
{
@@ -6573,33 +6619,18 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6573
6619
de.is_subaddress = info.is_subaddress ;
6574
6620
de.is_integrated = info.has_payment_id ;
6575
6621
6576
- if (info.has_payment_id || !payment_id_uri. empty () )
6622
+ if (info.has_payment_id )
6577
6623
{
6578
6624
if (payment_id_seen)
6579
6625
{
6580
6626
fail_msg_writer () << tr (" a single transaction cannot use more than one payment id" );
6581
6627
return false ;
6582
6628
}
6583
-
6584
- crypto::hash payment_id;
6585
6629
std::string extra_nonce;
6586
- if (info.has_payment_id )
6630
+ set_encrypted_payment_id_to_tx_extra_nonce (extra_nonce, info.payment_id );
6631
+ if (!add_extra_nonce_to_tx_extra (extra, extra_nonce))
6587
6632
{
6588
- set_encrypted_payment_id_to_tx_extra_nonce (extra_nonce, info.payment_id );
6589
- }
6590
- else if (tools::wallet2::parse_payment_id (payment_id_uri, payment_id))
6591
- {
6592
- LONG_PAYMENT_ID_SUPPORT_CHECK ();
6593
- }
6594
- else
6595
- {
6596
- fail_msg_writer () << tr (" failed to parse payment id, though it was detected" );
6597
- return false ;
6598
- }
6599
- bool r = add_extra_nonce_to_tx_extra (extra, extra_nonce);
6600
- if (!r)
6601
- {
6602
- fail_msg_writer () << tr (" failed to set up payment id, though it was decoded correctly" );
6633
+ fail_msg_writer () << tr (" failed to set up payment id" );
6603
6634
return false ;
6604
6635
}
6605
6636
payment_id_seen = true ;
@@ -6747,6 +6778,7 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6747
6778
}
6748
6779
}
6749
6780
6781
+ auto backup_ptx_vector = ptx_vector;
6750
6782
// actually commit the transactions
6751
6783
const multisig::multisig_account_status ms_status{m_wallet->get_multisig_status ()};
6752
6784
if (ms_status.multisig_is_active && called_by_mms)
@@ -6812,6 +6844,15 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6812
6844
{
6813
6845
commit_or_save (ptx_vector, m_do_not_relay);
6814
6846
}
6847
+
6848
+ if (!tx_description.empty ())
6849
+ {
6850
+ for (const auto &ptx : backup_ptx_vector)
6851
+ {
6852
+ crypto::hash txid = get_transaction_hash (ptx.tx );
6853
+ m_wallet->set_tx_note (txid, tx_description);
6854
+ }
6855
+ }
6815
6856
}
6816
6857
catch (const std::exception &e)
6817
6858
{
@@ -8699,12 +8740,21 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_)
8699
8740
std::string destinations = " -" ;
8700
8741
if (!transfer.outputs .empty ())
8701
8742
{
8702
- destinations = " " ;
8703
- for (const auto & output : transfer.outputs )
8743
+ if (transfer.outputs .size () == 1 )
8704
8744
{
8705
- if (!destinations.empty ())
8706
- destinations += " , " ;
8707
- destinations += (transfer.direction == " in" ? output.first .substr (0 , 6 ) : output.first ) + " :" + print_money (output.second );
8745
+ destinations = (transfer.direction == " in" ? transfer.outputs [0 ].first .substr (0 , 6 ) : transfer.outputs [0 ].first );
8746
+ }
8747
+ else
8748
+ {
8749
+ destinations.clear ();
8750
+ for (const auto & output : transfer.outputs )
8751
+ {
8752
+ if (!destinations.empty ())
8753
+ {
8754
+ destinations += " , " ;
8755
+ }
8756
+ destinations += (transfer.direction == " in" ? output.first .substr (0 , 6 ) : output.first ) + " :" + print_money (output.second );
8757
+ }
8708
8758
}
8709
8759
}
8710
8760
0 commit comments