Skip to content

Commit

Permalink
zero transaction size with fee for burning
Browse files Browse the repository at this point in the history
  • Loading branch information
darcys22 committed Aug 23, 2021
1 parent 7c5048a commit 8d4623e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/wallet/wallet2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8693,16 +8693,15 @@ wallet2::request_stake_unlock_result wallet2::can_request_stake_unlock(const cry
cryptonote::tx_destination_entry de = {};
de.addr = this->get_address();
de.is_subaddress = false;
de.amount = UNSTAKE_BURN_FIXED;
de.amount = 0;
dsts.push_back(de);

std::optional<uint8_t> hf_version = get_hard_fork_version();
std::vector<uint8_t> extra;
// Priority set to unimportant because it does not take effect until processed in a block
uint32_t priority = tx_priority::tx_priority_unimportant;
std::set<uint32_t> subaddr_indices = {};
oxen_construct_tx_params tx_params = wallet2::construct_params(*hf_version, cryptonote::txtype::key_image_unlock, priority);
tx_params.burn_fixed = UNSTAKE_BURN_FIXED;
oxen_construct_tx_params tx_params = wallet2::construct_params(*hf_version, cryptonote::txtype::key_image_unlock, priority, UNSTAKE_BURN_FIXED);

add_service_node_pubkey_to_tx_extra(extra, sn_key);
add_tx_key_image_unlock_to_tx_extra(extra, unlock);
Expand Down Expand Up @@ -9927,7 +9926,7 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
// throw if total amount overflows uint64_t
for(auto& dt: dsts)
{
THROW_WALLET_EXCEPTION_IF(0 == dt.amount && (tx_params.tx_type != txtype::oxen_name_system), error::zero_destination);
THROW_WALLET_EXCEPTION_IF(0 == dt.amount && !(tx_params.tx_type == txtype::oxen_name_system || tx_params.tx_type == txtype::key_image_unlock), error::zero_destination);
needed_money += dt.amount;
LOG_PRINT_L2("transfer: adding " << print_money(dt.amount) << ", for a total of " << print_money (needed_money));
THROW_WALLET_EXCEPTION_IF(needed_money < dt.amount, error::tx_sum_overflow, dsts, fee, m_nettype);
Expand Down Expand Up @@ -10874,6 +10873,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
hw::mode_resetter rst{hwdev};

bool const is_ons_tx = (tx_params.tx_type == txtype::oxen_name_system);
bool const is_unstake_tx = (tx_params.tx_type == txtype::key_image_unlock);
auto original_dsts = dsts;
if (is_ons_tx)
{
Expand Down Expand Up @@ -10965,15 +10965,16 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
needed_money = 0;
for(auto& dt: dsts)
{
THROW_WALLET_EXCEPTION_IF(0 == dt.amount && !is_ons_tx, error::zero_destination);
THROW_WALLET_EXCEPTION_IF(0 == dt.amount && !(is_ons_tx || is_unstake_tx), error::zero_destination);

needed_money += dt.amount;
LOG_PRINT_L2("transfer: adding " << print_money(dt.amount) << ", for a total of " << print_money (needed_money));
THROW_WALLET_EXCEPTION_IF(needed_money < dt.amount, error::tx_sum_overflow, dsts, 0, m_nettype);
}


// throw if attempting a transaction with no money
THROW_WALLET_EXCEPTION_IF(needed_money == 0 && !is_ons_tx, error::zero_destination);
THROW_WALLET_EXCEPTION_IF(needed_money == 0 && !(is_ons_tx || is_unstake_tx), error::zero_destination);

std::map<uint32_t, std::pair<uint64_t, std::pair<uint64_t, uint64_t>>> unlocked_balance_per_subaddr = unlocked_balance_per_subaddress(subaddr_account, false);
std::map<uint32_t, uint64_t> balance_per_subaddr = balance_per_subaddress(subaddr_account, false);
Expand Down

0 comments on commit 8d4623e

Please sign in to comment.