Browse Source

seed generation can take some time, do it in a background thread and

show a busy indicator while we wait
patch-4
Sander van Grieken 3 years ago
parent
commit
07452a6a7a
  1. 41
      electrum/gui/qml/components/WizardComponents.qml
  2. 13
      electrum/gui/qml/qebitcoin.py

41
electrum/gui/qml/components/WizardComponents.qml

@ -112,7 +112,7 @@ Item {
property Component createseed: Component {
WizardComponent {
valid: true
valid: seedtext.text != ''
onAccept: {
wizard_data['seed'] = seedtext.text
@ -121,6 +121,22 @@ Item {
wizard_data['seed_extra_words'] = extendcb.checked ? customwordstext.text : ''
}
function setWarningText(numwords) {
var t = [
"<p>",
qsTr("Please save these %1 words on paper (order is important). ").arg(numwords),
qsTr("This seed will allow you to recover your wallet in case of computer failure."),
"</p>",
"<b>" + qsTr("WARNING") + ":</b>",
"<ul>",
"<li>" + qsTr("Never disclose your seed.") + "</li>",
"<li>" + qsTr("Never type it on a website.") + "</li>",
"<li>" + qsTr("Do not store it electronically.") + "</li>",
"</ul>"
]
warningtext.text = t.join("")
}
GridLayout {
width: parent.width
columns: 1
@ -145,6 +161,13 @@ Item {
}
leftInset: -5
rightInset: -5
BusyIndicator {
anchors.centerIn: parent
height: parent.height *2/3
visible: seedtext.text == ''
}
}
CheckBox {
id: extendcb
@ -158,6 +181,7 @@ Item {
echoMode: TextInput.Password
}
Component.onCompleted : {
setWarningText(12)
bitcoin.generate_seed()
}
}
@ -166,20 +190,7 @@ Item {
id: bitcoin
onGeneratedSeedChanged: {
seedtext.text = generated_seed
var t = [
"<p>",
qsTr("Please save these %1 words on paper (order is important). ").arg(generated_seed.split(" ").length),
qsTr("This seed will allow you to recover your wallet in case of computer failure."),
"</p>",
"<b>" + qsTr("WARNING") + ":</b>",
"<ul>",
"<li>" + qsTr("Never disclose your seed.") + "</li>",
"<li>" + qsTr("Never type it on a website.") + "</li>",
"<li>" + qsTr("Do not store it electronically.") + "</li>",
"</ul>"
]
warningtext.text = t.join("")
setWarningText(generated_seed.split(" ").length)
}
}
}

13
electrum/gui/qml/qebitcoin.py

@ -1,3 +1,5 @@
import asyncio
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
from electrum.logging import get_logger
@ -25,9 +27,14 @@ class QEBitcoin(QObject):
@pyqtSlot(str,str)
def generate_seed(self, seed_type='segwit', language='en'):
self._logger.debug('generating seed of type ' + str(seed_type))
self.generatedSeed = mnemonic.Mnemonic(language).make_seed(seed_type=seed_type)
self._logger.debug('seed generated')
self.generatedSeedChanged.emit()
async def co_gen_seed(seed_type, language):
self.generatedSeed = mnemonic.Mnemonic(language).make_seed(seed_type=seed_type)
self._logger.debug('seed generated')
self.generatedSeedChanged.emit()
loop = asyncio.get_event_loop()
asyncio.run_coroutine_threadsafe(co_gen_seed(seed_type, language), loop)
@pyqtProperty(bool, notify=seedValidChanged)
def seed_valid(self):

Loading…
Cancel
Save