mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
CLI: use funding_point in channel_open and channel_close. add host:port to nodeid
This commit is contained in:
parent
0924503cb6
commit
d383573bc3
2 changed files with 14 additions and 7 deletions
|
@ -49,6 +49,7 @@ from .address_synchronizer import TX_HEIGHT_LOCAL
|
||||||
from .import lightning
|
from .import lightning
|
||||||
from .mnemonic import Mnemonic
|
from .mnemonic import Mnemonic
|
||||||
from .lnutil import SENT, RECEIVED
|
from .lnutil import SENT, RECEIVED
|
||||||
|
from .lnbase import channel_id_from_funding_tx
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .network import Network
|
from .network import Network
|
||||||
|
@ -789,12 +790,13 @@ class Commands:
|
||||||
# using requested_amount because it is documented in param_descriptions
|
# using requested_amount because it is documented in param_descriptions
|
||||||
return self.lnworker.add_invoice(satoshis(requested_amount), message)
|
return self.lnworker.add_invoice(satoshis(requested_amount), message)
|
||||||
|
|
||||||
@command('wn')
|
@command('w')
|
||||||
def nodeid(self):
|
def nodeid(self):
|
||||||
return bh2u(self.lnworker.node_keypair.pubkey)
|
listen_addr = self.config.get('lightning_listen')
|
||||||
|
return bh2u(self.lnworker.node_keypair.pubkey) + (('@' + listen_addr) if listen_addr else '')
|
||||||
|
|
||||||
@command('w')
|
@command('w')
|
||||||
def listchannels(self):
|
def list_channels(self):
|
||||||
return list(self.lnworker.list_channels())
|
return list(self.lnworker.list_channels())
|
||||||
|
|
||||||
@command('wn')
|
@command('wn')
|
||||||
|
@ -833,8 +835,9 @@ class Commands:
|
||||||
return self.lnworker.get_history()
|
return self.lnworker.get_history()
|
||||||
|
|
||||||
@command('wn')
|
@command('wn')
|
||||||
def closechannel(self, channel_point, force=False):
|
def close_channel(self, channel_point, force=False):
|
||||||
chan_id = bytes(reversed(bfh(channel_point)))
|
txid, index = channel_point.split(':')
|
||||||
|
chan_id, _ = channel_id_from_funding_tx(txid, int(index))
|
||||||
coro = self.lnworker.force_close_channel(chan_id) if force else self.lnworker.close_channel(chan_id)
|
coro = self.lnworker.force_close_channel(chan_id) if force else self.lnworker.close_channel(chan_id)
|
||||||
return self.network.run_from_another_thread(coro)
|
return self.network.run_from_another_thread(coro)
|
||||||
|
|
||||||
|
|
|
@ -444,7 +444,7 @@ class LNWorker(PrintError):
|
||||||
coro = self._open_channel_coroutine(peer, local_amt_sat, push_amt_sat, password)
|
coro = self._open_channel_coroutine(peer, local_amt_sat, push_amt_sat, password)
|
||||||
f = asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop)
|
f = asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop)
|
||||||
chan = f.result(timeout)
|
chan = f.result(timeout)
|
||||||
return bh2u(chan.node_id)
|
return chan.funding_outpoint.to_str()
|
||||||
|
|
||||||
def pay(self, invoice, amount_sat=None):
|
def pay(self, invoice, amount_sat=None):
|
||||||
"""
|
"""
|
||||||
|
@ -798,7 +798,11 @@ class LNWorker(PrintError):
|
||||||
addr = addr[1:-1]
|
addr = addr[1:-1]
|
||||||
async def cb(reader, writer):
|
async def cb(reader, writer):
|
||||||
t = LNResponderTransport(self.node_keypair.privkey, reader, writer)
|
t = LNResponderTransport(self.node_keypair.privkey, reader, writer)
|
||||||
|
try:
|
||||||
node_id = await t.handshake()
|
node_id = await t.handshake()
|
||||||
|
except:
|
||||||
|
self.print_error('handshake failure from incoming connection')
|
||||||
|
return
|
||||||
# FIXME extract host and port from transport
|
# FIXME extract host and port from transport
|
||||||
peer = Peer(self, LNPeerAddr("bogus", 1337, node_id),
|
peer = Peer(self, LNPeerAddr("bogus", 1337, node_id),
|
||||||
request_initial_sync=self.config.get("request_initial_sync", True),
|
request_initial_sync=self.config.get("request_initial_sync", True),
|
||||||
|
|
Loading…
Add table
Reference in a new issue