diff options
Diffstat (limited to 'patches/wownero/0003-wallet-background-sync-with-just-the-view-key.patch')
| -rw-r--r-- | patches/wownero/0003-wallet-background-sync-with-just-the-view-key.patch | 85 |
1 files changed, 45 insertions, 40 deletions
diff --git a/patches/wownero/0003-wallet-background-sync-with-just-the-view-key.patch b/patches/wownero/0003-wallet-background-sync-with-just-the-view-key.patch index 95a8cfa..e87a73c 100644 --- a/patches/wownero/0003-wallet-background-sync-with-just-the-view-key.patch +++ b/patches/wownero/0003-wallet-background-sync-with-just-the-view-key.patch @@ -1,4 +1,4 @@ -From 9d6099e9c47f7cbd12f4d6550d6fda520733c2c5 Mon Sep 17 00:00:00 2001 +From ebd0430956c71356ffa3ae0f5cbc90a749ceabc7 Mon Sep 17 00:00:00 2001 From: j-berman <justinberman@protonmail.com> Date: Thu, 13 Oct 2022 18:33:33 -0700 Subject: [PATCH 3/9] wallet: background sync with just the view key @@ -32,11 +32,11 @@ cache. src/cryptonote_config.h | 2 + src/simplewallet/simplewallet.cpp | 205 +++- src/simplewallet/simplewallet.h | 1 + - src/wallet/api/wallet.cpp | 230 +++- + src/wallet/api/wallet.cpp | 231 +++- src/wallet/api/wallet.h | 12 + - src/wallet/api/wallet2_api.h | 41 + - src/wallet/wallet2.cpp | 1029 ++++++++++++++++-- - src/wallet/wallet2.h | 155 ++- + src/wallet/api/wallet2_api.h | 42 + + src/wallet/wallet2.cpp | 1031 ++++++++++++++++-- + src/wallet/wallet2.h | 156 ++- src/wallet/wallet_errors.h | 39 + src/wallet/wallet_rpc_server.cpp | 162 +++ src/wallet/wallet_rpc_server.h | 6 + @@ -47,7 +47,7 @@ cache. tests/functional_tests/wallet.py | 43 +- tests/unit_tests/wipeable_string.cpp | 12 + utils/python-rpc/framework/wallet.py | 42 + - 20 files changed, 2350 insertions(+), 132 deletions(-) + 20 files changed, 2354 insertions(+), 133 deletions(-) diff --git a/src/cryptonote_basic/account.cpp b/src/cryptonote_basic/account.cpp index 4931c3740..2d556f285 100644 @@ -84,7 +84,7 @@ index 0099ebfe7..1f76febce 100644 void encrypt_keys(const crypto::chacha_key &key) { m_keys.encrypt(key); } diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h -index 1c1830ad4..a192bd64d 100644 +index 5b36c70de..d9151e8d2 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -255,6 +255,8 @@ namespace config @@ -748,7 +748,7 @@ index 8e3477ba3..ae1aa312b 100644 bool set_show_detailed_prompt(const std::vector<std::string> &args = std::vector<std::string>()); bool set_inactivity_lock_timeout(const std::vector<std::string> &args = std::vector<std::string>()); diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp -index db9c2b5d9..5ef3132d2 100644 +index ceb0bcb8b..bf8a95ffe 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -56,6 +56,40 @@ using namespace cryptonote; @@ -1167,7 +1167,7 @@ index db9c2b5d9..5ef3132d2 100644 void WalletImpl::clearStatus() const { boost::lock_guard<boost::mutex> l(m_statusMutex); -@@ -2670,11 +2857,22 @@ void WalletImpl::doRefresh() +@@ -2670,11 +2857,23 @@ void WalletImpl::doRefresh() boost::lock_guard<boost::mutex> guarg(m_refreshMutex2); do try { LOG_PRINT_L3(__FUNCTION__ << ": doRefresh, rescan = "<<rescan); @@ -1176,6 +1176,7 @@ index db9c2b5d9..5ef3132d2 100644 - m_wallet->refresh(true); - if (!m_synchronized) { - m_synchronized = true; ++ + // Syncing daemon and refreshing wallet simultaneously is very resource intensive. + // Disable refresh if wallet is disconnected or daemon isn't synced. + if (m_wallet->light_wallet() || daemonSynced()) { @@ -1195,7 +1196,7 @@ index db9c2b5d9..5ef3132d2 100644 } // assuming if we have empty history, it wasn't initialized yet // for further history changes client need to update history in -@@ -2784,6 +2982,24 @@ bool WalletImpl::doInit(const string &daemon_address, const std::string &proxy_a +@@ -2784,6 +2983,24 @@ bool WalletImpl::doInit(const string &daemon_address, const std::string &proxy_a return true; } @@ -1220,7 +1221,7 @@ index db9c2b5d9..5ef3132d2 100644 bool WalletImpl::parse_uri(const std::string &uri, std::string &address, std::string &payment_id, uint64_t &amount, std::string &tx_description, std::string &recipient_name, std::vector<std::string> &unknown_parameters, std::string &error) { return m_wallet->parse_uri(uri, address, payment_id, amount, tx_description, recipient_name, unknown_parameters, error); -@@ -2802,6 +3018,8 @@ std::string WalletImpl::getDefaultDataDir() const +@@ -2802,6 +3019,8 @@ std::string WalletImpl::getDefaultDataDir() const bool WalletImpl::rescanSpent() { clearStatus(); @@ -1267,7 +1268,7 @@ index 28135c82a..fc6341861 100644 std::unique_ptr<TransactionHistoryImpl> m_history; std::unique_ptr<Wallet2CallbackImpl> m_wallet2Callback; diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h -index a0ed60a39..626c63fc5 100644 +index a0ed60a39..db5509227 100644 --- a/src/wallet/api/wallet2_api.h +++ b/src/wallet/api/wallet2_api.h @@ -544,6 +544,12 @@ struct Wallet @@ -1283,10 +1284,10 @@ index a0ed60a39..626c63fc5 100644 virtual ~Wallet() = 0; virtual std::string seed(const std::string& seed_offset = "") const = 0; virtual std::string getSeedLanguage() const = 0; -@@ -1094,6 +1100,41 @@ struct Wallet - virtual std::string printScannedPoolTxs() = 0; +@@ -1095,6 +1101,42 @@ struct Wallet virtual bool importTransaction(const std::string &txid, std::vector<uint64_t> &o_indices, uint64_t height, uint8_t block_version, uint64_t ts, bool miner_tx, bool pool, bool double_spend_seen) = 0; + + /*! + * \brief setupBackgroundSync - setup background sync mode with just a view key + * \param background_sync_type - the mode the wallet background syncs in @@ -1322,11 +1323,12 @@ index a0ed60a39..626c63fc5 100644 + * @brief isBackgroundWallet - returns true if the wallet is a background wallet + */ + virtual bool isBackgroundWallet() const = 0; - ++ virtual TransactionHistory * history() = 0; virtual AddressBook * addressBook() = 0; + virtual Coins * coins() = 0; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp -index 83aba6253..d7e2a9699 100644 +index dfcc206a0..e013313b9 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -158,6 +158,8 @@ static const std::string MULTISIG_SIGNATURE_MAGIC = "SigMultisigPkV1"; @@ -1364,18 +1366,18 @@ index 83aba6253..d7e2a9699 100644 { locked = false; return; -@@ -1235,6 +1237,11 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended, std +@@ -1233,6 +1235,11 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended, std + m_ignore_outputs_above(MONEY_SUPPLY), + m_ignore_outputs_below(0), m_track_uses(false), - m_show_wallet_name_when_locked(true), - m_show_detailed_prompt(true), + m_is_background_wallet(false), + m_background_sync_type(BackgroundSyncOff), + m_background_syncing(false), + m_processing_background_cache(false), + m_custom_background_key(boost::none), + m_show_wallet_name_when_locked(true), + m_show_detailed_prompt(true), m_inactivity_lock_timeout(DEFAULT_INACTIVITY_LOCK_TIMEOUT), - m_setup_background_mining(BackgroundMiningNo), - m_persistent_rpc_client_id(false), @@ -1897,6 +1904,9 @@ bool has_nonrequested_tx_at_height_or_above_requested(uint64_t height, const std //---------------------------------------------------------------------------------------------------- void wallet2::scan_tx(const std::unordered_set<crypto::hash> &txids) @@ -1845,17 +1847,19 @@ index 83aba6253..d7e2a9699 100644 // The contents should be JSON if the wallet follows the new format. if (json.Parse(account_data.c_str()).HasParseError()) { -@@ -4864,6 +5090,7 @@ bool wallet2::load_keys_buf(const std::string& keys_buf, const epee::wipeable_st +@@ -4862,7 +5088,8 @@ bool wallet2::load_keys_buf(const std::string& keys_buf, const epee::wipeable_st + m_ignore_outputs_above = MONEY_SUPPLY; + m_ignore_outputs_below = 0; m_track_uses = false; - m_show_wallet_name_when_locked = true; - m_show_detailed_prompt = true; +- m_show_wallet_name_when_locked = true; + m_background_sync_type = BackgroundSyncOff; ++ m_show_wallet_name_when_locked = false; + m_show_detailed_prompt = true; m_inactivity_lock_timeout = DEFAULT_INACTIVITY_LOCK_TIMEOUT; m_setup_background_mining = BackgroundMiningNo; - m_subaddress_lookahead_major = SUBADDRESS_LOOKAHEAD_MAJOR; @@ -4881,6 +5108,7 @@ bool wallet2::load_keys_buf(const std::string& keys_buf, const epee::wipeable_st m_enable_multisig = false; - m_allow_mismatched_daemon_version = true; + m_allow_mismatched_daemon_version = false; m_polyseed = false; + m_custom_background_key = boost::none; } @@ -2769,7 +2773,7 @@ index 83aba6253..d7e2a9699 100644 { payment_container payments; diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h -index db5c1feb3..2f2664f8e 100644 +index db5c1feb3..009dce766 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -257,6 +257,20 @@ private: @@ -2931,16 +2935,17 @@ index db5c1feb3..2f2664f8e 100644 bool show_wallet_name_when_locked() const { return m_show_wallet_name_when_locked; } void show_wallet_name_when_locked(bool value) { m_show_wallet_name_when_locked = value; } bool show_detailed_prompt() const { return m_show_detailed_prompt; } -@@ -1738,6 +1824,8 @@ private: - std::string printTxPrefix(const cryptonote::transaction_prefix &tx); +@@ -1739,6 +1825,9 @@ private: std::string printPaymentDetails(const payment_details &pd); std::string printTxDestinationEntry(const cryptonote::tx_destination_entry &tx); + + void start_background_sync(); + void stop_background_sync(const epee::wipeable_string &wallet_password, const crypto::secret_key &spend_secret_key = crypto::null_skey); - ++ // MMS ------------------------------------------------------------------------------------------------- mms::message_store& get_message_store() { return m_message_store; }; -@@ -1775,6 +1863,9 @@ private: + const mms::message_store& get_message_store() const { return m_message_store; }; +@@ -1775,6 +1864,9 @@ private: * \return Whether it was successful. */ bool store_keys(const std::string& keys_file_name, const epee::wipeable_string& password, bool watch_only = false); @@ -2950,7 +2955,7 @@ index db5c1feb3..2f2664f8e 100644 /*! * \brief Load wallet keys information from wallet file. * \param keys_file_name Name of wallet file -@@ -1788,6 +1879,7 @@ private: +@@ -1788,6 +1880,7 @@ private: */ bool load_keys_buf(const std::string& keys_buf, const epee::wipeable_string& password); bool load_keys_buf(const std::string& keys_buf, const epee::wipeable_string& password, boost::optional<crypto::chacha_key>& keys_to_encrypt); @@ -2958,7 +2963,7 @@ index db5c1feb3..2f2664f8e 100644 void process_new_transaction(const crypto::hash &txid, const cryptonote::transaction& tx, const std::vector<uint64_t> &o_indices, uint64_t height, uint8_t block_version, uint64_t ts, bool miner_tx, bool pool, bool double_spend_seen, const tx_cache_data &tx_cache_data, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL, bool ignore_callbacks = false); bool should_skip_block(const cryptonote::block &b, uint64_t height) const; void process_new_blockchain_entry(const cryptonote::block& b, const cryptonote::block_complete_entry& bche, const parsed_block &parsed_block, const crypto::hash& bl_id, uint64_t height, const std::vector<tx_cache_data> &tx_cache_data, size_t tx_cache_data_offset, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL); -@@ -1796,6 +1888,15 @@ private: +@@ -1796,6 +1889,15 @@ private: void get_short_chain_history(std::list<crypto::hash>& ids, uint64_t granularity = 1) const; bool clear(); void clear_soft(bool keep_key_images=false); @@ -2974,7 +2979,7 @@ index db5c1feb3..2f2664f8e 100644 void pull_blocks(bool first, bool try_incremental, uint64_t start_height, uint64_t& blocks_start_height, const std::list<crypto::hash> &short_chain_history, std::vector<cryptonote::block_complete_entry> &blocks, std::vector<cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices> &o_indices, uint64_t ¤t_height); void pull_hashes(uint64_t start_height, uint64_t& blocks_start_height, const std::list<crypto::hash> &short_chain_history, std::vector<crypto::hash> &hashes); void fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history, bool force = false); -@@ -1847,10 +1948,23 @@ private: +@@ -1847,10 +1949,23 @@ private: bool get_ring(const crypto::chacha_key &key, const crypto::key_image &key_image, std::vector<uint64_t> &outs); crypto::chacha_key get_ringdb_key(); void setup_keys(const epee::wipeable_string &password); @@ -2998,7 +3003,7 @@ index db5c1feb3..2f2664f8e 100644 void register_devices(); hw::device& lookup_device(const std::string & device_descriptor); -@@ -1966,6 +2080,8 @@ private: +@@ -1966,6 +2081,8 @@ private: uint64_t m_ignore_outputs_above; uint64_t m_ignore_outputs_below; bool m_track_uses; @@ -3007,7 +3012,7 @@ index db5c1feb3..2f2664f8e 100644 bool m_show_wallet_name_when_locked; bool m_show_detailed_prompt; uint32_t m_inactivity_lock_timeout; -@@ -2012,6 +2128,7 @@ private: +@@ -2012,6 +2129,7 @@ private: uint64_t m_last_block_reward; std::unique_ptr<tools::file_locker> m_keys_file_locker; @@ -3015,7 +3020,7 @@ index db5c1feb3..2f2664f8e 100644 mms::message_store m_message_store; bool m_original_keys_available; -@@ -2019,6 +2136,7 @@ private: +@@ -2019,6 +2137,7 @@ private: crypto::secret_key m_original_view_secret_key; crypto::chacha_key m_cache_key; @@ -3023,7 +3028,7 @@ index db5c1feb3..2f2664f8e 100644 std::shared_ptr<wallet_keys_unlocker> m_encrypt_keys_after_refresh; bool m_unattended; -@@ -2034,9 +2152,13 @@ private: +@@ -2034,9 +2153,13 @@ private: static boost::mutex default_daemon_address_lock; static std::string default_daemon_address; @@ -3038,7 +3043,7 @@ index db5c1feb3..2f2664f8e 100644 BOOST_CLASS_VERSION(tools::wallet2::transfer_details, 12) BOOST_CLASS_VERSION(tools::wallet2::multisig_info, 1) BOOST_CLASS_VERSION(tools::wallet2::multisig_info::LR, 0) -@@ -2052,6 +2174,8 @@ BOOST_CLASS_VERSION(tools::wallet2::signed_tx_set, 1) +@@ -2052,6 +2175,8 @@ BOOST_CLASS_VERSION(tools::wallet2::signed_tx_set, 1) BOOST_CLASS_VERSION(tools::wallet2::tx_construction_data, 4) BOOST_CLASS_VERSION(tools::wallet2::pending_tx, 3) BOOST_CLASS_VERSION(tools::wallet2::multisig_sig, 1) @@ -3047,7 +3052,7 @@ index db5c1feb3..2f2664f8e 100644 namespace boost { -@@ -2550,6 +2674,29 @@ namespace boost +@@ -2550,6 +2675,29 @@ namespace boost return; a & x.multisig_sigs; } |
