Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide import from other ChannelGraph formats (lnd, ldk, eclaire) #5

Open
renepickhardt opened this issue May 6, 2022 · 5 comments
Labels
good first issue Good for newcomers

Comments

@renepickhardt
Copy link
Owner

Currently the Channel class internally just stores the json blog from c-lightning's listchannels command and accesses this. Obviously it would be nice to have wrappers that allow other implementations to load the channel graph into this library

@VasanthManiVasi
Copy link

VasanthManiVasi commented May 24, 2022

Does eclair provide any API call similar to describe graph in LND (#22) which can be used for providing support to eclair formats?

It doesn't seem to have a single API call that provides all the information we need.
We can use 3 different calls for getting most of the information we need,

  • Nodes - provides features
  • AllChannels - provides src, dest address
  • AllUpdates - rest of the information

However, the channel capacity (which is one of the main data that we need) doesn't seem to be provided in any of these api calls in eclair.

We can get the channel capacity from the funding transaction using the short channel ID

BLOCKHEIGHT_ENDPOINT = "https://blockstream.info/api/block-height/"
TXID_ENDPOINT = "https://blockstream.info/api/block/"
TX_ENDPOINT = "https://blockstream.info/api/tx/"

def capacity_from_short_channel_id(sid):
    block_height, tx, out = sid.split('x')
    block_hash = requests.get(BLOCKHEIGHT_ENDPOINT + block_height)
    txid = requests.get(TXID_ENDPOINT + block_hash.text + '/txid/' + tx)
    txinfo = requests.get(TX_ENDPOINT + txid.text)
    return json.loads(txinfo.text)['vout'][int(out)]['value']

But it involves 3 API requests to blockstream for every channel to find its channel capacity (while it can be reduced to 2, it still seems like a lot of requests for a regular channel graph with many channels)

Is there a better way to do this?

@Hasancan2
Copy link

Şu anda sınıf dahili olarak blogu ' komutundan Channeldepolar ve buna erişir. Açıkçası, diğer uygulamaların kanal grafiğini bu kitaplığa yüklemesine izin veren sarmalayıcılara sahip olmak güzel olurdu.json``c-lightning``listchannels

bu komutları nereye ekleyeceğim

@renepickhardt
Copy link
Owner Author

Is there a better way to do this?

I got the following reply from @t-bast:

We don't have any API to dump the graph: that would be very inefficient and definitely not something a user should regularly call on a mainnet node. A much better model in eclair is to write a plugin, which can have access to the graph as it is used for path-finding. But the plugin needs to be in a JVM language, which most devs don't find fancy enough nowadays ;)
We could add APIs to do some graph introspection for debugging and research, but it really should be used sparingly in production. We'd welcome external contributions to add these APIs if that's interesting for your path-finding research

I guess unless eclair provides a solution we can't support data import from eclair then?

@renepickhardt
Copy link
Owner Author

bu komutları nereye ekleyeceğim

I am not sure this is the place to ask where those commands are beeing added. You will need a running c-lightnig node and then you can call lightning-cli listchannels in your command line. The resulting json is being added to the constructor of the ChannelGraph class as provided in the example at: https://github.com/renepickhardt/pickhardtpayments/blob/main/examples/basicexample.py

@Hasancan2
Copy link

Hasancan2 commented May 28, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants