renepickhardt / pickhardtpayments

python package to showcase, test and build your own version of Pickhardt Payments
Apache License 2.0
42 stars 14 forks source link

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

Open renepickhardt opened 2 years ago

renepickhardt commented 2 years ago

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 commented 2 years ago

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,

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 commented 2 years ago

Ş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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

but i don't know anything about this can you help me

28 May 2022 Cmt 09:15 tarihinde Rene Pickhardt @.***> şunu yazdı:

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

— Reply to this email directly, view it on GitHub https://github.com/renepickhardt/pickhardtpayments/issues/5#issuecomment-1140183529, or unsubscribe https://github.com/notifications/unsubscribe-auth/AS65OVXGLG7DGGK3KXHUAZ3VMG2WLANCNFSM5VHLZEUQ . You are receiving this because you commented.Message ID: @.***>