Browse Source

trampoline: less verbose, do not log routes that are not tried

patch-4
ThomasV 2 years ago
parent
commit
c6f940d092
  1. 8
      electrum/lnworker.py
  2. 8
      electrum/trampoline.py

8
electrum/lnworker.py

@ -1577,7 +1577,7 @@ class LNWallet(LNWorker):
amount_with_fees = amount_msat
cltv_delta = min_cltv_expiry
else:
trampoline_onion, amount_with_fees, cltv_delta = create_trampoline_route_and_onion(
trampoline_route, trampoline_onion, amount_with_fees, cltv_delta = create_trampoline_route_and_onion(
amount_msat=amount_msat,
total_msat=final_total_msat,
min_cltv_expiry=min_cltv_expiry,
@ -1595,6 +1595,8 @@ class LNWallet(LNWorker):
trampoline_total_msat = amount_with_fees
if chan.available_to_spend(LOCAL, strict=True) < amount_with_fees:
continue
self.logger.info(f'created route with trampoline fee level={trampoline_fee_level}')
self.logger.info(f'trampoline hops: {[hop.end_node.hex() for hop in trampoline_route]}')
route = [
RouteEdge(
start_node=self.node_keypair.pubkey,
@ -1659,7 +1661,7 @@ class LNWallet(LNWorker):
routes = []
for trampoline_node_id, trampoline_parts in per_trampoline_channel_amounts.items():
per_trampoline_amount = sum([x[1] for x in trampoline_parts])
trampoline_onion, per_trampoline_amount_with_fees, per_trampoline_cltv_delta = create_trampoline_route_and_onion(
trampoline_route, trampoline_onion, per_trampoline_amount_with_fees, per_trampoline_cltv_delta = create_trampoline_route_and_onion(
amount_msat=per_trampoline_amount,
total_msat=final_total_msat,
min_cltv_expiry=min_cltv_expiry,
@ -1676,6 +1678,8 @@ class LNWallet(LNWorker):
# node_features is only used to determine is_tlv
per_trampoline_secret = os.urandom(32)
per_trampoline_fees = per_trampoline_amount_with_fees - per_trampoline_amount
self.logger.info(f'created route with trampoline fee level={trampoline_fee_level}')
self.logger.info(f'trampoline hops: {[hop.end_node.hex() for hop in trampoline_route]}')
self.logger.info(f'per trampoline fees: {per_trampoline_fees}')
for chan_id, part_amount_msat in trampoline_parts:
chan = self.channels[chan_id]

8
electrum/trampoline.py

@ -4,7 +4,6 @@ import random
from typing import Mapping, DefaultDict, Tuple, Optional, Dict, List
from .logging import get_logger, Logger
from .lnutil import LnFeatures
from .lnonion import calc_hops_data_for_payment, new_onion_packet
from .lnrouter import RouteEdge, TrampolineEdge, LNPaymentRoute, is_route_sane_to_use
@ -12,8 +11,6 @@ from .lnutil import NoPathFound, LNPeerAddr
from . import constants
_logger = get_logger(__name__)
# trampoline nodes are supposed to advertise their fee and cltv in node_update message
TRAMPOLINE_FEES = [
{
@ -216,8 +213,6 @@ def create_trampoline_route(
amount_msat += edge.fee_for_edge(amount_msat)
if not is_route_sane_to_use(route, amount_msat, min_cltv_expiry):
raise NoPathFound("We cannot afford to pay the fees.")
_logger.info(f'created route with trampoline fee level={trampoline_fee_level}, is legacy: {is_legacy}')
_logger.info(f'trampoline hops: {[hop.end_node.hex() for hop in route]}')
return route
@ -255,7 +250,6 @@ def create_trampoline_onion(*, route, amount_msat, final_cltv, total_msat, payme
"payment_secret": payment_secret,
"total_msat": total_msat
}
_logger.info(f'payload {i} {payload}')
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)
return trampoline_onion, amount_msat, cltv
@ -301,4 +295,4 @@ def create_trampoline_route_and_onion(
# trampoline fee for this very trampoline
trampoline_fee = trampoline_route[0].fee_for_edge(amount_with_fees)
amount_with_fees += trampoline_fee
return trampoline_onion, amount_with_fees, bucket_cltv_delta
return trampoline_route, trampoline_onion, amount_with_fees, bucket_cltv_delta

Loading…
Cancel
Save