Browse Source

fix bundled payments:

- prepayment should be accepted immediately once bundle is here
 - mpp timeout all parts, but accept only current part
master
ThomasV 3 years ago
parent
commit
c4c2123b4b
  1. 16
      electrum/lnworker.py

16
electrum/lnworker.py

@ -1923,8 +1923,6 @@ class LNWallet(LNWorker):
is_accepted = True is_accepted = True
elif self.stopping_soon: elif self.stopping_soon:
is_expired = True # try to time out pending HTLCs before shutting down is_expired = True # try to time out pending HTLCs before shutting down
elif time.time() - first_timestamp > self.MPP_EXPIRY:
is_expired = True
elif all([self.is_mpp_amount_reached(x) for x in payment_secrets]): elif all([self.is_mpp_amount_reached(x) for x in payment_secrets]):
preimage = self.get_preimage(payment_hash) preimage = self.get_preimage(payment_hash)
hold_invoice_callback = self.hold_invoice_callbacks.get(payment_hash) hold_invoice_callback = self.hold_invoice_callbacks.get(payment_hash)
@ -1935,14 +1933,18 @@ class LNWallet(LNWorker):
cb(payment_hash) cb(payment_hash)
else: else:
is_expired = True is_expired = True
elif bundle is not None:
is_accepted = all([bool(self.get_preimage(x)) for x in bundle])
else: else:
# trampoline forwarding needs this to return True # note: preimage will be None for outer trampoline onion
is_accepted = True is_accepted = True
# set status for the bundle elif time.time() - first_timestamp > self.MPP_EXPIRY:
if is_expired or is_accepted: is_expired = True
if is_accepted:
# accept only the current part of a bundle
self.set_mpp_status(payment_secret, is_expired, is_accepted)
elif is_expired:
# .. but expire all parts
for x in payment_secrets: for x in payment_secrets:
if x in self.received_mpp_htlcs: if x in self.received_mpp_htlcs:
self.set_mpp_status(x, is_expired, is_accepted) self.set_mpp_status(x, is_expired, is_accepted)

Loading…
Cancel
Save