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

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

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

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

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

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

@ -123,7 +123,6 @@ Item {
Item {
enabled: !Daemon.currentWallet.isWatchOnly
Loader {
anchors.fill: parent
Send {
@ -148,7 +147,6 @@ Item {
font.pixelSize: constants.fontSizeLarge
}
TabButton {
enabled: !Daemon.currentWallet.isWatchOnly
text: qsTr('Send')
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
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()
self._effectiveAmount = QEAmount(amount_sat=amount)
self._effectiveAmount.satsInt = amount
self.effectiveAmountChanged.emit()
tx_size = tx.estimated_size()
fee = tx.get_fee()
feerate = Decimal(fee) / tx_size # sat/byte
self.fee = QEAmount(amount_sat=fee)
self.fee.satsInt = fee
self.feeRate = f'{feerate:.1f}'
#TODO
@ -310,3 +310,7 @@ class QETxFinalizer(QObject):
return
self._wallet.sign_and_broadcast(self._tx)
@pyqtSlot(result=str)
def serializedTx(self):
return str(self._tx)

Loading…
Cancel
Save