From 9024419fdcd78dc3740c544cf81578c18ac87f02 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 24 Feb 2021 20:34:34 +0100 Subject: [PATCH] lnpeer: MPP receive: require payment_secret for each htlc BOLT-04 says: The final node: if it supports basic_mpp: MUST require payment_secret for all HTLCs in the set https://github.com/lightningnetwork/lightning-rfc/blob/90468030d5c374ced568c91df5d37699fe020010/04-onion-routing.md#basic-multi-part-payments --- electrum/lnpeer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py index d74543386..36b8de175 100644 --- a/electrum/lnpeer.py +++ b/electrum/lnpeer.py @@ -1559,7 +1559,10 @@ class Peer(Logger): try: payment_secret_from_onion = processed_onion.hop_data.payload["payment_data"]["payment_secret"] except: - pass # skip + if total_msat > amt_to_forward: + # payment_secret is required for MPP + raise OnionRoutingFailure(code=OnionFailureCode.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS, data=b'') + # TODO fail here if invoice has set PAYMENT_SECRET_REQ else: if payment_secret_from_onion != derive_payment_secret_from_payment_preimage(preimage): raise OnionRoutingFailure(code=OnionFailureCode.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS, data=b'')