From 225a25f327f42a6f97e594e94d899ded55ef9cad Mon Sep 17 00:00:00 2001 From: Jaquee Date: Fri, 18 Aug 2017 14:19:07 +0200 Subject: import_key_images - allow importing without being connected to daemon --- src/wallet/wallet2.cpp | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'src/wallet/wallet2.cpp') diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index b63e07b2d..bde439cfe 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -5324,7 +5324,7 @@ uint64_t wallet2::import_key_images(const std::string &filename, uint64_t &spent } //---------------------------------------------------------------------------------------------------- -uint64_t wallet2::import_key_images(const std::vector> &signed_key_images, uint64_t &spent, uint64_t &unspent) +uint64_t wallet2::import_key_images(const std::vector> &signed_key_images, uint64_t &spent, uint64_t &unspent, bool check_spent) { COMMAND_RPC_IS_KEY_IMAGE_SPENT::request req = AUTO_VAL_INIT(req); COMMAND_RPC_IS_KEY_IMAGE_SPENT::response daemon_resp = AUTO_VAL_INIT(daemon_resp); @@ -5373,32 +5373,37 @@ uint64_t wallet2::import_key_images(const std::vector Date: Fri, 18 Aug 2017 14:27:54 +0200 Subject: wallet2: export/import wallet data functions --- src/wallet/wallet2.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/wallet/wallet2.h | 7 ++++++- 2 files changed, 55 insertions(+), 1 deletion(-) (limited to 'src/wallet/wallet2.cpp') diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index bde439cfe..3ddc2c634 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -5406,6 +5406,55 @@ uint64_t wallet2::import_key_images(const std::vector> &confirmed_payments) +{ + m_confirmed_txs.clear(); + for (auto const &p : confirmed_payments) + { + m_confirmed_txs.emplace(p); + } +} + +std::vector wallet2::export_blockchain() const +{ + std::vector bc; + for (auto const &b : m_blockchain) + { + bc.push_back(b); + } + return bc; +} + +void wallet2::import_blockchain(const std::vector &bc) +{ + m_blockchain.clear(); + for (auto const &b : bc) + { + m_blockchain.push_back(b); + } + cryptonote::block genesis; + generate_genesis(genesis); + crypto::hash genesis_hash = get_block_hash(genesis); + check_genesis(genesis_hash); + m_local_bc_height = m_blockchain.size(); +} //---------------------------------------------------------------------------------------------------- std::vector wallet2::export_outputs() const { diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index c275ba2a3..c14707477 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -580,9 +580,14 @@ namespace tools std::string sign(const std::string &data) const; bool verify(const std::string &data, const cryptonote::account_public_address &address, const std::string &signature) const; + // Import/Export wallet data std::vector export_outputs() const; size_t import_outputs(const std::vector &outputs); - + payment_container export_payments() const; + void import_payments(const payment_container &payments); + void import_payments_out(const std::list> &confirmed_payments); + std::vector export_blockchain() const; + void import_blockchain(const std::vector &bc); bool export_key_images(const std::string filename); std::vector> export_key_images() const; uint64_t import_key_images(const std::vector> &signed_key_images, uint64_t &spent, uint64_t &unspent, bool check_spent = true); -- cgit v1.2.3