electrum

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

commit a471859a3a48f32444f4d64cd7f9365421212fa6
parent 3d78be8f465a9e0ce538e705f28b8911f6d85e6f
Author: ThomasV <thomasv@gitorious>
Date:   Mon, 14 Jul 2014 02:08:21 +0200

move master_private_keys and master_public_keys to NewWallet

Diffstat:
Mlib/wallet.py | 52++++++++++++++++++++++++++++++----------------------
1 file changed, 30 insertions(+), 22 deletions(-)

diff --git a/lib/wallet.py b/lib/wallet.py @@ -147,8 +147,6 @@ class Abstract_Wallet(object): self.history = storage.get('addr_history',{}) # address -> list(txid, height) self.fee = int(storage.get('fee_per_kb', 10000)) - self.master_public_keys = storage.get('master_public_keys',{}) - self.master_private_keys = storage.get('master_private_keys', {}) self.next_addresses = storage.get('next_addresses',{}) @@ -356,26 +354,6 @@ class Abstract_Wallet(object): account_id, sequence = self.get_address_index(address) return self.accounts[account_id].get_pubkeys(sequence) - def can_sign(self, tx): - - if self.is_watching_only(): - return False - - if tx.is_complete(): - return False - - addr_list, xpub_list = tx.inputs_to_sign() - for addr in addr_list: - if self.is_mine(addr): - return True - - mpk = [ self.master_public_keys[k] for k in self.master_private_keys.keys() ] - for xpub, sequence in xpub_list: - if xpub in mpk: - return True - - return False - def add_keypairs(self, tx, keypairs, password): # first check the provided password. This will raise if invalid. self.check_password(password) @@ -1260,6 +1238,8 @@ class NewWallet(Deterministic_Wallet): def __init__(self, storage): Deterministic_Wallet.__init__(self, storage) + self.master_public_keys = storage.get('master_public_keys', {}) + self.master_private_keys = storage.get('master_private_keys', {}) def default_account(self): return self.accounts["m/0'"] @@ -1341,6 +1321,21 @@ class NewWallet(Deterministic_Wallet): self.add_master_public_key("m/", xpub) self.add_master_private_key("m/", xpriv, password) + def can_sign(self, tx): + if self.is_watching_only(): + return False + if tx.is_complete(): + return False + addr_list, xpub_list = tx.inputs_to_sign() + for addr in addr_list: + if self.is_mine(addr): + return True + mpk = [ self.master_public_keys[k] for k in self.master_private_keys.keys() ] + for xpub, sequence in xpub_list: + if xpub in mpk: + return True + return False + def find_root_by_master_key(self, xpub): for key, xpub2 in self.master_public_keys.items(): if key == "m/":continue @@ -1542,6 +1537,19 @@ class OldWallet(Deterministic_Wallet): def check_pending_accounts(self): pass + def can_sign(self, tx): + if self.is_watching_only(): + return False + if tx.is_complete(): + return False + addr_list, xpub_list = tx.inputs_to_sign() + for addr in addr_list: + if self.is_mine(addr): + return True + for xpub, sequence in xpub_list: + if xpub == self.master_public_key: + return True + return False # former WalletFactory class Wallet(object):