-
Notifications
You must be signed in to change notification settings - Fork 3.5k
QML send change to lightning #10723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
QML send change to lightning #10723
Changes from all commits
d91f490
6bbb20f
5bb718d
2224250
cdfcf88
708dc41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -112,10 +112,12 @@ Item { | |||||
| message: invoice.message | ||||||
| }) | ||||||
| var canComplete = !Daemon.currentWallet.isWatchOnly && Daemon.currentWallet.canSignWithoutCosigner | ||||||
| dialog.accepted.connect(function() { | ||||||
| dialog.confirmed.connect(function() { | ||||||
| if (invoice.canSave) | ||||||
| if (!invoice.saveInvoice()) | ||||||
| if (!invoice.saveInvoice()) { | ||||||
| dialog.close() | ||||||
| return | ||||||
| } | ||||||
| if (!canComplete) { | ||||||
| if (Daemon.currentWallet.isWatchOnly) { | ||||||
| dialog.finalizer.saveOrShow() | ||||||
|
|
@@ -142,13 +144,12 @@ Item { | |||||
| var finalizerDialog = confirmSweepDialog.createObject(mainView, { | ||||||
| privateKeys: dialog.privateKeys, | ||||||
| message: qsTr('Sweep transaction'), | ||||||
| showOptions: false, | ||||||
| amountLabelText: qsTr('Total sweep amount'), | ||||||
| sendButtonText: Daemon.currentWallet.isWatchOnly | ||||||
| ? qsTr('Sweep...') | ||||||
| : qsTr('Sweep') | ||||||
| }) | ||||||
| finalizerDialog.accepted.connect(function() { | ||||||
| finalizerDialog.confirmed.connect(function() { | ||||||
| if (Daemon.currentWallet.isWatchOnly) { | ||||||
| var confirmdialog = app.messageDialog.createObject(mainView, { | ||||||
| title: qsTr('Confirm Sweep'), | ||||||
|
|
@@ -164,6 +165,7 @@ Item { | |||||
| } | ||||||
| console.log("Sending sweep transaction") | ||||||
| finalizerDialog.finalizer.send() | ||||||
| finalizerDialog.close() | ||||||
| }) | ||||||
| finalizerDialog.open() | ||||||
| }) | ||||||
|
|
@@ -672,8 +674,13 @@ Item { | |||||
| id: _confirmPaymentDialog | ||||||
| title: qsTr('Confirm Payment') | ||||||
| finalizer: TxFinalizer { | ||||||
| id: _txfinalizer | ||||||
| property var _swapwaitdialog | ||||||
| wallet: Daemon.currentWallet | ||||||
| canRbf: true | ||||||
| txOptions: TxFinalizer.TxOptions.MULTIPLE_CHANGE | ||||||
| | TxFinalizer.TxOptions.OUTPUT_ROUNDING | ||||||
| | TxFinalizer.TxOptions.SEND_CHANGE_TO_LIGHTNING | ||||||
| onFinished: (signed, saved, complete) => { | ||||||
| if (!complete) { | ||||||
| var msg | ||||||
|
|
@@ -693,7 +700,7 @@ Item { | |||||
| } | ||||||
| showExport(getSerializedTx(), msg) | ||||||
| } | ||||||
| _confirmPaymentDialog.destroy() | ||||||
| _confirmPaymentDialog.close() | ||||||
| } | ||||||
| onSignError: (message) => { | ||||||
| var dialog = app.messageDialog.createObject(mainView, { | ||||||
|
|
@@ -703,12 +710,43 @@ Item { | |||||
| }) | ||||||
| dialog.open() | ||||||
| } | ||||||
| onSwapError: (message) => { | ||||||
| if (_swapwaitdialog) | ||||||
| _swapwaitdialog.close() | ||||||
| var dialog = app.messageDialog.createObject(mainView, { | ||||||
| title: qsTr('Error'), | ||||||
| text: [qsTr('Could not swap change'), message].join('\n\n'), | ||||||
| iconSource: '../../../icons/warning.png' | ||||||
| }) | ||||||
| dialog.open() | ||||||
| } | ||||||
| onSwapStart: { | ||||||
| _swapwaitdialog = app.messageDialog.createObject(mainView, { | ||||||
| title: qsTr('Please wait...'), | ||||||
| text: [qsTr('waiting for lightning invoice'), ''].join('\n\n'), | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Might be easier to understand? It might not be clear to the user why they have to wait for a lightning invoice if they aren't aware of the swap technicalities.
|
||||||
| iconSource: Qt.resolvedUrl('../../icons/info.png'), | ||||||
| buttonText: qsTr('Cancel'), | ||||||
| buttonIcon: Qt.resolvedUrl('../../icons/closebutton.png') | ||||||
| }) | ||||||
| _swapwaitdialog.accepted.connect(function() { | ||||||
| cancelSwap() | ||||||
| }) | ||||||
|
Comment on lines
+731
to
+733
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should clicking outside the dialog/back maybe also cancel the swap? _swapwaitdialog.rejected.connect(function() {
cancelSwap()
})Alternatively we could also disallow closing the dialog by clicking outside so the user must either wait or click cancel. |
||||||
| _swapwaitdialog.open() | ||||||
| } | ||||||
| onSwapFunded: { | ||||||
| if (_swapwaitdialog) | ||||||
| _swapwaitdialog.close() | ||||||
| } | ||||||
| onAuthRequired: (method, authMessage) => { | ||||||
| app.handleAuthRequired(_txfinalizer, method, authMessage) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // TODO: lingering confirmPaymentDialogs can raise exceptions in | ||||||
| // the child finalizer when currentWallet disappears, but we need | ||||||
| // it long enough for the finalizer to finish.. | ||||||
| // onClosed: destroy() | ||||||
| // NOTE: destroy-on-close was previously disabled due to the 'accept' signal implicitly | ||||||
| // closing the dialog, while the finalizer could still trigger a callback. | ||||||
| // ConfirmTxDialog now instead emits a custom 'confirmed' signal when user ok's, but | ||||||
| // keep in mind this requires explicit closing of the dialog afterwards | ||||||
| onClosed: destroy() | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -724,7 +762,10 @@ Item { | |||||
| wallet: Daemon.currentWallet | ||||||
| canRbf: true | ||||||
| privateKeys: _confirmSweepDialog.privateKeys | ||||||
| txOptions: TxFinalizer.TxOptions.NONE | ||||||
| } | ||||||
|
|
||||||
| onClosed: destroy() | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe using
> submarine_swaps.MIN_SWAP_AMOUNT_SATwould be more reliable UX than> 0as it is still not possible to receive change on lightning if the inbound liquidity is lower than the minimum swap amount.