Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 51 additions & 40 deletions ArmoryQt.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@

from armoryengine.PyBtcWallet import PyBtcWallet
from armoryengine.Transaction import PyTx
from armoryengine.WalletUtils import WalletMap, \
WalletTypes, WalletFilter, determineWalletType
from armoryengine.WalletUtils import WalletTypes, WalletFilter, \
determineWalletType, loadWalletsForMainApp

from qtdialogs.qtdefines import GETFONT, NETWORKMODE, \
QRichLabel_AutoToolTip, tightSizeNChar, USERMODE, initialColResize, \
Expand Down Expand Up @@ -93,6 +93,7 @@
from qtdialogs.MsgBoxWithDNAA import MsgBoxWithDNAA
from qtdialogs.DlgUniversalRestoreSelect import DlgUniversalRestoreSelect
from qtdialogs.DlgWalletMigration import DlgWalletMigration
from qtdialogs.setupmanager import DlgSetupManager

from ui.QtExecuteSignal import TheSignalExecution
from armorymodels import AllWalletsDispModel, AllWalletsCheckboxDelegate, \
Expand Down Expand Up @@ -149,8 +150,8 @@ class ArmoryMainWindow(QtWidgets.QMainWindow):
scriptDispStrings = {}

#############################################################################
def __init__(self, parent=None, splashScreen=None):
super(ArmoryMainWindow, self).__init__(parent)
def __init__(self, wallets):
super().__init__()

self.isShuttingDown = False
self.ledgerView = None
Expand Down Expand Up @@ -215,7 +216,8 @@ def __init__(self, parent=None, splashScreen=None):
self.lockboxIDMap = {}
self.cppLockboxWltMap = {}
self.broadcasting = {}
self.wallets = WalletMap(self)
self.wallets = wallets
self.walletModel = AllWalletsDispModel(self.wallets, self)

self.nodeStatus = None
self.numHeartBeat = 0
Expand Down Expand Up @@ -331,7 +333,7 @@ def cppNotifySignal(action, arglist):
self.statusBar().insertPermanentWidget(0, self.lblArmoryStatus)

# Table for all the wallets
self.walletModel = AllWalletsDispModel(self.wallets)
self.walletModel = AllWalletsDispModel(self.wallets, self)
self.walletsView = QtWidgets.QTableView(self)

w,h = tightSizeNChar(self.walletsView, 55)
Expand Down Expand Up @@ -773,10 +775,6 @@ def msrevsign():
if reply[1]==True:
TheSettings.set('DNAA_DeleteLevelDB', True)

#############################################################################
def networkReadyCallback(self):
self.loadWallets()

#############################################################################
def changeWltFilter(self):
if self.netMode == NETWORKMODE.Offline:
Expand Down Expand Up @@ -1813,18 +1811,9 @@ def loadSettings(self):
self.walletSideScanProgress = {}
self.promptMap = {}

#############################################################################
def loadWallets(self):
def loadWltsLbd():
wltList = TheBridge.wltManager.listWallets()
wltsProto = TheBridge.wltManager.loadWallets()
self.wallets.setupFromProto(wltsProto)
self.setupBlockchainService_step1()
TheSignalExecution.executeMethod(self.finalizeLoadWallets)
TheSignalExecution.executeMethod(loadWltsLbd)

