Browse Source

qml: enable send for watch-only wallets, show raw tx dialog after finalizing

also use QEAMount setters in qetxfinalizer instead of re-instantiating
patch-4
Sander van Grieken 3 years ago
parent
commit
46d3aa4515
  1. 8
      electrum/gui/qml/components/ConfirmTxDialog.qml
  2. 3
      electrum/gui/qml/components/GenericShareDialog.qml
  3. 15
      electrum/gui/qml/components/Send.qml
  4. 2
      electrum/gui/qml/components/WalletMainView.qml
  5. 8
      electrum/gui/qml/components/main.qml
  6. 8
      electrum/gui/qml/qetxfinalizer.py

8
electrum/gui/qml/components/ConfirmTxDialog.qml

@ -224,7 +224,7 @@ ElDialog {
} }
} }
} }
Rectangle { Rectangle {
height: 1 height: 1
Layout.fillWidth: true Layout.fillWidth: true
@ -248,11 +248,13 @@ ElDialog {
Button { Button {
id: sendButton id: sendButton
text: qsTr('Pay') text: Daemon.currentWallet.isWatchOnly ? qsTr('Finalize') : qsTr('Pay')
enabled: finalizer.valid enabled: finalizer.valid
onClicked: { onClicked: {
txaccepted() txaccepted()
finalizer.send_onchain() if (!Daemon.currentWallet.isWatchOnly) {
finalizer.send_onchain()
}
dialog.close() dialog.close()
} }
} }

3
electrum/gui/qml/components/GenericShareDialog.qml

@ -13,7 +13,7 @@ ElDialog {
title: '' title: ''
parent: Overlay.overlay parent: Overlay.overlay
modal: true modal: true
standardButtons: Dialog.Ok standardButtons: Dialog.Close
width: parent.width width: parent.width
height: parent.height height: parent.height
@ -86,7 +86,6 @@ ElDialog {
onClicked: AppController.textToClipboard(dialog.text) onClicked: AppController.textToClipboard(dialog.text)
} }
Button { Button {
//enabled: false
text: qsTr('Share') text: qsTr('Share')
icon.source: '../../icons/share.png' icon.source: '../../icons/share.png'
onClicked: { onClicked: {

15
electrum/gui/qml/components/Send.qml

@ -18,6 +18,13 @@ Pane {
is_max.checked = false is_max.checked = false
} }
function showUnsignedTx(tx) {
var dialog = app.genericShareDialog.createObject(rootItem,
{ title: qsTr('Raw Transaction'), text: tx }
)
dialog.open()
}
GridLayout { GridLayout {
id: form id: form
width: parent.width width: parent.width
@ -162,6 +169,9 @@ Pane {
dialog.txaccepted.connect(function() { dialog.txaccepted.connect(function() {
userEnteredPayment.clear() userEnteredPayment.clear()
rootItem.clear() rootItem.clear()
if (Daemon.currentWallet.isWatchOnly) {
showUnsignedTx(dialog.finalizer.serializedTx())
}
}) })
dialog.open() dialog.open()
} }
@ -268,6 +278,11 @@ Pane {
'satoshis': invoice.amount, 'satoshis': invoice.amount,
'message': invoice.message 'message': invoice.message
}) })
dialog.txaccepted.connect(function() {
if (Daemon.currentWallet.isWatchOnly) {
showUnsignedTx(dialog.finalizer.serializedTx())
}
})
dialog.open() dialog.open()
} else if (invoice.invoiceType == Invoice.LightningInvoice) { } else if (invoice.invoiceType == Invoice.LightningInvoice) {
console.log('About to pay lightning invoice') console.log('About to pay lightning invoice')

2
electrum/gui/qml/components/WalletMainView.qml

@ -123,7 +123,6 @@ Item {
Item { Item {
enabled: !Daemon.currentWallet.isWatchOnly
Loader { Loader {
anchors.fill: parent anchors.fill: parent
Send { Send {
@ -148,7 +147,6 @@ Item {
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeLarge
} }
TabButton { TabButton {
enabled: !Daemon.currentWallet.isWatchOnly
text: qsTr('Send') text: qsTr('Send')
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeLarge
} }

8
electrum/gui/qml/components/main.qml

@ -186,6 +186,14 @@ ApplicationWindow
} }
} }
property alias genericShareDialog: _genericShareDialog
Component {
id: _genericShareDialog
GenericShareDialog {
onClosed: destroy()
}
}
property alias channelOpenProgressDialog: _channelOpenProgressDialog property alias channelOpenProgressDialog: _channelOpenProgressDialog
ChannelOpenProgressDialog { ChannelOpenProgressDialog {
id: _channelOpenProgressDialog id: _channelOpenProgressDialog

8
electrum/gui/qml/qetxfinalizer.py

@ -273,14 +273,14 @@ class QETxFinalizer(QObject):
amount = self._amount.satsInt if not self._amount.isMax else tx.output_value() amount = self._amount.satsInt if not self._amount.isMax else tx.output_value()
self._effectiveAmount = QEAmount(amount_sat=amount) self._effectiveAmount.satsInt = amount
self.effectiveAmountChanged.emit() self.effectiveAmountChanged.emit()
tx_size = tx.estimated_size() tx_size = tx.estimated_size()
fee = tx.get_fee() fee = tx.get_fee()
feerate = Decimal(fee) / tx_size # sat/byte feerate = Decimal(fee) / tx_size # sat/byte
self.fee = QEAmount(amount_sat=fee) self.fee.satsInt = fee
self.feeRate = f'{feerate:.1f}' self.feeRate = f'{feerate:.1f}'
#TODO #TODO
@ -310,3 +310,7 @@ class QETxFinalizer(QObject):
return return
self._wallet.sign_and_broadcast(self._tx) self._wallet.sign_and_broadcast(self._tx)
@pyqtSlot(result=str)
def serializedTx(self):
return str(self._tx)

Loading…
Cancel
Save