bitcoinjs / bolt11

A library for encoding and decoding lightning network payment requests as defined in BOLT #11.
MIT License
92 stars 64 forks source link

LND chan id is not 8bytes #29

Closed tiero closed 4 years ago

tiero commented 4 years ago

If I try to encode the routing info passing the chan id I get with lnd in regtest

$ lncli -n=regtest listchannels
....
"chan_id": "286972534915072"

In the LND doc chan_id is defined as The first 3 bytes are the block height, the next 3 the index within the block, and the last 2 bytes are the output index for the channel.

junderw commented 4 years ago

https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md

I don't see any problem with the explanation in BOLT11. 64 bits = 8 bytes.

tiero commented 4 years ago

@junderw I'm sorry, the question was incomplete. I was saying that using the chan_id printed by lnd is not in the right format.

eg. With 286972534915072 it gives me Routing info short channel id must be 8 bytes

I see here that https://github.com/bitcoinjs/bolt11/blob/master/payreq.js#L261 is supposed to be an hex string, meanwhile for lnd in an uint64

Do you have any hints?

junderw commented 4 years ago

convert from base10 to base16.