The specification of the short_channel_id
describes the format as follows:
The short_channel_id
is the unique description of the funding transaction. It is constructed as follows:
- the most significant 3 bytes: indicating the block height
- the next 3 bytes: indicating the transaction index within the block
- the least significant 2 bytes: indicating the output index that pays to the channel.
Hence to convert between the two formats you can use the following python snippets:
def lnd_to_cl_scid(s):
block = s >> 40
tx = s >> 16 & 0xFFFFFF
output = s & 0xFFFF
return (block, tx, output)
def cl_to_lnd_scid(s):
s = [int(i) for i in s.split('x')]
return (s[0] << 40) | (s[1] << 16) | s[2]
The reason we (c-lightning) use the dotted format is because it allows us to look up the funding TX without having to do a conversion (and it usually is shorter than the u64
representation)
x
as a separator instead of:
while colon was very readable the short channel ids that use x as a separator are doubleclickable.