aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet2.cpp230
-rw-r--r--src/wallet/wallet2.h24
-rw-r--r--src/wallet/wallet_errors.h5
-rw-r--r--src/wallet/wallet_rpc_server.cpp59
-rw-r--r--src/wallet/wallet_rpc_server.h2
-rw-r--r--src/wallet/wallet_rpc_server_commands_defs.h35
6 files changed, 345 insertions, 10 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 14da8d7a2..85ca82920 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -578,6 +578,24 @@ void wallet2::pull_blocks(uint64_t start_height, uint64_t &blocks_start_height,
blocks = res.blocks;
}
//----------------------------------------------------------------------------------------------------
+void wallet2::pull_hashes(uint64_t start_height, uint64_t &blocks_start_height, const std::list<crypto::hash> &short_chain_history, std::list<crypto::hash> &hashes)
+{
+ cryptonote::COMMAND_RPC_GET_HASHES_FAST::request req = AUTO_VAL_INIT(req);
+ cryptonote::COMMAND_RPC_GET_HASHES_FAST::response res = AUTO_VAL_INIT(res);
+ req.block_ids = short_chain_history;
+
+ req.start_height = start_height;
+ m_daemon_rpc_mutex.lock();
+ bool r = net_utils::invoke_http_bin_remote_command2(m_daemon_address + "/gethashes.bin", req, res, m_http_client, WALLET_RCP_CONNECTION_TIMEOUT);
+ m_daemon_rpc_mutex.unlock();
+ THROW_WALLET_EXCEPTION_IF(!r, error::no_connection_to_daemon, "gethashes.bin");
+ THROW_WALLET_EXCEPTION_IF(res.status == CORE_RPC_STATUS_BUSY, error::daemon_busy, "gethashes.bin");
+ THROW_WALLET_EXCEPTION_IF(res.status != CORE_RPC_STATUS_OK, error::get_hashes_error, res.status);
+
+ blocks_start_height = res.start_height;
+ hashes = res.m_block_ids;
+}
+//----------------------------------------------------------------------------------------------------
void wallet2::process_blocks(uint64_t start_height, const std::list<cryptonote::block_complete_entry> &blocks, uint64_t& blocks_added)
{
size_t current_index = start_height;
@@ -772,6 +790,60 @@ void wallet2::check_pending_txes()
}
}
//----------------------------------------------------------------------------------------------------
+void wallet2::fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history)
+{
+ std::list<crypto::hash> hashes;
+ size_t current_index = m_blockchain.size();
+ while(current_index < stop_height)
+ {
+ pull_hashes(0, blocks_start_height, short_chain_history, hashes);
+ if (hashes.size() < 3)
+ return;
+ if (hashes.size() + current_index < stop_height) {
+ std::list<crypto::hash>::iterator right;
+ // drop early 3 off, skipping the genesis block
+ if (short_chain_history.size() > 3) {
+ right = short_chain_history.end();
+ std::advance(right,-1);
+ std::list<crypto::hash>::iterator left = right;
+ std::advance(left, -3);
+ short_chain_history.erase(left, right);
+ }
+ right = hashes.end();
+ // prepend 3 more
+ for (int i = 0; i<3; i++) {
+ right--;
+ short_chain_history.push_front(*right);
+ }
+ }
+ current_index = blocks_start_height;
+ BOOST_FOREACH(auto& bl_id, hashes)
+ {
+ if(current_index >= m_blockchain.size())
+ {
+ LOG_PRINT_L2( "Skipped block by height: " << current_index);
+ m_blockchain.push_back(bl_id);
+ ++m_local_bc_height;
+
+ if (0 != m_callback)
+ { // FIXME: this isn't right, but simplewallet just logs that we got a block.
+ cryptonote::block dummy;
+ m_callback->on_new_block(current_index, dummy);
+ }
+ }
+ else if(bl_id != m_blockchain[current_index])
+ {
+ //split detected here !!!
+ return;
+ }
+ ++current_index;
+ if (current_index >= stop_height)
+ return;
+ }
+ }
+}
+
+//----------------------------------------------------------------------------------------------------
void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& received_money)
{
received_money = false;
@@ -786,7 +858,22 @@ void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& re
// pull the first set of blocks
get_short_chain_history(short_chain_history);
+ if (start_height > m_blockchain.size() || m_refresh_from_block_height > m_blockchain.size()) {
+ if (!start_height)
+ start_height = m_refresh_from_block_height;
+ // we can shortcut by only pulling hashes up to the start_height
+ fast_refresh(start_height, blocks_start_height, short_chain_history);
+ // regenerate the history now that we've got a full set of hashes
+ short_chain_history.clear();
+ get_short_chain_history(short_chain_history);
+ start_height = 0;
+ // and then fall through to regular refresh processing
+ }
+
pull_blocks(start_height, blocks_start_height, short_chain_history, blocks);
+ // always reset start_height to 0 to force short_chain_ history to be used on
+ // subsequent pulls in this refresh.
+ start_height = 0;
m_run.store(true, std::memory_order_relaxed);
while(m_run.load(std::memory_order_relaxed))
@@ -1966,8 +2053,9 @@ void wallet2::commit_tx(pending_tx& ptx)
BOOST_FOREACH(transfer_container::iterator it, ptx.selected_transfers)
it->m_spent = true;
+ //fee includes dust if dust policy specified it.
LOG_PRINT_L0("Transaction successfully sent. <" << txid << ">" << ENDL
- << "Commission: " << print_money(ptx.fee+ptx.dust) << " (dust: " << print_money(ptx.dust) << ")" << ENDL
+ << "Commission: " << print_money(ptx.fee) << " (dust sent to dust addr: " << print_money((ptx.dust_added_to_fee ? 0 : ptx.dust)) << ")" << ENDL
<< "Balance: " << print_money(balance()) << ENDL
<< "Unlocked: " << print_money(unlocked_balance()) << ENDL
<< "Please, wait for confirmation for your balance to be unlocked.");
@@ -2225,10 +2313,17 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent
return true;
});
THROW_WALLET_EXCEPTION_IF(!all_are_txin_to_key, error::unexpected_txin_type, tx);
+
+
+ bool dust_sent_elsewhere = (dust_policy.addr_for_dust.m_view_public_key != change_dts.addr.m_view_public_key
+ || dust_policy.addr_for_dust.m_spend_public_key != change_dts.addr.m_spend_public_key);
+
+ if (dust_policy.add_to_fee || dust_sent_elsewhere) change_dts.amount -= dust;
ptx.key_images = key_images;
- ptx.fee = fee;
- ptx.dust = dust;
+ ptx.fee = (dust_policy.add_to_fee ? fee+dust : fee);
+ ptx.dust = ((dust_policy.add_to_fee || dust_sent_elsewhere) ? dust : 0);
+ ptx.dust_added_to_fee = dust_policy.add_to_fee;
ptx.tx = tx;
ptx.change_dts = change_dts;
ptx.selected_transfers = selected_transfers;
@@ -2393,7 +2488,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
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);
needed_fee = calculate_fee(txBlob);
- available_for_fee = test_ptx.fee + test_ptx.change_dts.amount;
+ available_for_fee = test_ptx.fee + test_ptx.change_dts.amount + (!test_ptx.dust_added_to_fee ? test_ptx.dust : 0);
LOG_PRINT_L2("Made a " << txBlob.size() << " kB tx, with " << print_money(available_for_fee) << " available for fee (" <<
print_money(needed_fee) << " needed)");
@@ -2475,6 +2570,133 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
return ptx_vector;
}
+std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, const uint64_t fee_UNUSED, const std::vector<uint8_t> extra, bool trusted_daemon)
+{
+ std::vector<size_t> unused_transfers_indices;
+ std::vector<size_t> unused_dust_indices;
+ uint64_t accumulated_fee, accumulated_outputs, accumulated_change;
+ struct TX {
+ std::list<transfer_container::iterator> selected_transfers;
+ std::vector<cryptonote::tx_destination_entry> dsts;
+ cryptonote::transaction tx;
+ pending_tx ptx;
+ size_t bytes;
+ };
+ std::vector<TX> txes;
+ uint64_t needed_fee, available_for_fee = 0;
+ uint64_t upper_transaction_size_limit = get_upper_tranaction_size_limit();
+
+ // gather all our dust and non dust outputs
+ for (size_t i = 0; i < m_transfers.size(); ++i)
+ {
+ const transfer_details& td = m_transfers[i];
+ if (!td.m_spent && is_transfer_unlocked(td))
+ {
+ if (is_valid_decomposed_amount(td.amount()))
+ unused_transfers_indices.push_back(i);
+ else
+ unused_dust_indices.push_back(i);
+ }
+ }
+ LOG_PRINT_L2("Starting with " << unused_transfers_indices.size() << " non-dust outputs and " << unused_dust_indices.size() << " dust outputs");
+
+ // start with an empty tx
+ txes.push_back(TX());
+ accumulated_fee = 0;
+ accumulated_outputs = 0;
+ accumulated_change = 0;
+ needed_fee = 0;
+
+ // while we have something to send
+ while (!unused_dust_indices.empty() || !unused_transfers_indices.empty()) {
+ TX &tx = txes.back();
+
+ // get a random unspent output and use it to pay next chunk. We try to alternate
+ // dust and non dust to ensure we never get with only dust, from which we might
+ // get a tx that can't pay for itself
+ size_t idx = unused_transfers_indices.empty() ? pop_random_value(unused_dust_indices) : unused_dust_indices.empty() ? pop_random_value(unused_transfers_indices) : ((tx.selected_transfers.size() & 1) || accumulated_outputs > FEE_PER_KB * (upper_transaction_size_limit + 1023) / 1024) ? pop_random_value(unused_dust_indices) : pop_random_value(unused_transfers_indices);
+
+ const transfer_details &td = m_transfers[idx];
+ LOG_PRINT_L2("Picking output " << idx << ", amount " << print_money(td.amount()));
+
+ // add this output to the list to spend
+ tx.selected_transfers.push_back(m_transfers.begin() + idx);
+ uint64_t available_amount = td.amount();
+ accumulated_outputs += available_amount;
+
+ // 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 "
+ << 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));
+
+ if (try_tx) {
+ cryptonote::transaction test_tx;
+ pending_tx test_ptx;
+
+ needed_fee = 0;
+
+ tx.dsts.push_back(tx_destination_entry(1, address));
+
+ LOG_PRINT_L2("Trying to create a tx now, with " << tx.dsts.size() << " destinations and " <<
+ tx.selected_transfers.size() << " outputs");
+ 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);
+ auto txBlob = t_serializable_object_to_blob(test_ptx.tx);
+ needed_fee = calculate_fee(txBlob);
+ available_for_fee = test_ptx.fee + test_ptx.dests[0].amount + test_ptx.change_dts.amount;
+ LOG_PRINT_L2("Made a " << txBlob.size() << " kB tx, with " << print_money(available_for_fee) << " available for fee (" <<
+ print_money(needed_fee) << " needed)");
+
+ THROW_WALLET_EXCEPTION_IF(needed_fee > available_for_fee, error::wallet_internal_error, "Transaction cannot pay for itself");
+
+ do {
+ LOG_PRINT_L2("We made a tx, adjusting fee and saving it");
+ tx.dsts[0].amount = available_for_fee - needed_fee;
+ 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);
+ txBlob = t_serializable_object_to_blob(test_ptx.tx);
+ needed_fee = calculate_fee(txBlob);
+ LOG_PRINT_L2("Made an attempt at a final " << ((txBlob.size() + 1023)/1024) << " kB tx, with " << print_money(test_ptx.fee) <<
+ " fee and " << print_money(test_ptx.change_dts.amount) << " change");
+ } while (needed_fee > test_ptx.fee);
+
+ LOG_PRINT_L2("Made a final " << ((txBlob.size() + 1023)/1024) << " kB tx, with " << print_money(test_ptx.fee) <<
+ " fee and " << print_money(test_ptx.change_dts.amount) << " change");
+
+ tx.tx = test_tx;
+ tx.ptx = test_ptx;
+ tx.bytes = txBlob.size();
+ accumulated_fee += test_ptx.fee;
+ accumulated_change += test_ptx.change_dts.amount;
+ if (!unused_transfers_indices.empty() || !unused_dust_indices.empty())
+ {
+ LOG_PRINT_L2("We have more to pay, starting another tx");
+ txes.push_back(TX());
+ }
+ }
+ }
+
+ LOG_PRINT_L1("Done creating " << txes.size() << " transactions, " << print_money(accumulated_fee) <<
+ " total fee, " << print_money(accumulated_change) << " total change");
+
+ std::vector<wallet2::pending_tx> ptx_vector;
+ for (std::vector<TX>::iterator i = txes.begin(); i != txes.end(); ++i)
+ {
+ TX &tx = *i;
+ uint64_t tx_money = 0;
+ for (std::list<transfer_container::iterator>::const_iterator mi = tx.selected_transfers.begin(); mi != tx.selected_transfers.end(); ++mi)
+ tx_money += (*mi)->amount();
+ LOG_PRINT_L1(" Transaction " << (1+std::distance(txes.begin(), i)) << "/" << txes.size() <<
+ ": " << (tx.bytes+1023)/1024 << " kB, sending " << print_money(tx_money) << " in " << tx.selected_transfers.size() <<
+ " outputs to " << tx.dsts.size() << " destination(s), including " <<
+ print_money(tx.ptx.fee) << " fee, " << print_money(tx.ptx.change_dts.amount) << " change");
+ ptx_vector.push_back(tx.ptx);
+ }
+
+ // if we made it this far, we're OK to actually send the transactions
+ return ptx_vector;
+}
+
uint64_t wallet2::unlocked_dust_balance(const tx_dust_policy &dust_policy) const
{
uint64_t money = 0;
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index 179d1553e..e76d7a0aa 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -143,6 +143,7 @@ namespace tools
{
cryptonote::transaction tx;
uint64_t dust, fee;
+ bool dust_added_to_fee;
cryptonote::tx_destination_entry change_dts;
std::list<transfer_container::iterator> selected_transfers;
std::string key_images;
@@ -289,6 +290,7 @@ namespace tools
void commit_tx(std::vector<pending_tx>& ptx_vector);
std::vector<pending_tx> create_transactions(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, const uint64_t fee, const std::vector<uint8_t> extra, bool trusted_daemon);
std::vector<wallet2::pending_tx> create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, const uint64_t fee_UNUSED, const std::vector<uint8_t> extra, bool trusted_daemon);
+ std::vector<wallet2::pending_tx> create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, const uint64_t fee_UNUSED, const std::vector<uint8_t> extra, bool trusted_daemon);
std::vector<pending_tx> create_unmixable_sweep_transactions(bool trusted_daemon);
bool check_connection();
void get_transfers(wallet2::transfer_container& incoming_transfers) const;
@@ -364,6 +366,12 @@ namespace tools
std::string get_wallet_file() const;
std::string get_keys_file() const;
+
+ std::vector<size_t> select_available_outputs_from_histogram(uint64_t count, bool atleast, bool trusted_daemon);
+ std::vector<size_t> select_available_outputs(const std::function<bool(const transfer_details &td)> &f);
+ std::vector<size_t> select_available_unmixable_outputs(bool trusted_daemon);
+ std::vector<size_t> select_available_mixable_outputs(bool trusted_daemon);
+
private:
/*!
* \brief Stores wallet information to wallet file.
@@ -387,6 +395,8 @@ namespace tools
bool is_transfer_unlocked(const transfer_details& td) const;
bool clear();
void pull_blocks(uint64_t start_height, uint64_t& blocks_start_height, const std::list<crypto::hash> &short_chain_history, std::list<cryptonote::block_complete_entry> &blocks);
+ void pull_hashes(uint64_t start_height, uint64_t& blocks_start_height, const std::list<crypto::hash> &short_chain_history, std::list<crypto::hash> &hashes);
+ void fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history);
void pull_next_blocks(uint64_t start_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history, const std::list<cryptonote::block_complete_entry> &prev_blocks, std::list<cryptonote::block_complete_entry> &blocks, bool &error);
void process_blocks(uint64_t start_height, const std::list<cryptonote::block_complete_entry> &blocks, uint64_t& blocks_added);
uint64_t select_transfers(uint64_t needed_money, std::vector<size_t> unused_transfers_indices, std::list<transfer_container::iterator>& selected_transfers, bool trusted_daemon);
@@ -403,10 +413,6 @@ namespace tools
uint64_t get_upper_tranaction_size_limit();
void check_pending_txes();
std::vector<uint64_t> get_unspent_amounts_vector();
- std::vector<size_t> select_available_outputs_from_histogram(uint64_t count, bool atleast, bool trusted_daemon);
- std::vector<size_t> select_available_outputs(const std::function<bool(const transfer_details &td)> &f);
- std::vector<size_t> select_available_unmixable_outputs(bool trusted_daemon);
- std::vector<size_t> select_available_mixable_outputs(bool trusted_daemon);
cryptonote::account_base m_account;
std::string m_daemon_address;
@@ -711,10 +717,16 @@ namespace tools
return true;
});
THROW_WALLET_EXCEPTION_IF(!all_are_txin_to_key, error::unexpected_txin_type, tx);
+
+ bool dust_sent_elsewhere = (dust_policy.addr_for_dust.m_view_public_key != change_dts.addr.m_view_public_key
+ || dust_policy.addr_for_dust.m_spend_public_key != change_dts.addr.m_spend_public_key);
+
+ if (dust_policy.add_to_fee || dust_sent_elsewhere) change_dts.amount -= dust;
ptx.key_images = key_images;
- ptx.fee = fee;
- ptx.dust = dust;
+ ptx.fee = (dust_policy.add_to_fee ? fee+dust : fee);
+ ptx.dust = ((dust_policy.add_to_fee || dust_sent_elsewhere) ? dust : 0);
+ ptx.dust_added_to_fee = dust_policy.add_to_fee;
ptx.tx = tx;
ptx.change_dts = change_dts;
ptx.selected_transfers = selected_transfers;
diff --git a/src/wallet/wallet_errors.h b/src/wallet/wallet_errors.h
index 3de97f49d..184d8a2a1 100644
--- a/src/wallet/wallet_errors.h
+++ b/src/wallet/wallet_errors.h
@@ -60,6 +60,7 @@ namespace tools
// acc_outs_lookup_error
// block_parse_error
// get_blocks_error
+ // get_hashes_error
// get_out_indexes_error
// tx_parse_error
// get_tx_pool_error
@@ -107,12 +108,14 @@ namespace tools
//----------------------------------------------------------------------------------------------------
const char* const failed_rpc_request_messages[] = {
"failed to get blocks",
+ "failed to get hashes",
"failed to get out indices",
"failed to get random outs"
};
enum failed_rpc_request_message_indices
{
get_blocks_error_message_index,
+ get_hashes_error_message_index,
get_out_indices_error_message_index,
get_random_outs_error_message_index
};
@@ -291,6 +294,8 @@ namespace tools
//----------------------------------------------------------------------------------------------------
typedef failed_rpc_request<refresh_error, get_blocks_error_message_index> get_blocks_error;
//----------------------------------------------------------------------------------------------------
+ typedef failed_rpc_request<refresh_error, get_hashes_error_message_index> get_hashes_error;
+ //----------------------------------------------------------------------------------------------------
typedef failed_rpc_request<refresh_error, get_out_indices_error_message_index> get_out_indices_error;
//----------------------------------------------------------------------------------------------------
struct tx_parse_error : public refresh_error
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index 6897c3d45..b01ac2f1e 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -382,6 +382,65 @@ namespace tools
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
+ bool wallet_rpc_server::on_sweep_all(const wallet_rpc::COMMAND_RPC_SWEEP_ALL::request& req, wallet_rpc::COMMAND_RPC_SWEEP_ALL::response& res, epee::json_rpc::error& er)
+ {
+ std::vector<cryptonote::tx_destination_entry> dsts;
+ std::vector<uint8_t> extra;
+
+ if (m_wallet.restricted())
+ {
+ er.code = WALLET_RPC_ERROR_CODE_DENIED;
+ er.message = "Command unavailable in restricted mode.";
+ return false;
+ }
+
+ // validate the transfer requested and populate dsts & extra
+ std::list<wallet_rpc::transfer_destination> destination;
+ destination.push_back(wallet_rpc::transfer_destination());
+ destination.back().amount = 0;
+ destination.back().address = req.address;
+ if (!validate_transfer(destination, req.payment_id, dsts, extra, er))
+ {
+ return false;
+ }
+
+ try
+ {
+ std::vector<wallet2::pending_tx> ptx_vector = m_wallet.create_transactions_all(dsts[0].addr, req.mixin, req.unlock_time, req.fee, extra, req.trusted_daemon);
+
+ m_wallet.commit_tx(ptx_vector);
+
+ // populate response with tx hashes
+ for (auto & ptx : ptx_vector)
+ {
+ res.tx_hash_list.push_back(boost::lexical_cast<std::string>(cryptonote::get_transaction_hash(ptx.tx)));
+ if (req.get_tx_keys)
+ res.tx_key_list.push_back(boost::lexical_cast<std::string>(ptx.tx_key));
+ }
+
+ return true;
+ }
+ catch (const tools::error::daemon_busy& e)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_DAEMON_IS_BUSY;
+ er.message = e.what();
+ return false;
+ }
+ catch (const std::exception& e)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR;
+ er.message = e.what();
+ return false;
+ }
+ catch (...)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = "WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR";
+ return false;
+ }
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_make_integrated_address(const wallet_rpc::COMMAND_RPC_MAKE_INTEGRATED_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_MAKE_INTEGRATED_ADDRESS::response& res, epee::json_rpc::error& er)
{
try
diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h
index 6b41df8fb..b41590de5 100644
--- a/src/wallet/wallet_rpc_server.h
+++ b/src/wallet/wallet_rpc_server.h
@@ -67,6 +67,7 @@ namespace tools
MAP_JON_RPC_WE("transfer", on_transfer, wallet_rpc::COMMAND_RPC_TRANSFER)
MAP_JON_RPC_WE("transfer_split", on_transfer_split, wallet_rpc::COMMAND_RPC_TRANSFER_SPLIT)
MAP_JON_RPC_WE("sweep_dust", on_sweep_dust, wallet_rpc::COMMAND_RPC_SWEEP_DUST)
+ MAP_JON_RPC_WE("sweep_all", on_sweep_all, wallet_rpc::COMMAND_RPC_SWEEP_ALL)
MAP_JON_RPC_WE("store", on_store, wallet_rpc::COMMAND_RPC_STORE)
MAP_JON_RPC_WE("get_payments", on_get_payments, wallet_rpc::COMMAND_RPC_GET_PAYMENTS)
MAP_JON_RPC_WE("get_bulk_payments", on_get_bulk_payments, wallet_rpc::COMMAND_RPC_GET_BULK_PAYMENTS)
@@ -87,6 +88,7 @@ namespace tools
bool on_transfer(const wallet_rpc::COMMAND_RPC_TRANSFER::request& req, wallet_rpc::COMMAND_RPC_TRANSFER::response& res, epee::json_rpc::error& er);
bool on_transfer_split(const wallet_rpc::COMMAND_RPC_TRANSFER_SPLIT::request& req, wallet_rpc::COMMAND_RPC_TRANSFER_SPLIT::response& res, epee::json_rpc::error& er);
bool on_sweep_dust(const wallet_rpc::COMMAND_RPC_SWEEP_DUST::request& req, wallet_rpc::COMMAND_RPC_SWEEP_DUST::response& res, epee::json_rpc::error& er);
+ bool on_sweep_all(const wallet_rpc::COMMAND_RPC_SWEEP_ALL::request& req, wallet_rpc::COMMAND_RPC_SWEEP_ALL::response& res, epee::json_rpc::error& er);
bool on_make_integrated_address(const wallet_rpc::COMMAND_RPC_MAKE_INTEGRATED_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_MAKE_INTEGRATED_ADDRESS::response& res, epee::json_rpc::error& er);
bool on_split_integrated_address(const wallet_rpc::COMMAND_RPC_SPLIT_INTEGRATED_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_SPLIT_INTEGRATED_ADDRESS::response& res, epee::json_rpc::error& er);
bool on_store(const wallet_rpc::COMMAND_RPC_STORE::request& req, wallet_rpc::COMMAND_RPC_STORE::response& res, epee::json_rpc::error& er);
diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h
index 2d90bf623..73ab66f9b 100644
--- a/src/wallet/wallet_rpc_server_commands_defs.h
+++ b/src/wallet/wallet_rpc_server_commands_defs.h
@@ -202,6 +202,41 @@ namespace wallet_rpc
};
};
+ struct COMMAND_RPC_SWEEP_ALL
+ {
+ struct request
+ {
+ std::string address;
+ uint64_t fee;
+ uint64_t mixin;
+ uint64_t unlock_time;
+ std::string payment_id;
+ bool get_tx_keys;
+ bool trusted_daemon;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(address)
+ KV_SERIALIZE(fee)
+ KV_SERIALIZE(mixin)
+ KV_SERIALIZE(unlock_time)
+ KV_SERIALIZE(payment_id)
+ KV_SERIALIZE(get_tx_keys)
+ KV_SERIALIZE(trusted_daemon)
+ END_KV_SERIALIZE_MAP()
+ };
+
+ struct response
+ {
+ std::list<std::string> tx_hash_list;
+ std::list<std::string> tx_key_list;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(tx_hash_list)
+ KV_SERIALIZE(tx_key_list)
+ END_KV_SERIALIZE_MAP()
+ };
+ };
+
struct COMMAND_RPC_STORE
{
struct request