|
|
@ -6,6 +6,7 @@ from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject |
|
|
|
|
|
|
|
from electrum.i18n import _ |
|
|
|
from electrum.gui import messages |
|
|
|
from electrum.util import bfh |
|
|
|
from electrum.lnutil import extract_nodeid, LNPeerAddr, ln_dummy_address |
|
|
|
from electrum.lnworker import hardcoded_trampoline_nodes |
|
|
|
from electrum.logging import get_logger |
|
|
@ -27,12 +28,13 @@ class QEChannelOpener(QObject, AuthMixin): |
|
|
|
_amount = QEAmount() |
|
|
|
_valid = False |
|
|
|
_opentx = None |
|
|
|
_txdetails = None |
|
|
|
|
|
|
|
validationError = pyqtSignal([str,str], arguments=['code','message']) |
|
|
|
conflictingBackup = pyqtSignal([str], arguments=['message']) |
|
|
|
channelOpening = pyqtSignal([str], arguments=['peer']) |
|
|
|
channelOpenError = pyqtSignal([str], arguments=['message']) |
|
|
|
channelOpenSuccess = pyqtSignal([str,bool], arguments=['cid','has_backup']) |
|
|
|
channelOpenSuccess = pyqtSignal([str,bool,int], arguments=['cid','has_onchain_backup','min_depth','tx_complete']) |
|
|
|
|
|
|
|
dataChanged = pyqtSignal() # generic notify signal |
|
|
|
|
|
|
@ -82,6 +84,11 @@ class QEChannelOpener(QObject, AuthMixin): |
|
|
|
def finalizer(self): |
|
|
|
return self._finalizer |
|
|
|
|
|
|
|
txDetailsChanged = pyqtSignal() |
|
|
|
@pyqtProperty(QETxDetails, notify=txDetailsChanged) |
|
|
|
def txDetails(self): |
|
|
|
return self._txdetails |
|
|
|
|
|
|
|
@pyqtProperty(list, notify=dataChanged) |
|
|
|
def trampolineNodeNames(self): |
|
|
|
return list(hardcoded_trampoline_nodes().keys()) |
|
|
@ -180,7 +187,16 @@ class QEChannelOpener(QObject, AuthMixin): |
|
|
|
push_amt_sat=0, |
|
|
|
password=password) |
|
|
|
self._logger.debug('opening channel succeeded') |
|
|
|
self.channelOpenSuccess.emit(chan.channel_id.hex(), chan.has_onchain_backup()) |
|
|
|
self.channelOpenSuccess.emit(chan.channel_id.hex(), chan.has_onchain_backup(), |
|
|
|
chan.constraints.funding_txn_minimum_depth, funding_tx.is_complete()) |
|
|
|
|
|
|
|
# TODO: handle incomplete TX |
|
|
|
#if not funding_tx.is_complete(): |
|
|
|
#self._txdetails = QETxDetails(self) |
|
|
|
#self._txdetails.rawTx = funding_tx |
|
|
|
#self._txdetails.wallet = self._wallet |
|
|
|
#self.txDetailsChanged.emit() |
|
|
|
|
|
|
|
except (CancelledError,TimeoutError): |
|
|
|
error = _('Could not connect to channel peer') |
|
|
|
except Exception as e: |
|
|
@ -212,3 +228,22 @@ class QEChannelOpener(QObject, AuthMixin): |
|
|
|
#close_button_text=_('OK'), |
|
|
|
#on_close=lambda: self.maybe_show_funding_tx(chan, funding_tx)) |
|
|
|
#popup.open() |
|
|
|
|
|
|
|
|
|
|
|
#def maybe_show_funding_tx(self, chan, funding_tx): |
|
|
|
#n = chan.constraints.funding_txn_minimum_depth |
|
|
|
#message = '\n'.join([ |
|
|
|
#_('Channel established.'), |
|
|
|
#_('Remote peer ID') + ':' + chan.node_id.hex(), |
|
|
|
#_('This channel will be usable after {} confirmations').format(n) |
|
|
|
#]) |
|
|
|
#if not funding_tx.is_complete(): |
|
|
|
#message += '\n\n' + _('Please sign and broadcast the funding transaction') |
|
|
|
#self.app.show_info(message) |
|
|
|
|
|
|
|
#if not funding_tx.is_complete(): |
|
|
|
#self.app.tx_dialog(funding_tx) |
|
|
|
|
|
|
|
@pyqtSlot(str, result=str) |
|
|
|
def channelBackup(self, cid): |
|
|
|
return self._wallet.wallet.lnworker.export_channel_backup(bfh(cid)) |
|
|
|