diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-04-12 13:36:46 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-04-12 13:40:42 +0000 |
commit | bcb86ae6516ffd18bdd7bb4fa89be1def0588878 (patch) | |
tree | 1d52de7160f27894aa1898c23b6dd92e3c5125b0 /utils/python-rpc | |
parent | Merge pull request #5386 (diff) | |
download | monero-bcb86ae6516ffd18bdd7bb4fa89be1def0588878.tar.xz |
wallet_rpc_server: fix inconsistent wallet caches on reload
Loading the same wallet as the currently loaded one would autosave
the current state after loading it, leading to some kind of rollback
effect. We now save before loading to avoid this. If loading fails,
it means the current wallet will be saved (or maybe not, depending
on where the failure occurs: most of the sanity checks occur before
saving). There is a new autosave_current flag to open/restore calls
so the (enabled by default) autosave can be skipped.
Diffstat (limited to 'utils/python-rpc')
-rw-r--r-- | utils/python-rpc/framework/wallet.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/utils/python-rpc/framework/wallet.py b/utils/python-rpc/framework/wallet.py index a80aaefec..a55750e3a 100644 --- a/utils/python-rpc/framework/wallet.py +++ b/utils/python-rpc/framework/wallet.py @@ -265,7 +265,7 @@ class Wallet(object): } return self.rpc.send_json_rpc_request(query_key) - def restore_deterministic_wallet(self, seed = '', seed_offset = '', filename = '', restore_height = 0, password = '', language = ''): + def restore_deterministic_wallet(self, seed = '', seed_offset = '', filename = '', restore_height = 0, password = '', language = '', autosave_current = True): restore_deterministic_wallet = { 'method': 'restore_deterministic_wallet', 'params' : { @@ -274,14 +274,15 @@ class Wallet(object): 'seed': seed, 'seed_offset': seed_offset, 'password': password, - 'language': language + 'language': language, + 'autosave_current': autosave_current, }, 'jsonrpc': '2.0', 'id': '0' } return self.rpc.send_json_rpc_request(restore_deterministic_wallet) - def generate_from_keys(self, restore_height = 0, filename = "", password = "", address = "", spendkey = "", viewkey = ""): + def generate_from_keys(self, restore_height = 0, filename = "", password = "", address = "", spendkey = "", viewkey = "", autosave_current = True): generate_from_keys = { 'method': 'generate_from_keys', 'params' : { @@ -291,16 +292,31 @@ class Wallet(object): 'spendkey': spendkey, 'viewkey': viewkey, 'password': password, + 'autosave_current': autosave_current, }, 'jsonrpc': '2.0', 'id': '0' } return self.rpc.send_json_rpc_request(generate_from_keys) - def close_wallet(self): + def open_wallet(self, filename, password='', autosave_current = True): + open_wallet = { + 'method': 'open_wallet', + 'params' : { + 'filename': filename, + 'password': password, + 'autosave_current': autosave_current, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(open_wallet) + + def close_wallet(self, autosave_current = True): close_wallet = { 'method': 'close_wallet', 'params' : { + 'autosave_current': autosave_current }, 'jsonrpc': '2.0', 'id': '0' |