From 9a0327cd256e92b15de072db2d732350d4043dcf Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Thu, 15 Oct 2020 10:23:02 +0200 Subject: [PATCH] pyln-proto: Add compactsize alias for varint_{encode,decode} We were mistakenly calling it varint, while Bitcoin refers to it as CompactSize. --- contrib/pyln-proto/pyln/proto/primitives.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/contrib/pyln-proto/pyln/proto/primitives.py b/contrib/pyln-proto/pyln/proto/primitives.py index b0bec15d3..418f52212 100644 --- a/contrib/pyln-proto/pyln/proto/primitives.py +++ b/contrib/pyln-proto/pyln/proto/primitives.py @@ -2,7 +2,7 @@ import coincurve import struct -def varint_encode(i, w): +def compactsize_encode(i, w): """Encode an integer `i` into the writer `w` """ if i < 0xFD: @@ -15,7 +15,7 @@ def varint_encode(i, w): w.write(struct.pack("!BQ", 0xFF, i)) -def varint_decode(r): +def compactsize_decode(r): """Decode an integer from reader `r` """ raw = r.read(1) @@ -33,6 +33,14 @@ def varint_decode(r): return struct.unpack("!Q", r.read(8))[0] +def varint_encode(i, w): + return compactsize_encode(i, w) + + +def varint_decode(r): + return compactsize_decode(r) + + class ShortChannelId(object): def __init__(self, block, txnum, outnum): self.block = block