qml: auto close invoicedialog after successful onchain tx broadcast
This commit is contained in:
@@ -12,6 +12,7 @@ ElDialog {
|
|||||||
|
|
||||||
property Invoice invoice
|
property Invoice invoice
|
||||||
property bool payImmediately: false
|
property bool payImmediately: false
|
||||||
|
property string broadcastTxid
|
||||||
|
|
||||||
signal doPay
|
signal doPay
|
||||||
signal invoiceAmountChanged
|
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 {
|
FontMetrics {
|
||||||
id: amountFontMetrics
|
id: amountFontMetrics
|
||||||
font: amountBtc.font
|
font: amountBtc.font
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ Item {
|
|||||||
dialog.open()
|
dialog.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
function payOnchain(invoice) {
|
function payOnchain(invoicedialog, invoice) {
|
||||||
var dialog = confirmPaymentDialog.createObject(mainView, {
|
var dialog = confirmPaymentDialog.createObject(mainView, {
|
||||||
address: invoice.address,
|
address: invoice.address,
|
||||||
satoshis: invoice.amountOverride.isEmpty
|
satoshis: invoice.amountOverride.isEmpty
|
||||||
@@ -120,6 +120,8 @@ Item {
|
|||||||
dialog.finalizer.sign()
|
dialog.finalizer.sign()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// store txid in invoicedialog so the dialog can detect broadcast success
|
||||||
|
invoicedialog.broadcastTxid = dialog.finalizer.finalizedTxid
|
||||||
dialog.finalizer.signAndSend()
|
dialog.finalizer.signAndSend()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -519,7 +521,7 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (invoice.invoiceType == Invoice.OnchainInvoice) {
|
if (invoice.invoiceType == Invoice.OnchainInvoice) {
|
||||||
payOnchain(invoice)
|
payOnchain(_invoiceDialog, invoice)
|
||||||
} else if (invoice.invoiceType == Invoice.LightningInvoice) {
|
} else if (invoice.invoiceType == Invoice.LightningInvoice) {
|
||||||
if (lninvoiceButPayOnchain) {
|
if (lninvoiceButPayOnchain) {
|
||||||
var dialog = app.messageDialog.createObject(mainView, {
|
var dialog = app.messageDialog.createObject(mainView, {
|
||||||
@@ -527,7 +529,7 @@ Item {
|
|||||||
yesno: true
|
yesno: true
|
||||||
})
|
})
|
||||||
dialog.accepted.connect(function() {
|
dialog.accepted.connect(function() {
|
||||||
payOnchain(invoice)
|
payOnchain(_invoiceDialog, invoice)
|
||||||
})
|
})
|
||||||
dialog.open()
|
dialog.open()
|
||||||
} else {
|
} else {
|
||||||
@@ -653,6 +655,7 @@ Item {
|
|||||||
dialog.open()
|
dialog.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: lingering confirmPaymentDialogs can raise exceptions in
|
// TODO: lingering confirmPaymentDialogs can raise exceptions in
|
||||||
// the child finalizer when currentWallet disappears, but we need
|
// the child finalizer when currentWallet disappears, but we need
|
||||||
// it long enough for the finalizer to finish..
|
// it long enough for the finalizer to finish..
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ class TxFeeSlider(FeeSlider):
|
|||||||
self._tx = None
|
self._tx = None
|
||||||
self._inputs = []
|
self._inputs = []
|
||||||
self._outputs = []
|
self._outputs = []
|
||||||
|
self._finalized_txid = ''
|
||||||
self._valid = False
|
self._valid = False
|
||||||
self._warning = ''
|
self._warning = ''
|
||||||
|
|
||||||
@@ -211,6 +212,17 @@ class TxFeeSlider(FeeSlider):
|
|||||||
self._outputs = outputs
|
self._outputs = outputs
|
||||||
self.outputsChanged.emit()
|
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()
|
warningChanged = pyqtSignal()
|
||||||
@pyqtProperty(str, notify=warningChanged)
|
@pyqtProperty(str, notify=warningChanged)
|
||||||
def warning(self):
|
def warning(self):
|
||||||
@@ -238,6 +250,7 @@ class TxFeeSlider(FeeSlider):
|
|||||||
|
|
||||||
self.fee = QEAmount(amount_sat=int(fee))
|
self.fee = QEAmount(amount_sat=int(fee))
|
||||||
self.feeRate = f'{feerate:.1f}'
|
self.feeRate = f'{feerate:.1f}'
|
||||||
|
self.finalizedTxid = tx.txid()
|
||||||
|
|
||||||
self.update_inputs_from_tx(tx)
|
self.update_inputs_from_tx(tx)
|
||||||
self.update_outputs_from_tx(tx)
|
self.update_outputs_from_tx(tx)
|
||||||
|
|||||||
Reference in New Issue
Block a user