electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit f956363d889d49d65fc19dd560692487498aa2b5
parent 3d34fd9294ea5178002fe29e540c95a928223449
Author: ThomasV <thomasv@electrum.org>
Date:   Tue,  1 Aug 2017 15:07:51 +0200

Merge pull request #2669 from neocogent/contacts-validate

Validate and extract contacts on import
Diffstat:
Mlib/contacts.py | 14+++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/contacts.py b/lib/contacts.py @@ -55,7 +55,7 @@ class Contacts(dict): def import_file(self, path): try: with open(path, 'r') as f: - d = json.loads(f.read()) + d = self._validate(json.loads(f.read())) except: return self.update(d) @@ -116,4 +116,16 @@ class Contacts(dict): return regex.search(haystack).groups()[0] except AttributeError: return None + + def _validate(self, data): + for k,v in data.items(): + if k == 'contacts': + return self._validate(v) + if not bitcoin.is_address(k): + data.pop(k) + else: + _type,_ = v + if _type != 'address': + data.pop(k) + return data