Stop including all invoice r_tags in legacy trampoline onion
This change modifies create_trampoline_onion to only include as many available r_tags as there is space left in the trampoline onion payload. Previously we tried to include all passed invoice r_tags of legacy trampoline payments into the payload which caused an user facing exception and payment failure as the onion can only store a max of 400 bytes. A single, single hop r_tag is around 52 bytes and the payload without r_tags is already at ~280 bytes. So usually there is enough space for 2 r_tags. The implementation shuffles the r_tags on each call so the payment will try different route hints on the attempts (fee level increase or user retry). I have logged the following byte sizes of the trampoline onion with a 2 trampoline onion hop and changing amounts of r_tags: 3 rtags: payload size [0]: 113 (hop size: 81) payload size [1]: 440 (hop size: 295) ( 52 bytes/rtag ) payload size [2]: 550 (hop size: 78) 2 rtags: payload size [0]: 113 (hop size: 81) payload size [1]: 386 (hop size: 241) ( 52 bytes/rtag ) payload size [2]: 496 (hop size: 78) 1 rtag: payload size [0]: 113 (hop size: 81) payload size [1]: 334 (hop size: 189) ( 52 bytes/rtag ) payload size [2]: 444 (hop size: 78) 0 rtags: payload size [0]: 113 (hop size: 81) payload size [1]: 282 (hop size: 137) payload size [2]: 392 (hop size: 78) As can be seen in the data, using 2 trampoline hops there is not enough space for even a single r_tag which is why this option is being removed too.
This commit is contained in:
@@ -115,7 +115,7 @@ class RouteEdge(PathEdge):
|
||||
|
||||
@attr.s
|
||||
class TrampolineEdge(RouteEdge):
|
||||
invoice_routing_info = attr.ib(type=bytes, default=None)
|
||||
invoice_routing_info = attr.ib(type=Sequence[bytes], default=None)
|
||||
invoice_features = attr.ib(type=int, default=None)
|
||||
# this is re-defined from parent just to specify a default value:
|
||||
short_channel_id = attr.ib(default=ShortChannelID(8), repr=lambda val: str(val))
|
||||
|
||||
Reference in New Issue
Block a user