mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-07 02:59:53 +00:00
test funding_txn_minimum_depth, show it in GUI
This commit is contained in:
parent
bbec1dceda
commit
9f8e2c689e
5 changed files with 22 additions and 10 deletions
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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…
Add table
Reference in a new issue