tln: request_initial_sync, increase our max_htlc_value, fix receiving payment - electrum - Electrum Bitcoin wallet (HTM) git clone https://git.parazyd.org/electrum (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules --- (DIR) commit 5ed6f79a330b09175cf5b3abc8d5d034af83326e (DIR) parent 6e71340e526bf5bbc0807419ea641ffefd3ac933 (HTM) Author: Janus <ysangkok@gmail.com> Date: Fri, 8 Jun 2018 17:17:46 +0200 ln: request_initial_sync, increase our max_htlc_value, fix receiving payment Diffstat: M lib/lnbase.py | 13 ++++++------- M lib/lnworker.py | 6 ++++-- 2 files changed, 10 insertions(+), 9 deletions(-) --- (DIR) diff --git a/lib/lnbase.py b/lib/lnbase.py t@@ -801,7 +801,7 @@ class Peer(PrintError): revocation_basepoint=keypair_generator(keyfamilyrevocationbase, 0), to_self_delay=143, dust_limit_sat=10, - max_htlc_value_in_flight_msat=500000 * 1000, + max_htlc_value_in_flight_msat=0xffffffffffffffff, max_accepted_htlcs=5 ) # TODO derive this? t@@ -1019,10 +1019,7 @@ class Peer(PrintError): assert amount_msat > 0, "amount_msat is not greater zero" height = self.network.get_local_height() their_revstore = chan.remote_state.revocation_store - if chan.channel_id in self.commitment_signed: - print("too many commitments signed") - del self.commitment_signed[chan.channel_id] - route = self.path_finder.create_route_from_path(path, self.lnworker.pubkey) + route = self.lnworker.path_finder.create_route_from_path(path, self.lnworker.pubkey) hops_data = [] sum_of_deltas = sum(route_edge.channel_policy.cltv_expiry_delta for route_edge in route[1:]) total_fee = 0 t@@ -1121,7 +1118,9 @@ class Peer(PrintError): while True: self.print_error("receiving commitment") commitment_signed_msg = await self.commitment_signed[channel_id].get() - if int.from_bytes(commitment_signed_msg["num_htlcs"], "big") == 1: + num_htlcs = int.from_bytes(commitment_signed_msg["num_htlcs"], "big") + print("num_htlcs", num_htlcs) + if num_htlcs == 1: break htlc_id = int.from_bytes(htlc["id"], 'big') assert htlc_id == chan.remote_state.next_htlc_id, (htlc_id, chan.remote_state.next_htlc_id) t@@ -1231,7 +1230,7 @@ class Peer(PrintError): next_htlc_id=htlc_id + 1 ) ) - # TODO save new_chan + self.lnworker.save_channel(new_chan) def on_commitment_signed(self, payload): self.print_error("commitment_signed", payload) (DIR) diff --git a/lib/lnworker.py b/lib/lnworker.py t@@ -120,7 +120,7 @@ class LNWorker(PrintError): def add_peer(self, host, port, pubkey): node_id = bfh(pubkey) channels = self.channels_for_peer(node_id) - peer = Peer(self, host, int(port), node_id, request_initial_sync=False) + peer = Peer(self, host, int(port), node_id, request_initial_sync=self.config.get("request_initial_sync", True)) self.network.futures.append(asyncio.run_coroutine_threadsafe(peer.main_loop(), asyncio.get_event_loop())) self.peers[node_id] = peer self.lock = threading.Lock() t@@ -188,13 +188,15 @@ class LNWorker(PrintError): invoice_pubkey = addr.pubkey.serialize() amount_msat = int(addr.amount * COIN * 1000) path = self.path_finder.find_path_for_payment(self.pubkey, invoice_pubkey, amount_msat) + if path is None: + return "No path found" node_id, short_channel_id = path[0] peer = self.peers[node_id] for chan in self.channels.values(): if chan.short_channel_id == short_channel_id: break coro = peer.pay(path, chan, amount_msat, payment_hash, invoice_pubkey, addr.min_final_cltv_expiry) - asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop) + return asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop) def add_invoice(self, amount_sat, message): is_open = lambda chan: self.channel_state[chan.channel_id] == "OPEN"