URI: 
       tmaybe_fulfill_htlc: add failure reason to logs - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 2da90add8f3df5f4302631abcecc46100d0cc53f
   DIR parent 693583edc5010ece804e312626c7c40157613ff1
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Tue,  2 Mar 2021 14:26:16 +0100
       
       maybe_fulfill_htlc: add failure reason to logs
       
       Diffstat:
         M electrum/lnpeer.py                  |      13 +++++++++----
       
       1 file changed, 9 insertions(+), 4 deletions(-)
       ---
   DIR diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py
       t@@ -1512,8 +1512,8 @@ class Peer(Logger):
                    chan: Channel,
                    htlc: UpdateAddHtlc,
                    processed_onion: ProcessedOnionPacket,
       -            is_trampoline: bool = False,
       -    ) -> Optional[bytes]:
       +            is_trampoline: bool = False) -> Optional[bytes]:
       +
                """As a final recipient of an HTLC, decide if we should fulfill it.
                Returns the preimage if yes, or None.
                """
       t@@ -1531,9 +1531,10 @@ class Peer(Logger):
                    raise OnionRoutingFailure(code=OnionFailureCode.TEMPORARY_NODE_FAILURE, data=b'')
                local_height = chain.height()
                exc_incorrect_or_unknown_pd = OnionRoutingFailure(
       -                code=OnionFailureCode.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS,
       -                data=amt_to_forward.to_bytes(8, byteorder="big") + local_height.to_bytes(4, byteorder="big"))
       +            code=OnionFailureCode.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS,
       +            data=amt_to_forward.to_bytes(8, byteorder="big") + local_height.to_bytes(4, byteorder="big"))
                if local_height + MIN_FINAL_CLTV_EXPIRY_ACCEPTED > htlc.cltv_expiry:
       +            self.logger.info('cltv expiry too soon')
                    raise exc_incorrect_or_unknown_pd
                try:
                    cltv_from_onion = processed_onion.hop_data.payload["outgoing_cltv_value"]["outgoing_cltv_value"]
       t@@ -1561,6 +1562,7 @@ class Peer(Logger):
        
                info = self.lnworker.get_payment_info(htlc.payment_hash)
                if info is None:
       +            self.logger.info('unknown payment hash')
                    raise exc_incorrect_or_unknown_pd
                preimage = self.lnworker.get_preimage(htlc.payment_hash)
                try:
       t@@ -1568,13 +1570,16 @@ class Peer(Logger):
                except:
                    if total_msat > amt_to_forward:
                        # payment_secret is required for MPP
       +                self.logger.info('total_msat > amt to forward')
                        raise exc_incorrect_or_unknown_pd
                    # TODO fail here if invoice has set PAYMENT_SECRET_REQ
                else:
                    if payment_secret_from_onion != derive_payment_secret_from_payment_preimage(preimage):
       +                self.logger.info(f'incorrect payment secret {payment_secret_from_onion.hex()} != {derive_payment_secret_from_payment_preimage(preimage).hex()}')
                        raise exc_incorrect_or_unknown_pd
                invoice_msat = info.amount_msat
                if not (invoice_msat is None or invoice_msat <= total_msat <= 2 * invoice_msat):
       +            self.logger.info('incorrect total msat')
                    raise exc_incorrect_or_unknown_pd
                mpp_status = self.lnworker.add_received_htlc(chan.short_channel_id, htlc, total_msat)
                if mpp_status == True: