test funding_txn_minimum_depth, show it in GUI
This commit is contained in:
@@ -782,7 +782,8 @@ class Commands:
|
|||||||
|
|
||||||
@command('wpn')
|
@command('wpn')
|
||||||
def open_channel(self, connection_string, amount, channel_push=0, password=None):
|
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')
|
@command('wn')
|
||||||
def lnpay(self, invoice, attempts=1, timeout=10):
|
def lnpay(self, invoice, attempts=1, timeout=10):
|
||||||
|
|||||||
@@ -136,8 +136,14 @@ class LightningOpenChannelDialog(Factory.Popup):
|
|||||||
|
|
||||||
def do_open_channel(self, conn_str, amount, password):
|
def do_open_channel(self, conn_str, amount, password):
|
||||||
try:
|
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:
|
except Exception as e:
|
||||||
self.app.show_error(_('Problem opening channel: ') + '\n' + repr(e))
|
self.app.show_error(_('Problem opening channel: ') + '\n' + repr(e))
|
||||||
return
|
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)
|
||||||
|
|||||||
@@ -1839,12 +1839,14 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||||||
def open_channel(self, *args, **kwargs):
|
def open_channel(self, *args, **kwargs):
|
||||||
def task():
|
def task():
|
||||||
return self.wallet.lnworker.open_channel(*args, **kwargs)
|
return self.wallet.lnworker.open_channel(*args, **kwargs)
|
||||||
def on_success(node_id):
|
def on_success(chan):
|
||||||
self.show_message('\n'.join([
|
n = chan.constraints.funding_txn_minimum_depth
|
||||||
|
message = '\n'.join([
|
||||||
_('Channel established.'),
|
_('Channel established.'),
|
||||||
_('Remote peer ID') + ':' + node_id,
|
_('Remote peer ID') + ':' + chan.node_id.hex(),
|
||||||
_('This channel will be usable after 3 confirmations')
|
_('This channel will be usable after {} confirmations').format(n)
|
||||||
]))
|
])
|
||||||
|
self.show_message(message)
|
||||||
def on_failure(exc_info):
|
def on_failure(exc_info):
|
||||||
type_, e, traceback = exc_info
|
type_, e, traceback = exc_info
|
||||||
self.show_error(_('Could not open channel: {}').format(e))
|
self.show_error(_('Could not open channel: {}').format(e))
|
||||||
|
|||||||
@@ -498,7 +498,10 @@ class Peer(Logger):
|
|||||||
raise Exception('Remote Lightning peer reported error: ' + repr(payload.get('error')))
|
raise Exception('Remote Lightning peer reported error: ' + repr(payload.get('error')))
|
||||||
remote_per_commitment_point = payload['first_per_commitment_point']
|
remote_per_commitment_point = payload['first_per_commitment_point']
|
||||||
funding_txn_minimum_depth = int.from_bytes(payload['minimum_depth'], 'big')
|
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_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)
|
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:
|
if remote_dust_limit_sat > remote_reserve_sat:
|
||||||
|
|||||||
@@ -717,7 +717,7 @@ class LNWallet(LNWorker):
|
|||||||
chan = fut.result(timeout=timeout)
|
chan = fut.result(timeout=timeout)
|
||||||
except concurrent.futures.TimeoutError:
|
except concurrent.futures.TimeoutError:
|
||||||
raise Exception(_("open_channel timed out"))
|
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):
|
def pay(self, invoice, attempts=1, amount_sat=None, timeout=10):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user