create a trampoline onion when directly paying a trampoline node
This commit is contained in:
@@ -1968,37 +1968,29 @@ class LNWallet(LNWorker):
|
|||||||
# for each trampoline forwarder, construct mpp trampoline
|
# for each trampoline forwarder, construct mpp trampoline
|
||||||
for trampoline_node_id, trampoline_parts in per_trampoline_channel_amounts.items():
|
for trampoline_node_id, trampoline_parts in per_trampoline_channel_amounts.items():
|
||||||
per_trampoline_amount = sum([x[1] for x in trampoline_parts])
|
per_trampoline_amount = sum([x[1] for x in trampoline_parts])
|
||||||
if trampoline_node_id == paysession.invoice_pubkey:
|
trampoline_route, trampoline_onion, per_trampoline_amount_with_fees, per_trampoline_cltv_delta = create_trampoline_route_and_onion(
|
||||||
trampoline_route = None
|
amount_msat=per_trampoline_amount,
|
||||||
trampoline_onion = None
|
total_msat=paysession.amount_to_pay,
|
||||||
per_trampoline_secret = paysession.payment_secret
|
min_final_cltv_delta=paysession.min_final_cltv_delta,
|
||||||
per_trampoline_amount_with_fees = amount_msat
|
my_pubkey=self.node_keypair.pubkey,
|
||||||
per_trampoline_cltv_delta = paysession.min_final_cltv_delta
|
invoice_pubkey=paysession.invoice_pubkey,
|
||||||
per_trampoline_fees = 0
|
invoice_features=paysession.invoice_features,
|
||||||
else:
|
node_id=trampoline_node_id,
|
||||||
trampoline_route, trampoline_onion, per_trampoline_amount_with_fees, per_trampoline_cltv_delta = create_trampoline_route_and_onion(
|
r_tags=paysession.r_tags,
|
||||||
amount_msat=per_trampoline_amount,
|
payment_hash=paysession.payment_hash,
|
||||||
total_msat=paysession.amount_to_pay,
|
payment_secret=paysession.payment_secret,
|
||||||
min_final_cltv_delta=paysession.min_final_cltv_delta,
|
local_height=local_height,
|
||||||
my_pubkey=self.node_keypair.pubkey,
|
trampoline_fee_level=paysession.trampoline_fee_level,
|
||||||
invoice_pubkey=paysession.invoice_pubkey,
|
use_two_trampolines=paysession.use_two_trampolines,
|
||||||
invoice_features=paysession.invoice_features,
|
failed_routes=paysession.failed_trampoline_routes,
|
||||||
node_id=trampoline_node_id,
|
budget=budget._replace(fee_msat=budget.fee_msat // len(per_trampoline_channel_amounts)),
|
||||||
r_tags=paysession.r_tags,
|
)
|
||||||
payment_hash=paysession.payment_hash,
|
# node_features is only used to determine is_tlv
|
||||||
payment_secret=paysession.payment_secret,
|
per_trampoline_secret = os.urandom(32)
|
||||||
local_height=local_height,
|
per_trampoline_fees = per_trampoline_amount_with_fees - per_trampoline_amount
|
||||||
trampoline_fee_level=paysession.trampoline_fee_level,
|
self.logger.info(f'created route with trampoline fee level={paysession.trampoline_fee_level}')
|
||||||
use_two_trampolines=paysession.use_two_trampolines,
|
self.logger.info(f'trampoline hops: {[hop.end_node.hex() for hop in trampoline_route]}')
|
||||||
failed_routes=paysession.failed_trampoline_routes,
|
self.logger.info(f'per trampoline fees: {per_trampoline_fees}')
|
||||||
budget=budget._replace(fee_msat=budget.fee_msat // len(per_trampoline_channel_amounts)),
|
|
||||||
)
|
|
||||||
# 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={paysession.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:
|
for chan_id, part_amount_msat in trampoline_parts:
|
||||||
chan = self.channels[chan_id]
|
chan = self.channels[chan_id]
|
||||||
margin = chan.available_to_spend(LOCAL, strict=True) - part_amount_msat
|
margin = chan.available_to_spend(LOCAL, strict=True) - part_amount_msat
|
||||||
|
|||||||
@@ -267,7 +267,9 @@ def create_trampoline_route(
|
|||||||
|
|
||||||
# Add final edge. note: eclair requires an encrypted t-onion blob even in legacy case.
|
# Add final edge. note: eclair requires an encrypted t-onion blob even in legacy case.
|
||||||
# Also needed for fees for last TF!
|
# Also needed for fees for last TF!
|
||||||
_extend_trampoline_route(route, end_node=invoice_pubkey, trampoline_fee_level=trampoline_fee_level)
|
if route[-1].end_node != invoice_pubkey:
|
||||||
|
_extend_trampoline_route(route, end_node=invoice_pubkey, trampoline_fee_level=trampoline_fee_level)
|
||||||
|
|
||||||
# check that we can pay amount and fees
|
# check that we can pay amount and fees
|
||||||
if not is_route_within_budget(
|
if not is_route_within_budget(
|
||||||
route=route,
|
route=route,
|
||||||
|
|||||||
Reference in New Issue
Block a user