1
0

Fix detection of payments.

1. In lnhtlc, sent_in_ctn and failed_in_ctn need to look at the
remote ctx, and they need to be called when we receive a revocation,
not when we send one.

2. In lnchannel, we use 3 lnworker callbacks:
   - payment sent/payment failed (called when we receive a revocation)
   - payment received (called when we send a revocation)

3. Make revoke_current_commitment return a single value.
The second value was only used in tests, there is no need
to bloat the code with that
This commit is contained in:
ThomasV
2020-03-04 18:09:43 +01:00
parent b9eaba3e85
commit 8f3fcdd1a8
7 changed files with 51 additions and 45 deletions

View File

@@ -289,19 +289,31 @@ class HTLCManager:
return sent + received
def received_in_ctn(self, ctn: int) -> Sequence[UpdateAddHtlc]:
"""
received htlcs that became fulfilled when we send a revocation.
we check only local, because they are commited in the remote ctx first.
"""
return [self.log[REMOTE]['adds'][htlc_id]
for htlc_id, ctns in self.log[REMOTE]['settles'].items()
if ctns[LOCAL] == ctn]
def sent_in_ctn(self, ctn: int) -> Sequence[UpdateAddHtlc]:
"""
sent htlcs that became fulfilled when we received a revocation
we check only remote, because they are commited in the local ctx first.
"""
return [self.log[LOCAL]['adds'][htlc_id]
for htlc_id, ctns in self.log[LOCAL]['settles'].items()
if ctns[LOCAL] == ctn]
if ctns[REMOTE] == ctn]
def failed_in_ctn(self, ctn: int) -> Sequence[UpdateAddHtlc]:
"""
sent htlcs that became failed when we received a revocation
we check only remote, because they are commited in the local ctx first.
"""
return [self.log[LOCAL]['adds'][htlc_id]
for htlc_id, ctns in self.log[LOCAL]['fails'].items()
if ctns[LOCAL] == ctn]
if ctns[REMOTE] == ctn]
##### Queries re Fees: