qml: auto sign & broadcast fee bump transactions if wallet can sign without cosigners.
Show a dialog otherwise
This commit is contained in:
@@ -447,7 +447,15 @@ Pane {
|
||||
|
||||
onTxaccepted: {
|
||||
root.rawtx = rbffeebumper.getNewTx()
|
||||
// TODO: sign & send when possible?
|
||||
if (Daemon.currentWallet.canSignWithoutCosigner) {
|
||||
txdetails.sign(true)
|
||||
// close txdetails?
|
||||
} else {
|
||||
var dialog = app.messageDialog.createObject(app, {
|
||||
text: qsTr('Transaction fee updated.') + '\n\n' + qsTr('You still need to sign and broadcast this transaction.')
|
||||
})
|
||||
dialog.open()
|
||||
}
|
||||
}
|
||||
onClosed: destroy()
|
||||
}
|
||||
@@ -466,7 +474,15 @@ Pane {
|
||||
onTxaccepted: {
|
||||
// replaces parent tx with cpfp tx
|
||||
root.rawtx = cpfpfeebumper.getNewTx()
|
||||
// TODO: sign & send when possible?
|
||||
if (Daemon.currentWallet.canSignWithoutCosigner) {
|
||||
txdetails.sign(true)
|
||||
// close txdetails?
|
||||
} else {
|
||||
var dialog = app.messageDialog.createObject(app, {
|
||||
text: qsTr('CPFP fee bump transaction created.') + '\n\n' + qsTr('You still need to sign and broadcast this transaction.')
|
||||
})
|
||||
dialog.open()
|
||||
}
|
||||
}
|
||||
onClosed: destroy()
|
||||
}
|
||||
|
||||
@@ -238,6 +238,16 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Daemon.currentWallet
|
||||
function onBroadcastFailed(txid, code, message) {
|
||||
var dialog = app.messageDialog.createObject(app, {
|
||||
text: message
|
||||
})
|
||||
dialog.open()
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: invoiceDialog
|
||||
InvoiceDialog {
|
||||
|
||||
@@ -67,6 +67,12 @@ class QETxDetails(QObject, QtEventListener):
|
||||
self._logger.debug('verified event for our txid %s' % txid)
|
||||
self.update()
|
||||
|
||||
@event_listener
|
||||
def on_event_new_transaction(self, wallet, tx):
|
||||
if wallet == self._wallet.wallet and tx.txid() == self._txid:
|
||||
self._logger.debug('new_transaction event for our txid %s' % self._txid)
|
||||
self.update()
|
||||
|
||||
walletChanged = pyqtSignal()
|
||||
@pyqtProperty(QEWallet, notify=walletChanged)
|
||||
def wallet(self):
|
||||
@@ -293,25 +299,24 @@ class QETxDetails(QObject, QtEventListener):
|
||||
self._header_hash = tx_mined_info.header_hash
|
||||
|
||||
@pyqtSlot()
|
||||
def sign(self):
|
||||
@pyqtSlot(bool)
|
||||
def sign(self, broadcast = False):
|
||||
# TODO: connecting/disconnecting signal handlers here is hmm
|
||||
try:
|
||||
self._wallet.transactionSigned.disconnect(self.onSigned)
|
||||
self._wallet.broadcastSucceeded.disconnect(self.onBroadcastSucceeded)
|
||||
if broadcast:
|
||||
self._wallet.broadcastfailed.disconnect(self.onBroadcastFailed)
|
||||
except:
|
||||
pass
|
||||
self._wallet.transactionSigned.connect(self.onSigned)
|
||||
self._wallet.sign(self._tx)
|
||||
self._wallet.broadcastSucceeded.connect(self.onBroadcastSucceeded)
|
||||
if broadcast:
|
||||
self._wallet.broadcastFailed.connect(self.onBroadcastFailed)
|
||||
self._wallet.sign(self._tx, broadcast=broadcast)
|
||||
# side-effect: signing updates self._tx
|
||||
# we rely on this for broadcast
|
||||
|
||||
@pyqtSlot(str)
|
||||
def onSigned(self, txid):
|
||||
if txid != self._txid:
|
||||
return
|
||||
|
||||
self._logger.debug('onSigned')
|
||||
self._wallet.transactionSigned.disconnect(self.onSigned)
|
||||
self.update()
|
||||
|
||||
@pyqtSlot()
|
||||
def broadcast(self):
|
||||
assert self._tx.is_complete()
|
||||
@@ -327,6 +332,26 @@ class QETxDetails(QObject, QtEventListener):
|
||||
|
||||
self._wallet.broadcast(self._tx)
|
||||
|
||||
@pyqtSlot(str)
|
||||
def onSigned(self, txid):
|
||||
if txid != self._txid:
|
||||
return
|
||||
|
||||
self._logger.debug('onSigned')
|
||||
self._wallet.transactionSigned.disconnect(self.onSigned)
|
||||
self.update()
|
||||
|
||||
@pyqtSlot(str)
|
||||
def onBroadcastSucceeded(self, txid):
|
||||
if txid != self._txid:
|
||||
return
|
||||
|
||||
self._logger.debug('onBroadcastSucceeded')
|
||||
self._wallet.broadcastSucceeded.disconnect(self.onBroadcastSucceeded)
|
||||
|
||||
self._can_broadcast = False
|
||||
self.detailsChanged.emit()
|
||||
|
||||
@pyqtSlot(str,str,str)
|
||||
def onBroadcastFailed(self, txid, code, reason):
|
||||
if txid != self._txid:
|
||||
|
||||
@@ -541,10 +541,10 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
||||
self.wallet.network.run_from_another_thread(self.wallet.network.broadcast_transaction(tx))
|
||||
except TxBroadcastError as e:
|
||||
self._logger.error(repr(e))
|
||||
self.broadcastFailed.emit(tx.txid(),'',repr(e))
|
||||
self.broadcastFailed.emit(tx.txid(),'',str(e))
|
||||
except BestEffortRequestFailed as e:
|
||||
self._logger.error(repr(e))
|
||||
self.broadcastFailed.emit(tx.txid(),'',repr(e))
|
||||
self.broadcastFailed.emit(tx.txid(),'',str(e))
|
||||
else:
|
||||
self._logger.info('broadcast success')
|
||||
self.broadcastSucceeded.emit(tx.txid())
|
||||
|
||||
Reference in New Issue
Block a user