wallet_rpc_server: add all field to export_key_images

To use if you want all key images, not just the ones for
recently imported outputs
This commit is contained in:
moneromooo-monero 2018-12-24 12:58:25 +00:00
parent ed54ac8fdf
commit d7354c7864
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
4 changed files with 12 additions and 6 deletions

View file

@ -10771,14 +10771,17 @@ bool wallet2::export_key_images(const std::string &filename) const
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
std::pair<size_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> wallet2::export_key_images() const std::pair<size_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> wallet2::export_key_images(bool all) const
{ {
PERF_TIMER(export_key_images_raw); PERF_TIMER(export_key_images_raw);
std::vector<std::pair<crypto::key_image, crypto::signature>> ski; std::vector<std::pair<crypto::key_image, crypto::signature>> ski;
size_t offset = 0; size_t offset = 0;
if (!all)
{
while (offset < m_transfers.size() && !m_transfers[offset].m_key_image_requested) while (offset < m_transfers.size() && !m_transfers[offset].m_key_image_requested)
++offset; ++offset;
}
ski.reserve(m_transfers.size() - offset); ski.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)

View file

@ -1109,7 +1109,7 @@ namespace tools
std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> export_blockchain() const; std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> export_blockchain() const;
void import_blockchain(const std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> &bc); void import_blockchain(const std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> &bc);
bool export_key_images(const std::string &filename) const; bool export_key_images(const std::string &filename) const;
std::pair<size_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> export_key_images() const; std::pair<size_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> export_key_images(bool all = false) const;
uint64_t import_key_images(const std::vector<std::pair<crypto::key_image, crypto::signature>> &signed_key_images, size_t offset, uint64_t &spent, uint64_t &unspent, bool check_spent = true); uint64_t import_key_images(const std::vector<std::pair<crypto::key_image, crypto::signature>> &signed_key_images, size_t offset, uint64_t &spent, uint64_t &unspent, bool check_spent = true);
uint64_t import_key_images(const std::string &filename, uint64_t &spent, uint64_t &unspent); uint64_t import_key_images(const std::string &filename, uint64_t &spent, uint64_t &unspent);
bool import_key_images(std::vector<crypto::key_image> key_images); bool import_key_images(std::vector<crypto::key_image> key_images);

View file

@ -2495,7 +2495,7 @@ namespace tools
if (!m_wallet) return not_open(er); if (!m_wallet) return not_open(er);
try try
{ {
std::pair<size_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> ski = m_wallet->export_key_images(); std::pair<size_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> ski = m_wallet->export_key_images(req.all);
res.offset = ski.first; res.offset = ski.first;
res.signed_key_images.resize(ski.second.size()); res.signed_key_images.resize(ski.second.size());
for (size_t n = 0; n < ski.second.size(); ++n) for (size_t n = 0; n < ski.second.size(); ++n)

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 6 #define WALLET_RPC_VERSION_MINOR 7
#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
@ -1565,7 +1565,10 @@ namespace wallet_rpc
{ {
struct request struct request
{ {
bool all;
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_OPT(all, false);
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };