mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-12-17 22:10:05 -07:00
wallet2: fix failure to create tx if inputs are not enough for fee
This commit is contained in:
parent
7a9a4a6669
commit
66eeeaa1a2
@ -6621,6 +6621,17 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
|||||||
const size_t estimated_tx_size = estimate_tx_size(use_rct, tx.selected_transfers.size(), fake_outs_count, tx.dsts.size(), extra.size(), bulletproof);
|
const size_t estimated_tx_size = estimate_tx_size(use_rct, tx.selected_transfers.size(), fake_outs_count, tx.dsts.size(), extra.size(), bulletproof);
|
||||||
needed_fee = calculate_fee(fee_per_kb, estimated_tx_size, fee_multiplier);
|
needed_fee = calculate_fee(fee_per_kb, estimated_tx_size, fee_multiplier);
|
||||||
|
|
||||||
|
uint64_t inputs = 0, outputs = needed_fee;
|
||||||
|
for (size_t idx: tx.selected_transfers) inputs += m_transfers[idx].amount();
|
||||||
|
for (const auto &o: tx.dsts) outputs += o.amount;
|
||||||
|
|
||||||
|
if (inputs < outputs)
|
||||||
|
{
|
||||||
|
LOG_PRINT_L2("We don't have enough for the basic fee, switching to adding_fee");
|
||||||
|
adding_fee = true;
|
||||||
|
goto skip_tx;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_PRINT_L2("Trying to create a tx now, with " << tx.dsts.size() << " outputs and " <<
|
LOG_PRINT_L2("Trying to create a tx now, with " << tx.dsts.size() << " outputs and " <<
|
||||||
tx.selected_transfers.size() << " inputs");
|
tx.selected_transfers.size() << " inputs");
|
||||||
if (use_rct)
|
if (use_rct)
|
||||||
@ -6696,6 +6707,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skip_tx:
|
||||||
// if unused_*_indices is empty while unused_*_indices_per_subaddr has multiple elements, and if we still have something to pay,
|
// if unused_*_indices is empty while unused_*_indices_per_subaddr has multiple elements, and if we still have something to pay,
|
||||||
// pop front of unused_*_indices_per_subaddr and have unused_*_indices point to the front of unused_*_indices_per_subaddr
|
// pop front of unused_*_indices_per_subaddr and have unused_*_indices point to the front of unused_*_indices_per_subaddr
|
||||||
if ((!dsts.empty() && dsts[0].amount > 0) || adding_fee)
|
if ((!dsts.empty() && dsts[0].amount > 0) || adding_fee)
|
||||||
|
Loading…
Reference in New Issue
Block a user