lnworker.check_mpp_status: add docstring
This explains why stopping_soon behaves sanely with hold-invoice-htlcs.
This commit is contained in:
@@ -2269,11 +2269,20 @@ class LNWallet(LNWorker):
|
|||||||
htlc: UpdateAddHtlc,
|
htlc: UpdateAddHtlc,
|
||||||
expected_msat: int,
|
expected_msat: int,
|
||||||
) -> RecvMPPResolution:
|
) -> RecvMPPResolution:
|
||||||
|
"""Returns the status of the incoming htlc set the given *htlc* belongs to.
|
||||||
|
|
||||||
|
ACCEPTED simply means the mpp set is complete, and we can proceed with further
|
||||||
|
checks before fulfilling (or failing) the htlcs.
|
||||||
|
In particular, note that hold-invoice-htlcs typically remain in the ACCEPTED state
|
||||||
|
for quite some time -- not in the "WAITING" state (which would refer to the mpp set
|
||||||
|
not yet being complete!).
|
||||||
|
"""
|
||||||
payment_hash = htlc.payment_hash
|
payment_hash = htlc.payment_hash
|
||||||
payment_key = payment_hash + payment_secret
|
payment_key = payment_hash + payment_secret
|
||||||
self.update_mpp_with_received_htlc(
|
self.update_mpp_with_received_htlc(
|
||||||
payment_key=payment_key, scid=short_channel_id, htlc=htlc, expected_msat=expected_msat)
|
payment_key=payment_key, scid=short_channel_id, htlc=htlc, expected_msat=expected_msat)
|
||||||
mpp_resolution = self.received_mpp_htlcs[payment_key].resolution
|
mpp_resolution = self.received_mpp_htlcs[payment_key].resolution
|
||||||
|
# if still waiting, calc resolution now:
|
||||||
if mpp_resolution == RecvMPPResolution.WAITING:
|
if mpp_resolution == RecvMPPResolution.WAITING:
|
||||||
bundle = self.get_payment_bundle(payment_key)
|
bundle = self.get_payment_bundle(payment_key)
|
||||||
if bundle:
|
if bundle:
|
||||||
@@ -2290,7 +2299,7 @@ class LNWallet(LNWorker):
|
|||||||
mpp_resolution = RecvMPPResolution.ACCEPTED
|
mpp_resolution = RecvMPPResolution.ACCEPTED
|
||||||
elif time.time() - first_timestamp > self.MPP_EXPIRY:
|
elif time.time() - first_timestamp > self.MPP_EXPIRY:
|
||||||
mpp_resolution = RecvMPPResolution.EXPIRED
|
mpp_resolution = RecvMPPResolution.EXPIRED
|
||||||
|
# save resolution, if any.
|
||||||
if mpp_resolution != RecvMPPResolution.WAITING:
|
if mpp_resolution != RecvMPPResolution.WAITING:
|
||||||
for pkey in payment_keys:
|
for pkey in payment_keys:
|
||||||
if pkey in self.received_mpp_htlcs:
|
if pkey in self.received_mpp_htlcs:
|
||||||
|
|||||||
Reference in New Issue
Block a user