qml: move save_tx to qewallet
This commit is contained in:
@@ -421,7 +421,13 @@ Pane {
|
|||||||
})
|
})
|
||||||
dialog.open()
|
dialog.open()
|
||||||
}
|
}
|
||||||
onSaveTxSuccess: {
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Daemon.currentWallet
|
||||||
|
function onSaveTxSuccess(txid) {
|
||||||
|
if (txid != txdetails.txid)
|
||||||
|
return
|
||||||
var dialog = app.messageDialog.createObject(app, {
|
var dialog = app.messageDialog.createObject(app, {
|
||||||
text: qsTr('Transaction added to wallet history.') + '\n\n' +
|
text: qsTr('Transaction added to wallet history.') + '\n\n' +
|
||||||
qsTr('Note: this is an offline transaction, if you want the network to see it, you need to broadcast it.')
|
qsTr('Note: this is an offline transaction, if you want the network to see it, you need to broadcast it.')
|
||||||
@@ -429,7 +435,9 @@ Pane {
|
|||||||
dialog.open()
|
dialog.open()
|
||||||
root.close()
|
root.close()
|
||||||
}
|
}
|
||||||
onSaveTxError: {
|
function onSaveTxError(txid, code, message) {
|
||||||
|
if (txid != txdetails.txid)
|
||||||
|
return
|
||||||
var dialog = app.messageDialog.createObject(app, { text: message })
|
var dialog = app.messageDialog.createObject(app, { text: message })
|
||||||
dialog.open()
|
dialog.open()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -386,17 +386,7 @@ class QETxDetails(QObject, QtEventListener):
|
|||||||
if not self._tx:
|
if not self._tx:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
if self._wallet.save_tx(self._tx):
|
||||||
if not self._wallet.wallet.adb.add_transaction(self._tx):
|
|
||||||
self.saveTxError.emit('conflict',
|
|
||||||
_("Transaction could not be saved.") + "\n" + _("It conflicts with current history."))
|
|
||||||
return
|
|
||||||
self._wallet.wallet.save_db()
|
|
||||||
self.saveTxSuccess.emit()
|
|
||||||
self._wallet.historyModel.init_model(True)
|
|
||||||
except AddTransactionException as e:
|
|
||||||
self.saveTxError.emit('error', str(e))
|
|
||||||
finally:
|
|
||||||
self._can_save_as_local = False
|
self._can_save_as_local = False
|
||||||
self._can_remove = True
|
self._can_remove = True
|
||||||
self.detailsChanged.emit()
|
self.detailsChanged.emit()
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ from electrum.i18n import _
|
|||||||
from electrum.invoices import InvoiceError, PR_DEFAULT_EXPIRATION_WHEN_CREATING, PR_PAID
|
from electrum.invoices import InvoiceError, PR_DEFAULT_EXPIRATION_WHEN_CREATING, PR_PAID
|
||||||
from electrum.logging import get_logger
|
from electrum.logging import get_logger
|
||||||
from electrum.network import TxBroadcastError, BestEffortRequestFailed
|
from electrum.network import TxBroadcastError, BestEffortRequestFailed
|
||||||
from electrum.transaction import PartialTxOutput
|
from electrum.transaction import PartialTxOutput, PartialTransaction
|
||||||
from electrum.util import (parse_max_spend, InvalidPassword, event_listener)
|
from electrum.util import parse_max_spend, InvalidPassword, event_listener, AddTransactionException
|
||||||
from electrum.plugin import run_hook
|
from electrum.plugin import run_hook
|
||||||
from electrum.wallet import Multisig_Wallet
|
from electrum.wallet import Multisig_Wallet
|
||||||
from electrum.crypto import pw_decode_with_version_and_mac
|
from electrum.crypto import pw_decode_with_version_and_mac
|
||||||
@@ -65,6 +65,8 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
|||||||
transactionSigned = pyqtSignal([str], arguments=['txid'])
|
transactionSigned = pyqtSignal([str], arguments=['txid'])
|
||||||
broadcastSucceeded = pyqtSignal([str], arguments=['txid'])
|
broadcastSucceeded = pyqtSignal([str], arguments=['txid'])
|
||||||
broadcastFailed = pyqtSignal([str,str,str], arguments=['txid','code','reason'])
|
broadcastFailed = pyqtSignal([str,str,str], arguments=['txid','code','reason'])
|
||||||
|
saveTxSuccess = pyqtSignal([str], arguments=['txid'])
|
||||||
|
saveTxError = pyqtSignal([str,str], arguments=['txid', 'code', 'message'])
|
||||||
importChannelBackupFailed = pyqtSignal([str], arguments=['message'])
|
importChannelBackupFailed = pyqtSignal([str], arguments=['message'])
|
||||||
labelsUpdated = pyqtSignal()
|
labelsUpdated = pyqtSignal()
|
||||||
otpRequested = pyqtSignal()
|
otpRequested = pyqtSignal()
|
||||||
@@ -509,7 +511,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
|||||||
if broadcast:
|
if broadcast:
|
||||||
self.broadcast(tx)
|
self.broadcast(tx)
|
||||||
else:
|
else:
|
||||||
# not broadcasted, so add to history now
|
# not broadcasted, so refresh history here
|
||||||
self.historyModel.init_model(True)
|
self.historyModel.init_model(True)
|
||||||
|
|
||||||
# this assumes a 2fa wallet, but there are no other tc_sign_wrapper hooks, so that's ok
|
# this assumes a 2fa wallet, but there are no other tc_sign_wrapper hooks, so that's ok
|
||||||
@@ -553,6 +555,22 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
|||||||
|
|
||||||
#TODO: properly catch server side errors, e.g. bad-txns-inputs-missingorspent
|
#TODO: properly catch server side errors, e.g. bad-txns-inputs-missingorspent
|
||||||
|
|
||||||
|
def save_tx(self, tx: 'PartialTransaction'):
|
||||||
|
assert tx
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not self.wallet.adb.add_transaction(tx):
|
||||||
|
self.saveTxError.emit(tx.txid(), 'conflict',
|
||||||
|
_("Transaction could not be saved.") + "\n" + _("It conflicts with current history."))
|
||||||
|
return
|
||||||
|
self.wallet.save_db()
|
||||||
|
self.saveTxSuccess.emit(tx.txid())
|
||||||
|
self.historyModel.init_model(True)
|
||||||
|
return True
|
||||||
|
except AddTransactionException as e:
|
||||||
|
self.saveTxError.emit(tx.txid(), 'error', str(e))
|
||||||
|
return False
|
||||||
|
|
||||||
paymentAuthRejected = pyqtSignal()
|
paymentAuthRejected = pyqtSignal()
|
||||||
def ln_auth_rejected(self):
|
def ln_auth_rejected(self):
|
||||||
self.paymentAuthRejected.emit()
|
self.paymentAuthRejected.emit()
|
||||||
|
|||||||
Reference in New Issue
Block a user