Merge pull request #7065 from SomberNight/20210224_mpp_recv_amt_sum
lnpeer: MPP recv: only fulfill htlc if amt sum exact-matches total_msat
This commit is contained in:
@@ -1051,7 +1051,9 @@ class Channel(AbstractChannel):
|
||||
if is_sent:
|
||||
self.lnworker.htlc_fulfilled(self, payment_hash, htlc.htlc_id, htlc.amount_msat)
|
||||
else:
|
||||
self.lnworker.htlc_received(self, payment_hash)
|
||||
# FIXME
|
||||
#self.lnworker.htlc_received(self, payment_hash)
|
||||
pass
|
||||
|
||||
def balance(self, whose: HTLCOwner, *, ctx_owner=HTLCOwner.LOCAL, ctn: int = None) -> int:
|
||||
assert type(whose) is HTLCOwner
|
||||
|
||||
@@ -1566,13 +1566,10 @@ class Peer(Logger):
|
||||
else:
|
||||
if payment_secret_from_onion != derive_payment_secret_from_payment_preimage(preimage):
|
||||
raise OnionRoutingFailure(code=OnionFailureCode.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS, data=b'')
|
||||
expected_received_msat = info.amount_msat
|
||||
if expected_received_msat is None:
|
||||
return preimage
|
||||
|
||||
if not (expected_received_msat <= total_msat <= 2 * expected_received_msat):
|
||||
invoice_msat = info.amount_msat
|
||||
if not (invoice_msat is None or invoice_msat <= total_msat <= 2 * invoice_msat):
|
||||
raise OnionRoutingFailure(code=OnionFailureCode.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS, data=b'')
|
||||
accepted, expired = self.lnworker.htlc_received(chan.short_channel_id, htlc, expected_received_msat)
|
||||
accepted, expired = self.lnworker.htlc_received(chan.short_channel_id, htlc, total_msat)
|
||||
if accepted:
|
||||
return preimage
|
||||
elif expired:
|
||||
|
||||
@@ -1692,7 +1692,7 @@ class LNWallet(LNWorker):
|
||||
total = sum([htlc.amount_msat for scid, htlc in s])
|
||||
first_timestamp = min([htlc.timestamp for scid, htlc in s])
|
||||
expired = time.time() - first_timestamp > MPP_EXPIRY
|
||||
if total >= expected_msat and not expired:
|
||||
if total == expected_msat and not expired:
|
||||
# status must be persisted
|
||||
self.set_payment_status(htlc.payment_hash, PR_PAID)
|
||||
util.trigger_callback('request_status', self.wallet, htlc.payment_hash.hex(), PR_PAID)
|
||||
|
||||
Reference in New Issue
Block a user