mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-29 16:31:29 +00:00
ln: request_initial_sync, increase our max_htlc_value, fix receiving payment
This commit is contained in:
parent
6e71340e52
commit
5ed6f79a33
2 changed files with 10 additions and 9 deletions
|
@ -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?
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue