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.
This commit is contained in:
j-berman 2022-10-13 18:33:33 -07:00
parent 24ccaba6ef
commit e44e8b1640
20 changed files with 2342 additions and 135 deletions

View file

@ -37,6 +37,8 @@
from __future__ import print_function
import subprocess
import psutil
import os
import errno
def available_ram_gb():
ram_bytes = psutil.virtual_memory().available
@ -51,3 +53,26 @@ def get_time_pi_seconds(cores, app_dir='.'):
miliseconds = int(decoded)
return miliseconds / 1000.0
def remove_file(name):
WALLET_DIRECTORY = os.environ['WALLET_DIRECTORY']
assert WALLET_DIRECTORY != ''
try:
os.unlink(WALLET_DIRECTORY + '/' + name)
except OSError as e:
if e.errno != errno.ENOENT:
raise
def get_file_path(name):
WALLET_DIRECTORY = os.environ['WALLET_DIRECTORY']
assert WALLET_DIRECTORY != ''
return WALLET_DIRECTORY + '/' + name
def remove_wallet_files(name):
for suffix in ['', '.keys', '.background', '.background.keys', '.address.txt']:
remove_file(name + suffix)
def file_exists(name):
WALLET_DIRECTORY = os.environ['WALLET_DIRECTORY']
assert WALLET_DIRECTORY != ''
return os.path.isfile(WALLET_DIRECTORY + '/' + name)