lnpeer.pay: also log hops_data for trampoline_onion
We were already logging the outer-layer hops_data,
now we also log the inner trampoline-onion hops_data.
Example:
```
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | lnpeer.pay len(route)=1
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | 0: edge=9926297x9781928x61754 hop_data=<OnionHopsDataSingle. payload={'amt_to_forward': {'amt_to_forward': 100000000}, 'outgoing_cltv_value': {'outgoing_cltv_value': 601299}, 'payment_data': {'payment_secret': b'\xd2\x9cl\xdfV\xd4\xea_\x06{\xed\xc9\xc7\xa6\xf5\xc0\n\x1a\x95\xad\xad\xd2F\xb8;&\x9f\xa1\xe1\xd1\x07H', 'total_msat': 100000000, 'amount_msat': 100000000}}. hmac=None>
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | adding trampoline onion to final payload
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | lnpeer.pay len(t_route)=3
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | 0: t_node=02389c93b85ef8f7264c6fa3d3b239341c2631c2cab97e815b33453bd8d0254e77 hop_data=<OnionHopsDataSingle. payload={'amt_to_forward': {'amt_to_forward': 100000000}, 'outgoing_cltv_value': {'outgoing_cltv_value': 600723}, 'outgoing_node_id': {'outgoing_node_id': b'\x03\x06\xd9,\x9c\xabRe\x83Mr\x0b\x14(\xf5\x81\xf9\xfb\x9b\xfeV\xc1q\x85&L\xda\xffs\xe5y(\x81'}}. hmac=b'\xe7\x04\xe2>\x9a\xd9\xf0\x92<\xf8Q\xe4\xf4\xd8\x8cr{\x1e\xb1\xee\xb0\xd4R\xba\xe5\xfd\x83\xfc\xd7\xa7\x1dt'>
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | 1: t_node=0306d92c9cab5265834d720b1428f581f9fb9bfe56c17185264cdaff73e5792881 hop_data=<OnionHopsDataSingle. payload={'amt_to_forward': {'amt_to_forward': 100000000}, 'outgoing_cltv_value': {'outgoing_cltv_value': 600147}, 'outgoing_node_id': {'outgoing_node_id': b'\x03\x85v\xac:\xf8AUW\xcf\x1d\x12e\xcc\xff\xb1\xea\xd6\x01\xd5\x17HX?\x12\x83\x9cD\xbe\xebC\x82o'}}. hmac=b's-\xe1\xdb\xbc\xa5\x88\x90\xc0\xafu\xab\xba\xb6k\x81\xeae)#\x85\x12fm\xe6\xc3\xbd\xf6\x86eR\xd2'>
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | 2: t_node=038576ac3af8415557cf1d1265ccffb1ead601d51748583f12839c44beeb43826f hop_data=<OnionHopsDataSingle. payload={'amt_to_forward': {'amt_to_forward': 100000000}, 'outgoing_cltv_value': {'outgoing_cltv_value': 600147}, 'payment_data': {'payment_secret': b'B-P\x01\xc3\x1e#\x19\xf9!\xbb\xd8\xd1pu\xc7J\x11A\xa8J\xfe\xb8\x8a\xb8\xc4Oi\x0f\xe8\xac\xab', 'total_msat': 100000000}}. hmac=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'>
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | starting payment. len(route)=1.
```
This commit is contained in:
@@ -117,6 +117,9 @@ class OnionPacket:
|
||||
self.hmac = hmac
|
||||
if not ecc.ECPubkey.is_pubkey_bytes(public_key):
|
||||
raise InvalidOnionPubkey()
|
||||
# for debugging our own onions:
|
||||
self._debug_hops_data = None # type: Optional[Sequence[OnionHopsDataSingle]]
|
||||
self._debug_route = None # type: Optional[LNPaymentRoute]
|
||||
|
||||
def to_bytes(self) -> bytes:
|
||||
ret = bytes([self.version])
|
||||
|
||||
@@ -1478,7 +1478,7 @@ class Peer(Logger):
|
||||
payment_hash: bytes,
|
||||
min_final_cltv_expiry: int,
|
||||
payment_secret: bytes,
|
||||
trampoline_onion=None,
|
||||
trampoline_onion: Optional[OnionPacket] = None,
|
||||
):
|
||||
# add features learned during "init" for direct neighbour:
|
||||
route[0].node_features |= self.features
|
||||
@@ -1506,6 +1506,12 @@ class Peer(Logger):
|
||||
"hops_data": trampoline_onion.hops_data,
|
||||
"hmac": trampoline_onion.hmac
|
||||
}
|
||||
if t_hops_data := trampoline_onion._debug_hops_data: # None if trampoline-forwarding
|
||||
t_route = trampoline_onion._debug_route
|
||||
assert t_route is not None
|
||||
self.logger.info(f"lnpeer.pay len(t_route)={len(t_route)}")
|
||||
for i in range(len(t_route)):
|
||||
self.logger.info(f" {i}: t_node={t_route[i].end_node.hex()} hop_data={t_hops_data[i]!r}")
|
||||
# create onion packet
|
||||
payment_path_pubkeys = [x.node_id for x in route]
|
||||
onion = new_onion_packet(payment_path_pubkeys, session_key, hops_data, associated_data=payment_hash) # must use another sessionkey
|
||||
@@ -1540,7 +1546,7 @@ class Peer(Logger):
|
||||
payment_hash: bytes,
|
||||
min_final_cltv_expiry: int,
|
||||
payment_secret: bytes,
|
||||
trampoline_onion=None,
|
||||
trampoline_onion: Optional[OnionPacket] = None,
|
||||
) -> UpdateAddHtlc:
|
||||
|
||||
assert amount_msat > 0, "amount_msat is not greater zero"
|
||||
|
||||
@@ -1560,7 +1560,7 @@ class LNWallet(LNWorker):
|
||||
paysession: PaySession,
|
||||
sent_htlc_info: SentHtlcInfo,
|
||||
min_cltv_expiry: int,
|
||||
trampoline_onion: bytes = None,
|
||||
trampoline_onion: Optional[OnionPacket] = None,
|
||||
) -> None:
|
||||
"""Sends a single HTLC."""
|
||||
shi = sent_htlc_info
|
||||
|
||||
@@ -9,6 +9,10 @@ from .lnonion import calc_hops_data_for_payment, new_onion_packet
|
||||
from .lnrouter import RouteEdge, TrampolineEdge, LNPaymentRoute, is_route_sane_to_use
|
||||
from .lnutil import NoPathFound, LNPeerAddr
|
||||
from . import constants
|
||||
from .logging import get_logger
|
||||
|
||||
|
||||
_logger = get_logger(__name__)
|
||||
|
||||
# trampoline nodes are supposed to advertise their fee and cltv in node_update message
|
||||
TRAMPOLINE_FEES = [
|
||||
@@ -307,6 +311,8 @@ def create_trampoline_onion(
|
||||
}
|
||||
trampoline_session_key = os.urandom(32)
|
||||
trampoline_onion = new_onion_packet(payment_path_pubkeys, trampoline_session_key, hops_data, associated_data=payment_hash, trampoline=True)
|
||||
trampoline_onion._debug_hops_data = hops_data
|
||||
trampoline_onion._debug_route = route
|
||||
return trampoline_onion, amount_msat, cltv
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user