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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user