electrum

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

commit 97e03cb73850664d948de068bd4dcb355c296a82
parent e84d087a640bbcc878b3c235c1a3e0186562c34d
Author: thomasv <thomasv@gitorious>
Date:   Sat,  2 Mar 2013 11:40:17 +0100

replace wallet.all_addresses() with wallet.addresses(True)

Diffstat:
Mlib/commands.py | 6+++---
Mlib/gui.py | 2+-
Mlib/gui_lite.py | 2+-
Mlib/gui_qt.py | 4++--
Mlib/receiving_widget.py | 2+-
Mlib/wallet.py | 29+++++++++++++++--------------
6 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/lib/commands.py b/lib/commands.py @@ -148,7 +148,7 @@ class Commands: def dumpprivkeys(self, addresses = None): if addresses is None: - addresses = self.wallet.all_addresses() + addresses = self.wallet.addresses(True) return self.wallet.get_private_keys(addresses, self.password) def validateaddress(self,addr): @@ -220,7 +220,7 @@ class Commands: if not is_valid(from_addr): raise BaseException("invalid Bitcoin address", from_addr) - if from_addr not in self.wallet.all_addresses(): + if not self.wallet.is_mine(from_addr): raise BaseException("address not in wallet") for k, v in self.wallet.labels.items(): @@ -281,7 +281,7 @@ class Commands: def listaddresses(self, show_all = False, show_balance = False, show_label = False): out = [] - for addr in self.wallet.all_addresses(): + for addr in self.wallet.addresses(True): if show_all or not self.wallet.is_change(addr): if show_balance or show_label: item = { 'address': addr } diff --git a/lib/gui.py b/lib/gui.py @@ -1134,7 +1134,7 @@ class ElectrumWindow: def update_receiving_tab(self): self.recv_list.clear() - for address in self.wallet.all_addresses(): + for address in self.wallet.addresses(True): if self.wallet.is_change(address):continue label = self.wallet.labels.get(address) h = self.wallet.history.get(address,[]) diff --git a/lib/gui_lite.py b/lib/gui_lite.py @@ -795,7 +795,7 @@ class MiniActuator: def copy_address(self, receive_popup): """Copy the wallet addresses into the client.""" - addrs = [addr for addr in self.wallet.all_addresses() + addrs = [addr for addr in self.wallet.addresses(True) if not self.wallet.is_change(addr)] # Select most recent addresses from gap limit addrs = addrs[-self.wallet.gap_limit:] diff --git a/lib/gui_qt.py b/lib/gui_qt.py @@ -1987,7 +1987,7 @@ class ElectrumWindow(QMainWindow): transaction.writerow(["address", "private_key"]) - for addr, pk in self.wallet.get_private_keys(self.wallet.all_addresses(), password).items(): + for addr, pk in self.wallet.get_private_keys(self.wallet.addresses(True), password).items(): transaction.writerow(["%34s"%addr,pk]) self.show_message(_("Private keys exported.")) @@ -2510,7 +2510,7 @@ class ElectrumGui: waiting_dialog(waiting) waiting = lambda: False if wallet.is_up_to_date() else "%s\n%s %d\n%s %.1f"\ - %(_("Please wait..."),_("Addresses generated:"),len(wallet.all_addresses()),_("Kilobytes received:"), wallet.interface.bytes_received/1024.) + %(_("Please wait..."),_("Addresses generated:"),len(wallet.addresses(True)),_("Kilobytes received:"), wallet.interface.bytes_received/1024.) wallet.set_up_to_date(False) wallet.interface.poke('synchronizer') diff --git a/lib/receiving_widget.py b/lib/receiving_widget.py @@ -36,7 +36,7 @@ class ReceivingWidget(QTreeWidget): def update_list(self): self.clear() - addresses = [addr for addr in self.owner.actuator.wallet.all_addresses() if not self.owner.actuator.wallet.is_change(addr)] + addresses = self.owner.actuator.wallet.addresses() for address in addresses: history = self.owner.actuator.wallet.history.get(address,[]) diff --git a/lib/wallet.py b/lib/wallet.py @@ -150,7 +150,7 @@ class Wallet: seed = self.decode_seed(password) address = address_from_private_key(sec) - if address in self.all_addresses(): + if self.is_mine(address): raise BaseException('Address already in wallet') # store the originally requested keypair into the imported keys table @@ -178,16 +178,16 @@ class Wallet: - def all_addresses(self): + def addresses(self, include_change = False): o = self.imported_keys.keys() for a in self.accounts.values(): o += a[0] - o += a[1] + if include_change: o += a[1] return o def is_mine(self, address): - return address in self.all_addresses() + return address in self.addresses(True) def is_change(self, address): #return address in self.change_addresses @@ -419,7 +419,7 @@ class Wallet: def get_tx_value(self, tx, addresses=None): - if addresses is None: addresses = self.all_addresses() + if addresses is None: addresses = self.addresses(True) return tx.get_value(addresses, self.prevout_values) @@ -549,7 +549,7 @@ class Wallet: def get_unspent_coins(self, domain=None): coins = [] - if domain is None: domain = self.all_addresses() + if domain is None: domain = self.addresses(True) for addr in domain: h = self.history.get(addr, []) if h == ['*']: continue @@ -572,7 +572,7 @@ class Wallet: coins = [] prioritized_coins = [] - domain = [from_addr] if from_addr else self.all_addresses() + domain = [from_addr] if from_addr else self.addresses(True) for i in self.frozen_addresses: if i in domain: domain.remove(i) @@ -603,7 +603,8 @@ class Wallet: if change_amount != 0: # normally, the update thread should ensure that the last change address is unused if not change_addr: - change_addr = self.change_addresses[-self.gap_limit_for_change] + change_addresses = self.accounts[0][1] + change_addr = change_addresses[-self.gap_limit_for_change] # Insert the change output at a random position in the outputs posn = random.randint(0, len(outputs)) outputs[posn:posn] = [( change_addr, change_amount)] @@ -911,7 +912,7 @@ class Wallet: if label and self.labels.get(address) != label: if question('Give label "%s" to address %s ?'%(label,address)): - if address not in self.addressbook and address not in self.all_addresses(): + if address not in self.addressbook and not self.is_mine(address): self.addressbook.append(address) self.labels[address] = label @@ -941,7 +942,7 @@ class Wallet: def freeze(self,addr): - if addr in self.all_addresses() and addr not in self.frozen_addresses: + if self.is_mine(addr) and addr not in self.frozen_addresses: self.unprioritize(addr) self.frozen_addresses.append(addr) self.config.set_key('frozen_addresses', self.frozen_addresses, True) @@ -950,7 +951,7 @@ class Wallet: return False def unfreeze(self,addr): - if addr in self.all_addresses() and addr in self.frozen_addresses: + if self.is_mine(addr) and addr in self.frozen_addresses: self.frozen_addresses.remove(addr) self.config.set_key('frozen_addresses', self.frozen_addresses, True) return True @@ -958,7 +959,7 @@ class Wallet: return False def prioritize(self,addr): - if addr in self.all_addresses() and addr not in self.prioritized_addresses: + if is_mine(addr) and addr not in self.prioritized_addresses: self.unfreeze(addr) self.prioritized_addresses.append(addr) self.config.set_key('prioritized_addresses', self.prioritized_addresses, True) @@ -967,7 +968,7 @@ class Wallet: return False def unprioritize(self,addr): - if addr in self.all_addresses() and addr in self.prioritized_addresses: + if is_mine(addr) and addr in self.prioritized_addresses: self.prioritized_addresses.remove(addr) self.config.set_key('prioritized_addresses', self.prioritized_addresses, True) return True @@ -1185,7 +1186,7 @@ class WalletSynchronizer(threading.Thread): self.interface.send([('server.banner',[])],'synchronizer') # subscriptions - self.subscribe_to_addresses(self.wallet.all_addresses()) + self.subscribe_to_addresses(self.wallet.addresses(True)) while self.is_running(): # 1. send new requests