wallet: make sweep_all work with rct txes too
This commit is contained in:
parent
c2ec6d35b9
commit
1181c57967
|
@ -3282,14 +3282,15 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptono
|
||||||
std::vector<TX> txes;
|
std::vector<TX> txes;
|
||||||
uint64_t needed_fee, available_for_fee = 0;
|
uint64_t needed_fee, available_for_fee = 0;
|
||||||
uint64_t upper_transaction_size_limit = get_upper_tranaction_size_limit();
|
uint64_t upper_transaction_size_limit = get_upper_tranaction_size_limit();
|
||||||
|
const bool use_rct = use_fork_rules(3);
|
||||||
|
|
||||||
// gather all our dust and non dust outputs
|
// gather all our dust and non dust outputs
|
||||||
for (size_t i = 0; i < m_transfers.size(); ++i)
|
for (size_t i = 0; i < m_transfers.size(); ++i)
|
||||||
{
|
{
|
||||||
const transfer_details& td = m_transfers[i];
|
const transfer_details& td = m_transfers[i];
|
||||||
if (!td.m_spent && !td.is_rct() && is_transfer_unlocked(td))
|
if (!td.m_spent && (use_rct ? true : !td.is_rct()) && is_transfer_unlocked(td))
|
||||||
{
|
{
|
||||||
if (is_valid_decomposed_amount(td.amount()))
|
if (td.is_rct() || is_valid_decomposed_amount(td.amount()))
|
||||||
unused_transfers_indices.push_back(i);
|
unused_transfers_indices.push_back(i);
|
||||||
else
|
else
|
||||||
unused_dust_indices.push_back(i);
|
unused_dust_indices.push_back(i);
|
||||||
|
@ -3324,7 +3325,12 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptono
|
||||||
// here, check if we need to sent tx and start a new one
|
// here, check if we need to sent tx and start a new one
|
||||||
LOG_PRINT_L2("Considering whether to create a tx now, " << tx.selected_transfers.size() << " inputs, tx limit "
|
LOG_PRINT_L2("Considering whether to create a tx now, " << tx.selected_transfers.size() << " inputs, tx limit "
|
||||||
<< upper_transaction_size_limit);
|
<< upper_transaction_size_limit);
|
||||||
bool try_tx = (unused_dust_indices.empty() && unused_transfers_indices.empty()) || (tx.selected_transfers.size() * (fake_outs_count+1) * APPROXIMATE_INPUT_BYTES >= TX_SIZE_TARGET(upper_transaction_size_limit));
|
size_t estimated_rct_tx_size;
|
||||||
|
if (use_rct)
|
||||||
|
estimated_rct_tx_size = estimate_rct_tx_size(tx.selected_transfers.size(), fake_outs_count, tx.dsts.size() + 1);
|
||||||
|
else
|
||||||
|
estimated_rct_tx_size = tx.selected_transfers.size() * (fake_outs_count+1) * APPROXIMATE_INPUT_BYTES;
|
||||||
|
bool try_tx = (unused_dust_indices.empty() && unused_transfers_indices.empty()) || ( estimated_rct_tx_size >= TX_SIZE_TARGET(upper_transaction_size_limit));
|
||||||
|
|
||||||
if (try_tx) {
|
if (try_tx) {
|
||||||
cryptonote::transaction test_tx;
|
cryptonote::transaction test_tx;
|
||||||
|
@ -3336,6 +3342,10 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptono
|
||||||
|
|
||||||
LOG_PRINT_L2("Trying to create a tx now, with " << tx.dsts.size() << " destinations and " <<
|
LOG_PRINT_L2("Trying to create a tx now, with " << tx.dsts.size() << " destinations and " <<
|
||||||
tx.selected_transfers.size() << " outputs");
|
tx.selected_transfers.size() << " outputs");
|
||||||
|
if (use_rct)
|
||||||
|
transfer_selected_rct(tx.dsts, tx.selected_transfers, fake_outs_count, unlock_time, needed_fee, extra,
|
||||||
|
test_tx, test_ptx);
|
||||||
|
else
|
||||||
transfer_selected(tx.dsts, tx.selected_transfers, fake_outs_count, unlock_time, needed_fee, extra,
|
transfer_selected(tx.dsts, tx.selected_transfers, fake_outs_count, unlock_time, needed_fee, extra,
|
||||||
detail::digit_split_strategy, tx_dust_policy(::config::DEFAULT_DUST_THRESHOLD), test_tx, test_ptx);
|
detail::digit_split_strategy, tx_dust_policy(::config::DEFAULT_DUST_THRESHOLD), test_tx, test_ptx);
|
||||||
auto txBlob = t_serializable_object_to_blob(test_ptx.tx);
|
auto txBlob = t_serializable_object_to_blob(test_ptx.tx);
|
||||||
|
@ -3349,6 +3359,10 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptono
|
||||||
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");
|
||||||
tx.dsts[0].amount = available_for_fee - needed_fee;
|
tx.dsts[0].amount = available_for_fee - needed_fee;
|
||||||
|
if (use_rct)
|
||||||
|
transfer_selected_rct(tx.dsts, tx.selected_transfers, fake_outs_count, unlock_time, needed_fee, extra,
|
||||||
|
test_tx, test_ptx);
|
||||||
|
else
|
||||||
transfer_selected(tx.dsts, tx.selected_transfers, fake_outs_count, unlock_time, needed_fee, extra,
|
transfer_selected(tx.dsts, tx.selected_transfers, fake_outs_count, unlock_time, needed_fee, extra,
|
||||||
detail::digit_split_strategy, tx_dust_policy(::config::DEFAULT_DUST_THRESHOLD), test_tx, test_ptx);
|
detail::digit_split_strategy, tx_dust_policy(::config::DEFAULT_DUST_THRESHOLD), test_tx, test_ptx);
|
||||||
txBlob = t_serializable_object_to_blob(test_ptx.tx);
|
txBlob = t_serializable_object_to_blob(test_ptx.tx);
|
||||||
|
|
Loading…
Reference in New Issue