maybe_fulfill_htlc: add failure reason to logs
This commit is contained in:
@@ -1512,8 +1512,8 @@ class Peer(Logger):
|
|||||||
chan: Channel,
|
chan: Channel,
|
||||||
htlc: UpdateAddHtlc,
|
htlc: UpdateAddHtlc,
|
||||||
processed_onion: ProcessedOnionPacket,
|
processed_onion: ProcessedOnionPacket,
|
||||||
is_trampoline: bool = False,
|
is_trampoline: bool = False) -> Optional[bytes]:
|
||||||
) -> Optional[bytes]:
|
|
||||||
"""As a final recipient of an HTLC, decide if we should fulfill it.
|
"""As a final recipient of an HTLC, decide if we should fulfill it.
|
||||||
Returns the preimage if yes, or None.
|
Returns the preimage if yes, or None.
|
||||||
"""
|
"""
|
||||||
@@ -1531,9 +1531,10 @@ class Peer(Logger):
|
|||||||
raise OnionRoutingFailure(code=OnionFailureCode.TEMPORARY_NODE_FAILURE, data=b'')
|
raise OnionRoutingFailure(code=OnionFailureCode.TEMPORARY_NODE_FAILURE, data=b'')
|
||||||
local_height = chain.height()
|
local_height = chain.height()
|
||||||
exc_incorrect_or_unknown_pd = OnionRoutingFailure(
|
exc_incorrect_or_unknown_pd = OnionRoutingFailure(
|
||||||
code=OnionFailureCode.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS,
|
code=OnionFailureCode.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS,
|
||||||
data=amt_to_forward.to_bytes(8, byteorder="big") + local_height.to_bytes(4, byteorder="big"))
|
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:
|
if local_height + MIN_FINAL_CLTV_EXPIRY_ACCEPTED > htlc.cltv_expiry:
|
||||||
|
self.logger.info('cltv expiry too soon')
|
||||||
raise exc_incorrect_or_unknown_pd
|
raise exc_incorrect_or_unknown_pd
|
||||||
try:
|
try:
|
||||||
cltv_from_onion = processed_onion.hop_data.payload["outgoing_cltv_value"]["outgoing_cltv_value"]
|
cltv_from_onion = processed_onion.hop_data.payload["outgoing_cltv_value"]["outgoing_cltv_value"]
|
||||||
@@ -1561,6 +1562,7 @@ class Peer(Logger):
|
|||||||
|
|
||||||
info = self.lnworker.get_payment_info(htlc.payment_hash)
|
info = self.lnworker.get_payment_info(htlc.payment_hash)
|
||||||
if info is None:
|
if info is None:
|
||||||
|
self.logger.info('unknown payment hash')
|
||||||
raise exc_incorrect_or_unknown_pd
|
raise exc_incorrect_or_unknown_pd
|
||||||
preimage = self.lnworker.get_preimage(htlc.payment_hash)
|
preimage = self.lnworker.get_preimage(htlc.payment_hash)
|
||||||
try:
|
try:
|
||||||
@@ -1568,13 +1570,16 @@ class Peer(Logger):
|
|||||||
except:
|
except:
|
||||||
if total_msat > amt_to_forward:
|
if total_msat > amt_to_forward:
|
||||||
# payment_secret is required for MPP
|
# payment_secret is required for MPP
|
||||||
|
self.logger.info('total_msat > amt to forward')
|
||||||
raise exc_incorrect_or_unknown_pd
|
raise exc_incorrect_or_unknown_pd
|
||||||
# TODO fail here if invoice has set PAYMENT_SECRET_REQ
|
# TODO fail here if invoice has set PAYMENT_SECRET_REQ
|
||||||
else:
|
else:
|
||||||
if payment_secret_from_onion != derive_payment_secret_from_payment_preimage(preimage):
|
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
|
raise exc_incorrect_or_unknown_pd
|
||||||
invoice_msat = info.amount_msat
|
invoice_msat = info.amount_msat
|
||||||
if not (invoice_msat is None or invoice_msat <= total_msat <= 2 * invoice_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
|
raise exc_incorrect_or_unknown_pd
|
||||||
mpp_status = self.lnworker.add_received_htlc(chan.short_channel_id, htlc, total_msat)
|
mpp_status = self.lnworker.add_received_htlc(chan.short_channel_id, htlc, total_msat)
|
||||||
if mpp_status == True:
|
if mpp_status == True:
|
||||||
|
|||||||
Reference in New Issue
Block a user