@@ -6492,8 +6492,7 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6492
6492
return false ;
6493
6493
}
6494
6494
6495
- std::vector<uint8_t > extra;
6496
- bool payment_id_seen = false ;
6495
+ // Fail on parsed long payment ID
6497
6496
if (!local_args.empty ())
6498
6497
{
6499
6498
std::string payment_id_str = local_args.back ();
@@ -6533,6 +6532,7 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6533
6532
6534
6533
vector<cryptonote::address_parse_info> dsts_info;
6535
6534
vector<cryptonote::tx_destination_entry> dsts;
6535
+ std::pair<crypto::hash8, std::size_t > payment_id{crypto::null_hash8, 0 };
6536
6536
for (size_t i = 0 ; i < local_args.size (); )
6537
6537
{
6538
6538
dsts_info.emplace_back ();
@@ -6594,19 +6594,18 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6594
6594
6595
6595
if (info.has_payment_id || !payment_id_uri.empty ())
6596
6596
{
6597
- if (payment_id_seen)
6597
+ if (payment_id. first != crypto::null_hash8) // other pid seen before
6598
6598
{
6599
6599
fail_msg_writer () << tr (" a single transaction cannot use more than one payment id" );
6600
6600
return false ;
6601
6601
}
6602
6602
6603
- crypto::hash payment_id;
6604
- std::string extra_nonce;
6603
+ crypto::hash ignored_long_pid;
6605
6604
if (info.has_payment_id )
6606
6605
{
6607
- set_encrypted_payment_id_to_tx_extra_nonce (extra_nonce, info.payment_id ) ;
6606
+ payment_id = { info.payment_id , dsts. size ()} ;
6608
6607
}
6609
- else if (tools::wallet2::parse_payment_id (payment_id_uri, payment_id ))
6608
+ else if (tools::wallet2::parse_payment_id (payment_id_uri, ignored_long_pid ))
6610
6609
{
6611
6610
LONG_PAYMENT_ID_SUPPORT_CHECK ();
6612
6611
}
@@ -6615,13 +6614,6 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6615
6614
fail_msg_writer () << tr (" failed to parse payment id, though it was detected" );
6616
6615
return false ;
6617
6616
}
6618
- bool r = add_extra_nonce_to_tx_extra (extra, extra_nonce);
6619
- if (!r)
6620
- {
6621
- fail_msg_writer () << tr (" failed to set up payment id, though it was decoded correctly" );
6622
- return false ;
6623
- }
6624
- payment_id_seen = true ;
6625
6617
}
6626
6618
6627
6619
dsts.push_back (de);
@@ -6639,7 +6631,7 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
6639
6631
try
6640
6632
{
6641
6633
// figure out what tx will be necessary
6642
- auto ptx_vector = m_wallet->create_transactions_2 (dsts, fake_outs_count, priority, extra,
6634
+ auto ptx_vector = m_wallet->create_transactions_2 (dsts, payment_id, fake_outs_count, priority, /* extra= */ {} ,
6643
6635
m_current_subaddress_account, subaddr_indices, subtract_fee_from_outputs);
6644
6636
6645
6637
if (ptx_vector.empty ())
@@ -7075,14 +7067,13 @@ bool simple_wallet::sweep_main(uint32_t account, uint64_t below, const std::vect
7075
7067
}
7076
7068
}
7077
7069
7078
- std::vector<uint8_t > extra;
7079
- bool payment_id_seen = false ;
7070
+ // Fail on parsed long payment ID
7080
7071
if (local_args.size () >= 2 )
7081
7072
{
7082
7073
std::string payment_id_str = local_args.back ();
7083
7074
7084
- crypto::hash payment_id ;
7085
- bool r = tools::wallet2::parse_long_payment_id (payment_id_str, payment_id );
7075
+ crypto::hash ignored_long_pid ;
7076
+ bool r = tools::wallet2::parse_long_payment_id (payment_id_str, ignored_long_pid );
7086
7077
if (r)
7087
7078
{
7088
7079
LONG_PAYMENT_ID_SUPPORT_CHECK ();
@@ -7094,8 +7085,6 @@ bool simple_wallet::sweep_main(uint32_t account, uint64_t below, const std::vect
7094
7085
print_usage ();
7095
7086
return true ;
7096
7087
}
7097
- if (payment_id_seen)
7098
- local_args.pop_back ();
7099
7088
}
7100
7089
7101
7090
cryptonote::address_parse_info info;
@@ -7106,31 +7095,12 @@ bool simple_wallet::sweep_main(uint32_t account, uint64_t below, const std::vect
7106
7095
return true ;
7107
7096
}
7108
7097
7109
- if (info.has_payment_id )
7110
- {
7111
- if (payment_id_seen)
7112
- {
7113
- fail_msg_writer () << tr (" a single transaction cannot use more than one payment id: " ) << local_args[0 ];
7114
- return true ;
7115
- }
7116
-
7117
- std::string extra_nonce;
7118
- set_encrypted_payment_id_to_tx_extra_nonce (extra_nonce, info.payment_id );
7119
- bool r = add_extra_nonce_to_tx_extra (extra, extra_nonce);
7120
- if (!r)
7121
- {
7122
- fail_msg_writer () << tr (" failed to set up payment id, though it was decoded correctly" );
7123
- return true ;
7124
- }
7125
- payment_id_seen = true ;
7126
- }
7127
-
7128
7098
SCOPED_WALLET_UNLOCK ();
7129
7099
7130
7100
try
7131
7101
{
7132
7102
// figure out what tx will be necessary
7133
- auto ptx_vector = m_wallet->create_transactions_all (below, info.address , info.is_subaddress , outputs, fake_outs_count, priority, extra, account, subaddr_indices);
7103
+ 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);
7134
7104
7135
7105
if (ptx_vector.empty ())
7136
7106
{
@@ -7325,13 +7295,11 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
7325
7295
}
7326
7296
}
7327
7297
7328
- std::vector<uint8_t > extra;
7329
- bool payment_id_seen = false ;
7298
+ // Fail on parsed long payment ID
7330
7299
if (local_args.size () == 3 )
7331
7300
{
7332
- crypto::hash payment_id;
7333
- std::string extra_nonce;
7334
- if (tools::wallet2::parse_long_payment_id (local_args.back (), payment_id))
7301
+ crypto::hash ignored_long_pid;
7302
+ if (tools::wallet2::parse_long_payment_id (local_args.back (), ignored_long_pid))
7335
7303
{
7336
7304
LONG_PAYMENT_ID_SUPPORT_CHECK ();
7337
7305
}
@@ -7340,15 +7308,6 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
7340
7308
fail_msg_writer () << tr (" failed to parse Payment ID" );
7341
7309
return true ;
7342
7310
}
7343
-
7344
- if (!add_extra_nonce_to_tx_extra (extra, extra_nonce))
7345
- {
7346
- fail_msg_writer () << tr (" failed to set up payment id, though it was decoded correctly" );
7347
- return true ;
7348
- }
7349
-
7350
- local_args.pop_back ();
7351
- payment_id_seen = true ;
7352
7311
}
7353
7312
7354
7313
if (local_args.size () != 2 )
@@ -7371,30 +7330,12 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
7371
7330
return true ;
7372
7331
}
7373
7332
7374
- if (info.has_payment_id )
7375
- {
7376
- if (payment_id_seen)
7377
- {
7378
- fail_msg_writer () << tr (" a single transaction cannot use more than one payment id: " ) << local_args[0 ];
7379
- return true ;
7380
- }
7381
-
7382
- std::string extra_nonce;
7383
- set_encrypted_payment_id_to_tx_extra_nonce (extra_nonce, info.payment_id );
7384
- if (!add_extra_nonce_to_tx_extra (extra, extra_nonce))
7385
- {
7386
- fail_msg_writer () << tr (" failed to set up payment id, though it was decoded correctly" );
7387
- return true ;
7388
- }
7389
- payment_id_seen = true ;
7390
- }
7391
-
7392
7333
SCOPED_WALLET_UNLOCK ();
7393
7334
7394
7335
try
7395
7336
{
7396
7337
// figure out what tx will be necessary
7397
- auto ptx_vector = m_wallet->create_transactions_single (ki, info.address , info.is_subaddress , outputs, fake_outs_count, priority, extra);
7338
+ auto ptx_vector = m_wallet->create_transactions_single (ki, info.address , info.is_subaddress , outputs, info. payment_id , fake_outs_count, priority, /* extra= */ {} );
7398
7339
7399
7340
if (ptx_vector.empty ())
7400
7341
{
@@ -7561,14 +7502,18 @@ bool simple_wallet::donate(const std::vector<std::string> &args_)
7561
7502
std::string amount_str;
7562
7503
std::string payment_id_str;
7563
7504
// get payment id and pop
7564
- crypto::hash payment_id;
7565
- crypto::hash8 payment_id8;
7505
+ crypto::hash payment_id = crypto::null_hash ;
7506
+ crypto::hash8 payment_id8 = crypto::null_hash8 ;
7566
7507
if (tools::wallet2::parse_long_payment_id (local_args.back (), payment_id ) ||
7567
7508
tools::wallet2::parse_short_payment_id (local_args.back (), payment_id8))
7568
7509
{
7569
7510
payment_id_str = local_args.back ();
7570
7511
local_args.pop_back ();
7571
7512
}
7513
+ if (payment_id != crypto::null_hash)
7514
+ {
7515
+ LONG_PAYMENT_ID_SUPPORT_CHECK ();
7516
+ }
7572
7517
// get amount and pop
7573
7518
uint64_t amount;
7574
7519
bool ok = cryptonote::parse_amount (amount, local_args.back ());
0 commit comments