aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_basic
diff options
context:
space:
mode:
authorj-berman <justinberman@protonmail.com>2022-10-13 18:33:33 -0700
committerj-berman <justinberman@protonmail.com>2024-05-24 20:42:59 -0700
commite44e8b164030cfbddb9ae8b39251c1ccf396e2b6 (patch)
tree987d979f7d89e1515c57453b5b666a82b795f12e /src/cryptonote_basic
parent24ccaba6ef429fdd37a3281c586e655987201a5c (diff)
downloadmonzero-core-e44e8b164030cfbddb9ae8b39251c1ccf396e2b6.tar.gz
monzero-core-e44e8b164030cfbddb9ae8b39251c1ccf396e2b6.tar.xz
monzero-core-e44e8b164030cfbddb9ae8b39251c1ccf396e2b6.zip
wallet: background sync with just the view key
- When background syncing, the wallet wipes the spend key from memory and processes all new transactions. The wallet saves all receives, spends, and "plausible" spends of receives the wallet does not know key images for. - When background sync disabled, the wallet processes all background synced txs and then clears the background sync cache. - Adding "plausible" spends to the background sync cache ensures that the wallet does not need to query the daemon to see if any received outputs were spent while background sync was enabled. This would harm privacy especially for users of 3rd party daemons. - To enable the feature in the CLI wallet, the user can set background-sync to reuse-wallet-password or custom-background-password and the wallet automatically syncs in the background when the wallet locks, then processes all background synced txs when the wallet is unlocked. - The custom-background-password option enables the user to open a distinct background wallet that only has a view key saved and can be opened/closed/synced separately from the main wallet. When the main wallet opens, it processes the background wallet's cache. - To enable the feature in the RPC wallet, there is a new `/setup_background_sync` endpoint. - HW, multsig and view-only wallets cannot background sync.
Diffstat (limited to 'src/cryptonote_basic')
-rw-r--r--src/cryptonote_basic/account.cpp11
-rw-r--r--src/cryptonote_basic/account.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/cryptonote_basic/account.cpp b/src/cryptonote_basic/account.cpp
index 2ac455fda..4e87d4477 100644
--- a/src/cryptonote_basic/account.cpp
+++ b/src/cryptonote_basic/account.cpp
@@ -152,6 +152,17 @@ DISABLE_VS_WARNINGS(4244 4345)
m_keys.m_multisig_keys.clear();
}
//-----------------------------------------------------------------
+ void account_base::set_spend_key(const crypto::secret_key& spend_secret_key)
+ {
+ // make sure derived spend public key matches saved public spend key
+ crypto::public_key spend_public_key;
+ crypto::secret_key_to_public_key(spend_secret_key, spend_public_key);
+ CHECK_AND_ASSERT_THROW_MES(m_keys.m_account_address.m_spend_public_key == spend_public_key,
+ "Unexpected derived public spend key");
+
+ m_keys.m_spend_secret_key = spend_secret_key;
+ }
+ //-----------------------------------------------------------------
crypto::secret_key account_base::generate(const crypto::secret_key& recovery_key, bool recover, bool two_random)
{
crypto::secret_key first = generate_keys(m_keys.m_account_address.m_spend_public_key, m_keys.m_spend_secret_key, recovery_key, recover);
diff --git a/src/cryptonote_basic/account.h b/src/cryptonote_basic/account.h
index 2ee9545d4..93d1d28f0 100644
--- a/src/cryptonote_basic/account.h
+++ b/src/cryptonote_basic/account.h
@@ -95,6 +95,7 @@ namespace cryptonote
bool store(const std::string& file_path);
void forget_spend_key();
+ void set_spend_key(const crypto::secret_key& spend_secret_key);
const std::vector<crypto::secret_key> &get_multisig_keys() const { return m_keys.m_multisig_keys; }
void encrypt_keys(const crypto::chacha_key &key) { m_keys.encrypt(key); }