1
0

qml: auto close invoicedialog after successful onchain tx broadcast

This commit is contained in:
Sander van Grieken
2025-03-24 12:10:41 +01:00
parent 1aa066ea19
commit d0ecf634c8
3 changed files with 34 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ ElDialog {
property Invoice invoice
property bool payImmediately: false
property string broadcastTxid
signal doPay
signal invoiceAmountChanged
@@ -511,6 +512,20 @@ ElDialog {
}
}
Connections {
target: Daemon.currentWallet
function onBroadcastSucceeded(txid) {
if (dialog.broadcastTxid == txid) {
// our txid was broadcast successfully, close invoicedialog and show success popup
dialog.close()
var successdialog = app.messageDialog.createObject(mainView, {
text: qsTr('Payment sent.')
})
successdialog.open()
}
}
}
FontMetrics {
id: amountFontMetrics
font: amountBtc.font

View File

@@ -103,7 +103,7 @@ Item {
dialog.open()
}
function payOnchain(invoice) {
function payOnchain(invoicedialog, invoice) {
var dialog = confirmPaymentDialog.createObject(mainView, {
address: invoice.address,
satoshis: invoice.amountOverride.isEmpty
@@ -120,6 +120,8 @@ Item {
dialog.finalizer.sign()
}
} else {
// store txid in invoicedialog so the dialog can detect broadcast success
invoicedialog.broadcastTxid = dialog.finalizer.finalizedTxid
dialog.finalizer.signAndSend()
}
})
@@ -519,7 +521,7 @@ Item {
}
}
if (invoice.invoiceType == Invoice.OnchainInvoice) {
payOnchain(invoice)
payOnchain(_invoiceDialog, invoice)
} else if (invoice.invoiceType == Invoice.LightningInvoice) {
if (lninvoiceButPayOnchain) {
var dialog = app.messageDialog.createObject(mainView, {
@@ -527,7 +529,7 @@ Item {
yesno: true
})
dialog.accepted.connect(function() {
payOnchain(invoice)
payOnchain(_invoiceDialog, invoice)
})
dialog.open()
} else {
@@ -653,6 +655,7 @@ Item {
dialog.open()
}
}
// TODO: lingering confirmPaymentDialogs can raise exceptions in
// the child finalizer when currentWallet disappears, but we need
// it long enough for the finalizer to finish..

View File

@@ -152,6 +152,7 @@ class TxFeeSlider(FeeSlider):
self._tx = None
self._inputs = []
self._outputs = []
self._finalized_txid = ''
self._valid = False
self._warning = ''
@@ -211,6 +212,17 @@ class TxFeeSlider(FeeSlider):
self._outputs = outputs
self.outputsChanged.emit()
finalizedTxidChanged = pyqtSignal()
@pyqtProperty(str, notify=finalizedTxidChanged)
def finalizedTxid(self):
return self._finalized_txid
@finalizedTxid.setter
def finalizedTxid(self, finalized_txid):
if self._finalized_txid != finalized_txid:
self._finalized_txid = finalized_txid
self.finalizedTxidChanged.emit()
warningChanged = pyqtSignal()
@pyqtProperty(str, notify=warningChanged)
def warning(self):
@@ -238,6 +250,7 @@ class TxFeeSlider(FeeSlider):
self.fee = QEAmount(amount_sat=int(fee))
self.feeRate = f'{feerate:.1f}'
self.finalizedTxid = tx.txid()
self.update_inputs_from_tx(tx)
self.update_outputs_from_tx(tx)