electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit d383573bc39431f865d83f8e574e7f13e7f15019
parent 0924503cb67a55abac2b576d00db4d02b097c461
Author: ThomasV <thomasv@electrum.org>
Date:   Fri,  1 Feb 2019 15:27:50 +0100

CLI: use funding_point in channel_open and channel_close. add host:port to nodeid

Diffstat:
Melectrum/commands.py | 13++++++++-----
Melectrum/lnworker.py | 8++++++--
2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/electrum/commands.py b/electrum/commands.py @@ -49,6 +49,7 @@ from .address_synchronizer import TX_HEIGHT_LOCAL from .import lightning from .mnemonic import Mnemonic from .lnutil import SENT, RECEIVED +from .lnbase import channel_id_from_funding_tx if TYPE_CHECKING: from .network import Network @@ -789,12 +790,13 @@ class Commands: # using requested_amount because it is documented in param_descriptions return self.lnworker.add_invoice(satoshis(requested_amount), message) - @command('wn') + @command('w') 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') - def listchannels(self): + def list_channels(self): return list(self.lnworker.list_channels()) @command('wn') @@ -833,8 +835,9 @@ class Commands: return self.lnworker.get_history() @command('wn') - def closechannel(self, channel_point, force=False): - chan_id = bytes(reversed(bfh(channel_point))) + def close_channel(self, channel_point, force=False): + 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) return self.network.run_from_another_thread(coro) diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -444,7 +444,7 @@ class LNWorker(PrintError): coro = self._open_channel_coroutine(peer, local_amt_sat, push_amt_sat, password) f = asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop) chan = f.result(timeout) - return bh2u(chan.node_id) + return chan.funding_outpoint.to_str() def pay(self, invoice, amount_sat=None): """ @@ -798,7 +798,11 @@ class LNWorker(PrintError): addr = addr[1:-1] async def cb(reader, writer): t = LNResponderTransport(self.node_keypair.privkey, reader, writer) - node_id = await t.handshake() + try: + node_id = await t.handshake() + except: + self.print_error('handshake failure from incoming connection') + return # FIXME extract host and port from transport peer = Peer(self, LNPeerAddr("bogus", 1337, node_id), request_initial_sync=self.config.get("request_initial_sync", True),