mirror of
				https://git.wownero.com/wownero/wownero.git
				synced 2024-08-15 01:03:23 +00:00 
			
		
		
		
	wallet2: ensure transfers and sweeps use same fee calc logic
Ensures both transfers and sweeps use a fee that's calculated from the tx's weight. Using different logic could theoretically enable distinguishability between the two types of txs. We don't want that.
This commit is contained in:
		
							parent
							
								
									1cb536ff45
								
							
						
					
					
						commit
						1e38c3c508
					
				
					 1 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
					@ -11352,7 +11352,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        LOG_PRINT_L2("We made a tx, adjusting fee and saving it, we need " << print_money(needed_fee) << " and we have " << print_money(test_ptx.fee));
 | 
					        LOG_PRINT_L2("We made a tx, adjusting fee and saving it, we need " << print_money(needed_fee) << " and we have " << print_money(test_ptx.fee));
 | 
				
			||||||
        while (needed_fee > test_ptx.fee) {
 | 
					        do {
 | 
				
			||||||
          if (use_rct)
 | 
					          if (use_rct)
 | 
				
			||||||
            transfer_selected_rct(tx.dsts, tx.selected_transfers, fake_outs_count, outs, valid_public_keys_cache, unlock_time, needed_fee, extra,
 | 
					            transfer_selected_rct(tx.dsts, tx.selected_transfers, fake_outs_count, outs, valid_public_keys_cache, unlock_time, needed_fee, extra,
 | 
				
			||||||
              test_tx, test_ptx, rct_config, use_view_tags);
 | 
					              test_tx, test_ptx, rct_config, use_view_tags);
 | 
				
			||||||
| 
						 | 
					@ -11363,7 +11363,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
 | 
				
			||||||
          needed_fee = calculate_fee(use_per_byte_fee, test_ptx.tx, txBlob.size(), base_fee, fee_quantization_mask);
 | 
					          needed_fee = calculate_fee(use_per_byte_fee, test_ptx.tx, txBlob.size(), base_fee, fee_quantization_mask);
 | 
				
			||||||
          LOG_PRINT_L2("Made an attempt at a  final " << get_weight_string(test_ptx.tx, txBlob.size()) << " tx, with " << print_money(test_ptx.fee) <<
 | 
					          LOG_PRINT_L2("Made an attempt at a  final " << get_weight_string(test_ptx.tx, txBlob.size()) << " tx, with " << print_money(test_ptx.fee) <<
 | 
				
			||||||
            " fee  and " << print_money(test_ptx.change_dts.amount) << " change");
 | 
					            " fee  and " << print_money(test_ptx.change_dts.amount) << " change");
 | 
				
			||||||
        }
 | 
					        } while (needed_fee > test_ptx.fee);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        LOG_PRINT_L2("Made a final " << get_weight_string(test_ptx.tx, txBlob.size()) << " tx, with " << print_money(test_ptx.fee) <<
 | 
					        LOG_PRINT_L2("Made a final " << get_weight_string(test_ptx.tx, txBlob.size()) << " tx, with " << print_money(test_ptx.fee) <<
 | 
				
			||||||
          " fee  and " << print_money(test_ptx.change_dts.amount) << " change");
 | 
					          " fee  and " << print_money(test_ptx.change_dts.amount) << " change");
 | 
				
			||||||
| 
						 | 
					@ -11759,7 +11759,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_from(const crypton
 | 
				
			||||||
      THROW_WALLET_EXCEPTION_IF(needed_fee > available_for_fee, error::wallet_internal_error, "Transaction cannot pay for itself");
 | 
					      THROW_WALLET_EXCEPTION_IF(needed_fee > available_for_fee, error::wallet_internal_error, "Transaction cannot pay for itself");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      do {
 | 
					      do {
 | 
				
			||||||
        LOG_PRINT_L2("We made a tx, adjusting fee and saving it");
 | 
					        LOG_PRINT_L2("We made a tx, adjusting fee and saving it, we need " << print_money(needed_fee) << " and we have " << print_money(test_ptx.fee));
 | 
				
			||||||
        // distribute total transferred amount between outputs
 | 
					        // distribute total transferred amount between outputs
 | 
				
			||||||
        uint64_t amount_transferred = available_for_fee - needed_fee;
 | 
					        uint64_t amount_transferred = available_for_fee - needed_fee;
 | 
				
			||||||
        uint64_t dt_amount = amount_transferred / outputs;
 | 
					        uint64_t dt_amount = amount_transferred / outputs;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue