lnworker: nicer logs/error msgs for payment failure
try to decode onion error and log it in human-readable form
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
|
||||
import io
|
||||
import hashlib
|
||||
from typing import Sequence, List, Tuple, NamedTuple, TYPE_CHECKING
|
||||
from typing import Sequence, List, Tuple, NamedTuple, TYPE_CHECKING, Dict, Any, Optional
|
||||
from enum import IntEnum, IntFlag
|
||||
|
||||
from . import ecc
|
||||
@@ -33,7 +33,7 @@ from .crypto import sha256, hmac_oneshot, chacha20_encrypt
|
||||
from .util import bh2u, profiler, xor_bytes, bfh
|
||||
from .lnutil import (get_ecdh, PaymentFailure, NUM_MAX_HOPS_IN_PAYMENT_PATH,
|
||||
NUM_MAX_EDGES_IN_PAYMENT_PATH, ShortChannelID, OnionFailureCodeMetaFlag)
|
||||
from .lnmsg import OnionWireSerializer, read_bigsize_int, write_bigsize_int
|
||||
from .lnmsg import OnionWireSerializer, read_bigsize_int, write_bigsize_int, UnknownMsgType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .lnrouter import LNPaymentRoute
|
||||
@@ -431,7 +431,7 @@ class OnionRoutingFailure(Exception):
|
||||
try:
|
||||
failure_code = OnionFailureCode(failure_code)
|
||||
except ValueError:
|
||||
pass # uknown failure code
|
||||
pass # unknown failure code
|
||||
failure_data = failure_msg[2:]
|
||||
return OnionRoutingFailure(failure_code, failure_data)
|
||||
|
||||
@@ -440,6 +440,13 @@ class OnionRoutingFailure(Exception):
|
||||
return str(self.code.name)
|
||||
return f"Unknown error ({self.code!r})"
|
||||
|
||||
def decode_data(self) -> Optional[Dict[str, Any]]:
|
||||
try:
|
||||
message_type, payload = OnionWireSerializer.decode_msg(self.to_bytes())
|
||||
except UnknownMsgType:
|
||||
payload = None
|
||||
return payload
|
||||
|
||||
|
||||
def construct_onion_error(
|
||||
reason: OnionRoutingFailure,
|
||||
|
||||
Reference in New Issue
Block a user