#############################################################################
def finalizeLoadWallets(self):
self.setupBlockchainService_step1()
self.walletModel.reset()
if self.wallets.empty():
self.execIntroDialog()
Expand Down Expand Up @@ -2193,7 +2182,7 @@ def convertLedgerToTable(self, ledgerProto, showSentToSelfAmt=True, wltIDIn=None
continue

if wlt:
isWatch = (determineWalletType(wlt, self)[0] == WalletTypes.WatchOnly)
isWatch = (determineWalletType(wlt) == WalletTypes.WatchOnly)
wltName = wlt.getDisplayStr(pref="")
dispComment = self.getCommentForLE(le, wltID)
else:
Expand Down Expand Up @@ -3059,7 +3048,7 @@ def clickReceiveCoins(self):
selectionMade = False

if selectionMade:
wlttype = determineWalletType(wlt, self)[0]
wlttype = determineWalletType(wlt)
if ShowRecvCoinsWarningIfNecessary(wlt, self, self):
QAPP.processEvents()
dlg = DlgNewAddressDisp(wlt, self, self, loading)
Expand Down Expand Up @@ -5048,39 +5037,61 @@ def unregisterProgressCallback(self, id):

################################################################################
if 1:
#setup splash screen
# 1) Show splash screen during actual loading (bridge startup)
pixLogo = QtGui.QPixmap('./img/splashlogo.png')
if USE_TESTNET or USE_REGTEST:
pixLogo = QtGui.QPixmap('./img/splashlogo_testnet.png')
SPLASH = ArmorySplashScreen(pixLogo)
SPLASH.setMask(pixLogo.mask())

SPLASH.show()
QAPP.processEvents()

# Will make this customizable
QAPP.setFont(GETFONT('var'))

# Setup translations
# Setup translations before any dialogs
translator = QtCore.QTranslator(QAPP)
app_dir = "./"
try:
app_dir = os.path.dirname(os.path.realpath(__file__))
except:
if OS_WINDOWS and getattr(sys, 'frozen', False):
app_dir = os.path.dirname(sys.executable)
translator.load(TheSettings.getGuiLanguage(), os.path.join(app_dir, "lang/"))
QAPP.installTranslator(translator)
# Determine app directory for translations
app_dir = os.path.dirname(os.path.realpath(__file__))

#setup main dialog
armoryMainWindow = ArmoryMainWindow(splashScreen=SPLASH)

#start cppbridge
TheBDM.startBridge(getBridgeArgList(), armoryMainWindow.networkReadyCallback)
translator.load(TheSettings.getGuiLanguage(),
os.path.join(app_dir, "lang/"))
QAPP.installTranslator(translator)

#show main dialog
# 2) Start bridge with ready handler - sequential process per maintainer
dlg = DlgSetupManager(parent=None, main=None)

def bridgeReadyHandler():
# Bridge is ready - explicitly call wallet listing and close splash
TheSignalExecution.executeMethod(dlg.onBridgeReady)
def closeSplash():
SPLASH.close()
TheSignalExecution.executeMethod(closeSplash)

#build bridge args with settings-based additions
bridgeArgs = getBridgeArgList()
if CLI_OPTIONS.ram_usage == -1 and TheSettings.hasSetting('RAMUsage'):
ramUsage = TheSettings.get('RAMUsage')
if ramUsage > 0:
bridgeArgs.append(f"--ram-usage={ramUsage}")
if CLI_OPTIONS.thread_count == -1 and TheSettings.hasSetting('ThreadCount'):
threadCount = TheSettings.get('ThreadCount')
if threadCount > 0:
bridgeArgs.append(f"--thread-count={threadCount}")
if TheSettings.hasSetting('ManageSatoshi') and TheSettings.get('ManageSatoshi'):
bridgeArgs.append("--automateDb")
TheBDM.startBridge(bridgeArgs, bridgeReadyHandler)

# Show setup manager (wallet list will populate when bridge ready)
if dlg.exec_() != QtWidgets.QDialog.Accepted:
TheBridge.service.shutdown()
sys.exit(1)

# Spawn main window after setup accepted
wallets = loadWalletsForMainApp()
armoryMainWindow = ArmoryMainWindow(wallets)
TheSignalExecution.executeMethod(armoryMainWindow.finalizeLoadWallets)
armoryMainWindow.show()

SPLASH.finish(armoryMainWindow)
QAPP.setQuitOnLastWindowClosed(True)
os._exit(QAPP.exec_())
10 changes: 10 additions & 0 deletions armoryengine/CppBridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,16 @@ def deleteWallet(self, walletId):
reply = fut.getVal(nothrow=True)
return reply.success

####
def unlockControlHeader(self,
walletPath: str, callbackId: str, callbackFunc: callable):
"""Unlock wallet using proper unlock control header pattern."""
packet = Bridge.ToBridge.new_message()
request = packet.init("walletManager").init("unlockControlHeader")
request.walletPath = walletPath
request.callbackId = callbackId
self.send(packet, callback=callbackFunc)

################################################################################
class BridgeWalletWrapper(ProtoWrapper):
#############################################################################
Expand Down
Loading