@@ -6484,7 +6484,8 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6484
6484
return false ;
6485
6485
}
6486
6486
6487
- // Fail on parsed long payment ID
6487
+ std::vector<uint8_t > extra;
6488
+ bool payment_id_seen = false ;
6488
6489
if (!local_args.empty ())
6489
6490
{
6490
6491
std::string payment_id_str = local_args.back ();
@@ -6524,7 +6525,6 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6524
6525
6525
6526
vector<cryptonote::address_parse_info> dsts_info;
6526
6527
vector<cryptonote::tx_destination_entry> dsts;
6527
- std::pair<crypto::hash8, std::size_t > payment_id{crypto::null_hash8, 0 };
6528
6528
for (size_t i = 0 ; i < local_args.size (); )
6529
6529
{
6530
6530
dsts_info.emplace_back ();
@@ -6586,18 +6586,19 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6586
6586
6587
6587
if (info.has_payment_id || !payment_id_uri.empty ())
6588
6588
{
6589
- if (payment_id. first != crypto::null_hash8) // other pid seen before
6589
+ if (payment_id_seen)
6590
6590
{
6591
6591
fail_msg_writer () << tr (" a single transaction cannot use more than one payment id" );
6592
6592
return false ;
6593
6593
}
6594
6594
6595
- crypto::hash ignored_long_pid;
6595
+ crypto::hash payment_id;
6596
+ std::string extra_nonce;
6596
6597
if (info.has_payment_id )
6597
6598
{
6598
- payment_id = { info.payment_id , dsts. size ()} ;
6599
+ set_encrypted_payment_id_to_tx_extra_nonce (extra_nonce, info.payment_id ) ;
6599
6600
}
6600
- else if (tools::wallet2::parse_payment_id (payment_id_uri, ignored_long_pid ))
6601
+ else if (tools::wallet2::parse_payment_id (payment_id_uri, payment_id ))
6601
6602
{
6602
6603
LONG_PAYMENT_ID_SUPPORT_CHECK ();
6603
6604
}
@@ -6606,6 +6607,13 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6606
6607
fail_msg_writer () << tr (" failed to parse payment id, though it was detected" );
6607
6608
return false ;
6608
6609
}
6610
+ bool r = add_extra_nonce_to_tx_extra (extra, extra_nonce);
6611
+ if (!r)
6612
+ {
6613
+ fail_msg_writer () << tr (" failed to set up payment id, though it was decoded correctly" );
6614
+ return false ;
6615
+ }
6616
+ payment_id_seen = true ;
6609
6617
}
6610
6618
6611
6619
dsts.push_back (de);
@@ -6623,7 +6631,7 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6623
6631
try
6624
6632
{
6625
6633
// figure out what tx will be necessary
6626
- auto ptx_vector = m_wallet->create_transactions_2 (dsts, payment_id, fake_outs_count, priority, /* extra= */ {} ,
6634
+ auto ptx_vector = m_wallet->create_transactions_2 (dsts, fake_outs_count, priority, extra,
6627
6635
m_current_subaddress_account, subaddr_indices, subtract_fee_from_outputs);
6628
6636
6629
6637
if (ptx_vector.empty ())
@@ -7059,13 +7067,14 @@ bool simple_wallet::sweep_main(uint32_t account, uint64_t below, const std::vect
7059
7067
}
7060
7068
}
7061
7069
7062
- // Fail on parsed long payment ID
7070
+ std::vector<uint8_t > extra;
7071
+ bool payment_id_seen = false ;
7063
7072
if (local_args.size () >= 2 )
7064
7073
{
7065
7074
std::string payment_id_str = local_args.back ();
7066
7075
7067
- crypto::hash ignored_long_pid ;
7068
- bool r = tools::wallet2::parse_long_payment_id (payment_id_str, ignored_long_pid );
7076
+ crypto::hash payment_id ;
7077
+ bool r = tools::wallet2::parse_long_payment_id (payment_id_str, payment_id );
7069
7078
if (r)
7070
7079
{
7071
7080
LONG_PAYMENT_ID_SUPPORT_CHECK ();
@@ -7077,6 +7086,8 @@ bool simple_wallet::sweep_main(uint32_t account, uint64_t below, const std::vect
7077
7086
print_usage ();
7078
7087
return true ;
7079
7088
}
7089
+ if (payment_id_seen)
7090
+ local_args.pop_back ();
7080
7091
}
7081
7092
7082
7093
cryptonote::address_parse_info info;
@@ -7087,12 +7098,31 @@ bool simple_wallet::sweep_main(uint32_t account, uint64_t below, const std::vect
7087
7098
return true ;
7088
7099
}
7089
7100
7101
+ if (info.has_payment_id )
7102
+ {
7103
+ if (payment_id_seen)
7104
+ {
7105
+ fail_msg_writer () << tr (" a single transaction cannot use more than one payment id: " ) << local_args[0 ];
7106
+ return true ;
7107
+ }
7108
+
7109
+ std::string extra_nonce;
7110
+ set_encrypted_payment_id_to_tx_extra_nonce (extra_nonce, info.payment_id );
7111
+ bool r = add_extra_nonce_to_tx_extra (extra, extra_nonce);
7112
+ if (!r)
7113
+ {
7114
+ fail_msg_writer () << tr (" failed to set up payment id, though it was decoded correctly" );
7115
+ return true ;
7116
+ }
7117
+ payment_id_seen = true ;
7118
+ }
7119
+
7090
7120
SCOPED_WALLET_UNLOCK ();
7091
7121
7092
7122
try
7093
7123
{
7094
7124
// figure out what tx will be necessary
7095
- auto ptx_vector = m_wallet->create_transactions_all (below, info.address , info.is_subaddress , outputs, info. payment_id , fake_outs_count, priority, /* extra= */ {} , account, subaddr_indices);
7125
+ auto ptx_vector = m_wallet->create_transactions_all (below, info.address , info.is_subaddress , outputs, fake_outs_count, priority, extra, account, subaddr_indices);
7096
7126
7097
7127
if (ptx_vector.empty ())
7098
7128
{
@@ -7287,11 +7317,13 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
7287
7317
}
7288
7318
}
7289
7319
7290
- // Fail on parsed long payment ID
7320
+ std::vector<uint8_t > extra;
7321
+ bool payment_id_seen = false ;
7291
7322
if (local_args.size () == 3 )
7292
7323
{
7293
- crypto::hash ignored_long_pid;
7294
- if (tools::wallet2::parse_long_payment_id (local_args.back (), ignored_long_pid))
7324
+ crypto::hash payment_id;
7325
+ std::string extra_nonce;
7326
+ if (tools::wallet2::parse_long_payment_id (local_args.back (), payment_id))
7295
7327
{
7296
7328
LONG_PAYMENT_ID_SUPPORT_CHECK ();
7297
7329
}
@@ -7300,6 +7332,15 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
7300
7332
fail_msg_writer () << tr (" failed to parse Payment ID" );
7301
7333
return true ;
7302
7334
}
7335
+
7336
+ if (!add_extra_nonce_to_tx_extra (extra, extra_nonce))
7337
+ {
7338
+ fail_msg_writer () << tr (" failed to set up payment id, though it was decoded correctly" );
7339
+ return true ;
7340
+ }
7341
+
7342
+ local_args.pop_back ();
7343
+ payment_id_seen = true ;
7303
7344
}
7304
7345
7305
7346
if (local_args.size () != 2 )
@@ -7322,12 +7363,30 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
7322
7363
return true ;
7323
7364
}
7324
7365
7366
+ if (info.has_payment_id )
7367
+ {
7368
+ if (payment_id_seen)
7369
+ {
7370
+ fail_msg_writer () << tr (" a single transaction cannot use more than one payment id: " ) << local_args[0 ];
7371
+ return true ;
7372
+ }
7373
+
7374
+ std::string extra_nonce;
7375
+ set_encrypted_payment_id_to_tx_extra_nonce (extra_nonce, info.payment_id );
7376
+ if (!add_extra_nonce_to_tx_extra (extra, extra_nonce))
7377
+ {
7378
+ fail_msg_writer () << tr (" failed to set up payment id, though it was decoded correctly" );
7379
+ return true ;
7380
+ }
7381
+ payment_id_seen = true ;
7382
+ }
7383
+
7325
7384
SCOPED_WALLET_UNLOCK ();
7326
7385
7327
7386
try
7328
7387
{
7329
7388
// figure out what tx will be necessary
7330
- auto ptx_vector = m_wallet->create_transactions_single (ki, info.address , info.is_subaddress , outputs, info. payment_id , fake_outs_count, priority, /* extra= */ {} );
7389
+ auto ptx_vector = m_wallet->create_transactions_single (ki, info.address , info.is_subaddress , outputs, fake_outs_count, priority, extra);
7331
7390
7332
7391
if (ptx_vector.empty ())
7333
7392
{
@@ -7491,9 +7550,9 @@ bool simple_wallet::donate(const std::vector<std::string> &args_)
7491
7550
}
7492
7551
std::string amount_str;
7493
7552
std::string payment_id_str;
7494
- // get payment id and pop (long PIDs handled in `transfer()`)
7495
- crypto::hash payment_id = crypto::null_hash ;
7496
- crypto::hash8 payment_id8 = crypto::null_hash8 ;
7553
+ // get payment id and pop
7554
+ crypto::hash payment_id;
7555
+ crypto::hash8 payment_id8;
7497
7556
if (tools::wallet2::parse_long_payment_id (local_args.back (), payment_id ) ||
7498
7557
tools::wallet2::parse_short_payment_id (local_args.back (), payment_id8))
7499
7558
{
0 commit comments