diff --git a/electrum/json_db.py b/electrum/json_db.py index d16031865..4b87e6f59 100644 --- a/electrum/json_db.py +++ b/electrum/json_db.py @@ -88,7 +88,10 @@ def key_path(path, key): else: assert isinstance(x, str) return x - return '/' + '/'.join([to_str(x) for x in path + [to_str(key)]]) + items = [to_str(x) for x in path] + if key is not None: + items.append(to_str(key)) + return '/' + '/'.join(items) class StoredObject: @@ -209,6 +212,12 @@ class StoredList(list): if self.db: self.db.add_patch({'op': 'remove', 'path': key_path(self.path, '%d'%n)}) + @locked + def clear(self): + list.clear(self) + if self.db: + self.db.add_patch({'op': 'replace', 'path': key_path(self.path, None), 'value':[]}) + class JsonDB(Logger):