Browse Source

Rename single-letter main window variable from `w`

master
chris-belcher 6 years ago
parent
commit
fdc6194006
  1. 72
      scripts/joinmarket-qt.py

72
scripts/joinmarket-qt.py

@ -167,7 +167,7 @@ class HelpLabel(QLabel):
self.setStyleSheet(BLUE_FG) self.setStyleSheet(BLUE_FG)
def mouseReleaseEvent(self, x): def mouseReleaseEvent(self, x):
QMessageBox.information(w, self.wtitle, self.help_text) QMessageBox.information(mainWindow, self.wtitle, self.help_text)
def enterEvent(self, event): def enterEvent(self, event):
self.font.setUnderline(True) self.font.setUnderline(True)
@ -243,7 +243,7 @@ class SettingsTab(QDialog):
oname = 'network' oname = 'network'
oval = 'testnet' if checked else 'mainnet' oval = 'testnet' if checked else 'mainnet'
add = '' if not checked else ' - Testnet' add = '' if not checked else ' - Testnet'
w.setWindowTitle(appWindowTitle + add) mainWindow.setWindowTitle(appWindowTitle + add)
else: else:
oname = str(t[0].text()) oname = str(t[0].text())
oval = 'true' if checked else 'false' oval = 'true' if checked else 'false'
@ -371,7 +371,7 @@ class SpendTab(QWidget):
JMQtMessageBox(self, "Not a valid JM schedule file", mbtype='crit', JMQtMessageBox(self, "Not a valid JM schedule file", mbtype='crit',
title='Error') title='Error')
else: else:
w.statusBar().showMessage("Schedule loaded OK.") mainWindow.statusBar().showMessage("Schedule loaded OK.")
self.spendstate.loaded_schedule = schedule self.spendstate.loaded_schedule = schedule
self.spendstate.schedule_name = os.path.basename(str(firstarg[0])) self.spendstate.schedule_name = os.path.basename(str(firstarg[0]))
self.updateSchedView() self.updateSchedView()
@ -516,17 +516,14 @@ class SpendTab(QWidget):
def updateConsoleText(self, txt): def updateConsoleText(self, txt):
#these alerts are a bit suboptimal; #these alerts are a bit suboptimal;
#colored is better, and in the ultra-rare #colored is better
#case of getting both, one will be swallowed.
#However, the transaction confirmation dialog #However, the transaction confirmation dialog
#will at least show both in RED and BOLD, and they will be more prominent. #will at least show both in RED and BOLD, and they will be more prominent.
#TODO in new daemon this is not accessible? Or? #TODO in new daemon this is not accessible? Or?
""" """
if joinmarket_alert[0]: if joinmarket_alert[0]:
w.statusBar().showMessage("JOINMARKET ALERT: " + joinmarket_alert[ mainWindow.statusBar().showMessage("JOINMARKET ALERT: " + joinmarket_alert[
0]) 0])
if core_alert[0]:
w.statusBar().showMessage("BITCOIN CORE ALERT: " + core_alert[0])
""" """
self.textedit.insertPlainText(txt) self.textedit.insertPlainText(txt)
@ -537,7 +534,7 @@ class SpendTab(QWidget):
if restart_wait(self.waitingtxid): if restart_wait(self.waitingtxid):
self.restartTimer.stop() self.restartTimer.stop()
self.waitingtxid = None self.waitingtxid = None
w.statusBar().showMessage("Transaction in a block, now continuing.") mainWindow.statusBar().showMessage("Transaction in a block, now continuing.")
self.startJoin() self.startJoin()
def startMultiple(self): def startMultiple(self):
@ -573,7 +570,7 @@ class SpendTab(QWidget):
self.spendstate.loaded_schedule[0][5]) == 64: self.spendstate.loaded_schedule[0][5]) == 64:
#ensure last transaction is confirmed before restart #ensure last transaction is confirmed before restart
tumble_log.info("WAITING TO RESTART...") tumble_log.info("WAITING TO RESTART...")
w.statusBar().showMessage("Waiting for confirmation to restart..") mainWindow.statusBar().showMessage("Waiting for confirmation to restart..")
txid = self.spendstate.loaded_schedule[0][5] txid = self.spendstate.loaded_schedule[0][5]
#remove the already-done entry (this connects to the other TODO, #remove the already-done entry (this connects to the other TODO,
#probably better *not* to truncate the done-already txs from file, #probably better *not* to truncate the done-already txs from file,
@ -622,7 +619,7 @@ class SpendTab(QWidget):
makercount = int(self.widgets[1][1].text()) makercount = int(self.widgets[1][1].text())
mixdepth = int(self.widgets[2][1].text()) mixdepth = int(self.widgets[2][1].text())
if makercount == 0: if makercount == 0:
txid = direct_send(w.wallet_service, amount, mixdepth, txid = direct_send(mainWindow.wallet_service, amount, mixdepth,
destaddr, accept_callback=self.checkDirectSend, destaddr, accept_callback=self.checkDirectSend,
info_callback=self.infoDirectSend) info_callback=self.infoDirectSend)
if not txid: if not txid:
@ -652,7 +649,7 @@ class SpendTab(QWidget):
self.startJoin() self.startJoin()
def startJoin(self): def startJoin(self):
if not w.wallet_service: if not mainWindow.wallet_service:
JMQtMessageBox(self, "Cannot start without a loaded wallet.", JMQtMessageBox(self, "Cannot start without a loaded wallet.",
mbtype="crit", title="Error") mbtype="crit", title="Error")
return return
@ -666,7 +663,7 @@ class SpendTab(QWidget):
check_offers_callback = None check_offers_callback = None
destaddrs = self.tumbler_destaddrs if self.tumbler_options else [] destaddrs = self.tumbler_destaddrs if self.tumbler_options else []
self.taker = Taker(w.wallet_service, self.taker = Taker(mainWindow.wallet_service,
self.spendstate.loaded_schedule, self.spendstate.loaded_schedule,
order_chooser=weighted_order_choose, order_chooser=weighted_order_choose,
callbacks=[check_offers_callback, callbacks=[check_offers_callback,
@ -690,7 +687,7 @@ class SpendTab(QWidget):
#This will re-use IRC connections in background (daemon), no restart #This will re-use IRC connections in background (daemon), no restart
self.clientfactory.getClient().client = self.taker self.clientfactory.getClient().client = self.taker
self.clientfactory.getClient().clientStart() self.clientfactory.getClient().clientStart()
w.statusBar().showMessage("Connecting to IRC ...") mainWindow.statusBar().showMessage("Connecting to IRC ...")
def takerInfo(self, infotype, infomsg): def takerInfo(self, infotype, infomsg):
if infotype == "INFO": if infotype == "INFO":
@ -698,7 +695,7 @@ class SpendTab(QWidget):
if len(infomsg) > 200: if len(infomsg) > 200:
log.info("INFO: " + infomsg) log.info("INFO: " + infomsg)
else: else:
w.statusBar().showMessage(infomsg) mainWindow.statusBar().showMessage(infomsg)
elif infotype == "ABORT": elif infotype == "ABORT":
JMQtMessageBox(self, infomsg, JMQtMessageBox(self, infomsg,
mbtype='warn') mbtype='warn')
@ -795,7 +792,7 @@ class SpendTab(QWidget):
#GUI-specific updates; QTimer.singleShot serves the role #GUI-specific updates; QTimer.singleShot serves the role
#of reactor.callLater #of reactor.callLater
if fromtx == "unconfirmed": if fromtx == "unconfirmed":
w.statusBar().showMessage( mainWindow.statusBar().showMessage(
"Transaction seen on network: " + self.taker.txid) "Transaction seen on network: " + self.taker.txid)
if self.spendstate.typestate == 'single': if self.spendstate.typestate == 'single':
JMQtMessageBox(self, "Transaction broadcast OK. You can safely \n" JMQtMessageBox(self, "Transaction broadcast OK. You can safely \n"
@ -813,7 +810,7 @@ class SpendTab(QWidget):
return return
if fromtx: if fromtx:
if res: if res:
w.statusBar().showMessage("Transaction confirmed: " + self.taker.txid) mainWindow.statusBar().showMessage("Transaction confirmed: " + self.taker.txid)
#singleShot argument is in milliseconds #singleShot argument is in milliseconds
if self.nextTxTimer: if self.nextTxTimer:
self.nextTxTimer.stop() self.nextTxTimer.stop()
@ -825,14 +822,14 @@ class SpendTab(QWidget):
# self.startNextTransaction) # self.startNextTransaction)
else: else:
if self.tumbler_options: if self.tumbler_options:
w.statusBar().showMessage("Transaction failed, trying again...") mainWindow.statusBar().showMessage("Transaction failed, trying again...")
QtCore.QTimer.singleShot(0, self.startNextTransaction) QtCore.QTimer.singleShot(0, self.startNextTransaction)
else: else:
#currently does not continue for non-tumble schedules #currently does not continue for non-tumble schedules
self.giveUp() self.giveUp()
else: else:
if res: if res:
w.statusBar().showMessage("All transaction(s) completed successfully.") mainWindow.statusBar().showMessage("All transaction(s) completed successfully.")
if len(self.taker.schedule) == 1: if len(self.taker.schedule) == 1:
msg = "Transaction has been confirmed.\n" + "Txid: " + \ msg = "Transaction has been confirmed.\n" + "Txid: " + \
str(self.taker.txid) str(self.taker.txid)
@ -851,7 +848,7 @@ class SpendTab(QWidget):
).strftime("%Y/%m/%d %H:%M:%S")])).encode('utf-8')) ).strftime("%Y/%m/%d %H:%M:%S")])).encode('utf-8'))
f.write(b'\n') #TODO: Windows f.write(b'\n') #TODO: Windows
#update the TxHistory tab #update the TxHistory tab
txhist = w.centralWidget().widget(3) txhist = mainWindow.centralWidget().widget(3)
txhist.updateTxInfo() txhist.updateTxInfo()
def toggleButtons(self): def toggleButtons(self):
@ -888,7 +885,7 @@ class SpendTab(QWidget):
"""Inform the user that the transaction failed, then reset state. """Inform the user that the transaction failed, then reset state.
""" """
log.debug("Transaction aborted.") log.debug("Transaction aborted.")
w.statusBar().showMessage("Transaction aborted.") mainWindow.statusBar().showMessage("Transaction aborted.")
if self.taker and len(self.taker.ignored_makers) > 0: if self.taker and len(self.taker.ignored_makers) > 0:
JMQtMessageBox(self, "These Makers did not respond, and will be \n" JMQtMessageBox(self, "These Makers did not respond, and will be \n"
"ignored in future: \n" + str( "ignored in future: \n" + str(
@ -921,7 +918,7 @@ class SpendTab(QWidget):
if len(self.widgets[i][1].text()) == 0: if len(self.widgets[i][1].text()) == 0:
JMQtMessageBox(self, errs[i - 1], mbtype='warn', title="Error") JMQtMessageBox(self, errs[i - 1], mbtype='warn', title="Error")
return False return False
if not w.wallet_service: if not mainWindow.wallet_service:
JMQtMessageBox(self, JMQtMessageBox(self,
"There is no wallet loaded.", "There is no wallet loaded.",
mbtype='warn', mbtype='warn',
@ -966,8 +963,8 @@ class TxHistoryTab(QWidget):
def getTxInfoFromFile(self): def getTxInfoFromFile(self):
hf = jm_single().config.get("GUI", "history_file") hf = jm_single().config.get("GUI", "history_file")
if not os.path.isfile(hf): if not os.path.isfile(hf):
if w: if mainWindow:
w.statusBar().showMessage("No transaction history found.") mainWindow.statusBar().showMessage("No transaction history found.")
return [] return []
txhist = [] txhist = []
with open(hf, 'rb') as f: with open(hf, 'rb') as f:
@ -979,7 +976,7 @@ class TxHistoryTab(QWidget):
"Incorrectedly formatted file " + hf, "Incorrectedly formatted file " + hf,
mbtype='warn', mbtype='warn',
title="Error") title="Error")
w.statusBar().showMessage("No transaction history found.") mainWindow.statusBar().showMessage("No transaction history found.")
return [] return []
return txhist[::-1 return txhist[::-1
] #appended to file in date order, window shows reverse ] #appended to file in date order, window shows reverse
@ -1039,13 +1036,13 @@ class CoinsTab(QWidget):
self.cTW.addChild(m_item) self.cTW.addChild(m_item)
self.cTW.show() self.cTW.show()
if not w.wallet_service: if not mainWindow.wallet_service:
show_blank() show_blank()
return return
utxos_enabled = {} utxos_enabled = {}
utxos_disabled = {} utxos_disabled = {}
for i in range(jm_single().config.getint("GUI", "max_mix_depth")): for i in range(jm_single().config.getint("GUI", "max_mix_depth")):
utxos_e, utxos_d = get_utxos_enabled_disabled(w.wallet_service, i) utxos_e, utxos_d = get_utxos_enabled_disabled(mainWindow.wallet_service, i)
if utxos_e != {}: if utxos_e != {}:
utxos_enabled[i] = utxos_e utxos_enabled[i] = utxos_e
if utxos_d != {}: if utxos_d != {}:
@ -1072,7 +1069,7 @@ class CoinsTab(QWidget):
# txid:index, btc, address # txid:index, btc, address
t = btc.safe_hexlify(k[0])+":"+str(k[1]) t = btc.safe_hexlify(k[0])+":"+str(k[1])
s = "{0:.08f}".format(v['value']/1e8) s = "{0:.08f}".format(v['value']/1e8)
a = w.wallet_service.script_to_addr(v["script"]) a = mainWindow.wallet_service.script_to_addr(v["script"])
item = QTreeWidgetItem([t, s, a]) item = QTreeWidgetItem([t, s, a])
item.setFont(0, QFont(MONOSPACE_FONT)) item.setFont(0, QFont(MONOSPACE_FONT))
#if rows[i][forchange][j][3] != 'new': #if rows[i][forchange][j][3] != 'new':
@ -1082,7 +1079,7 @@ class CoinsTab(QWidget):
def toggle_utxo_disable(self, txid, idx): def toggle_utxo_disable(self, txid, idx):
txid_bytes = btc.safe_from_hex(txid) txid_bytes = btc.safe_from_hex(txid)
w.wallet_service.toggle_disable_utxo(txid_bytes, idx) mainWindow.wallet_service.toggle_disable_utxo(txid_bytes, idx)
self.updateUtxos() self.updateUtxos()
def create_menu(self, position): def create_menu(self, position):
@ -1203,13 +1200,12 @@ class JMWalletTab(QWidget):
esrs.append(expandedness) esrs.append(expandedness)
l.clear() l.clear()
if walletinfo: if walletinfo:
self.mainwindow = self.parent().parent().parent()
rows, mbalances, xpubs, total_bal = walletinfo rows, mbalances, xpubs, total_bal = walletinfo
if jm_single().config.get("BLOCKCHAIN", "blockchain_source") == "regtest": if jm_single().config.get("BLOCKCHAIN", "blockchain_source") == "regtest":
self.wallet_name = self.mainwindow.testwalletname self.wallet_name = mainWindow.testwalletname
else: else:
self.wallet_name = os.path.basename( self.wallet_name = os.path.basename(
self.mainwindow.wallet_service.get_storage_location()) mainWindow.wallet_service.get_storage_location())
if total_bal is None: if total_bal is None:
total_bal = " (syncing..)" total_bal = " (syncing..)"
self.label1.setText("CURRENT WALLET: " + self.wallet_name + self.label1.setText("CURRENT WALLET: " + self.wallet_name +
@ -1787,8 +1783,8 @@ tumble_log = get_tumble_log(logsdir)
ignored_makers = [] ignored_makers = []
appWindowTitle = 'JoinMarketQt' appWindowTitle = 'JoinMarketQt'
from twisted.internet import reactor from twisted.internet import reactor
w = JMMainWindow(reactor) mainWindow = JMMainWindow(reactor)
tabWidget = QTabWidget(w) tabWidget = QTabWidget(mainWindow)
tabWidget.addTab(JMWalletTab(), "JM Wallet") tabWidget.addTab(JMWalletTab(), "JM Wallet")
settingsTab = SettingsTab() settingsTab = SettingsTab()
tabWidget.addTab(settingsTab, "Settings") tabWidget.addTab(settingsTab, "Settings")
@ -1796,12 +1792,12 @@ tabWidget.addTab(SpendTab(), "Coinjoins")
tabWidget.addTab(TxHistoryTab(), "Tx History") tabWidget.addTab(TxHistoryTab(), "Tx History")
tabWidget.addTab(CoinsTab(), "Coins") tabWidget.addTab(CoinsTab(), "Coins")
w.resize(600, 500) mainWindow.resize(600, 500)
suffix = ' - Testnet' if get_network() == 'testnet' else '' suffix = ' - Testnet' if get_network() == 'testnet' else ''
w.setWindowTitle(appWindowTitle + suffix) mainWindow.setWindowTitle(appWindowTitle + suffix)
tabWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) tabWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
w.setCentralWidget(tabWidget) mainWindow.setCentralWidget(tabWidget)
tabWidget.currentChanged.connect(onTabChange) tabWidget.currentChanged.connect(onTabChange)
w.show() mainWindow.show()
reactor.runReturn() reactor.runReturn()
sys.exit(app.exec_()) sys.exit(app.exec_())

Loading…
Cancel
Save