electrum

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

commit c533b797e0d2d976da3ee1ab1afb7f5562f5747b
parent a3830e5903fb11319fdd4397bb94fae1ff71b76c
Author: Julian Tosh <Julian@Tosh.us>
Date:   Sat,  7 Jul 2012 06:41:16 -0700

Merge branch 'master' of gitorious.org:electrum/electrum

Diffstat:
Mlib/gui_lite.py | 20+++++++++++++++++++-
Mlib/wallet.py | 75++++++++++++++++++++++++++++++++++++++++-----------------------------------
2 files changed, 59 insertions(+), 36 deletions(-)

diff --git a/lib/gui_lite.py b/lib/gui_lite.py @@ -120,7 +120,8 @@ class MiniWindow(QDialog): self.connect(expand_button, SIGNAL("clicked()"), expand_callback) self.btc_balance = None - self.quote_currencies = ("EUR", "USD", "GBP") + self.quote_currencies = ["EUR", "USD", "GBP"] + self.actuator.set_configured_currency(self.set_quote_currency) self.exchanger = exchange_rate.Exchanger(self) # Needed because price discovery is done in a different thread # which needs to be sent back to this main one to update the GUI @@ -212,9 +213,16 @@ class MiniWindow(QDialog): def deactivate(self): pass + def set_quote_currency(self, currency): + assert currency in self.quote_currencies + self.quote_currencies.remove(currency) + self.quote_currencies = [currency] + self.quote_currencies + self.refresh_balance() + def change_quote_currency(self): self.quote_currencies = \ self.quote_currencies[1:] + self.quote_currencies[0:1] + self.actuator.set_config_currency(self.quote_currencies[0]) self.refresh_balance() def refresh_balance(self): @@ -440,9 +448,19 @@ class MiniActuator: def __init__(self, wallet): self.wallet = wallet + def set_configured_currency(self, set_quote_currency): + currency = self.wallet.conversion_currency + assert currency is not None + set_quote_currency(currency) + + def set_config_currency(self, conversion_currency): + self.wallet.conversion_currency = conversion_currency + def copy_address(self, receive_popup): addrs = [addr for addr in self.wallet.all_addresses() if not self.wallet.is_change(addr)] + # Select most recent addresses from gap limit + addrs = addrs[-self.wallet.gap_limit:] copied_address = random.choice(addrs) qApp.clipboard().setText(copied_address) receive_popup.setup(copied_address) diff --git a/lib/wallet.py b/lib/wallet.py @@ -281,6 +281,7 @@ class Wallet: self.fee = 100000 self.num_zeros = 0 self.master_public_key = '' + self.conversion_currency = None # saved fields self.use_encryption = False @@ -638,30 +639,34 @@ class Wallet: def save(self): + # TODO: Need special config storage class. Should not be mixed + # up with the wallet. + # Settings should maybe be stored in a flat ini file. s = { - 'seed_version':self.seed_version, - 'use_encryption':self.use_encryption, - 'use_change':self.use_change, + 'seed_version': self.seed_version, + 'use_encryption': self.use_encryption, + 'use_change': self.use_change, 'master_public_key': self.master_public_key.encode('hex'), - 'fee':self.fee, - 'server':self.server, - 'seed':self.seed, - 'addresses':self.addresses, - 'change_addresses':self.change_addresses, - 'history':self.history, - 'labels':self.labels, - 'contacts':self.addressbook, - 'imported_keys':self.imported_keys, - 'aliases':self.aliases, - 'authorities':self.authorities, - 'receipts':self.receipts, - 'num_zeros':self.num_zeros, - 'frozen_addresses':self.frozen_addresses, - 'prioritized_addresses':self.prioritized_addresses, - 'expert_mode':self.expert_mode, - 'gap_limit':self.gap_limit, - 'debug_server':self.debug_server, - } + 'fee': self.fee, + 'server': self.server, + 'seed': self.seed, + 'addresses': self.addresses, + 'change_addresses': self.change_addresses, + 'history': self.history, + 'labels': self.labels, + 'contacts': self.addressbook, + 'imported_keys': self.imported_keys, + 'aliases': self.aliases, + 'authorities': self.authorities, + 'receipts': self.receipts, + 'num_zeros': self.num_zeros, + 'frozen_addresses': self.frozen_addresses, + 'prioritized_addresses': self.prioritized_addresses, + 'expert_mode': self.expert_mode, + 'gap_limit': self.gap_limit, + 'debug_server': self.debug_server, + 'conversion_currency': self.conversion_currency + } f = open(self.path,"w") f.write( repr(s) ) f.close() @@ -685,26 +690,26 @@ class Wallet: self.seed_version = d.get('seed_version') self.master_public_key = d.get('master_public_key').decode('hex') self.use_encryption = d.get('use_encryption') - self.use_change = bool(d.get('use_change',True)) - self.fee = int( d.get('fee') ) + self.use_change = bool(d.get('use_change', True)) + self.fee = int(d.get('fee')) self.seed = d.get('seed') self.server = d.get('server') - #blocks = d.get('blocks') self.addresses = d.get('addresses') self.change_addresses = d.get('change_addresses') self.history = d.get('history') self.labels = d.get('labels') self.addressbook = d.get('contacts') - self.imported_keys = d.get('imported_keys',{}) - self.aliases = d.get('aliases',{}) - self.authorities = d.get('authorities',{}) - self.receipts = d.get('receipts',{}) - self.num_zeros = d.get('num_zeros',0) - self.frozen_addresses = d.get('frozen_addresses',[]) - self.prioritized_addresses = d.get('prioritized_addresses',[]) - self.expert_mode = d.get('expert_mode',False) - self.gap_limit = d.get('gap_limit',5) - self.debug_server = d.get('debug_server',False) + self.imported_keys = d.get('imported_keys', {}) + self.aliases = d.get('aliases', {}) + self.authorities = d.get('authorities', {}) + self.receipts = d.get('receipts', {}) + self.num_zeros = d.get('num_zeros', 0) + self.frozen_addresses = d.get('frozen_addresses', []) + self.prioritized_addresses = d.get('prioritized_addresses', []) + self.expert_mode = d.get('expert_mode', False) + self.gap_limit = d.get('gap_limit', 5) + self.debug_server = d.get('debug_server', False) + self.conversion_currency = d.get('conversion_currency', 'USD') except: raise BaseException("cannot read wallet file")