Skip to content

Commit 93f5825

Browse files
authored
Merge pull request #10668 from f321x/trampoline_routing_info
lnonion/trampoline: stop double counting HMAC size
2 parents f90887f + eb7bf23 commit 93f5825

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

electrum/lnonion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def new_onion_packet(
228228
payload_size = 0
229229
for i in range(num_hops):
230230
# FIXME: serializing here and again below. cache bytes in OnionHopsDataSingle? _raw_bytes_payload?
231-
payload_size += PER_HOP_HMAC_SIZE + len(hops_data[i].to_bytes())
231+
payload_size += len(hops_data[i].to_bytes())
232232
if trampoline:
233233
data_size = payload_size
234234
elif onion_message:

electrum/trampoline.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from .lnutil import LnFeatures, PaymentFeeBudget, FeeBudgetExceeded
1212
from .lnonion import (
13-
calc_hops_data_for_payment, new_onion_packet, OnionPacket, PER_HOP_HMAC_SIZE
13+
calc_hops_data_for_payment, new_onion_packet, OnionPacket
1414
)
1515
from .lnrouter import TrampolineEdge, is_route_within_budget, LNPaymentTRoute
1616
from .lnutil import NoPathFound
@@ -418,8 +418,7 @@ def create_trampoline_onion(
418418
payload = dict(hops_data[index].payload)
419419
# try different r_tag order on each attempt
420420
invoice_routing_info = random_shuffled_copy(route[index].invoice_routing_info)
421-
remaining_payload_space = TRAMPOLINE_HOPS_MAX_DATA_SIZE \
422-
- sum(len(hop.to_bytes()) + PER_HOP_HMAC_SIZE for hop in hops_data)
421+
remaining_payload_space = TRAMPOLINE_HOPS_MAX_DATA_SIZE - sum(len(hop.to_bytes()) for hop in hops_data)
423422
routing_info_to_use = []
424423
for encoded_r_tag in invoice_routing_info:
425424
if remaining_payload_space < 50:

0 commit comments

Comments
 (0)