Browse Source

Qt: replace QInputDialog with JMInputDialog

add_frost_channel_encryption
zebra-lucky 2 months ago
parent
commit
0691795322
  1. 49
      scripts/joinmarket-qt.py

49
scripts/joinmarket-qt.py

@ -2201,10 +2201,9 @@ class JMMainWindow(QMainWindow):
log.debug('Looking for wallet in: ' + str(filename)) log.debug('Looking for wallet in: ' + str(filename))
decrypted = False decrypted = False
while not decrypted: while not decrypted:
text, ok = QInputDialog.getText(self, text, ok = await JMInputDialog(
'Decrypt wallet', self, 'Decrypt wallet', 'Enter your password:',
'Enter your password:', echo=QLineEdit.Password)
echo=QLineEdit.Password)
if not ok: if not ok:
return return
pwd = str(text).strip() pwd = str(text).strip()
@ -2221,11 +2220,11 @@ class JMMainWindow(QMainWindow):
self.close() self.close()
else: else:
if not testnet_seed: if not testnet_seed:
testnet_seed, ok = QInputDialog.getText(self, testnet_seed, ok = await JMInputDialog(
'Load Testnet wallet', self, 'Load Testnet wallet', 'Enter a testnet seed:',
'Enter a testnet seed:', QLineEdit.Normal)
QLineEdit.Normal) if testnet_seed:
testnet_seed = testnet_seed.strip() testnet_seed = testnet_seed.strip()
if not ok or not testnet_seed: if not ok or not testnet_seed:
await JMQtMessageBox(self, "No seed entered, aborting", await JMQtMessageBox(self, "No seed entered, aborting",
mbtype='warn', title="Error") mbtype='warn', title="Error")
@ -2344,12 +2343,12 @@ class JMMainWindow(QMainWindow):
else: else:
await self.initWallet() await self.initWallet()
def checkPassphrase(self): async def checkPassphrase(self):
match = False match = False
while not match: while not match:
text, ok = QInputDialog.getText(self, 'Passphrase check', text, ok = await JMInputDialog(
'Enter your passphrase:', self, 'Passphrase check', 'Enter your passphrase:',
echo=QLineEdit.Password) echo=QLineEdit.Password)
if not ok: if not ok:
return False return False
pwd = str(text).strip().encode('utf-8') pwd = str(text).strip().encode('utf-8')
@ -2367,7 +2366,7 @@ class JMMainWindow(QMainWindow):
mbtype="crit", title="Error") mbtype="crit", title="Error")
return return
change_res = False change_res = False
check_res = self.checkPassphrase() check_res = await self.checkPassphrase()
if check_res: if check_res:
change_res = await wallet_change_passphrase( change_res = await wallet_change_passphrase(
self.wallet_service, self.getPassword) self.wallet_service, self.getPassword)
@ -2381,7 +2380,8 @@ class JMMainWindow(QMainWindow):
async def getTestnetSeed(self): async def getTestnetSeed(self):
text, ok = await JMInputDialog( text, ok = await JMInputDialog(
self, 'Testnet seed', 'Enter a 32 char hex string as seed:') self, 'Testnet seed', 'Enter a 32 char hex string as seed:')
text = text.strip() if text:
text = text.strip()
if not ok or not text: if not ok or not text:
await JMQtMessageBox(self, "No seed entered, aborting", await JMQtMessageBox(self, "No seed entered, aborting",
mbtype='warn', title="Error") mbtype='warn', title="Error")
@ -2409,17 +2409,17 @@ class JMMainWindow(QMainWindow):
self.textpassword = textpassword = await JMPasswordDialog(parent=self) self.textpassword = textpassword = await JMPasswordDialog(parent=self)
return textpassword.encode('utf-8') if textpassword else textpassword return textpassword.encode('utf-8') if textpassword else textpassword
def getWalletFileName(self) -> str: async def getWalletFileName(self) -> str:
walletname, ok = QInputDialog.getText(self, 'Choose wallet name', walletname, ok = await JMInputDialog(
'Enter wallet file name:', self, 'Choose wallet name', 'Enter wallet file name:',
QLineEdit.Normal, "wallet.jmdat") QLineEdit.Normal, "wallet.jmdat")
if not ok: if not ok:
asyncio.ensure_future( asyncio.ensure_future(
JMQtMessageBox(self, "Create wallet aborted", mbtype='warn')) JMQtMessageBox(self, "Create wallet aborted", mbtype='warn'))
# cannot use None for a 'fail' condition, as this is used # cannot use None for a 'fail' condition, as this is used
# for the case where the default wallet name is to be used in non-Qt. # for the case where the default wallet name is to be used in non-Qt.
return "cancelled" return "cancelled"
self.walletname = str(walletname) self.walletname = str(walletname).strip()
return self.walletname return self.walletname
def displayWords(self, words: str, mnemonic_extension: str) -> None: def displayWords(self, words: str, mnemonic_extension: str) -> None:
@ -2446,11 +2446,10 @@ class JMMainWindow(QMainWindow):
mbtype='question') mbtype='question')
return reply == QMessageBox.Yes return reply == QMessageBox.Yes
def promptInputMnemonicExtension(self) -> Optional[str]: async def promptInputMnemonicExtension(self) -> Optional[str]:
mnemonic_extension, ok = QInputDialog.getText(self, mnemonic_extension, ok = await JMInputDialog(
'Input Mnemonic Extension', self, 'Input Mnemonic Extension', 'Enter mnemonic Extension:',
'Enter mnemonic Extension:', QLineEdit.Normal, "")
QLineEdit.Normal, "")
if not ok: if not ok:
return None return None
return str(mnemonic_extension) return str(mnemonic_extension)

Loading…
Cancel
Save