1
0

Reorganize code so that we can send Multi Part Payments:

- LNWorker is notified about htlc events and creates payment events.
 - LNWorker._pay is a while loop that calls create_routes_from_invoice.
 - create_route_from_invoices should decide whether to split the payment,
   using graph knowledge and feedback from previous attempts (not in this commit)
 - data structures for payment logs are simplified into a single type, HtlcLog
This commit is contained in:
ThomasV
2021-01-30 16:10:51 +01:00
parent 1102ea50e8
commit f28a2aae73
6 changed files with 204 additions and 192 deletions

View File

@@ -991,7 +991,7 @@ class Channel(AbstractChannel):
if self.lnworker:
sent = self.hm.sent_in_ctn(new_ctn)
for htlc in sent:
self.lnworker.payment_sent(self, htlc.payment_hash)
self.lnworker.htlc_fulfilled(self, htlc.payment_hash, htlc.htlc_id, htlc.amount_msat)
failed = self.hm.failed_in_ctn(new_ctn)
for htlc in failed:
try:
@@ -1002,7 +1002,7 @@ class Channel(AbstractChannel):
if self.lnworker.get_payment_info(htlc.payment_hash) is None:
self.save_fail_htlc_reason(htlc.htlc_id, error_bytes, failure_message)
else:
self.lnworker.payment_failed(self, htlc.payment_hash, error_bytes, failure_message)
self.lnworker.htlc_failed(self, htlc.payment_hash, htlc.htlc_id, htlc.amount_msat, error_bytes, failure_message)
def save_fail_htlc_reason(
self,
@@ -1048,9 +1048,9 @@ class Channel(AbstractChannel):
info = self.lnworker.get_payment_info(payment_hash)
if info is not None and info.status != PR_PAID:
if is_sent:
self.lnworker.payment_sent(self, payment_hash)
self.lnworker.htlc_fulfilled(self, payment_hash, htlc.htlc_id, htlc.amount_msat)
else:
self.lnworker.payment_received(payment_hash)
self.lnworker.htlc_received(self, payment_hash)
def balance(self, whose: HTLCOwner, *, ctx_owner=HTLCOwner.LOCAL, ctn: int = None) -> int:
assert type(whose) is HTLCOwner