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 peer: peerText.text
|
||||
|
||||
property string channelBackup
|
||||
|
||||
function reset() {
|
||||
state = ''
|
||||
errorText.text = ''
|
||||
peerText.text = ''
|
||||
channelBackup = ''
|
||||
}
|
||||
|
||||
Item {
|
||||
@@ -97,23 +100,35 @@ ElDialog {
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
InfoTextArea {
|
||||
id: errorText
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Layout.preferredWidth: dialog.width * 2/3
|
||||
InfoTextArea {
|
||||
id: errorText
|
||||
visible: false
|
||||
iconStyle: InfoTextArea.IconStyle.Error
|
||||
width: parent.width
|
||||
textFormat: TextEdit.PlainText
|
||||
}
|
||||
visible: false
|
||||
iconStyle: InfoTextArea.IconStyle.Error
|
||||
textFormat: TextEdit.PlainText
|
||||
}
|
||||
|
||||
InfoTextArea {
|
||||
id: infoText
|
||||
visible: false
|
||||
width: parent.width
|
||||
}
|
||||
InfoTextArea {
|
||||
id: infoText
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
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")
|
||||
|
||||
function close() {
|
||||
app.stack.pop()
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
id: form
|
||||
width: parent.width
|
||||
@@ -200,28 +204,17 @@ Pane {
|
||||
var message = qsTr('Channel established.') + ' '
|
||||
+ qsTr('This channel will be usable after %1 confirmations').arg(min_depth)
|
||||
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.info = message
|
||||
if (!has_onchain_backup) {
|
||||
app.channelOpenProgressDialog.closed.connect(function() {
|
||||
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()
|
||||
})
|
||||
app.channelOpenProgressDialog.channelBackup = channelopener.channelBackup(cid)
|
||||
}
|
||||
// TODO: handle incomplete TX
|
||||
channelopener.wallet.channelModel.new_channel(cid)
|
||||
app.stack.pop()
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ Pane {
|
||||
|
||||
signal detailsChanged
|
||||
|
||||
function close() {
|
||||
app.stack.pop()
|
||||
}
|
||||
|
||||
property QtObject menu: Menu {
|
||||
id: menu
|
||||
MenuItem {
|
||||
@@ -55,7 +59,7 @@ Pane {
|
||||
action: Action {
|
||||
text: qsTr('Remove')
|
||||
enabled: txdetails.canRemove
|
||||
onTriggered: notificationPopup.show('Not implemented')
|
||||
onTriggered: txdetails.removeLocalTx()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -368,6 +372,16 @@ Pane {
|
||||
txid: root.txid
|
||||
rawtx: root.rawtx
|
||||
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 {
|
||||
|
||||
@@ -131,7 +131,6 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
|
||||
self._logger.debug('new channel with cid %s' % cid)
|
||||
lnchannels = self.wallet.lnworker.channels
|
||||
for channel in lnchannels.values():
|
||||
self._logger.debug(repr(channel))
|
||||
if cid == channel.channel_id.hex():
|
||||
item = self.channel_to_model(channel)
|
||||
self._logger.debug(item)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
||||
|
||||
from electrum.i18n import _
|
||||
from electrum.logging import get_logger
|
||||
from electrum.util import format_time
|
||||
from electrum.transaction import tx_from_any
|
||||
@@ -21,9 +22,9 @@ class QETxDetails(QObject):
|
||||
_tx = None
|
||||
|
||||
_status = ''
|
||||
_amount = QEAmount(amount_sat=0)
|
||||
_lnamount = QEAmount(amount_sat=0)
|
||||
_fee = QEAmount(amount_sat=0)
|
||||
_amount = QEAmount()
|
||||
_lnamount = QEAmount()
|
||||
_fee = QEAmount()
|
||||
_inputs = []
|
||||
_outputs = []
|
||||
|
||||
@@ -47,6 +48,8 @@ class QETxDetails(QObject):
|
||||
_txpos = -1
|
||||
_header_hash = ''
|
||||
|
||||
confirmRemoveLocalTx = pyqtSignal([str], arguments=['message'])
|
||||
|
||||
detailsChanged = pyqtSignal()
|
||||
|
||||
walletChanged = pyqtSignal()
|
||||
@@ -305,3 +308,21 @@ class QETxDetails(QObject):
|
||||
|
||||
self._can_broadcast = True
|
||||
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