Browse Source

test funding_txn_minimum_depth, show it in GUI

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
ThomasV 6 years ago
parent
commit
9f8e2c689e
  1. 3
      electrum/commands.py
  2. 10
      electrum/gui/kivy/uix/dialogs/lightning_open_channel.py
  3. 12
      electrum/gui/qt/main_window.py
  4. 5
      electrum/lnpeer.py
  5. 2
      electrum/lnworker.py

3
electrum/commands.py

@ -782,7 +782,8 @@ class Commands:
@command('wpn')
def open_channel(self, connection_string, amount, channel_push=0, password=None):
return self.lnworker.open_channel(connection_string, satoshis(amount), satoshis(channel_push), password)
chan = self.lnworker.open_channel(connection_string, satoshis(amount), satoshis(channel_push), password)
return chan.funding_outpoint.to_str()
@command('wn')
def lnpay(self, invoice, attempts=1, timeout=10):

10
electrum/gui/kivy/uix/dialogs/lightning_open_channel.py

@ -136,8 +136,14 @@ class LightningOpenChannelDialog(Factory.Popup):
def do_open_channel(self, conn_str, amount, password):
try:
node_id_hex = self.app.wallet.lnworker.open_channel(conn_str, amount, 0, password=password)
chan = self.app.wallet.lnworker.open_channel(conn_str, amount, 0, password=password)
except Exception as e:
self.app.show_error(_('Problem opening channel: ') + '\n' + repr(e))
return
self.app.show_info(_('Please wait for confirmation, channel is opening with node ') + node_id_hex[:16])
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)
])
self.app.show_info(message)

12
electrum/gui/qt/main_window.py

@ -1839,12 +1839,14 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
def open_channel(self, *args, **kwargs):
def task():
return self.wallet.lnworker.open_channel(*args, **kwargs)
def on_success(node_id):
self.show_message('\n'.join([
def on_success(chan):
n = chan.constraints.funding_txn_minimum_depth
message = '\n'.join([
_('Channel established.'),
_('Remote peer ID') + ':' + node_id,
_('This channel will be usable after 3 confirmations')
]))
_('Remote peer ID') + ':' + chan.node_id.hex(),
_('This channel will be usable after {} confirmations').format(n)
])
self.show_message(message)
def on_failure(exc_info):
type_, e, traceback = exc_info
self.show_error(_('Could not open channel: {}').format(e))

5
electrum/lnpeer.py

@ -498,7 +498,10 @@ class Peer(Logger):
raise Exception('Remote Lightning peer reported error: ' + repr(payload.get('error')))
remote_per_commitment_point = payload['first_per_commitment_point']
funding_txn_minimum_depth = int.from_bytes(payload['minimum_depth'], 'big')
assert funding_txn_minimum_depth > 0, funding_txn_minimum_depth
if funding_txn_minimum_depth <= 0:
raise Exception(f"minimum depth too low, {funding_txn_minimum_depth}")
if funding_txn_minimum_depth > 30:
raise Exception(f"minimum depth too high, {funding_txn_minimum_depth}")
remote_dust_limit_sat = int.from_bytes(payload['dust_limit_satoshis'], byteorder='big')
remote_reserve_sat = self.validate_remote_reserve(payload["channel_reserve_satoshis"], remote_dust_limit_sat, funding_sat)
if remote_dust_limit_sat > remote_reserve_sat:

2
electrum/lnworker.py

@ -717,7 +717,7 @@ class LNWallet(LNWorker):
chan = fut.result(timeout=timeout)
except concurrent.futures.TimeoutError:
raise Exception(_("open_channel timed out"))
return chan.funding_outpoint.to_str()
return chan
def pay(self, invoice, attempts=1, amount_sat=None, timeout=10):
"""

Loading…
Cancel
Save