Browse Source

Qt: move more code to main fn

add_frost_channel_encryption
zebra-lucky 4 months ago
parent
commit
1a3149e312
  1. 84
      scripts/joinmarket-qt.py

84
scripts/joinmarket-qt.py

@ -31,8 +31,6 @@ from PySide6.QtGui import *
from PySide6.QtWidgets import * from PySide6.QtWidgets import *
import PySide6.QtAsyncio as QtAsyncio
if platform.system() == 'Windows': if platform.system() == 'Windows':
MONOSPACE_FONT = 'Lucida Console' MONOSPACE_FONT = 'Lucida Console'
elif platform.system() == 'Darwin': elif platform.system() == 'Darwin':
@ -2537,8 +2535,34 @@ async def get_wallet_printout(wallet_service):
total_bal = walletview.get_fmt_balance() if wallet_service.synced else None total_bal = walletview.get_fmt_balance() if wallet_service.synced else None
return (rows, mbalances, xpubs, total_bal) return (rows, mbalances, xpubs, total_bal)
################################ ################################
async def refuse_if_non_segwit_wallet():
# refuse to load non-segwit wallet (needs extra work in wallet-utils).
if not jm_single().config.get("POLICY", "segwit") == "true":
wallet_load_error = ''.join([
"Joinmarket-Qt only supports segwit based wallets, ",
"please edit the config file and remove any setting ",
"of the field `segwit` in the `POLICY` section."])
await JMQtMessageBox(None, wallet_load_error, mbtype='crit',
title='Incompatible wallet type')
sys.exit(EXIT_FAILURE)
async def onTabChange(i, tabWidget):
""" Respond to change of tab.
"""
# TODO: hardcoded literal;
# note that this is needed for an auto-update
# of utxos on the Coins tab only atm.
if i == 2:
await tabWidget.widget(2).updateUtxos()
async def main():
global logsdir, tumble_log, mainWindow
parser = OptionParser(usage='usage: %prog [options]') parser = OptionParser(usage='usage: %prog [options]')
add_base_options(parser) add_base_options(parser)
# wallet related base options are not applicable: # wallet related base options are not applicable:
@ -2558,7 +2582,8 @@ except Exception as e:
"or the rpc ports are not correct in your joinmarket.cfg or your ", "or the rpc ports are not correct in your joinmarket.cfg or your ",
"bitcoin.conf file)." "bitcoin.conf file)."
]) ])
JMQtMessageBox(None, config_load_error, mbtype='crit', title='failed to load') await JMQtMessageBox(None, config_load_error,
mbtype='crit', title='failed to load')
sys.exit(EXIT_FAILURE) sys.exit(EXIT_FAILURE)
# Only partial functionality (see wallet info, change config) is possible # Only partial functionality (see wallet info, change config) is possible
# without a blockchain interface. # without a blockchain interface.
@ -2568,33 +2593,15 @@ if jm_single().bc_interface is None:
"You will be able to see wallet information and change configuration ", "You will be able to see wallet information and change configuration ",
"but other functionality will be limited. ", "but other functionality will be limited. ",
"Go to the 'Settings' tab and configure blockchain settings there."]) "Go to the 'Settings' tab and configure blockchain settings there."])
JMQtMessageBox(None, blockchain_warning, mbtype='warn', await JMQtMessageBox(None, blockchain_warning,
title='No blockchain source') mbtype='warn', title='No blockchain source')
async def refuse_if_non_segwit_wallet(): await refuse_if_non_segwit_wallet()
#refuse to load non-segwit wallet (needs extra work in wallet-utils).
if not jm_single().config.get("POLICY", "segwit") == "true":
wallet_load_error = ''.join([
"Joinmarket-Qt only supports segwit based wallets, ",
"please edit the config file and remove any setting ",
"of the field `segwit` in the `POLICY` section."])
await JMQtMessageBox(None, wallet_load_error, mbtype='crit',
title='Incompatible wallet type')
sys.exit(EXIT_FAILURE)
update_config_for_gui() update_config_for_gui()
check_and_start_tor() check_and_start_tor()
async def onTabChange(i, tabWidget):
""" Respond to change of tab.
"""
# TODO: hardcoded literal;
# note that this is needed for an auto-update
# of utxos on the Coins tab only atm.
if i == 2:
await tabWidget.widget(2).updateUtxos()
# to allow testing of confirm/unconfirm callback for multiple txs # to allow testing of confirm/unconfirm callback for multiple txs
if isinstance(jm_single().bc_interface, RegtestBitcoinCoreInterface): if isinstance(jm_single().bc_interface, RegtestBitcoinCoreInterface):
jm_single().bc_interface.tick_forward_chain_interval = 10 jm_single().bc_interface.tick_forward_chain_interval = 10
@ -2606,16 +2613,7 @@ if isinstance(jm_single().bc_interface, RegtestBitcoinCoreInterface):
logsdir = os.path.join(jm_single().datadir, "logs") logsdir = os.path.join(jm_single().datadir, "logs")
# tumble log will not always be used, but is made available anyway: # tumble log will not always be used, but is made available anyway:
tumble_log = get_tumble_log(logsdir) tumble_log = get_tumble_log(logsdir)
#ignored makers list persisted across entire app run
ignored_makers = []
appWindowTitle = 'JoinMarketQt'
from twisted.internet import reactor
reactor.runReturn()
mainWindow = JMMainWindow(reactor)
async def main():
await refuse_if_non_segwit_wallet()
tabWidget = QTabWidget(mainWindow) tabWidget = QTabWidget(mainWindow)
jm_wallet_tab = JMWalletTab() jm_wallet_tab = JMWalletTab()
await jm_wallet_tab.async_initUI() await jm_wallet_tab.async_initUI()
@ -2656,7 +2654,21 @@ async def main():
set_custom_stop_reactor(qt_shutdown) set_custom_stop_reactor(qt_shutdown)
# Upon launching the app, ask the user to choose a wallet to open # Upon launching the app, ask the user to choose a wallet to open
await mainWindow.openWallet() # await mainWindow.openWallet()
logsdir = None
tumble_log = None
# ignored makers list persisted across entire app run
ignored_makers = []
appWindowTitle = 'JoinMarketQt'
from twisted.internet import reactor
mainWindow = JMMainWindow(reactor)
#mainWindow.show()
reactor.runReturn()
QtAsyncio.run(coro=main(), handle_sigint=True, debug=True) import PySide6.QtAsyncio as QtAsyncio
# sys.exit(app.exec_()) # FIXME? exit_status = QtAsyncio.run(
coro=main(), keep_running=True, handle_sigint=True, debug=False)
sys.exit(exit_status)

Loading…
Cancel
Save