1
0

detect conflicting channel backups, add warning before channel creation

This commit is contained in:
ThomasV
2021-03-29 19:57:51 +02:00
parent f2040b19ea
commit cd4df2fd85
5 changed files with 31 additions and 4 deletions

View File

@@ -15,6 +15,7 @@ from electrum.lnutil import ln_dummy_address, extract_nodeid
from .label_dialog import LabelDialog
from .confirm_tx_dialog import ConfirmTxDialog
from .qr_dialog import QRDialog
from .question import Question
if TYPE_CHECKING:
from ...main_window import ElectrumWindow
@@ -179,6 +180,18 @@ class LightningOpenChannelDialog(Factory.Popup, Logger):
amount = '!' if self.is_max else self.app.get_amount(self.amount)
self.dismiss()
lnworker = self.app.wallet.lnworker
node_id, rest = extract_nodeid(conn_str)
if lnworker.has_conflicting_backup_with(node_id):
msg = messages.MGS_CONFLICTING_BACKUP_INSTANCE
d = Question(msg, lambda x: self._open_channel(x, conn_str, amount))
d.open()
else:
self._open_channel(True, conn_str, amount)
def _open_channel(self, x, conn_str, amount):
if not x:
return
lnworker = self.app.wallet.lnworker
coins = self.app.wallet.get_spendable_coins(None, nonlocal_only=True)
node_id, rest = extract_nodeid(conn_str)
make_tx = lambda rbf: lnworker.mktx_for_open_channel(

View File

@@ -31,3 +31,9 @@ Lightning payments require finding a path through the Lightning Network. You may
Downloading the network gossip uses quite some bandwidth and storage, and is not recommended on mobile devices. If you use trampoline, you can only open channels with trampoline nodes.
"""
MGS_CONFLICTING_BACKUP_INSTANCE = """
Another instance of this wallet (same seed) has an open channel with the same remote node. If you create this channel, you will not be able to use both wallets at the same time.
Are you sure?
"""

View File

@@ -1813,6 +1813,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
except ConnStringFormatError as e:
self.show_error(str(e))
return
if self.wallet.lnworker.has_conflicting_backup_with(node_id):
msg = messages.MGS_CONFLICTING_BACKUP_INSTANCE
if not self.question(msg):
return
# use ConfirmTxDialog
# we need to know the fee before we broadcast, because the txid is required
make_tx = self.mktx_for_open_channel(funding_sat=funding_sat, node_id=node_id)