qml: implement remove local tx, show channel backup after channel open
This commit is contained in:
@@ -28,10 +28,13 @@ ElDialog {
|
|||||||
property alias info: infoText.text
|
property alias info: infoText.text
|
||||||
property alias peer: peerText.text
|
property alias peer: peerText.text
|
||||||
|
|
||||||
|
property string channelBackup
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
state = ''
|
state = ''
|
||||||
errorText.text = ''
|
errorText.text = ''
|
||||||
peerText.text = ''
|
peerText.text = ''
|
||||||
|
channelBackup = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
@@ -97,23 +100,35 @@ ElDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
InfoTextArea {
|
||||||
|
id: errorText
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Layout.preferredWidth: dialog.width * 2/3
|
Layout.preferredWidth: dialog.width * 2/3
|
||||||
InfoTextArea {
|
visible: false
|
||||||
id: errorText
|
iconStyle: InfoTextArea.IconStyle.Error
|
||||||
visible: false
|
textFormat: TextEdit.PlainText
|
||||||
iconStyle: InfoTextArea.IconStyle.Error
|
}
|
||||||
width: parent.width
|
|
||||||
textFormat: TextEdit.PlainText
|
|
||||||
}
|
|
||||||
|
|
||||||
InfoTextArea {
|
InfoTextArea {
|
||||||
id: infoText
|
id: infoText
|
||||||
visible: false
|
Layout.alignment: Qt.AlignHCenter
|
||||||
width: parent.width
|
Layout.preferredWidth: dialog.width * 2/3
|
||||||
}
|
visible: false
|
||||||
|
textFormat: TextEdit.PlainText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClosed: {
|
||||||
|
if (!dialog.channelBackup)
|
||||||
|
return
|
||||||
|
|
||||||
|
var sharedialog = app.genericShareDialog.createObject(app, {
|
||||||
|
title: qsTr('Save Channel Backup'),
|
||||||
|
text: dialog.channelBackup,
|
||||||
|
text_help: qsTr('The channel you created is not recoverable from seed.')
|
||||||
|
+ ' ' + qsTr('To prevent fund losses, please save this backup on another device.')
|
||||||
|
+ ' ' + qsTr('It may be imported in another Electrum wallet with the same seed.')
|
||||||
|
})
|
||||||
|
sharedialog.open()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ Pane {
|
|||||||
|
|
||||||
property string title: qsTr("Open Lightning Channel")
|
property string title: qsTr("Open Lightning Channel")
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
app.stack.pop()
|
||||||
|
}
|
||||||
|
|
||||||
GridLayout {
|
GridLayout {
|
||||||
id: form
|
id: form
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@@ -200,28 +204,17 @@ Pane {
|
|||||||
var message = qsTr('Channel established.') + ' '
|
var message = qsTr('Channel established.') + ' '
|
||||||
+ qsTr('This channel will be usable after %1 confirmations').arg(min_depth)
|
+ qsTr('This channel will be usable after %1 confirmations').arg(min_depth)
|
||||||
if (!tx_complete) {
|
if (!tx_complete) {
|
||||||
message = message + ' ' + qsTr('Please sign and broadcast the funding transaction.')
|
message = message + '\n\n' + qsTr('Please sign and broadcast the funding transaction.')
|
||||||
|
channelopener.wallet.historyModel.init_model() // local tx doesn't trigger model update
|
||||||
}
|
}
|
||||||
app.channelOpenProgressDialog.state = 'success'
|
app.channelOpenProgressDialog.state = 'success'
|
||||||
app.channelOpenProgressDialog.info = message
|
app.channelOpenProgressDialog.info = message
|
||||||
if (!has_onchain_backup) {
|
if (!has_onchain_backup) {
|
||||||
app.channelOpenProgressDialog.closed.connect(function() {
|
app.channelOpenProgressDialog.channelBackup = channelopener.channelBackup(cid)
|
||||||
var dialog = app.genericShareDialog.createObject(app,
|
|
||||||
{
|
|
||||||
title: qsTr('Save Backup'),
|
|
||||||
text: channelopener.channelBackup(cid),
|
|
||||||
text_help: qsTr('The channel you created is not recoverable from seed.')
|
|
||||||
+ ' ' + qsTr('To prevent fund losses, please save this backup on another device.')
|
|
||||||
+ ' ' + qsTr('It may be imported in another Electrum wallet with the same seed.')
|
|
||||||
}
|
|
||||||
)
|
|
||||||
dialog.open()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
// TODO: handle incomplete TX
|
// TODO: handle incomplete TX
|
||||||
channelopener.wallet.channelModel.new_channel(cid)
|
channelopener.wallet.channelModel.new_channel(cid)
|
||||||
app.stack.pop()
|
root.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ Pane {
|
|||||||
|
|
||||||
signal detailsChanged
|
signal detailsChanged
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
app.stack.pop()
|
||||||
|
}
|
||||||
|
|
||||||
property QtObject menu: Menu {
|
property QtObject menu: Menu {
|
||||||
id: menu
|
id: menu
|
||||||
MenuItem {
|
MenuItem {
|
||||||
@@ -55,7 +59,7 @@ Pane {
|
|||||||
action: Action {
|
action: Action {
|
||||||
text: qsTr('Remove')
|
text: qsTr('Remove')
|
||||||
enabled: txdetails.canRemove
|
enabled: txdetails.canRemove
|
||||||
onTriggered: notificationPopup.show('Not implemented')
|
onTriggered: txdetails.removeLocalTx()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -368,6 +372,16 @@ Pane {
|
|||||||
txid: root.txid
|
txid: root.txid
|
||||||
rawtx: root.rawtx
|
rawtx: root.rawtx
|
||||||
onLabelChanged: root.detailsChanged()
|
onLabelChanged: root.detailsChanged()
|
||||||
|
onConfirmRemoveLocalTx: {
|
||||||
|
var dialog = app.messageDialog.createObject(app, {'text': message, 'yesno': true})
|
||||||
|
dialog.yesClicked.connect(function() {
|
||||||
|
dialog.close()
|
||||||
|
txdetails.removeLocalTx(true)
|
||||||
|
txdetails.wallet.historyModel.init_model()
|
||||||
|
root.close()
|
||||||
|
})
|
||||||
|
dialog.open()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
|
|||||||
self._logger.debug('new channel with cid %s' % cid)
|
self._logger.debug('new channel with cid %s' % cid)
|
||||||
lnchannels = self.wallet.lnworker.channels
|
lnchannels = self.wallet.lnworker.channels
|
||||||
for channel in lnchannels.values():
|
for channel in lnchannels.values():
|
||||||
self._logger.debug(repr(channel))
|
|
||||||
if cid == channel.channel_id.hex():
|
if cid == channel.channel_id.hex():
|
||||||
item = self.channel_to_model(channel)
|
item = self.channel_to_model(channel)
|
||||||
self._logger.debug(item)
|
self._logger.debug(item)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
||||||
|
|
||||||
|
from electrum.i18n import _
|
||||||
from electrum.logging import get_logger
|
from electrum.logging import get_logger
|
||||||
from electrum.util import format_time
|
from electrum.util import format_time
|
||||||
from electrum.transaction import tx_from_any
|
from electrum.transaction import tx_from_any
|
||||||
@@ -21,9 +22,9 @@ class QETxDetails(QObject):
|
|||||||
_tx = None
|
_tx = None
|
||||||
|
|
||||||
_status = ''
|
_status = ''
|
||||||
_amount = QEAmount(amount_sat=0)
|
_amount = QEAmount()
|
||||||
_lnamount = QEAmount(amount_sat=0)
|
_lnamount = QEAmount()
|
||||||
_fee = QEAmount(amount_sat=0)
|
_fee = QEAmount()
|
||||||
_inputs = []
|
_inputs = []
|
||||||
_outputs = []
|
_outputs = []
|
||||||
|
|
||||||
@@ -47,6 +48,8 @@ class QETxDetails(QObject):
|
|||||||
_txpos = -1
|
_txpos = -1
|
||||||
_header_hash = ''
|
_header_hash = ''
|
||||||
|
|
||||||
|
confirmRemoveLocalTx = pyqtSignal([str], arguments=['message'])
|
||||||
|
|
||||||
detailsChanged = pyqtSignal()
|
detailsChanged = pyqtSignal()
|
||||||
|
|
||||||
walletChanged = pyqtSignal()
|
walletChanged = pyqtSignal()
|
||||||
@@ -305,3 +308,21 @@ class QETxDetails(QObject):
|
|||||||
|
|
||||||
self._can_broadcast = True
|
self._can_broadcast = True
|
||||||
self.detailsChanged.emit()
|
self.detailsChanged.emit()
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
@pyqtSlot(bool)
|
||||||
|
def removeLocalTx(self, confirm = False):
|
||||||
|
txid = self._txid
|
||||||
|
|
||||||
|
if not confirm:
|
||||||
|
num_child_txs = len(self._wallet.wallet.adb.get_depending_transactions(txid))
|
||||||
|
question = _("Are you sure you want to remove this transaction?")
|
||||||
|
if num_child_txs > 0:
|
||||||
|
question = (
|
||||||
|
_("Are you sure you want to remove this transaction and {} child transactions?")
|
||||||
|
.format(num_child_txs))
|
||||||
|
self.confirmRemoveLocalTx.emit(question)
|
||||||
|
return
|
||||||
|
|
||||||
|
self._wallet.wallet.adb.remove_transaction(txid)
|
||||||
|
self._wallet.wallet.save_db()
|
||||||
|
|||||||
Reference in New Issue
Block a user