qml: show private key in address details
This commit is contained in:
committed by
accumulator
parent
5f2fee5184
commit
016b5eb743
@@ -172,13 +172,67 @@ Pane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
Layout.columnSpan: 2
|
||||||
|
Layout.topMargin: constants.paddingSmall
|
||||||
|
visible: !Daemon.currentWallet.isWatchOnly
|
||||||
|
text: qsTr('Private key')
|
||||||
|
color: Material.accentColor
|
||||||
|
}
|
||||||
|
|
||||||
|
TextHighlightPane {
|
||||||
|
Layout.columnSpan: 2
|
||||||
|
Layout.fillWidth: true
|
||||||
|
visible: !Daemon.currentWallet.isWatchOnly
|
||||||
|
RowLayout {
|
||||||
|
width: parent.width
|
||||||
|
Label {
|
||||||
|
id: privateKeyText
|
||||||
|
Layout.fillWidth: true
|
||||||
|
visible: addressdetails.privkey
|
||||||
|
text: addressdetails.privkey
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
font.pixelSize: constants.fontSizeLarge
|
||||||
|
font.family: FixedFont
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
id: showPrivateKeyText
|
||||||
|
Layout.fillWidth: true
|
||||||
|
visible: !addressdetails.privkey
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
text: qsTr('Tap to show private key')
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
font.pixelSize: constants.fontSizeLarge
|
||||||
|
}
|
||||||
|
ToolButton {
|
||||||
|
icon.source: '../../icons/share.png'
|
||||||
|
visible: addressdetails.privkey
|
||||||
|
onClicked: {
|
||||||
|
var dialog = app.genericShareDialog.createObject(root, {
|
||||||
|
title: qsTr('Private key'),
|
||||||
|
text: addressdetails.privkey
|
||||||
|
})
|
||||||
|
dialog.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
enabled: !addressdetails.privkey
|
||||||
|
onClicked: addressdetails.requestShowPrivateKey()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
Layout.topMargin: constants.paddingSmall
|
||||||
text: qsTr('Script type')
|
text: qsTr('Script type')
|
||||||
color: Material.accentColor
|
color: Material.accentColor
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: addressdetails.scriptType
|
Layout.topMargin: constants.paddingSmall
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
text: addressdetails.scriptType
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
@@ -235,5 +289,8 @@ Pane {
|
|||||||
address: root.address
|
address: root.address
|
||||||
onFrozenChanged: addressDetailsChanged()
|
onFrozenChanged: addressDetailsChanged()
|
||||||
onLabelChanged: addressDetailsChanged()
|
onLabelChanged: addressDetailsChanged()
|
||||||
|
onAuthRequired: {
|
||||||
|
app.handleAuthRequired(addressdetails, method, authMessage)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
|||||||
|
|
||||||
from electrum.logging import get_logger
|
from electrum.logging import get_logger
|
||||||
|
|
||||||
|
from .auth import auth_protect, AuthMixin
|
||||||
from .qetransactionlistmodel import QETransactionListModel
|
from .qetransactionlistmodel import QETransactionListModel
|
||||||
from .qetypes import QEAmount
|
from .qetypes import QEAmount
|
||||||
from .qewallet import QEWallet
|
from .qewallet import QEWallet
|
||||||
|
|
||||||
|
|
||||||
class QEAddressDetails(QObject):
|
class QEAddressDetails(AuthMixin, QObject):
|
||||||
_logger = get_logger(__name__)
|
_logger = get_logger(__name__)
|
||||||
|
|
||||||
detailsChanged = pyqtSignal()
|
detailsChanged = pyqtSignal()
|
||||||
@@ -66,6 +67,10 @@ class QEAddressDetails(QObject):
|
|||||||
def pubkeys(self):
|
def pubkeys(self):
|
||||||
return self._pubkeys
|
return self._pubkeys
|
||||||
|
|
||||||
|
@pyqtProperty(str, notify=detailsChanged)
|
||||||
|
def privkey(self):
|
||||||
|
return self._privkey
|
||||||
|
|
||||||
@pyqtProperty(str, notify=detailsChanged)
|
@pyqtProperty(str, notify=detailsChanged)
|
||||||
def derivationPath(self):
|
def derivationPath(self):
|
||||||
return self._derivationPath
|
return self._derivationPath
|
||||||
@@ -108,6 +113,19 @@ class QEAddressDetails(QObject):
|
|||||||
onchain_domain=[self._address], include_lightning=False)
|
onchain_domain=[self._address], include_lightning=False)
|
||||||
return self._historyModel
|
return self._historyModel
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def requestShowPrivateKey(self):
|
||||||
|
self.retrieve_private_key()
|
||||||
|
|
||||||
|
@auth_protect(method='wallet')
|
||||||
|
def retrieve_private_key(self):
|
||||||
|
try:
|
||||||
|
self._privkey = self._wallet.wallet.export_private_key(self._address, self._wallet.password)
|
||||||
|
except Exception:
|
||||||
|
self._privkey = ''
|
||||||
|
|
||||||
|
self.detailsChanged.emit()
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
if self._wallet is None:
|
if self._wallet is None:
|
||||||
self._logger.error('wallet undefined')
|
self._logger.error('wallet undefined')
|
||||||
|
|||||||
Reference in New Issue
Block a user