Browse Source

pyln-proto: Add compactsize alias for varint_{encode,decode}

We were mistakenly calling it varint, while Bitcoin refers to it as
CompactSize.
ppa-prep
Christian Decker 4 years ago
committed by Rusty Russell
parent
commit
9a0327cd25
  1. 12
      contrib/pyln-proto/pyln/proto/primitives.py

12
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

Loading…
Cancel
Save