qml: multisig implement finalize tx not complete result
This commit is contained in:
@@ -224,7 +224,9 @@ ElDialog {
|
|||||||
FlatButton {
|
FlatButton {
|
||||||
id: sendButton
|
id: sendButton
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: Daemon.currentWallet.isWatchOnly ? qsTr('Finalize') : qsTr('Pay')
|
text: (Daemon.currentWallet.isWatchOnly || !Daemon.currentWallet.canSignWithoutCosigner)
|
||||||
|
? qsTr('Finalize')
|
||||||
|
: qsTr('Pay')
|
||||||
icon.source: '../../icons/confirmed.png'
|
icon.source: '../../icons/confirmed.png'
|
||||||
enabled: finalizer.valid
|
enabled: finalizer.valid
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ Pane {
|
|||||||
'satoshis': channelopener.amount
|
'satoshis': channelopener.amount
|
||||||
})
|
})
|
||||||
dialog.txaccepted.connect(function() {
|
dialog.txaccepted.connect(function() {
|
||||||
dialog.finalizer.send_onchain()
|
dialog.finalizer.signAndSend()
|
||||||
})
|
})
|
||||||
dialog.open()
|
dialog.open()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,12 +235,12 @@ Item {
|
|||||||
'satoshis': invoice.amount,
|
'satoshis': invoice.amount,
|
||||||
'message': invoice.message
|
'message': invoice.message
|
||||||
})
|
})
|
||||||
var wo = Daemon.currentWallet.isWatchOnly
|
var canComplete = !Daemon.currentWallet.isWatchOnly && Daemon.currentWallet.canSignWithoutCosigner
|
||||||
dialog.txaccepted.connect(function() {
|
dialog.txaccepted.connect(function() {
|
||||||
if (wo) {
|
if (!canComplete) {
|
||||||
showUnsignedTx(dialog.finalizer.serializedTx(false), dialog.finalizer.serializedTx(true))
|
dialog.finalizer.signAndSave()
|
||||||
} else {
|
} else {
|
||||||
dialog.finalizer.send_onchain()
|
dialog.finalizer.signAndSend()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
dialog.open()
|
dialog.open()
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ class QETxFinalizer(TxFeeSlider):
|
|||||||
self.validChanged.emit()
|
self.validChanged.emit()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def send_onchain(self):
|
def signAndSend(self):
|
||||||
if not self._valid or not self._tx:
|
if not self._valid or not self._tx:
|
||||||
self._logger.debug('no valid tx')
|
self._logger.debug('no valid tx')
|
||||||
return
|
return
|
||||||
@@ -331,6 +331,35 @@ class QETxFinalizer(TxFeeSlider):
|
|||||||
|
|
||||||
self._wallet.sign(self._tx, broadcast=True)
|
self._wallet.sign(self._tx, broadcast=True)
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def signAndSave(self):
|
||||||
|
if not self._valid or not self._tx:
|
||||||
|
self._logger.error('no valid tx')
|
||||||
|
return
|
||||||
|
|
||||||
|
# TODO: f_accept handler not used
|
||||||
|
# if self.f_accept:
|
||||||
|
# self.f_accept(self._tx)
|
||||||
|
# return
|
||||||
|
|
||||||
|
try:
|
||||||
|
self._wallet.transactionSigned.disconnect(self.onSigned)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
self._wallet.transactionSigned.connect(self.onSigned)
|
||||||
|
self._wallet.sign(self._tx)
|
||||||
|
|
||||||
|
@pyqtSlot(str)
|
||||||
|
def onSigned(self, txid):
|
||||||
|
if txid != self._tx.txid():
|
||||||
|
return
|
||||||
|
|
||||||
|
self._logger.debug('onSigned')
|
||||||
|
self._wallet.transactionSigned.disconnect(self.onSigned)
|
||||||
|
|
||||||
|
if not self._wallet.wallet.adb.add_transaction(self._tx):
|
||||||
|
self._logger.error('Could not save tx')
|
||||||
|
|
||||||
@pyqtSlot(result=str)
|
@pyqtSlot(result=str)
|
||||||
@pyqtSlot(bool, result=str)
|
@pyqtSlot(bool, result=str)
|
||||||
def serializedTx(self, for_qr=False):
|
def serializedTx(self, for_qr=False):
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ from electrum.network import TxBroadcastError, BestEffortRequestFailed
|
|||||||
from electrum.transaction import PartialTxOutput
|
from electrum.transaction import PartialTxOutput
|
||||||
from electrum.util import (parse_max_spend, InvalidPassword, event_listener)
|
from electrum.util import (parse_max_spend, InvalidPassword, event_listener)
|
||||||
from electrum.plugin import run_hook
|
from electrum.plugin import run_hook
|
||||||
|
from electrum.wallet import Multisig_Wallet
|
||||||
|
|
||||||
from .auth import AuthMixin, auth_protect
|
from .auth import AuthMixin, auth_protect
|
||||||
from .qeaddresslistmodel import QEAddressListModel
|
from .qeaddresslistmodel import QEAddressListModel
|
||||||
@@ -355,6 +356,14 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
|||||||
def canSignWithoutServer(self):
|
def canSignWithoutServer(self):
|
||||||
return self.wallet.can_sign_without_server() if self.wallet.wallet_type == '2fa' else True
|
return self.wallet.can_sign_without_server() if self.wallet.wallet_type == '2fa' else True
|
||||||
|
|
||||||
|
@pyqtProperty(bool, notify=dataChanged)
|
||||||
|
def canSignWithoutCosigner(self):
|
||||||
|
if isinstance(self.wallet, Multisig_Wallet):
|
||||||
|
if self.wallet.wallet_type == '2fa': # 2fa is multisig, but it handles cosigning itself
|
||||||
|
return True
|
||||||
|
return self.wallet.m == 1
|
||||||
|
return True
|
||||||
|
|
||||||
balanceChanged = pyqtSignal()
|
balanceChanged = pyqtSignal()
|
||||||
|
|
||||||
@pyqtProperty(QEAmount, notify=balanceChanged)
|
@pyqtProperty(QEAmount, notify=balanceChanged)
|
||||||
@@ -453,12 +462,12 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
|||||||
return
|
return
|
||||||
|
|
||||||
txid = tx.txid()
|
txid = tx.txid()
|
||||||
self._logger.debug(f'txid={txid}')
|
self._logger.debug(f'do_sign(), txid={txid}')
|
||||||
|
|
||||||
self.transactionSigned.emit(txid)
|
self.transactionSigned.emit(txid)
|
||||||
|
|
||||||
if not tx.is_complete():
|
if not tx.is_complete():
|
||||||
self._logger.info('tx not complete')
|
self._logger.debug('tx not complete')
|
||||||
return
|
return
|
||||||
|
|
||||||
if broadcast:
|
if broadcast:
|
||||||
|
|||||||
Reference in New Issue
Block a user