diff --git a/electrum/gui/qml/components/InvoiceDialog.qml b/electrum/gui/qml/components/InvoiceDialog.qml index df23a92c2..0a52b73a4 100644 --- a/electrum/gui/qml/components/InvoiceDialog.qml +++ b/electrum/gui/qml/components/InvoiceDialog.qml @@ -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 diff --git a/electrum/gui/qml/components/WalletMainView.qml b/electrum/gui/qml/components/WalletMainView.qml index 20f2d321b..ee218edd9 100644 --- a/electrum/gui/qml/components/WalletMainView.qml +++ b/electrum/gui/qml/components/WalletMainView.qml @@ -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() } }) @@ -541,7 +543,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, { @@ -549,7 +551,7 @@ Item { yesno: true }) dialog.accepted.connect(function() { - payOnchain(invoice) + payOnchain(_invoiceDialog, invoice) }) dialog.open() } else { @@ -675,6 +677,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.. diff --git a/electrum/gui/qml/qetxfinalizer.py b/electrum/gui/qml/qetxfinalizer.py index 96ac3070e..e8118a766 100644 --- a/electrum/gui/qml/qetxfinalizer.py +++ b/electrum/gui/qml/qetxfinalizer.py @@ -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)