|
|
|
@ -8617,15 +8617,16 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
|
|
|
|
|
|
|
|
|
TX() : weight(0), needed_fee(0) {}
|
|
|
|
|
|
|
|
|
|
void add(const account_public_address &addr, bool is_subaddress, uint64_t amount, unsigned int original_output_index, bool merge_destinations) {
|
|
|
|
|
void add(const cryptonote::tx_destination_entry &de, uint64_t amount, unsigned int original_output_index, bool merge_destinations) {
|
|
|
|
|
if (merge_destinations)
|
|
|
|
|
{
|
|
|
|
|
std::vector<cryptonote::tx_destination_entry>::iterator i;
|
|
|
|
|
i = std::find_if(dsts.begin(), dsts.end(), [&](const cryptonote::tx_destination_entry &d) { return !memcmp (&d.addr, &addr, sizeof(addr)); });
|
|
|
|
|
i = std::find_if(dsts.begin(), dsts.end(), [&](const cryptonote::tx_destination_entry &d) { return !memcmp (&d.addr, &de.addr, sizeof(de.addr)); });
|
|
|
|
|
if (i == dsts.end())
|
|
|
|
|
{
|
|
|
|
|
dsts.push_back(tx_destination_entry(0,addr,is_subaddress));
|
|
|
|
|
dsts.push_back(de);
|
|
|
|
|
i = dsts.end() - 1;
|
|
|
|
|
i->amount = 0;
|
|
|
|
|
}
|
|
|
|
|
i->amount += amount;
|
|
|
|
|
}
|
|
|
|
@ -8634,8 +8635,11 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
|
|
|
|
THROW_WALLET_EXCEPTION_IF(original_output_index > dsts.size(), error::wallet_internal_error,
|
|
|
|
|
std::string("original_output_index too large: ") + std::to_string(original_output_index) + " > " + std::to_string(dsts.size()));
|
|
|
|
|
if (original_output_index == dsts.size())
|
|
|
|
|
dsts.push_back(tx_destination_entry(0,addr,is_subaddress));
|
|
|
|
|
THROW_WALLET_EXCEPTION_IF(memcmp(&dsts[original_output_index].addr, &addr, sizeof(addr)), error::wallet_internal_error, "Mismatched destination address");
|
|
|
|
|
{
|
|
|
|
|
dsts.push_back(de);
|
|
|
|
|
dsts.back().amount = 0;
|
|
|
|
|
}
|
|
|
|
|
THROW_WALLET_EXCEPTION_IF(memcmp(&dsts[original_output_index].addr, &de.addr, sizeof(de.addr)), error::wallet_internal_error, "Mismatched destination address");
|
|
|
|
|
dsts[original_output_index].amount += amount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -8903,7 +8907,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
|
|
|
|
// we can fully pay that destination
|
|
|
|
|
LOG_PRINT_L2("We can fully pay " << get_account_address_as_str(m_nettype, dsts[0].is_subaddress, dsts[0].addr) <<
|
|
|
|
|
" for " << print_money(dsts[0].amount));
|
|
|
|
|
tx.add(dsts[0].addr, dsts[0].is_subaddress, dsts[0].amount, original_output_index, m_merge_destinations);
|
|
|
|
|
tx.add(dsts[0], dsts[0].amount, original_output_index, m_merge_destinations);
|
|
|
|
|
available_amount -= dsts[0].amount;
|
|
|
|
|
dsts[0].amount = 0;
|
|
|
|
|
pop_index(dsts, 0);
|
|
|
|
@ -8914,7 +8918,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
|
|
|
|
// we can partially fill that destination
|
|
|
|
|
LOG_PRINT_L2("We can partially pay " << get_account_address_as_str(m_nettype, dsts[0].is_subaddress, dsts[0].addr) <<
|
|
|
|
|
" for " << print_money(available_amount) << "/" << print_money(dsts[0].amount));
|
|
|
|
|
tx.add(dsts[0].addr, dsts[0].is_subaddress, available_amount, original_output_index, m_merge_destinations);
|
|
|
|
|
tx.add(dsts[0], available_amount, original_output_index, m_merge_destinations);
|
|
|
|
|
dsts[0].amount -= available_amount;
|
|
|
|
|
available_amount = 0;
|
|
|
|
|
}
|
|
|
|
|