apotdevin / thunderhub

ThunderHub LND Lightning Node Manager in your Browser
https://www.thunderhub.io/
MIT License
415 stars 87 forks source link

Track failed ForwardingEvent #78

Open manreo opened 4 years ago

manreo commented 4 years ago

It will be great if thunderhub could track and display failed ForwardingEvents: lightningnetwork/lnd#3420

In short - in lnd v10 and above, there is an option to track all the forward events that were failed, for example, you are able to see if you failed to pass a HTLC because the forward channel did not have enough funds. This will be very efficient for node operators to see this data in a chart on thunderhub to optimize the channel balances.

Provide examples https://api.lightning.community/?javascript#subscribehtlcevents

import codecs, grpc, os
import router_pb2 as lnd, router_pb2_grpc as routerrpc
macaroon = codecs.encode(open('/home/admin/.lnd/data/chain/bitcoin/mainnet/admin.macaroon', 'rb').read(), 'hex')
os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
cert = open('/home/admin/.lnd/tls.cert', 'rb').read()
ssl_creds = grpc.ssl_channel_credentials(cert)
channel = grpc.secure_channel('localhost:10009', ssl_creds)
stub = routerrpc.RouterStub(channel)
request = lnd.SubscribeHtlcEventsRequest()

for response in stub.SubscribeHtlcEvents(request, metadata=[('macaroon', macaroon)]):
    print('res_id = ' + str(response_id))
    print(response

Thanks

apotdevin commented 4 years ago

The current tech stack for ThunderHub does not allow for subscriptions due to the api's serverless nature. This means the api 'turns on' when it get's a request and then 'turns off' after it responded. For this to be possible an additional 'live' server would be needed that handles all the subscriptions. Have been working on a basic implementation of a server you can spin up next to ThunderHub that would provide this but nothing ready yet. It's definitely a very nice idea!

manreo commented 4 years ago

I understand, I assume thunderhub also need to explain to the user that it can only track failed forwards while thunderhub is on. Even maybe ask the user before starting this process (and have an autostart option tick). You then need to maintain a database for those failed events, right? as you don't want the chart to start from scratch each time you restart thunderhub. Indeed a lot of work,

Thank you for the great product :)

apotdevin commented 4 years ago

Yeah, database would be the next step to actually persist all these events. It also has to remain fairly easy to install for users. I'll hopefully soon have the subscription server ready as an initial test to see how it would work.

No problem! Thanks for the feature request 🥇