alexbosworth / ln-service

Node.js interface to LND
MIT License
318 stars 61 forks source link

Failed HTLC Events #171

Closed icebaker closed 1 year ago

icebaker commented 1 year ago

Hi, great work on this project!

Question: There's a subscription that streams failed HTLC events?

I inferred that subscribeToForwards with error would be the way, but I'm not receiving failed forwards:

const sub = subscribeToForwards({lnd});

sub.on('forward', event => {});
sub.on('error', event => {});

No success with subscribeToForwardRequests either:

const sub = subscribeToForwardRequests({lnd});

sub.on('forward_request', event => {});

To be fair, with subscribeToForwards + forward, eventually, I received some events like:

{
    "in_channel": "9x1",
    "in_payment": 123,
    "is_confirmed": false,
    "is_failed": true,
    "is_receive": false,
    "is_send": false,
    "out_channel": "3x4",
    "out_payment": 931
}

But I believe I'm receiving only some of the failed HTLC compared to other approaches and no additional info like the failure reason.

lndg goes for this approach:

connection = lnd_connect()
    routerstub = lnrouter.RouterStub(connection)
    for response in routerstub.SubscribeHtlcEvents(lnr.SubscribeHtlcEventsRequest()):
        if response.event_type == 3 and str(response.link_fail_event) != '':

I notice that people suggested a similar approach to thunderhub a while ago:

stub = routerrpc.RouterStub(channel)
request = lnd.SubscribeHtlcEventsRequest()

for response in stub.SubscribeHtlcEvents(request, metadata=[('macaroon', macaroon)]):

I tried to find some references to how to accomplish that, and I saw this discussion and this issue.

Also, apparently, this documentation no longer exists:

So, not sure if SubscribeHtlcEvents is a deprecated thing nowadays.

There's a reason for not abstracting SubscribeHtlcEvents alongside the other subscribeTo's methods?

Receive all failed Forward Attempts / HTLC Failures: What approach would you recommend for achieving this goal?

Thank you!

alexbosworth commented 1 year ago

It should show the failed forward events in that method

icebaker commented 1 year ago

I guess I initially misunderstood the purpose of subscribeToForwards. I accomplished receiving the exact events I was aiming for through router/SubscribeHtlcEvents. tks