Skip to content

Commit a8b5a10

Browse files
authored
fix: bug where short_channel_id in routehints is to big (#48)
* fix: bug where short_channel_id in routehints is to big * fix unsigned packing
1 parent 5f26caa commit a8b5a10

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

bolt11/models/routehint.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ def data(self) -> Bits:
4141
for route in self.routes:
4242
route_hints.append(
4343
BitArray(hex=route.public_key)
44-
+ pack("intbe:64", scid_to_int(route.short_channel_id))
45-
+ pack("intbe:32", route.base_fee)
46-
+ pack("intbe:32", route.ppm_fee)
47-
+ pack("intbe:16", route.cltv_expiry_delta)
44+
+ pack("uintbe:64", scid_to_int(route.short_channel_id))
45+
+ pack("uintbe:32", route.base_fee)
46+
+ pack("uintbe:32", route.ppm_fee)
47+
+ pack("uintbe:16", route.cltv_expiry_delta)
4848
)
4949

5050
return route_hints

tests/test_route_hints.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,23 @@ def test_route_hint_unordered(self):
100100
check_decoded_routes(decoded.route_hints, ex["route_hints"])
101101
re_encoded = encode(decoded)
102102
assert re_encoded == ex["payment_request"]
103+
104+
105+
class TestRouteHintsSize:
106+
def test_channel_id_size(self):
107+
big_channel_id = "16774490x12969991x22027"
108+
hints = RouteHint.from_list(
109+
[
110+
{
111+
"public_key": (
112+
"029e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255"
113+
),
114+
"short_channel_id": big_channel_id,
115+
"base_fee": 1,
116+
"ppm_fee": 20,
117+
"cltv_expiry_delta": 3,
118+
}
119+
]
120+
)
121+
122+
assert hints.data

0 commit comments

Comments
 (0)