trampoline MPP: handle direct payment to trampoline node
This commit is contained in:
@@ -1673,27 +1673,35 @@ class LNWallet(LNWorker):
|
|||||||
routes = []
|
routes = []
|
||||||
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])
|
||||||
trampoline_route, trampoline_onion, per_trampoline_amount_with_fees, per_trampoline_cltv_delta = create_trampoline_route_and_onion(
|
if trampoline_node_id == invoice_pubkey:
|
||||||
amount_msat=per_trampoline_amount,
|
trampoline_route = None
|
||||||
total_msat=final_total_msat,
|
trampoline_onion = None
|
||||||
min_cltv_expiry=min_cltv_expiry,
|
per_trampoline_secret = payment_secret
|
||||||
my_pubkey=self.node_keypair.pubkey,
|
per_trampoline_amount_with_fees = amount_msat
|
||||||
invoice_pubkey=invoice_pubkey,
|
per_trampoline_cltv_delta = min_cltv_expiry
|
||||||
invoice_features=invoice_features,
|
per_trampoline_fees = 0
|
||||||
node_id=trampoline_node_id,
|
else:
|
||||||
r_tags=r_tags,
|
trampoline_route, trampoline_onion, per_trampoline_amount_with_fees, per_trampoline_cltv_delta = create_trampoline_route_and_onion(
|
||||||
payment_hash=payment_hash,
|
amount_msat=per_trampoline_amount,
|
||||||
payment_secret=payment_secret,
|
total_msat=final_total_msat,
|
||||||
local_height=local_height,
|
min_cltv_expiry=min_cltv_expiry,
|
||||||
trampoline_fee_level=trampoline_fee_level,
|
my_pubkey=self.node_keypair.pubkey,
|
||||||
use_two_trampolines=use_two_trampolines,
|
invoice_pubkey=invoice_pubkey,
|
||||||
failed_routes=self.failed_trampoline_routes)
|
invoice_features=invoice_features,
|
||||||
# node_features is only used to determine is_tlv
|
node_id=trampoline_node_id,
|
||||||
per_trampoline_secret = os.urandom(32)
|
r_tags=r_tags,
|
||||||
per_trampoline_fees = per_trampoline_amount_with_fees - per_trampoline_amount
|
payment_hash=payment_hash,
|
||||||
self.logger.info(f'created route with trampoline fee level={trampoline_fee_level}')
|
payment_secret=payment_secret,
|
||||||
self.logger.info(f'trampoline hops: {[hop.end_node.hex() for hop in trampoline_route]}')
|
local_height=local_height,
|
||||||
self.logger.info(f'per trampoline fees: {per_trampoline_fees}')
|
trampoline_fee_level=trampoline_fee_level,
|
||||||
|
use_two_trampolines=use_two_trampolines,
|
||||||
|
failed_routes=self.failed_trampoline_routes)
|
||||||
|
# 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:
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user