lnpeer.htlc_switch: (bugfix) don't fulfill htlc until add is irrevocable
This makes the test added in prev commit pass.
This commit is contained in:
@@ -858,6 +858,7 @@ class Channel(AbstractChannel):
|
|||||||
local_ctn = self.get_latest_ctn(LOCAL)
|
local_ctn = self.get_latest_ctn(LOCAL)
|
||||||
remote_ctn = self.get_latest_ctn(REMOTE)
|
remote_ctn = self.get_latest_ctn(REMOTE)
|
||||||
if onion_packet:
|
if onion_packet:
|
||||||
|
# TODO neither local_ctn nor remote_ctn are used anymore... no point storing them.
|
||||||
self.hm.log['unfulfilled_htlcs'][htlc.htlc_id] = local_ctn, remote_ctn, onion_packet.hex(), False
|
self.hm.log['unfulfilled_htlcs'][htlc.htlc_id] = local_ctn, remote_ctn, onion_packet.hex(), False
|
||||||
|
|
||||||
self.logger.info("receive_htlc")
|
self.logger.info("receive_htlc")
|
||||||
|
|||||||
@@ -1666,10 +1666,7 @@ class Peer(Logger):
|
|||||||
done = set()
|
done = set()
|
||||||
unfulfilled = chan.hm.log.get('unfulfilled_htlcs', {})
|
unfulfilled = chan.hm.log.get('unfulfilled_htlcs', {})
|
||||||
for htlc_id, (local_ctn, remote_ctn, onion_packet_hex, forwarding_info) in unfulfilled.items():
|
for htlc_id, (local_ctn, remote_ctn, onion_packet_hex, forwarding_info) in unfulfilled.items():
|
||||||
# FIXME this test is not sufficient:
|
if not chan.hm.is_add_htlc_irrevocably_committed_yet(htlc_proposer=REMOTE, htlc_id=htlc_id):
|
||||||
if chan.get_oldest_unrevoked_ctn(LOCAL) <= local_ctn:
|
|
||||||
continue
|
|
||||||
if chan.get_oldest_unrevoked_ctn(REMOTE) <= remote_ctn:
|
|
||||||
continue
|
continue
|
||||||
chan.logger.info(f'found unfulfilled htlc: {htlc_id}')
|
chan.logger.info(f'found unfulfilled htlc: {htlc_id}')
|
||||||
htlc = chan.hm.get_htlc_by_id(REMOTE, htlc_id)
|
htlc = chan.hm.get_htlc_by_id(REMOTE, htlc_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user