1
0

replace wallet.interface everywhere

This commit is contained in:
thomasv
2013-09-12 14:58:42 +02:00
parent 907dca6eb9
commit 6b6c508976
10 changed files with 87 additions and 86 deletions

View File

@@ -242,17 +242,16 @@ class InstallWizard(QDialog):
def restore_wallet(self, wallet):
# wait until we are connected, because the user might have selected another server
if not wallet.interface.is_connected:
waiting = lambda: False if wallet.interface.is_connected else "%s \n" % (_("Connecting..."))
if not self.network.interface.is_connected:
waiting = lambda: False if self.network.interface.is_connected else "%s \n" % (_("Connecting..."))
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.addresses(True)),_("Kilobytes received:"), wallet.interface.bytes_received/1024.)
%(_("Please wait..."),_("Addresses generated:"),len(wallet.addresses(True)),_("Kilobytes received:"), self.network.interface.bytes_received/1024.)
# try to restore old account
wallet.create_old_account()
wallet.set_up_to_date(False)
wallet.interface.poke('synchronizer')
waiting_dialog(waiting)
if wallet.is_found():
@@ -262,7 +261,6 @@ class InstallWizard(QDialog):
wallet.accounts.pop(0)
wallet.create_accounts()
wallet.set_up_to_date(False)
wallet.interface.poke('synchronizer')
waiting_dialog(waiting)
if wallet.is_found():

View File

@@ -832,6 +832,7 @@ class MiniDriver(QObject):
super(QObject, self).__init__()
self.wallet = wallet
self.network = wallet.network
self.window = window
self.wallet.network.register_callback('updated',self.update_callback)
@@ -851,9 +852,9 @@ class MiniDriver(QObject):
self.emit(SIGNAL("updatesignal()"))
def update(self):
if not self.wallet.interface:
if not self.network.interface:
self.initializing()
elif not self.wallet.interface.is_connected:
elif not self.network.interface.is_connected:
self.connecting()
elif not self.wallet.up_to_date:
self.synchronizing()

View File

@@ -281,13 +281,11 @@ class ElectrumWindow(QMainWindow):
self.show_message("file not found "+ filename)
return
interface = self.wallet.interface
blockchain = self.wallet.verifier.blockchain
self.wallet.stop_threads()
# create new wallet
wallet = Wallet(storage)
wallet.start_threads(interface, blockchain)
wallet.start_threads(network)
self.load_wallet(wallet)
@@ -302,7 +300,7 @@ class ElectrumWindow(QMainWindow):
storage = WalletStorage({'wallet_path': filename})
assert not storage.file_exists
wizard = installwizard.InstallWizard(self.config, self.wallet.interface, self.wallet.verifier.blockchain, storage)
wizard = installwizard.InstallWizard(self.config, self.network, storage)
wallet = wizard.run()
if wallet:
self.load_wallet(wallet)
@@ -410,12 +408,12 @@ class ElectrumWindow(QMainWindow):
def notify_transactions(self):
print_error("Notifying GUI")
if len(self.wallet.interface.pending_transactions_for_notifications) > 0:
if len(self.network.interface.pending_transactions_for_notifications) > 0:
# Combine the transactions if there are more then three
tx_amount = len(self.wallet.interface.pending_transactions_for_notifications)
tx_amount = len(self.network.interface.pending_transactions_for_notifications)
if(tx_amount >= 3):
total_amount = 0
for tx in self.wallet.interface.pending_transactions_for_notifications:
for tx in self.network.interface.pending_transactions_for_notifications:
is_relevant, is_mine, v, fee = self.wallet.get_tx_value(tx)
if(v > 0):
total_amount += v
@@ -423,11 +421,11 @@ class ElectrumWindow(QMainWindow):
self.notify("%s new transactions received. Total amount received in the new transactions %s %s" \
% (tx_amount, self.format_amount(total_amount), self.base_unit()))
self.wallet.interface.pending_transactions_for_notifications = []
self.network.interface.pending_transactions_for_notifications = []
else:
for tx in self.wallet.interface.pending_transactions_for_notifications:
for tx in self.network.interface.pending_transactions_for_notifications:
if tx:
self.wallet.interface.pending_transactions_for_notifications.remove(tx)
self.network.interface.pending_transactions_for_notifications.remove(tx)
is_relevant, is_mine, v, fee = self.wallet.get_tx_value(tx)
if(v > 0):
self.notify("New transaction received. %s %s" % (self.format_amount(v), self.base_unit()))
@@ -535,7 +533,7 @@ class ElectrumWindow(QMainWindow):
return "BTC" if self.decimal_point == 8 else "mBTC"
def update_status(self):
if self.wallet.interface and self.wallet.interface.is_connected:
if self.network.interface and self.network.interface.is_connected:
if not self.wallet.up_to_date:
text = _("Synchronizing...")
icon = QIcon(":icons/status_waiting.png")
@@ -555,7 +553,7 @@ class ElectrumWindow(QMainWindow):
def update_wallet(self):
self.update_status()
if self.wallet.up_to_date or not self.wallet.interface.is_connected:
if self.wallet.up_to_date or not self.network.interface.is_connected:
self.update_history_tab()
self.update_receive_tab()
self.update_contacts_tab()
@@ -1308,7 +1306,7 @@ class ElectrumWindow(QMainWindow):
console.updateNamespace({'wallet' : self.wallet, 'network' : self.network, 'gui':self})
console.updateNamespace({'util' : util, 'bitcoin':bitcoin})
c = commands.Commands(self.wallet, self.wallet.interface, lambda: self.console.set_json(True))
c = commands.Commands(self.wallet, self.network.interface, lambda: self.console.set_json(True))
methods = {}
def mkfunc(f, method):
return lambda *args: apply( f, (method, args, self.password_dialog ))

View File

@@ -239,5 +239,6 @@ class NetworkDialog(QDialog):
self.config.set_key("proxy", proxy, True)
self.config.set_key("server", server, True)
self.network.set_server(server, proxy)
self.config.set_key('auto_cycle', self.autocycle_cb.isChecked(), True)
return True

View File

@@ -33,7 +33,7 @@ import platform
MONOSPACE_FONT = 'Lucida Console' if platform.system() == 'Windows' else 'monospace'
from electrum.util import format_satoshis
from electrum.interface import DEFAULT_SERVERS
from electrum.network import DEFAULT_SERVERS
from electrum.bitcoin import MIN_RELAY_TX_FEE
def numbify(entry, is_int = False):
@@ -268,7 +268,7 @@ def run_settings_dialog(wallet, parent):
def run_network_dialog( wallet, parent ):
image = gtk.Image()
image.set_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_DIALOG)
interface = wallet.interface
interface = wallet.network.interface
if parent:
if interface.is_connected:
status = "Connected to %s:%d\n%d blocks"%(interface.host, interface.port, wallet.network.blockchain.height)
@@ -279,7 +279,7 @@ def run_network_dialog( wallet, parent ):
status = "Please choose a server.\nSelect cancel if you are offline."
server = interface.server
servers = interface.get_servers()
servers = wallet.network.get_servers()
dialog = gtk.MessageDialog( parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, status)
@@ -345,7 +345,7 @@ def run_network_dialog( wallet, parent ):
treeview = gtk.TreeView(model=server_list)
treeview.show()
if wallet.interface.servers:
if interface.servers:
label = 'Active Servers'
else:
label = 'Default Servers'
@@ -1107,7 +1107,7 @@ class ElectrumWindow:
return vbox
def update_status_bar(self):
interface = self.wallet.interface
interface = self.wallet.network.interface
if self.funds_error:
text = "Not enough funds"
elif interface and interface.is_connected:
@@ -1133,7 +1133,7 @@ class ElectrumWindow:
self.update_history_tab()
self.update_receiving_tab()
# addressbook too...
self.info.set_text( self.wallet.interface.banner )
self.info.set_text( self.wallet.network.banner )
self.wallet_updated = False
def update_receiving_tab(self):

View File

@@ -102,7 +102,7 @@ class ElectrumGui:
def print_balance(self):
if self.wallet.interface and self.wallet.interface.is_connected:
if self.network.interface and self.network.interface.is_connected:
if not self.wallet.up_to_date:
msg = _( "Synchronizing..." )
else:
@@ -143,7 +143,7 @@ class ElectrumGui:
self.stdscr.addstr( 12, 25, _("[Clear]"), curses.A_REVERSE if self.pos%6==5 else curses.color_pair(2))
def print_banner(self):
for i, x in enumerate( self.wallet.interface.banner.split('\n') ):
for i, x in enumerate( self.network.banner.split('\n') ):
self.stdscr.addstr( 1+i, 1, x )
def print_list(self, list, firstline):
@@ -318,7 +318,7 @@ class ElectrumGui:
def network_dialog(self):
out = self.run_dialog('Network', [
{'label':'server', 'type':'str', 'value':self.wallet.interface.server},
{'label':'server', 'type':'str', 'value':self.network.interface.server},
{'label':'proxy', 'type':'str', 'value':self.config.get('proxy', '')},
], buttons = 1)
if out:
@@ -331,7 +331,7 @@ class ElectrumGui:
self.wallet.config.set_key("proxy", proxy, True)
self.wallet.config.set_key("server", server, True)
self.wallet.interface.set_server(server, proxy)
self.network.interface.set_server(server, proxy)