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