mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-04 21:05:11 +00:00
remove our closed channels from channeldb. note some FIXMEs
payment were attempting to use the closed channels.
This commit is contained in:
parent
b3c21aa8d8
commit
7baf428cb8
2 changed files with 10 additions and 2 deletions
|
@ -748,6 +748,7 @@ class Peer(PrintError):
|
|||
def mark_open(self, chan):
|
||||
if chan.get_state() == "OPEN":
|
||||
return
|
||||
# NOTE: even closed channels will be temporarily marked "OPEN"
|
||||
assert chan.local_state.funding_locked_received
|
||||
chan.set_state("OPEN")
|
||||
self.network.trigger_callback('channel', chan)
|
||||
|
@ -833,7 +834,8 @@ class Peer(PrintError):
|
|||
|
||||
@aiosafe
|
||||
async def pay(self, path, chan, amount_msat, payment_hash, pubkey_in_invoice, min_final_cltv_expiry):
|
||||
assert chan.get_state() == "OPEN"
|
||||
# FIXME aiosafe is breaking "raise PaymentFailure"
|
||||
assert chan.get_state() == "OPEN", chan.get_state()
|
||||
assert amount_msat > 0, "amount_msat is not greater zero"
|
||||
|
||||
height = self.network.get_local_height()
|
||||
|
@ -856,10 +858,15 @@ class Peer(PrintError):
|
|||
msat_remote = chan.remote_state.amount_msat + amount_msat
|
||||
htlc = UpdateAddHtlc(amount_msat, payment_hash, final_cltv_expiry_with_deltas)
|
||||
|
||||
# FIXME if we raise here, this channel will not get blacklisted, and the payment can never succeed,
|
||||
# as we will just keep retrying this same path. using the current blacklisting is not a solution as
|
||||
# then no other payment can use this channel either.
|
||||
# we need finer blacklisting -- e.g. a blacklist for just this "payment session"?
|
||||
# or blacklist entries could store an msat value and also expire
|
||||
if len(chan.htlcs_in_local) + 1 > chan.remote_config.max_accepted_htlcs:
|
||||
raise PaymentFailure('too many HTLCs already in channel')
|
||||
if chan.htlcsum(chan.htlcs_in_local) + amount_msat > chan.remote_config.max_htlc_value_in_flight_msat:
|
||||
raise PaymentFailure('HTLC value sum would exceed max allowed')
|
||||
raise PaymentFailure('HTLC value sum would exceed max allowed: {} msat'.format(chan.remote_config.max_htlc_value_in_flight_msat))
|
||||
if msat_local < 0:
|
||||
# FIXME what about channel_reserve_satoshis? will the remote fail the channel if we go below? test.
|
||||
raise PaymentFailure('not enough local balance')
|
||||
|
|
|
@ -124,6 +124,7 @@ class LNWorker(PrintError):
|
|||
if chan.funding_outpoint not in outpoints:
|
||||
chan.set_funding_txo_spentness(True)
|
||||
chan.set_state("CLOSED")
|
||||
self.channel_db.remove_channel(chan.short_channel_id)
|
||||
# FIXME is this properly GC-ed? (or too soon?)
|
||||
LNChanCloseHandler(self.network, self.wallet, chan)
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue