trampoline: do not add node in trampoline hints if it already is
the last trampoline of the route
This commit is contained in:
@@ -763,7 +763,7 @@ class TestPeer(ElectrumTestCase):
|
|||||||
graph.w_a.network.channel_db.stop()
|
graph.w_a.network.channel_db.stop()
|
||||||
graph.w_a.network.channel_db = None
|
graph.w_a.network.channel_db = None
|
||||||
# Note: first attempt will fail with insufficient trampoline fee
|
# Note: first attempt will fail with insufficient trampoline fee
|
||||||
self._test_multipart_payment(graph, attempts=2)
|
self._test_multipart_payment(graph, attempts=3)
|
||||||
|
|
||||||
@needs_test_with_all_chacha20_implementations
|
@needs_test_with_all_chacha20_implementations
|
||||||
def test_close(self):
|
def test_close(self):
|
||||||
|
|||||||
@@ -102,12 +102,11 @@ def create_trampoline_route(
|
|||||||
is_legacy = False
|
is_legacy = False
|
||||||
if len(r_tags) > 0 and len(r_tags[0]) == 1:
|
if len(r_tags) > 0 and len(r_tags[0]) == 1:
|
||||||
pubkey, scid, feebase, feerate, cltv = r_tags[0][0]
|
pubkey, scid, feebase, feerate, cltv = r_tags[0][0]
|
||||||
t_tag = pubkey, feebase, feerate, cltv
|
t_tags = [pubkey, feebase, feerate, cltv]
|
||||||
else:
|
else:
|
||||||
t_tag = None
|
t_tags = None
|
||||||
elif len(t_tags) > 0:
|
elif len(t_tags) > 0:
|
||||||
is_legacy = False
|
is_legacy = False
|
||||||
t_tag = t_tags[0]
|
|
||||||
else:
|
else:
|
||||||
is_legacy = True
|
is_legacy = True
|
||||||
|
|
||||||
@@ -154,8 +153,14 @@ def create_trampoline_route(
|
|||||||
route[-1].invoice_features = invoice_features
|
route[-1].invoice_features = invoice_features
|
||||||
route[-1].outgoing_node_id = invoice_pubkey
|
route[-1].outgoing_node_id = invoice_pubkey
|
||||||
else:
|
else:
|
||||||
if t_tag:
|
last_trampoline = route[-1].end_node
|
||||||
|
for t_tag in t_tags:
|
||||||
pubkey, feebase, feerate, cltv = t_tag
|
pubkey, feebase, feerate, cltv = t_tag
|
||||||
|
if pubkey == trampoline_node_id:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
random.shuffle(t_tags)
|
||||||
|
pubkey, feebase, feerate, cltv = t_tags[0]
|
||||||
if route[-1].node_id != pubkey:
|
if route[-1].node_id != pubkey:
|
||||||
route.append(
|
route.append(
|
||||||
TrampolineEdge(
|
TrampolineEdge(
|
||||||
@@ -165,6 +170,7 @@ def create_trampoline_route(
|
|||||||
fee_proportional_millionths=feerate,
|
fee_proportional_millionths=feerate,
|
||||||
cltv_expiry_delta=cltv,
|
cltv_expiry_delta=cltv,
|
||||||
node_features=trampoline_features))
|
node_features=trampoline_features))
|
||||||
|
|
||||||
# Final edge (not part of the route if payment is legacy, but eclair requires an encrypted blob)
|
# Final edge (not part of the route if payment is legacy, but eclair requires an encrypted blob)
|
||||||
route.append(
|
route.append(
|
||||||
TrampolineEdge(
|
TrampolineEdge(
|
||||||
@@ -266,4 +272,5 @@ def create_trampoline_route_and_onion(
|
|||||||
bucket_cltv_delta += trampoline_route[0].cltv_expiry_delta
|
bucket_cltv_delta += trampoline_route[0].cltv_expiry_delta
|
||||||
# trampoline fee for this very trampoline
|
# trampoline fee for this very trampoline
|
||||||
trampoline_fee = trampoline_route[0].fee_for_edge(amount_with_fees)
|
trampoline_fee = trampoline_route[0].fee_for_edge(amount_with_fees)
|
||||||
return trampoline_onion, trampoline_fee, amount_with_fees, bucket_cltv_delta
|
amount_with_fees += trampoline_fee
|
||||||
|
return trampoline_onion, amount_with_fees, bucket_cltv_delta
|
||||||
|
|||||||
Reference in New Issue
Block a user