wallet_rpc_server: add a all flag to export_outputs

if we don't want to export new outputs only
This commit is contained in:
moneromooo-monero 2019-04-10 10:37:34 +00:00
parent 5dbcceb664
commit 374f388de2
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
4 changed files with 13 additions and 9 deletions

View File

@ -11931,14 +11931,15 @@ void wallet2::import_blockchain(const std::tuple<size_t, crypto::hash, std::vect
m_last_block_reward = cryptonote::get_outs_money_amount(genesis.miner_tx); m_last_block_reward = cryptonote::get_outs_money_amount(genesis.miner_tx);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
std::pair<size_t, std::vector<tools::wallet2::transfer_details>> wallet2::export_outputs() const std::pair<size_t, std::vector<tools::wallet2::transfer_details>> wallet2::export_outputs(bool all) const
{ {
PERF_TIMER(export_outputs); PERF_TIMER(export_outputs);
std::vector<tools::wallet2::transfer_details> outs; std::vector<tools::wallet2::transfer_details> outs;
size_t offset = 0; size_t offset = 0;
while (offset < m_transfers.size() && (m_transfers[offset].m_key_image_known && !m_transfers[offset].m_key_image_request)) if (!all)
++offset; while (offset < m_transfers.size() && (m_transfers[offset].m_key_image_known && !m_transfers[offset].m_key_image_request))
++offset;
outs.reserve(m_transfers.size() - offset); outs.reserve(m_transfers.size() - offset);
for (size_t n = offset; n < m_transfers.size(); ++n) for (size_t n = offset; n < m_transfers.size(); ++n)
@ -11951,13 +11952,13 @@ std::pair<size_t, std::vector<tools::wallet2::transfer_details>> wallet2::export
return std::make_pair(offset, outs); return std::make_pair(offset, outs);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
std::string wallet2::export_outputs_to_str() const std::string wallet2::export_outputs_to_str(bool all) const
{ {
PERF_TIMER(export_outputs_to_str); PERF_TIMER(export_outputs_to_str);
std::stringstream oss; std::stringstream oss;
boost::archive::portable_binary_oarchive ar(oss); boost::archive::portable_binary_oarchive ar(oss);
const auto& outputs = export_outputs(); const auto& outputs = export_outputs(all);
ar << outputs; ar << outputs;
std::string magic(OUTPUT_EXPORT_FILE_MAGIC, strlen(OUTPUT_EXPORT_FILE_MAGIC)); std::string magic(OUTPUT_EXPORT_FILE_MAGIC, strlen(OUTPUT_EXPORT_FILE_MAGIC));

View File

@ -1135,8 +1135,8 @@ namespace tools
bool verify_with_public_key(const std::string &data, const crypto::public_key &public_key, const std::string &signature) const; bool verify_with_public_key(const std::string &data, const crypto::public_key &public_key, const std::string &signature) const;
// Import/Export wallet data // Import/Export wallet data
std::pair<size_t, std::vector<tools::wallet2::transfer_details>> export_outputs() const; std::pair<size_t, std::vector<tools::wallet2::transfer_details>> export_outputs(bool all = false) const;
std::string export_outputs_to_str() const; std::string export_outputs_to_str(bool all = false) const;
size_t import_outputs(const std::pair<size_t, std::vector<tools::wallet2::transfer_details>> &outputs); size_t import_outputs(const std::pair<size_t, std::vector<tools::wallet2::transfer_details>> &outputs);
size_t import_outputs_from_str(const std::string &outputs_st); size_t import_outputs_from_str(const std::string &outputs_st);
payment_container export_payments() const; payment_container export_payments() const;

View File

@ -2518,7 +2518,7 @@ namespace tools
try try
{ {
res.outputs_data_hex = epee::string_tools::buff_to_hex_nodelimer(m_wallet->export_outputs_to_str()); res.outputs_data_hex = epee::string_tools::buff_to_hex_nodelimer(m_wallet->export_outputs_to_str(req.all));
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {

View File

@ -47,7 +47,7 @@
// advance which version they will stop working with // advance which version they will stop working with
// Don't go over 32767 for any of these // Don't go over 32767 for any of these
#define WALLET_RPC_VERSION_MAJOR 1 #define WALLET_RPC_VERSION_MAJOR 1
#define WALLET_RPC_VERSION_MINOR 9 #define WALLET_RPC_VERSION_MINOR 10
#define MAKE_WALLET_RPC_VERSION(major,minor) (((major)<<16)|(minor)) #define MAKE_WALLET_RPC_VERSION(major,minor) (((major)<<16)|(minor))
#define WALLET_RPC_VERSION MAKE_WALLET_RPC_VERSION(WALLET_RPC_VERSION_MAJOR, WALLET_RPC_VERSION_MINOR) #define WALLET_RPC_VERSION MAKE_WALLET_RPC_VERSION(WALLET_RPC_VERSION_MAJOR, WALLET_RPC_VERSION_MINOR)
namespace tools namespace tools
@ -1622,7 +1622,10 @@ namespace wallet_rpc
{ {
struct request_t struct request_t
{ {
bool all;
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(all)
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };
typedef epee::misc_utils::struct_init<request_t> request; typedef epee::misc_utils::struct_init<request_t> request;