tvarious bugfixes for imported addresses - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 0c6d4702964d8b65bfef3b28985df8b2e17f9df5 DIR parent 57a0864055cdc9f3f8f733122ca63465f87e4dd4 HTML Author: ThomasV <thomasv@gitorious> Date: Tue, 24 Jun 2014 16:47:58 +0200 various bugfixes for imported addresses Diffstat: M lib/account.py | 3 +++ M lib/wallet.py | 38 +++++++++++++++++-------------- 2 files changed, 24 insertions(+), 17 deletions(-) --- DIR diff --git a/lib/account.py b/lib/account.py t@@ -91,6 +91,9 @@ class ImportedAccount(Account): addr = self.get_addresses(0)[i] return self.keypairs[addr][0] + def get_xpubkeys(self, *sequence): + return self.get_pubkeys(*sequence) + def get_private_key(self, sequence, wallet, password): from wallet import pw_decode for_change, i = sequence DIR diff --git a/lib/wallet.py b/lib/wallet.py t@@ -383,11 +383,12 @@ class Abstract_Wallet: def add_keypairs(self, tx, keypairs, password): # first check the provided password. This will raise if invalid. - self.get_seed(password) + self.check_password(password) + addr_list, xpub_list = tx.inputs_to_sign() for addr in addr_list: if self.is_mine(addr): - private_keys = self.get_private_key(address, password) + private_keys = self.get_private_key(addr, password) for sec in private_keys: pubkey = public_key_from_private_key(sec) keypairs[ pubkey ] = sec t@@ -1005,6 +1006,20 @@ class Abstract_Wallet: c, u = self.get_addr_balance(address) return len(h), len(h) > 0 and c == -u + def address_is_old(self, address, age_limit=2): + age = -1 + h = self.history.get(address, []) + if h == ['*']: + return True + for tx_hash, tx_height in h: + if tx_height == 0: + tx_age = 0 + else: + tx_age = self.network.get_local_height() - tx_height + 1 + if tx_age > age: + age = tx_age + return age > age_limit + class Imported_Wallet(Abstract_Wallet): t@@ -1033,6 +1048,9 @@ class Imported_Wallet(Abstract_Wallet): h = self.history.get(address,[]) return len(h), False + def get_master_public_keys(self): + return {} + class Deterministic_Wallet(Abstract_Wallet): t@@ -1115,20 +1133,6 @@ class Deterministic_Wallet(Abstract_Wallet): if n > nmax: nmax = n return nmax + 1 - def address_is_old(self, address): - age = -1 - h = self.history.get(address, []) - if h == ['*']: - return True - for tx_hash, tx_height in h: - if tx_height == 0: - tx_age = 0 - else: - tx_age = self.network.get_local_height() - tx_height + 1 - if tx_age > age: - age = tx_age - return age > 2 - def synchronize_sequence(self, account, for_change): limit = self.gap_limit_for_change if for_change else self.gap_limit new_addresses = [] t@@ -1274,7 +1278,7 @@ class NewWallet(Deterministic_Wallet): def create_accounts(self, password): # First check the password is valid (this raises if it isn't). - pw_decode(self.seed, password) + self.check_password(password) self.create_account('Main account', password) def add_master_public_key(self, name, mpk):